I was given an oil time series dataset (quarterly). I was trying to build an ARIMA Model in Stata. There is trend and seasonality in the data

I am trying to plot acf and pacf plot to determine the order of AR and MA process

I had already taken the log and differenced the data to remove the trend and seasonality and to make the data stationary.

So oil became log_oil and then D.log_oil

The following is the oil data plotted against time

time series plot

The following is the ACF plot of D.log_oil

acf plot of d.logoil

There is still a decaying pattern in the ACF plot even after differencing and taking log. Differencing a second time still retains a similar pattern.

  • $\begingroup$ Differencing won't remove seasonality: you need to perform seasonal differencing and fit a SARIMA model. $\endgroup$
    – whuber
    Commented Mar 5, 2023 at 17:07

1 Answer 1


The data needs to be seasonally differenced in Stata using the S. operator.

As seen in Page 4 of tsset manual entry of Stata: https://www.stata.com/manuals13/tstsset.pdf

The seasonal differencing operator needs to be used with the lag specified. The lag number is based on the type of time series data (quarterly, annual etc).

As this is a quarterly data we use lag = 4

so the command is :

gen d_lnoil = d.oil        // differencing for trend
gen d2_lnoil = s4.d_lnoil  // seasonal differencing with lag = 4

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.