[R] cor() and lagged ts objects

Dirk Eddelbuettel edd at debian.org
Wed Feb 13 21:07:56 CET 2002


The following is internally consistent, but not intuitive:

R : Copyright 2002, The R Development Core Team
Version 1.4.1  (2002-01-30)
[...]
> library(ts)
> x<-rnorm(100)			# white noise
> xTS<-ts(x,start=1)		# as time series
> xTSl<-lag(xTS,lag=-1)		# lagged once
> cor(xTS,xTSl)			# Big surprise
[1] 1
> cor(cbind(xTS,xTSl),use="pairwise")	# what was really meant
             xTS        xTSl
xTS   1.00000000 -0.04080141
xTSl -0.04080141  1.00000000
> 

Is there any way cor() could know that the first call was nonsensical (given
the semantics of lag) and issue a warning?

Dirk

-- 
Good judgment comes from experience; experience comes from bad judgment. 
							    -- Fred Brooks
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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