[R] question about 'coef' method and fitted_value calculation

Gabor Grothendieck ggrothendieck at gmail.com
Mon Aug 21 23:59:07 CEST 2006


Try

library(MASS)
y.lmr <- lm.ridge(y ~., longley)
coefs <- print(y.lmr)



On 8/21/06, jz7 at duke.edu <jz7 at duke.edu> wrote:
> Dear all,
>
> I am trying to calculate the fitted values using a ridge model
> (lm.ridge(), MASS library). Since the predict() does not work for lm.ridge
> object, I want to get the fitted_value from the coefficients information.
> The following are the codes I use:
>
>        fit = lm.ridge(myY~myX,lambda=lamb,scales=F,coef=T)
>        coeff = fit$coef
>
> However, it seems that "coeff" (or "fit$coef") is not really the
> coefficients matrix. From the manual, "Note that these are not on the
> original scale and are for use by the 'coef' method...".
>
> Could anyone please point out what is the 'coef' method the manual
> mentioned, and how should I get the fitted value? I have tried simple
> multiplication of the coeff and my X matrix ("coeff%*%X"). But the results
> seems to be in the wrong scale.
>
> Thanks so much!
>
> Sincerely,
> Jeny
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list