# Same data, different PACF? [R vs Stata]

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:

library(foreign)
airline.ts <- ts(bjg[, 1], start=c(1949,1), freq=12)

layout(1:2)
acf(airline.ts,ci.type="ma",lag.max=40)
pacf(airline.ts,lag.max=40)


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

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

• You graphs say air, not lnair on the y-axis. Are you sure the Stata code is correct? – Dimitriy V. Masterov Sep 3 '15 at 1:18
• 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. – Dimitriy V. Masterov Sep 3 '15 at 1:25
• 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? – Durden Sep 3 '15 at 12:25
• 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. – Dimitriy V. Masterov Sep 3 '15 at 18:36