[R] prediction with ridge regression
Rodrigo Briceño
rjavierbriceno at gmail.com
Fri May 9 22:58:44 CEST 2008
I'm running a ridge regression of Y over 8 explanatory variables. The
selection of lambda gave me a value of 1 as the minimum value to be
added for bias. I got the coeficients for this new regression.
The thing is that I have 8 new values for explanatory variables that
are needed in order to predict the response using the ridge regression
already ran. Since I'm not very familiar with the way R functions I
will explain what I did:
1. New values were inserted:
nx=c(64.8,263.7,181.08,178.56,91.44,35.64,40.95,38.79) each
corresponds to a new value for each of the explanatory variables.
Doubt: it is ok on this way or do I need to put like data frame?
x0 = data.frame(x1=64.8,x2=263.7,x3=181.08,x4=178.56,x5=91.44,x6=35.64,x7=40.95,x8=38.79)
2. Prediction with the original LM model was done using the command:
predict(spos.mod,x0), where spos.mod is the linear model and x0 is the
new data (data.frame)
3. Not clear how to do the same with ridge, in order to compare the
previous prediction with the one from the new model (spos.ridge)
Any help is really appreciated.
More information about the R-help
mailing list