Re: [R] mulitple mixed regression with spline

From: Prof Brian Ripley <>
Date: Fri 24 Jun 2005 - 19:02:55 EST

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,        
Professor of Applied Statistics,
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________ mailing list
PLEASE do read the posting guide!
Received on Fri Jun 24 19:05:45 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:33:02 EST