###RANDOM WALKS N<-321 index<-seq(0,(N-1)/12,1/12) u<-rnorm(N) y<-cumsum(u) plot(index,y,type="l",xlab="year",ylab="") fm<-lm(y~index) lines(index,fm$fitted.values,col="blue") z<-range(y) z0<-max(abs(z)) temp<-(abs(z)==z0) A<-round(summary(fm)$coefficients[2,],3) text(0.5, z[temp], paste("slope: ",A[1],"; t stat:", A[3]),pos=4,cex=1,font=2) #ARMA (0.92, -0.32, sd=0.11) N<-321 ar1<-0.9216 ma1<- -0.3159 index<-seq(0,(N-1)/12,1/12) u<-rnorm(N+200,sd= 0.1101969) y<-arima.sim(n=(N+200),model=list(ar=ar1,ma=ma1), innov=u) y<-y[201:(N+200)] plot(index,y,type="l",xlab="year",ylab="") fm<-lm(y~index) lines(index,fm$fitted.values,col="blue") z<-range(y) z0<-max(abs(z)) temp<-(abs(z)==z0) A<-round(summary(fm)$coefficients[2,],4) text(0.5, z[temp], paste("slope: ",A[1],"; t stat:", A[3]),pos=4,cex=1,font=2)