I am fittling a spline to a variable in a regression model, I am then using
the predict.glm funtion to make some predictions. When I use bs to fit the
spline I don't have any problems using the predict.glm function however when
I use ns I get the following error:
Error in model.frame(formula, rownames, variables, varnames, extras,
extranames, :
variable lengths differ (found for 'ns(DY, df = 6)')
In addition: Warning message:
'newdata' had 1 rows but variable(s) found have 6 rows
so for whatever reason this code works
model. <- glm.nb(CNT ~ WKDY + bs(DY,df=6) + H_FLAG + NH_FLAG + Trend)
predict(model,newdata=data[i,1:10],type="response",se=TRUE)
but this code does not work
model. <- glm.nb(CNT ~ WKDY + ns(DY,df=6) + H_FLAG + NH_FLAG + Trend)
predict(model,newdata=data[i,1:10],type="response",se=TRUE)
the two are identical aside from bs vs ns. I looked at the R help and from
what I could tell, both functions are based on splines.des and they output a
matrix of the same dimension.
Any feedback would be appreciated.
thanks,
Spencer
[[alternative HTML version deleted]]
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.