################################# # Passeio aleatorio sem e com drift ################################# n = 2000 # Varios drifts diferentes rho = 1.0 par(mfrow=c(1,3)) for (alpha in c(-0.2,0,0.2)){ e = rnorm(n,0,2) y0 = 0 y = rep(0,n) y[1] = alpha + rho*y0+e[1] for (t in 2:n) y[t] = alpha + rho*y[t-1]+e[t] ts.plot(y) title(paste("alpha=",alpha," - rho=",rho,sep="")) } # Series estacionarias alpha = 0.5 par(mfrow=c(1,3)) for (rho in c(0.9,0.95,0.99)){ e = rnorm(n,0,1) y0 = 0 y = rep(0,n) y[1] = alpha + rho*y0+e[1] for (t in 2:n) y[t] = alpha + rho*y[t-1]+e[t] ts.plot(y) title(paste("alpha=",alpha," - rho=",rho,sep="")) } install.packages("fUnitRoots") library(fUnitRoots) wants = c("fUnitRoots") has = wants %in% rownames(installed.packages()) if(any(!has)) install.packages(wants[!has]) library(mvtnorm) library(Hotelling) fUnitRoots