On Fri, 24 Jun 2005, james lumley wrote:
> Hi, I'm looking to implement a regression with mixed terms. I have 2
What do you mean by `mixed'? Not I think in the sense of Pinheiro &
Bates' book or nlme.
> biological endpoints for a dataset of n=77, one linearly related and
> the other fits a spline. I want to combine these two terms in a
> linear regression for prediction, then apply the model to a test set.
>
> this works fine, good r2 and I've graphed the spline.
> m1<-lm(y~x1,data=train)
> m2<-smooth.spline(x2,y); (spl)
>
> what i want is
> y=x+bilin(x2)
You can see several ways to do this in MASS. Most simply
lm(y ~ x1 + ns(s2, df=?))
for regression splines. For smoothing splines, see the functions gam() in
packages mgcv and gam (which differ considerably), or bruto() in mda or
package gss or ....
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595