1

I cannot figure out how na.pass in the acf function in R addresses NAs. For example:

a<-acf(x=c(1,NA,2),na.action = na.pass)
a$acf

I get the following results:

> a$acf
, , 1

           [,1]
[1,]  1.0000000
[2,]         NA
[3,] -0.3333333

To be honest I really couldn't get the value -0.3333333.

I am so confused about how the function treats NA in the very bottom? The original equation is:

def

But what is the equation for an irregular time series? (I don't want to use na.exclude, I want to keep the NAs in my data!)

Thanks!

CuteCat
  • 191
  • 9
  • Looking at the [source code](https://github.com/SurajGupta/r-source/blob/master/src/library/stats/R/acf.R) `na.pass` will pass `NA` to `as.ts()`. The final calculation will be done by `C_acf`. Does this probably help: ["Manual” calculation of ACF of a time series in R - close but not quite](https://stats.stackexchange.com/questions/254227/manual-calculation-of-acf-of-a-time-series-in-r-close-but-not-quite) or [Understanding this acf output](https://stats.stackexchange.com/questions/81754/understanding-this-acf-output)? – ava Jun 24 '21 at 07:32

0 Answers0