[R] R2

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Dec 29 18:28:59 CET 2009


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 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.
>> 
>
> ______________________________________________
> 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.
>

-- 
Brian D. Ripley,                  ripley at 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


More information about the R-help mailing list