[R] modifying model coefficients

tdm philb at philbrierley.com
Mon Oct 19 05:26:06 CEST 2009

I have build a model but want to then manipulate the coefficients in some

I can extract the coefficients and do the changes I need, but how do I then
put these new coefficients back in the model so I can use the predict

my_model <- lm(x ~ . , data=my_data)
my_scores <- predict(my_model, my_data)

my_coeffs <- coef(my_model)

## here we manipulate my_coeffs
## and then want to set the my_model 
## coefficients to the new values so we 
## predict using the new values

my_model.coefs <- my_coeffs ?? how is this done?

?? so that this will work with the new coefficients
my_scores_new <- predict(my_model, my_data)

Any code snippets would be appreciated very much.

View this message in context: http://www.nabble.com/modifying-model-coefficients-tp25952879p25952879.html
Sent from the R help mailing list archive at Nabble.com.

More information about the R-help mailing list