###################################################################################################################### #Generate time dependence ###################################################################################################################### #Defining the Sample Size and the increasing variance scale size <- 20 X <- seq(0,size,by=0.5) # Generating residuals dependent on time e <- c(NA,length(X)) e[1] = X[1] a <- 2 for(i in 2:length(X)) e[i] <- a*X[i-1] + rnorm(1,0,1) ## Plot the residual x time to validate the hypothesis plot(x=1:length(X),y=e) ## Load the library "lmtest" and run the Durbin-Watson test for correlation library("lmtest") dwtest(e)