Reputation: 179
I want to calculate the autocorrelation (lag 1) of a time series. To do so, I used the acf() function in R. Specifically, I simulated the following sequence
x<-c(-2,-2*0.9^c(1:50))
So in theory the autocorrelation should be 0.9. However, if I run the following
acf(x[1:10],1,plot=F)
The return is 0.69, which is far from the theoretical value. Am I doing anything wrong here?
Upvotes: 2
Views: 3070
Reputation: 3060
There is no problem with the original series if you do not subset the first ten observations.
If you run the following
acf(x,1,plot=F)
You will see that now the autocorrelation coefficient at lag 1 is equal to 0.889. By subsetting your input to the ACF function, you are asking to return the autocorrelation function for those 10 observations only and not for the whole series. That is why when you run
acf(x[1:10],1,plot=F)
You get a autocorrelation coefficient at lag 1 equal to 0.69.
The difference is an issue of how sample estimates work. A lot of the results from time-series analysis require large samples to converge to the actual value of the parameter. By restricting it to only 10 observations you are bound to have a lot of variability.
Also, if you create the following series:
x<-c(-2,-2*0.9^c(1:1000))
And run the whole series through the acf() function, you will get an autocorrelation coefficient at lag 1 equal to 0.9 Hope it helps.
Upvotes: 2