[R-sig-eco] Phase spectrum
stephen sefick
ssefick at gmail.com
Fri Mar 20 02:10:50 CET 2009
lag.plot2=function(data1,data2,max.lag=0,corr=TRUE,smooth=FALSE){
name1=paste(deparse(substitute(data1)),"(t-",sep="")
name2=paste(deparse(substitute(data2)),"(t)",sep="")
data1=as.ts(data1)
data2=as.ts(data2)
max.lag=as.integer(max.lag)
m1=max.lag+1
prow=ceiling(sqrt(m1))
pcol=ceiling(m1/prow)
a=ccf(data1,data2,max.lag,plot=FALSE)$acf
par(mfrow=c(prow,pcol), mar=c(2.5, 4, 2.5, 1), cex.main=1.1, font.main=1)
for(h in 0:max.lag){
plot(lag(data1,-h), data2, xy.labels=F,
main=paste(name1,h,")",sep=""), ylab=name2, xlab="")
if (smooth==TRUE)
lines(lowess(ts.intersect(lag(data1,-h),data2)[,1],
ts.intersect(lag(data1,-h),data2)[,2]), col="red")
if (corr==TRUE)
legend("topright", legend=round(a[m1-h], digits=2), text.col
="blue", bg="white", x.intersp=0)
}
}
I believe that it is neither
library(zoo)
plot(coredata(mdeaths)~coredata(fdeaths))
But I am still learning about timeseries analysis.
Stephen Sefick
On Thu, Mar 19, 2009 at 6:04 PM, Gunnar Hoyer
<gunnar.hoyer at uni-oldenburg.de> wrote:
> Hello,
>
> I have trouble to interpret the phase spectrum correctly.
>
> Here is the code (with different data) I used to get the phase spectrum:
>
> mfdeaths.spc <- spec.pgram(ts.union(mdeaths, fdeaths), spans = c(3,3))
> plot(mfdeaths.spc, plot.type = "phase")
>
> I would like to know whether positive or negative values indicate that the
> time series mdeaths leads or lags.
>
> Thanks in advance
> Gunnar Hoyer
>
> _______________________________________________
> R-sig-ecology mailing list
> R-sig-ecology at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
>
--
Stephen Sefick
Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods. We are mammals, and have not exhausted the
annoying little problems of being mammals.
-K. Mullis
More information about the R-sig-ecology
mailing list