Solved – sample autocovariance function vs autocovariance function

autocorrelationmathematical-statisticsrtime series

What is the difference between both functions? I have been reading, but I cannot see the difference. I suppose that the sample autocovariance function is the estimation of the autocovariance function. When I plot it in R using functions from the library itsmr, I donĀ“t which is which.

Maybe one autocovariance function is theoretical, but we estimate it with the sample autocovariance function.

Best Answer

Maybe one autocovariance function is theoretical, but we estimate it with the sample autocovariance function.

Yes, that's correct. One is based on random data, and the other is theoretical and based on properties of the true model along with its true parameters.

You don't tell us which function you're using in that package, but you can calculate both sample and theoretical autocorrelations in R. Below is a demonstration. Notice that if you re-generate the fake_data, you will get different data, and thus different sample autocorrelations. However, as long as you do not change the true model (an ARMA(2,2) in this case), the theoretical acf will not change.

fake_data <- arima.sim(n = 63, list(ar = c(0.8897, -0.4858), ma = c(-0.2279, 0.2488)),
                        sd = sqrt(0.1796))

acf(fake_data) #sample acf plot
lines(0:17, ARMAacf(ar = c(0.8897, -0.4858), ma =  c(-0.2279, 0.2488), lag.max = 17))  #overlay true 

In the itsmr package, which I try not to use whenever I can, the theoretical autocovariance (not autocorrelation) function is calculated by aacvf, while the sample one is calculated by acvf.