[R] predict( ..., type="terms")
tlumley at u.washington.edu
Wed Apr 7 17:43:53 CEST 2004
On Wed, 7 Apr 2004, Giovanni Petris wrote:
> 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.
More information about the R-help