Skip to content

lm combined with splines

2 messages · Randriamiharisoa Alex, Brian Ripley

#
This is really a question for R-help: it is not about R development 
nor software development in R.

The answer to the only question I see is simple: your model depends on 
'fb3' and you supplied 'height'.
On Tue, 9 Feb 2010, Randriamiharisoa Alex wrote:

            
Which 'example in R help'?  If you mean that from ?bs, then the 
comment about 'safe prediction' is why your third approach (even if 
done something like

ph3 <- predict(fm3, data.frame(fb3 = I(bs(ht3, df = 5))))

) would not be correct.  You need to predict using the spline with the 
knots computed by the original set of data, and predict() is smart 
enough to figure that out when it sees a formula involving bs() (look 
at str(fm1) to see where the information is stored, and hence how you 
could mimic this).