[R] R squared for lm prediction
Jeff Newmiller
jdnewmil at dcn.davis.ca.us
Tue Oct 5 07:08:01 CEST 2010
Or use the summary function on the lm object.
"Thomas Stewart" <tgstewart at gmail.com> wrote:
>I'm not sure I understand what you want, but here is a guess.
>
>Let y be the hold out response values. Let y.hat be the model predictions
>for the corresponding ys.
>
>The key is to remember that R^2 = cor( y , y.hat )^2.
>
>So,
>
>cor( cbind(y,y.hat))[1,2]^2
>
>should give you a measure you want.
>
>-tgs
>
>On Mon, Oct 4, 2010 at 10:06 PM, Brima <adamsteve2000 at yahoo.com> wrote:
>
>>
>> Hi all,
>>
>> I have used a hold out sample to predict a model but now I want to compute
>> an R squared value for the prediction. Any help is appreciated.
>>
>> Best regards
>> --
>> View this message in context:
>> http://r.789695.n4.nabble.com/R-squared-for-lm-prediction-tp2955328p2955328.html
>> Sent from the R help mailing list archive at Nabble.com.
>>
>> ______________________________________________
>> R-help at r-project.org 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.
>>
>
> [[alternative HTML version deleted]]
>
>______________________________________________
>R-help at r-project.org 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.
---------------------------------------------------------------------------
Jeff Newmiller The ..... ..... Go Live...
DCN:<jdnewmil at dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go...
Live: OO#.. Dead: OO#.. Playing
Research Engineer (Solar/Batteries O.O#. #.O#. with
/Software/Embedded Controllers) .OO#. .OO#. rocks...1k
---------------------------------------------------------------------------
Sent from my phone. Please excuse my brevity.
More information about the R-help
mailing list