Dear All
I would be grateful for some help regarding the plotting of fitted values
for a glm b-spline in R (or S-plus).
I have a binary response variable called sjukdom, which is 1 or 0 and a
continuous explanatory variable, five.d. I have fitted a b-spline of five.d
and am modelling it as a generalised linear model. After plotting the
response against the explanatory variable I want to add to that graph the
fitted b-spline regression curve. These are my commands:
cont.bs<-bs(five.d,df=4,degree=3,intercept=T)
bs.fit<-glm(sjukdom~cont.bs,family=binomial)
plot(five.d,sjukdom)
lines(five.d,fitted(bs.fit))
My problem is that the ‘lines’ command does not produce a smooth curve but a
mess of lines in various directions. If I use the following command instead
of the ‘lines‘ command
points(five.d,fitted(bs.fit))
The points show the curve that I want but not joined up. I have tried
sorting both variables but have only succeeded in producing various strange
line patterns.
Does anyone how to join these points to make the smooth curve I am after? Is
there a command that automatically plots the regression line?
Many thanks in advance for you help.
Rebecca Deacon
Post-graduate student, University of Southampton
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
|