Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

PACF (Partial AutoCorrelation Function)

In Lecture 19, we looked at the following heuristic procedure for selecting the AR order (i.e., selecting pp for fitting the AR(pp) model):

Here is an approach that we can use to select the order pp in AR(pp).

For each p=1,…,pmax⁡p = 1, \ldots, p_{\max}, we fit an AR(pp) model to the data. We record ϕ^p,p\widehat{\phi}_{p,p}, the estimated coefficient of the last lag in that model, together with its approximate 95% confidence interval. We then plot these estimates and intervals against pp.

The idea is that if the data follow an AR(p0p_0) model, additional lags beyond p0p_0 have zero coefficients. We therefore look for a cutoff after which the estimates fluctuate near zero, with most of their confidence intervals containing zero. The location of this cutoff suggests a suitable AR order.

This is a heuristic. We examine the entire plot rather than stopping at the first interval containing zero, because later coefficients may still be substantial. Conversely, an isolated interval excluding zero at a large lag may occur simply by chance when many orders are examined. The suggested order can be assessed further by checking residuals and comparing forecasting performance.

As an illustration, let us again use the sunspots dataset.

        0     1    2  3  4
0  1700.5   8.3 -1.0 -1  1
1  1701.5  18.3 -1.0 -1  1
2  1702.5  26.7 -1.0 -1  1
3  1703.5  38.3 -1.0 -1  1
4  1704.5  60.0 -1.0 -1  1
<Figure size 1200x600 with 1 Axes>
<Figure size 1000x500 with 1 Axes>

In the above plot, we are plotting both the fitted value for ϕp\phi_p (when AR(p) is fit) as well as the corresponding 95% confidence interval. We can get a simpler version of this plot by plotting only the fitted ϕp\phi_p (and omitting the confidence intervals).

<Figure size 1000x500 with 1 Axes>

In the literature, the above plot is referred to as the sample PACF (Partial AutoCorrelation Function) plot of the data. There is an inbuilt function in statsmodels to compute this (pacf) and to plot this (plot_pacf). Here is how these functions work.

<Figure size 640x480 with 1 Axes>

The PACF values (given by the functions pacf and plotted by plot_pacf) start with the value 1 at p=0p = 0. In other words, the PACF value at p=0p = 0 is always 1 (regardless of the data) so we ignore this value; and pay attention only to PACF for p=1,2,…,pmax⁡p = 1, 2, \dots, p_{\max}.

Below we check if the PACF values outputted by the pacf function match exactly with our calculation of the coefficients ϕp\phi_p when fitting AR(pp).

[[ 0.81703769  0.81703769]
 [-0.69541909 -0.69541909]
 [-0.14446005 -0.14446005]
 [ 0.0137408   0.0137408 ]
 [-0.01016752 -0.01016752]
 [ 0.1384172   0.1384172 ]
 [ 0.2035669   0.2035669 ]
 [ 0.22328627  0.22328627]
 [ 0.21954062  0.21954062]
 [ 0.02056707  0.02056707]
 [ 0.01077726  0.01077726]
 [-0.00809312 -0.00809312]
 [ 0.00533023  0.00533023]
 [ 0.04167164  0.04167164]
 [-0.05026545 -0.05026545]
 [-0.07467993 -0.07467993]
 [-0.16296494 -0.16296494]
 [-0.12285519 -0.12285519]
 [ 0.0513226   0.0513226 ]
 [-0.02407729 -0.02407729]
 [ 0.09988241  0.09988241]
 [ 0.01448813  0.01448813]
 [-0.13093041 -0.13093041]
 [-0.07242642 -0.07242642]
 [ 0.00174815  0.00174815]
 [-0.11308473 -0.11308473]
 [ 0.05036624  0.05036624]
 [ 0.071989    0.071989  ]
 [-0.13397222 -0.13397222]
 [-0.02359065 -0.02359065]]

Both the values coincide exactly. This is actually a general fact. The sample PACF at ‘lag’ pp is actually defined as the fitted estimate of ϕp\phi_p when the AR(pp) model is fit to the data.

The natural question then is the following: Why is the estimate of ϕp\phi_p when AR(pp) is fit to the data known as the partial autocorrelation at lag pp? This is explained below.

Regression and Partial Correlation

Once again, the sample pacf at lag pp is defined as the estimate ϕ^p\hat{\phi}_p of ϕp\phi_p when the AR(pp) model is fit to the data. Why does this definition have the name “partial correlation”? In statistics, the partial correlation between two variables y,xy, x given a bunch of other variables z1,…,zkz_1, \dots, z_k is defined as the correlation between the residuals ey∣z1,…,zke^{y \mid z_1, \dots, z_k} and ex∣z1,…,zke^{x \mid z_1, \dots, z_k}. Below we calculate the partial correlation in terms of residuals, and then see how it is related to our definition of the sample pacf.

Let us first fix a value of pp and then compute the sample PACF at lag pp directly (without using inbuilt library functions).

[ 1.26279267e+01  1.17023433e+00 -4.19499656e-01 -1.36597826e-01
  1.03750543e-01 -6.69284094e-02  1.44401407e-03  1.57749176e-02
 -4.38532862e-02  2.19540620e-01]
0.2195406201858306

Here the response variable yreg denotes yt,t=p+1,…,ny_t, t = p+1, \dots, n. The first column of Xmat is the column of ones, the second column is yt−1,t=p+1,…,ny_{t-1}, t = p+1, \dots, n, third column is yt−2,t=p+1,…,ny_{t-2}, t = p+1, \dots, n and so on with the last column being yt−p,t=p+1,…,ny_{t-p}, t = p+1, \dots, n.

[[ 13.3   1.   16.7 ...  26.7  18.3   8.3]
 [  5.    1.   13.3 ...  38.3  26.7  18.3]
 [  0.    1.    5.  ...  60.   38.3  26.7]
 ...
 [125.5   1.   83.2 ...  39.8  69.8 113.3]
 [154.7   1.  125.5 ...  21.7  39.8  69.8]
 [123.2   1.  154.7 ...   7.   21.7  39.8]]
[  8.3  18.3  26.7  38.3  60.   96.7  48.3  33.3  16.7  13.3   5.    0.
   0.    3.3  18.3  45.   78.3 105.  100.   65.   46.7  43.3  36.7  18.3
  35.   66.7 130.  203.3 171.7 121.7  78.3  58.3  18.3   8.3  26.7  56.7
 116.7 135.  185.  168.3 121.7  66.7  33.3  26.7   8.3  18.3  36.7  66.7
 100.  134.8 139.   79.5  79.7  51.2  20.3  16.   17.   54.   79.3  90.
 104.8 143.2 102.   75.2  60.7  34.8  19.   63.  116.3 176.8 168.  136.
 110.8  58.   51.   11.7  33.  154.2 257.3 209.8 141.3 113.5  64.2  38.
  17.   40.2 138.2 220.  218.2 196.8 149.8 111.  100.   78.2  68.3  35.5
  26.7  10.7   6.8  11.3  24.2  56.7  75.   71.8  79.2  70.3  46.8  16.8
  13.5   4.2   0.    2.3   8.3  20.3  23.2  59.   76.3  68.3  52.9  38.5
  24.2   9.2   6.3   2.2  11.4  28.2  59.9  83.  108.5 115.2 117.4  80.8
  44.3  13.4  19.5  85.8 192.7 227.3 168.7 143.  105.5  63.3  40.3  18.1
  25.1  65.8 102.7 166.3 208.3 182.5 126.3 122.  102.7  74.1  39.   12.7
   8.2  43.4 104.4 178.3 182.2 146.6 112.1  83.5  89.2  57.8  30.7  13.9
  62.8 123.6 232.  185.3 169.2 110.1  74.5  28.3  18.9  20.7   5.7  10.
  53.7  90.5  99.  106.1 105.8  86.3  42.4  21.8  11.2  10.4  11.8  59.5
 121.7 142.  130.  106.6  69.4  43.8  44.4  20.2  15.7   4.6   8.5  40.8
  70.1 105.5  90.1 102.8  80.9  73.2  30.9   9.5   6.    2.4  16.1  79.
  95.  173.6 134.6 105.7  62.7  43.5  23.7   9.7  27.9  74.  106.5 114.7
 129.7 108.2  59.4  35.1  18.6   9.2  14.6  60.2 132.8 190.6 182.6 148.
 113.   79.2  50.8  27.1  16.1  55.3 154.3 214.7 193.  190.7 118.9  98.3
  45.   20.1   6.6  54.2 200.7 269.3 261.7 225.1 159.   76.4  53.4  39.9
  15.   22.   66.8 132.9 150.  149.4 148.   94.4  97.6  54.1  49.2  22.5
  18.4  39.3 131.  220.1 218.9 198.9 162.4  91.   60.5  20.6  14.8  33.9
 123.  211.1 191.8 203.3 133.   76.1  44.9  25.1  11.6  28.9  88.3 136.3
 173.9 170.4 163.6  99.3  65.3  45.8  24.7  12.6   4.2   4.8  24.9  80.8
  84.5  94.  113.3  69.8  39.8  21.7   7.    3.6   8.8  29.6  83.2 125.5
 154.7 123.2]

Now let us calculate the same sample PACF value using partial correlation. Specifically, we will calculate the partial correlation between the variables yty_t and yt−py_{t-p} given all the intervening variables yt−1,yt−2,…,yt−p+1y_{t-1}, y_{t-2}, \dots, y_{t-p+1}. For this, we first need to calculate the residual of yty_t given yt−1,…,yt−p+1y_{t-1}, \dots, y_{t-p+1} as well as the residual of yt−py_{t-p} given yt−1,…,yt−p+1y_{t-1}, \dots, y_{t-p+1}.

The residual of yty_t given yt−1,…,yt−p+1y_{t-1}, \dots, y_{t-p+1} is calculated as follows.

The residual of yt−py_{t-p} given yt−1,…,yt−p+1y_{t-1}, \dots, y_{t-p+1} is calculated as follows.

The sample correlation between these two residuals is the sample PACF at lag pp:

0.22133128716736616 0.2195406201858306

Note that this is basically the same as the Sample PACF at lag pp. The minor discrepancy occurs because the two residuals do not have exactly the same variance. More precisely, the regression coefficient β^j\hat{\beta}_j in a multiple linear regression of yy on a set of covariates x1,…,xkx_1, \dots, x_k satisfies the following formula:

β^j=corr(ey∣xk,k≠j,exj∣xk,k≠j)var(ey∣xk,k≠j)var(exj∣xk,k≠j)\hat{\beta}_j = \text{corr}(e^{y \mid x_k, k \neq j}, e^{x_j \mid x_k, k \neq j}) \sqrt{\frac{\text{var}(e^{y \mid x_k, k \neq j})}{\text{var}(e^{x_j \mid x_k, k \neq j})}}
570.0746123783798 579.4120815077788

These residual variances are similar but not exactly the same. This explains why the correlation between the residuals does not exactly equal the fitted regression coefficient ϕ^p\hat{\phi}_p. But if we multiply the partial correlation by the ratio of the standard deviations, we recover the sample pacf at lag p (i.e., ϕ^p\hat{\phi}_p) exactly.

0.21954062018583118 0.2195406201858306

The PACF is a standard diagnostic that is used to determine the order for a suitable AR model.

ACF (AutoCorrelation Function)

ACF is a standard diagnostic that is used to determine the order for a suitable MA model. Recall the definition of the MA(qq) model. Given a positive integer q≥1q \geq 1, the Moving Average model with order qq (denoted by MA(qq)) is defined by the equation:

yt=μ+ϵt+θ1ϵt−1+θ2ϵt−2+⋯+θqϵt−qy_t = \mu + \epsilon_t + \theta_1 \epsilon_{t-1} + \theta_2 \epsilon_{t-2} + \dots + \theta_q \epsilon_{t-q}

where ϵt∼i.i.dN(0,σ2)\epsilon_t \overset{\text{i.i.d}}{\sim} N(0, \sigma^2). The MA(qq) model has q+2q + 2 unknown parameters which are estimated from observed data: μ,θ1,…,θq,σ\mu, \theta_1, \dots, \theta_q, \sigma.

For the MA(qq) model, the correlation between yty_t and yt+hy_{t+h} is given by: $$

cov(yt,yt+h)={∑j=0q−hθjθj+h∑j=0qθj2:0≤h≤q0:h>q\begin{align*} \text{cov}(y_t, y_{t+h}) = \left\{ \begin{array}{lr} \frac{\sum_{j=0}^{q-h} \theta_j \theta_{j+h}}{\sum_{j=0}^q \theta_j^2} & : 0 \leq h \leq q\\ 0 & : h > q \end{array} \right. \end{align*}

$Thekeyhereistonotethatthecorrelationbetween The key here is to note that the correlation between y_tand and y_{t+h}equalszerowhen equals zero when h > q.Thissuggestsusingthefollowingheuristicmethodtodetermine. This suggests using the following heuristic method to determine q.Calculatethesampleautocorrelationsforeachlag. Calculate the sample autocorrelations for each lag h.Thesampleautocorrelationatlag. The sample autocorrelation at lag h$ is given by

rh:=∑t=1n−h(yt−yˉ)(yt+h−yˉ)∑t=1n(yt−yˉ)2  for h=0,1,2,… \begin{align*} r_h := \frac{\sum_{t=1}^{n-h} (y_t - \bar{y})(y_{t+h} - \bar{y})}{\sum_{t=1}^{n} (y_t - \bar{y})^2} ~~\text{for $h = 0, 1, 2, \dots$} \end{align*}

Note that r0r_0 is always equal to 1.

The sample ACF rh,h≥0r_h, h \geq 0 can be computed for any time series dataset, although it is only useful for data for which stationary models are appropriate.

If the sample ACF rhr_h for a particular dataset becomes small (not exactly zero because of randomness) when hh exceeds a particular qq, then MA(qq) is probably a good model for that dataset. This diagnostic is very commonly used when working with MA models.

It is a common diagnostic tool to look at both the ACF and PACF for a given dataset. By eyeballing them, once can find a suitable AR(pp) or a suitable MA(qq) model for the data. Below, we look at the ACF and PACF for the sunspots dataset.

<Figure size 1200x600 with 2 Axes>

For this dataset, the ACF does not seem to have a simple structure in favor of an MA model. On the other hand, the PACF has two clear spikes at lags 1 and 2 suggesting AR(2). One can also go for the AR(9) model to take into account the spikes at lags 7, 8, 9. Below we fit both these models and obtain predictions.

<Figure size 1200x600 with 1 Axes>

Visually the AR(9) predictions appear better at least for the initial few predictions.

AutoReg vs ARIMA

There are two inbuilt functions in statsmodels for fitting AR models: (a) AutoReg (which we used previously), and (b) ARIMA (which can be used more generally for all ARIMA models). We compare and contrast these two ways below. We use the GNP dataset (from FRED).

  observation_date      GNP
0       1947-01-01  244.142
1       1947-04-01  247.063
2       1947-07-01  250.716
3       1947-10-01  260.981
4       1948-01-01  267.133
<Figure size 640x480 with 1 Axes>

Instead of the raw GNP, we work with their logarithms as usual.

<Figure size 640x480 with 1 Axes>

We fit AR models to differences of the logs (after multiplying by 100). The data now becomes percent change in GNP.

<Figure size 640x480 with 1 Axes>

Let us now fit the AR(1) model to this dataset. Let us first fit it using AutoReg.

                            AutoReg Model Results                             
==============================================================================
Dep. Variable:                      y   No. Observations:                  317
Model:                     AutoReg(1)   Log Likelihood                -516.768
Method:               Conditional MLE   S.D. of innovations              1.242
Date:                Sun, 08 Nov 2026   AIC                           1039.536
Time:                        14:06:18   BIC                           1050.803
Sample:                             1   HQIC                          1044.037
                                  317                                         
==============================================================================
                 coef    std err          z      P>|z|      [0.025      0.975]
------------------------------------------------------------------------------
const          1.1627      0.109     10.640      0.000       0.949       1.377
y.L1           0.2477      0.055      4.544      0.000       0.141       0.355
                                    Roots                                    
=============================================================================
                  Real          Imaginary           Modulus         Frequency
-----------------------------------------------------------------------------
AR.1            4.0369           +0.0000j            4.0369            0.0000
-----------------------------------------------------------------------------

AutoReg uses the method of conditional MLE, which maximizes the conditional likelihood of y2,…,yny_2, \dots, y_n given y1y_1. This conditional likelihood is given by:

(12πσ)n−1exp⁡(−12σ2∑t=2n(yt−ϕ0−ϕ1yt−1)2).\left(\frac{1}{\sqrt{2 \pi} \sigma} \right)^{n-1} \exp \left(-\frac{1}{2 \sigma^2} \sum_{t=2}^n (y_t - \phi_0 - \phi_1 y_{t-1})^2 \right).
[1.16274269 0.24771615]
1.5415767673398826

Next we use the ARIMA function to fit AR(1). ARIMA models have a triplet of indices (p,d,q)(p, d, q). pp stands for the AR order, dd stands for the amount of differencing, and qq stands for the MA order. To fit AR(1) through the ARIMA function, we need to use p=1p = 1, d=0d = 0 and q=0q = 0.

                               SARIMAX Results                                
==============================================================================
Dep. Variable:                      y   No. Observations:                  317
Model:                 ARIMA(1, 0, 0)   Log Likelihood                -517.973
Date:                Sun, 08 Nov 2026   AIC                           1041.945
Time:                        14:07:18   BIC                           1053.222
Sample:                             0   HQIC                          1046.450
                                - 317                                         
Covariance Type:                  opg                                         
==============================================================================
                 coef    std err          z      P>|z|      [0.025      0.975]
------------------------------------------------------------------------------
const          1.5437      0.112     13.783      0.000       1.324       1.763
ar.L1          0.2470      0.020     12.587      0.000       0.209       0.285
sigma2         1.5371      0.040     38.100      0.000       1.458       1.616
===================================================================================
Ljung-Box (L1) (Q):                   0.82   Jarque-Bera (JB):              6927.23
Prob(Q):                              0.36   Prob(JB):                         0.00
Heteroskedasticity (H):               1.64   Skew:                            -0.06
Prob(H) (two-sided):                  0.01   Kurtosis:                        25.90
===================================================================================

Warnings:
[1] Covariance matrix calculated using the outer product of gradients (complex-step).

ARIMA parametrizes the AR(1) model differently from AutoReg. It writes the AR(1) model as:

yt−μ=ϕ1(yt−1−μ)+ϵt.\begin{align*} y_t - \mu = \phi_1 (y_{t-1} - \mu) + \epsilon_t. \end{align*}

In other words, there is no ϕ0\phi_0 parameter. It is replaced by μ−μϕ1\mu - \mu \phi_1. This means that ϕ0=μ−μϕ1\phi_0 = \mu - \mu \phi_1 or μ=ϕ0/(1−ϕ1)\mu = \phi_0/(1 - \phi_1). So to compare the parameter estimates given by AutoReg and ARIMA, we need to convert the estimates ϕ0,ϕ1\phi_0, \phi_1 from AutoReg to μ,ϕ1\mu, \phi_1.

[[1.54561697 1.54372907]
 [0.24771615 0.24699388]
 [1.54157677 1.53707575]]

The parameter estimates are similar but not exactly the same. This is because ARIMA is using a different method of parameter estimation compared to AutoReg. ARIMA works with the full likelihood of y1,…,yny_1, \dots, y_n (not the conditional likelihood of y2,…,yny_2, \dots, y_n given y1y_1). We saw in lecture 17 that the full likelihood for AR(1) is given by:

1−ϕ122πσexp⁡(−1−ϕ122σ2(y1−ϕ01−ϕ1)2)(12πσ)n−1exp⁡(−12σ2∑t=2n(yt−ϕ0−ϕ1yt−1)2).\frac{\sqrt{1 - \phi_1^2}}{\sqrt{2 \pi} \sigma} \exp \left(-\frac{1 - \phi_1^2}{2 \sigma^2} \left(y_1 - \frac{\phi_0}{1 - \phi_1} \right)^2 \right) \left(\frac{1}{\sqrt{2 \pi} \sigma} \right)^{n-1} \exp \left(-\frac{1}{2 \sigma^2} \sum_{t=2}^n (y_t - \phi_0 - \phi_1 y_{t-1})^2 \right).

Instead of parametrizing using ϕ0,ϕ1\phi_0, \phi_1 and σ\sigma, an alternative parametrization is via ϕ1,σ\phi_1, \sigma and μ:=ϕ0/(1−ϕ1)\mu := \phi_0/(1 - \phi_1). With this the likelihood becomes:

1−ϕ122πσexp⁡(−1−ϕ122σ2(y1−μ)2)(12πσ)n−1exp⁡(−12σ2∑t=2n((yt−μ)−ϕ1(yt−1−μ))2).\frac{\sqrt{1 - \phi_1^2}}{\sqrt{2 \pi} \sigma} \exp \left(-\frac{1 - \phi_1^2}{2 \sigma^2} \left(y_1 - \mu \right)^2 \right) \left(\frac{1}{\sqrt{2 \pi} \sigma} \right)^{n-1} \exp \left(-\frac{1}{2 \sigma^2} \sum_{t=2}^n ((y_t - \mu) - \phi_1 (y_{t-1} - \mu))^2 \right).

The following function computes the log-likelihood given values of the parameters.

We can attempt to maximize this full log-likelihood using an inbuilt optimization function, starting with the parameter estimates given by AutoReg. The code for doing this is given below. This gives almost the same results as the parameter estimates given by ARIMA.

MLE estimates from custom optimization:
[[1.54561697 1.54372907 1.54375572]
 [0.24771615 0.24699388 0.24699483]
 [1.54157677 1.53707575 1.53708839]]
-517.9735374533072 -517.9725743205034 -517.9725742723975

Another difference between AutoReg and ARIMA is that ARIMA, by default, only searches for parameters in the stable region but AutoReg does not place any such restrictions. Stable region corresponds to the values of the parameters for which the roots of the polynomial 1−ϕ1z−ϕ2z2−⋯−ϕpzp1 - \phi_1 z - \phi_2 z^2 - \dots - \phi_p z^p are strictly larger than 1 in modulus. Another name for the stable region is ‘causal-stationary’ region (or simply ‘stationary’ region). For AR(1), the stable region corresponds to ∣ϕ1∣<1|\phi_1| < 1 (because the AR(1) polynomial is 1−ϕ1z1 - \phi_1 z whose root is 1/ϕ11/\phi_1. So root having modulus strictly larger than 1 is equivalent to ∣ϕ1∣<1|\phi_1| < 1).

To illustrate this difference between AutoReg and ARIMA, let us fit the AR(1) model to the original data (without any differencing and logging). Then the AutoReg will give an estimate of ϕ1\phi_1 that is strictly larger than 1. But ARIMA will still give an estimate from the stable region (strictly smaller than 1 in absolute value).

1.0121954720762598
0.9999195196243736
/Users/aditya/mambaforge/envs/stat153fall2026/lib/python3.14/site-packages/statsmodels/tsa/statespace/sarimax.py:966: UserWarning: Non-stationary starting autoregressive parameters found. Using zeros as starting parameters.
  warn('Non-stationary starting autoregressive parameters'

If we want the ARIMA function to not focus only on the stable region, then we have to explicitly use the clause ‘enforce_stationarity = False’.

1.012079994049166

Let us now get back to fitting models for the logarithms for yy. Instead of applying the ARIMA function to ylogdiff, we can apply it directly to ylog. In this case, we have to choose d=1d = 1 (as opposed to d=0d = 0).

                               SARIMAX Results                                
==============================================================================
Dep. Variable:                      y   No. Observations:                  318
Model:                 ARIMA(1, 1, 0)   Log Likelihood                -566.939
Date:                Sun, 08 Nov 2026   AIC                           1137.877
Time:                        14:37:05   BIC                           1145.395
Sample:                             0   HQIC                          1140.880
                                - 318                                         
Covariance Type:                  opg                                         
==============================================================================
                 coef    std err          z      P>|z|      [0.025      0.975]
------------------------------------------------------------------------------
ar.L1          0.6924      0.030     23.317      0.000       0.634       0.751
sigma2         2.0896      0.076     27.320      0.000       1.940       2.239
===================================================================================
Ljung-Box (L1) (Q):                  62.72   Jarque-Bera (JB):             22699.21
Prob(Q):                              0.00   Prob(JB):                         0.00
Heteroskedasticity (H):               2.01   Skew:                             2.66
Prob(H) (two-sided):                  0.00   Kurtosis:                        44.11
===================================================================================

Warnings:
[1] Covariance matrix calculated using the outer product of gradients (complex-step).

The difference now is that the μ\mu parameter is no longer present. In other words, the model that is fit here is:

100(log⁡yt−log⁡yt−1)=ϕ1100(log⁡yt−1−log⁡yt−2)+ϵt.\begin{align*} 100 \left( \log y_t - \log y_{t-1} \right) = \phi_1 100 \left( \log y_{t-1} - \log y_{t-2} \right) + \epsilon_t. \end{align*}

Whenever the differencing order is 1 or more, ARIMA does not use the intercept parameter. This makes a noticeable difference in predictions however.

<Figure size 640x480 with 1 Axes>

On the other hand, if we use the model on ylogdiff, then the predictions for ylog are computed in the following way. We basically obtain predictions for the differenced series, and then use the predictions for yn+1−yn,yn+2−yn+1,…,yn+k−yn+k−1y_{n+1} - y_n, y_{n+2} - y_{n+1}, \dots, y_{n+k}-y_{n+k-1} to get predictions for yn+1,…,yn+ky_{n+1}, \dots, y_{n+k}. This is done by taking telescoping sums of yn+1−yn,yn+2−yn+1,…,yn+k−yn+k−1y_{n+1} - y_n, y_{n+2} - y_{n+1}, \dots, y_{n+k}-y_{n+k-1}, and then adding yny_n.

<Figure size 640x480 with 1 Axes>

So here the presence of the intercept is leading to more intuitive predictions.

Another dataset from FRED

Here is a FRED dataset on total construction spending in the United States (https://fred.stlouisfed.org/series/TTLCONS).

  observation_date  TTLCONS
0       1993-01-01   458080
1       1993-02-01   462967
2       1993-03-01   458399
3       1993-04-01   469425
4       1993-05-01   468998
405
<Figure size 640x480 with 1 Axes>

As usual, we fit models to logarithms of the data.

<Figure size 640x480 with 1 Axes>

In order to obtain candidate models, let us first difference the data, and then look at acf and pacf.

<Figure size 640x480 with 1 Axes>

Here is how to compute the ACF and PACF.

<Figure size 1200x600 with 2 Axes>

These plots suggest:

  1. AR(3) for the differenced log data (to account for the three spikes in PACF)

  2. MA(6) for the differenced log data (to account for the six spikes in ACF)

  3. ARIMA(3, 1, 0) for the log data (this is technically the same as Model 1 but the ARIMA function does not include intercepts while fitting this model so it can lead to different predictions)

  4. ARIMA(0, 1, 6) for the log data

We can also take another difference of the data, and then look at acf and pacf.

<Figure size 640x480 with 1 Axes>
<Figure size 640x480 with 2 Axes>

The ACF plot above (which has a single spike) suggests the ARIMA(0, 1, 2) model for ylog.

Here is how to calculate the predictions for each of the five models.

First is Model One: AR(3) for the differenced log data.

<Figure size 640x480 with 1 Axes>

Next is Model Two: MA(6) on differenced log data.

<Figure size 640x480 with 1 Axes>

So Model One and Model Two lead to basically the same predictions.

Next is Model Three which ARIMA(3, 1, 0).

/Users/aditya/mambaforge/envs/stat153fall2026/lib/python3.14/site-packages/statsmodels/base/model.py:607: ConvergenceWarning: Maximum Likelihood optimization failed to converge. Check mle_retvals
  warnings.warn("Maximum Likelihood optimization failed to "
<Figure size 640x480 with 1 Axes>

The prediction is flat because of the lack of the intercept term in ARIMA(3, 1, 0).

<Figure size 640x480 with 1 Axes>

The forecasts for models 3 and 4 are largely similar.

Finally below are the predictions for model 5.

<Figure size 640x480 with 1 Axes>

Let us try to manually fit the AR(1) model to the double differenced data (so the model will involve an intercept), and then manually convert the predictions on the double differenced data to predictions on the original data.

<Figure size 640x480 with 1 Axes>

All these models give quite different predictions. Which prediction do you like?