Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### simulating lag1 autoregressive process
- library(dplyr)
- library(ggplot2)
- library(GGally)
- set.seed(12345)
- n <- 1000
- divisor <- 2 # how much less variance to give the lag1 variance contribution to tmp3
- tmp1 <- rnorm(n) # base data
- tmp2 <- dplyr::lag(tmp1, n = 1) # lag1 component
- tmp <- tmp1 + tmp2/divisor
- tmp <- na.omit(tmp)
- tmpDF <- as.data.frame(cbind(tmp,
- dplyr::lag(tmp, n = 1),
- dplyr::lag(tmp, n = 2),
- dplyr::lag(tmp, n = 3),
- dplyr::lag(tmp, n = 4)))
- colnames(tmpDF) <- c("tmp","lag1","lag2","lag3","lag4")
- ggpairs(tmpDF)
- acf(tmp, lag.max = 10)
- pacf(tmp, lag.max = 10)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement