### GAUSSIAN WHITE NOISE N <- 300 ### try changing sample size N W <- ts(rnorm(N)) plot(W,type="b",xlab="time") acf(W,lag.max=100) ### MOVING AVERAGE coeff <- rep(1,5) ## `circular=TRUE' prevents NAs at the start of time-series X <- filter(W,filter=coeff,sides=1,circular=TRUE) plot(X,type="b", xlab="time") acf(X, lag.max=12) ### AUTO-REGRESSIVE coeff <- 0.95 X <- filter(W,filter=coeff,sides=1,method="recursive",init=1) plot(X,type="l", xlab="time") acf(X, lag.max=10000) ### AUTO-REGRESSIVE with cyclic behaviour coeff <- c(sqrt(2)/1.01,-1/1.01^2) X <- filter(W,filter=coeff,sides=1,method="recursive",init=c(1,1)) plot(X,type="l", xlab="time") acf(X, lag.max=50) #### TEST FOR RANDOM INPUT X <- sample( c(0,1), 2000, replace=TRUE) acf(X,lag.max=5) # use self-typed "random" input X <- c(0,1,1,1,0,1,1,0,0,0,1,1,0,0,1,1,0,1,1,1,1,0,0,1,1,1,0,1,1,1,0,0,0,1,1,1,0,0,1,1,1,0,0,1,1,0,0,0,1,1,0,0,1,1,0,0,0,1,0,1,0,1,1,0,0,1,1,0,0,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,0,1,1,0,0,1,1,1,0,0,0,1,1,1,1,0,0,0,1,1,1,0,0,0,1,1,0,0,0,0) acf(X,lag.max=5) # easier input via character strings XC <- "0001101010001011110101010101000010101000110101010011010100101101001000101110010101010010101010100111101010100000010101011110101010101010101010101111111111" X <- as.numeric( strsplit(XC,"")[[1]]) acf(X,lag.max=5)