I am trying to get my head around simple time series analysis. I think this R code shows my confusion.
### 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)
That generates this ACF plot:
Which is pretty much what I'd expect. However it gives this PACF:
Thinking about that ACF plot made me realise that what I had there wasn't a typical autocorrelation process but the simple addition of a lag1 component to data, not the same thing! Oops. OK. I think this, though probably clumsy is a true lag1 autocorrelation process:
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)
And that generates this ACF plot with the decreasing later correlations I had expected.
and this PACF plot.
OK, that's what I expected so I've answered part of my own question but can anyone explain to me why I get those sequential and "significant" partial autocorrelations in the first example?
TIA,
Chris