Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
331
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. ### simulating lag1 autoregressive process
  2. library(dplyr)
  3. library(ggplot2)
  4. library(GGally)
  5. set.seed(12345)
  6. n <- 1000
  7. divisor <- 2 # how much less variance to give the lag1 variance contribution to tmp3
  8. tmp1 <- rnorm(n) # base data
  9. tmp2 <- dplyr::lag(tmp1, n = 1) # lag1 component
  10. tmp <- tmp1 + tmp2/divisor
  11. tmp <- na.omit(tmp)
  12. tmpDF <- as.data.frame(cbind(tmp,
  13. dplyr::lag(tmp, n = 1),
  14. dplyr::lag(tmp, n = 2),
  15. dplyr::lag(tmp, n = 3),
  16. dplyr::lag(tmp, n = 4)))
  17. colnames(tmpDF) <- c("tmp","lag1","lag2","lag3","lag4")
  18. ggpairs(tmpDF)
  19. acf(tmp, lag.max = 10)
  20. pacf(tmp, lag.max = 10)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement