SHARE
TWEET

Untitled

a guest Jun 18th, 2019 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top