[R] modifying model coefficients

tdm
Mon, 19 Oct 2009 20:01:28 -0000

Thanks for the tip. I actually had to learn a bit of matrix multiplication
and ended up calculating the RMSE this way.

scores_lr <- t(coeffs_alldata) %*% t(df_train)
rmseTrain <- (mean(((scores_lr)- trainY)^2))^0.5

full script and results here if you are interested.

http://ausdm09.freeforums.org/post34.html#p34




tdm wrote:
>
> I have build a model but want to then manipulate the coefficients in some
> way.
>
> 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
> function?
>
> 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-tp25952879p25964671.html
Sent from the R help mailing list archive at Nabble.com.