[R] Squared correlation error

Steve Lianoglou mailinglist.honeypot at gmail.com
Wed Dec 30 19:30:23 CET 2009


Hi Nancy,


On Wed, Dec 30, 2009 at 12:08 PM, Nancy Adam <nancyadam84 at hotmail.com> wrote:

> Hi everyone,
> Thanks a lot for the explanation…
>
> I tried the following code to compute R2 for a regression system but it does not work:
>
> my_svm_model <- function(myformula, mydata, mytestdata)
> {
> mymodel <- svm(myformula, data=mydata)
> k<- summary(mymodel)
> k$r.squared
> }
>
> Can anyone please tell me what I have to change to compute R2?

Out of curiosity, what makes you think you'll find "r.squared" in your
"k" object? Did you see that in the help somewhere?

Anyway, given that you've already shown that you know how to calculate
RMSE of a regression model, it should be pretty straightforward to rig
up the formulas found on the wikipedia page to get R^2:

http://en.wikipedia.org/wiki/Coefficient_of_determination

-steve

-- 
Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact




More information about the R-help mailing list