sg= cos(2*pi*(1/12)*seq(1:500)) xt=sg+ rnorm(500,0.25) ts.plot(xt,col=4) acf(xt,lag=200,col=3) acf(xt,lag=200,col=5,type="covariance") f=acf(xt,lag=20,col=3,plot=F) # xt=sg ts.plot(xt,col=4) acf(xt,lag=200,col=3) # out=rep(NA,1000) for(i in 1:1000){ z=rnorm(100); f=acf(z,lag=10,plot=F); out[i]=f$acf[6]} hist(out,prob=T) # data(UKLungDeaths) help(data(UKLungDeaths)) ts.plot(mdeaths,fdeaths,col=c(2,4)) acf(mdeaths) x=as.vector(mdeaths) acf(x) y=as.vector(fdeaths) par(mfrow=c(2,1)) acf(x,lag=40) acf(y,lag=40) par(mfrow=c(1,1)) plot(x,y,pch="*") plot(x[1:67],y[6:72],pch="*") plot(x[6:72],y[1:67],pch="*") ccf(x,y)