So I was playing around with R, trying to figure out how to do basic time series stuff. Using the Box-Jenkins Series G ("airline passengers") data, I wanted to plot ACF and PACF. So here's my code:

bjg <- read.dta("http://www.stata-press.com/data/r9/air2.dta")
airline.ts <- ts(bjg[, 1], start=c(1949,1), freq=12) 


But then compare the same graphs from Stata, using the same data set.

enter image description here

While the ACFs look alike, the PACFs are clearly different between R and Stata. How can that be? Where's my mistake?

P.S.: Here's the Stata code:

webuse air2
tsset t
ac air
pac air
  • $\begingroup$ You graphs say air, not lnair on the y-axis. Are you sure the Stata code is correct? $\endgroup$ – Dimitriy V. Masterov Sep 3 '15 at 1:18
  • 1
    $\begingroup$ Try adding , yw option in the pac command to have the partial autocorrelations be calculated using the Yule-Walker equations instead of using the default regression-based technique. $\endgroup$ – Dimitriy V. Masterov Sep 3 '15 at 1:25
  • $\begingroup$ You're right, I did in fact tested air in those graphs. I tested lnair, too. Sorry for messing up the code. As for your other answer, the , yw option in Stata indeed produces the same graphs. Thank you. Now is there in option in R to produce the PACF with the regression-based technique? $\endgroup$ – Durden Sep 3 '15 at 12:25
  • 2
    $\begingroup$ The method is in the Stata documentation and is pretty straigforward. I am not aware of an R implementation, but one may well exist. You might modify your question rather than asking in the comments. $\endgroup$ – Dimitriy V. Masterov Sep 3 '15 at 18:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.