
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?
Many thanks,
Nancy
 

> Date: Tue, 29 Dec 2009 17:28:59 +0000
> From: ripley@stats.ox.ac.uk
> To: spector@stat.berkeley.edu
> CC: nancyadam84@hotmail.com; r-help@r-project.org
> Subject: Re: [R] R2
> 
> On Tue, 29 Dec 2009, Phil Spector wrote:
> 
> > Nancy -
> > Please notice that ** is not an R operator. The caret (^) is the 
> > exponentiation operator in R.
> > - Phil
> 
> Actually, no,
> 
> > 2**3
> [1] 8
> 
> Indeed ^ is the preferred exponentiation operator, but ** has 'always' 
> been allowed. See the following note in ?"^"
> 
> Note:
> 
> ʽ**ʼ is translated in the parser to ʽ^ʼ, but this was undocumented
> for many years. It appears as an index entry in Becker _et al_
> (1988), pointing to the help for ʽDeprecatedʼ but is not actually
> mentioned on that page. Even though it has been deprecated in S
> for 20 years, it is still accepted.
> 
> I added that note in May 2008 (and it is not intended to be a 
> reference to current versions of S-PLUS, since we cannot keep checking 
> that, but that Svr4 accepted it).
> 
> >
> >
> >
> > On Tue, 29 Dec 2009, Nancy Adam wrote:
> >
> >> 
> >> Hi everyone,
> >> I tried to write the code of computing R2 for a regression system but I 
> >> failed.
> >> This is the code I use for computing RMSE:
> >> 
> >> my_svm_model <- function(myformula, mydata, mytestdata)
> >> {
> >> mymodel <- svm(myformula, data=mydata)
> >> mytest <- predict(mymodel, mytestdata)
> >> error <- mytest - mytestdata[,1]
> >> -sqrt(mean(error**2))
> >>
> >> }
> >> can anyone please tell me what I have to change to compute R2 instead of 
> >> RMSE?
> >> 
> >> Many thanks,
> >> Nancy
> >> _________________________________________________________________
> >> 
> >>
> >> [[alternative HTML version deleted]]
> >> 
> >> ______________________________________________
> >> R-help@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.
> >> 
> >
> > ______________________________________________
> > R-help@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.
> >
> 
> -- 
> Brian D. Ripley, ripley@stats.ox.ac.uk
> Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
> University of Oxford, Tel: +44 1865 272861 (self)
> 1 South Parks Road, +44 1865 272866 (PA)
> Oxford OX1 3TG, UK Fax: +44 1865 272595
 		 	   		  
_________________________________________________________________
Keep your friends updated—even when you’re not signed in.
http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_5:092010
	[[alternative HTML version deleted]]

