[R] linear correlation?

Joerg Maeder maeder at atmos.umnw.ethz.ch
Thu Mar 7 14:31:30 CET 2002


Hello 

dechao wang wrote:
> 
> Hi, I have checked statistic textbooks about
> correlations, but I am still not sure the correlation
> analysis with different units, for example,
> 
> x1<-c(1,  2,  3,   100, 200, 300)
> x2<-c(1.1,2.8,3.3, 108, 209, 303)
> the unit of the first 3 numbers is cm
> the unit of the last 3 numbers is kg
> 
> cor(x1,x2)=0.999655
> 
> Can I explain the correlation coefficient as normal in
> which all numbers have the same unit?

No, that will give different results. The unit must be the same for all
values. Which unit isn't important, but it must be the same


> Secondly, if keep the three large numbers unchanged,
> just change the three small numbers, the coefficient
> changes little, this means that the variation of three
> small numbers is hidden by the three larger numbers.
> Is there any solution in R to solve this issue?

If you have a vector with the units, you can use it to bring all values
to the same unit

eg (for two different units, if there are more it will be more
complicated)
xu <- c('m','m','m','cm','cm','cm') #units
cor(ifelse(xu=='m',100,1)*x1,ifelse(xu=='m',100,1)*x2)

gruess

joerg

> __________________________________________________
> 
> Everything you'll ever need on one web page
> from News and Sport to Email and Music Charts
> 
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

-- 
Joerg Maeder    .:|:||:..:.||.::   maeder at atmos.umnw.ethz.ch
Tel: +41 1 633 36 25   .:|:||:..:.||.::   
http://www.iac.ethz.ch/staff/maeder
PhD student at INSTITUTE FOR ATMOSPHERIC AND CLIMATE SCIENCE (IACETH)
ETH ZÜRICH Switzerland
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list