[R] predict( ..., type="terms")

BXC (Bendix Carstensen) bxc at steno.dk
Wed Apr 7 20:44:36 CEST 2004


> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch 
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Thomas Lumley
> Sent: Wednesday, April 07, 2004 5:44 PM
> To: Giovanni Petris

> On Wed, 7 Apr 2004, Giovanni Petris wrote:
> 
> >
> > Hello,
> >
> > After reading the help for predict.lm and predict.glm, it 
> is not clear 
> > to me what are the values returned by predict( ..., type="terms").
> >
> > Anybody willing to enlighten me?
> >
> 
> For each term in the formula, extract its coefficients and 
> the corresponding columns of the design matrix, and multiply 
> the two, and then center the result.
> 
> So, looking at the example in example(termplot) we have a 
> model y~ns(x,6)+z where z is a factor with 4 levels.
> 
> There are 9 coefficients in the model, but only two terms: 
> ns(x,6) (based on 5 coefficients) and z (based on 3 coefficients).
> 
> Adding up the terms and the centering value (also returned by
> predict(,type="terms")) gives the linear predictor.

1) It would be useful to have this in the help file for predict.(g)lm
   Also that the constant is accessed as attr( pr.obj, "const" )

2) A link to termplot might be useful too.

3) I guess that Giovanni (as well as I) was curious what the rationale
behind
   the centering of effects is. Can anyone tell us?

Bendix Carstensen

----------------------
Bendix Carstensen
Senior Statistician
Steno Diabetes Center
Niels Steensens Vej 2
DK-2820 Gentofte
Denmark
tel: +45 44 43 87 38
mob: +45 30 75 87 38
fax: +45 44 43 07 06
bxc at steno.dk
www.biostat.ku.dk/~bxc




More information about the R-help mailing list