Tutorials › Exam SRM - Statistics for Risk Modeling › Degrees of Freedom in Portmanteau Diagnostics

Exam SRM · Time-Series Model Selection · Tutorial 518 of 926

Degrees of Freedom in Portmanteau Diagnostics

Calculate the appropriate chi-square degrees of freedom for Ljung–Box diagnostics after fitting ARMA and ARIMA models, and recognize when the usual adjustment cannot support a test.

Advanced 12 min read

What You'll Learn

  • State the approximate null distribution used for a Ljung–Box residual test
  • Adjust the reference degrees of freedom for estimated AR and MA parameters
  • Count seasonal and nonseasonal AR and MA terms in a fitted ARIMA model
  • Distinguish differencing orders from parameters counted in the adjustment
  • Identify when the chosen lag leaves zero or negative reference degrees of freedom
  • Avoid confusing the degrees-of-freedom adjustment with the Ljung–Box statistic itself

Why Degrees of Freedom Change After Fitting

A Ljung–Box test checks whether a set of residual autocorrelations is collectively consistent with zero. When the series is observed directly, the usual large-sample reference distribution has degrees of freedom equal to the number of lags tested. After fitting an ARMA model, however, the residuals are not unrelated to the data used for fitting: estimating autoregressive and moving-average parameters has already used information about serial dependence. The reference degrees of freedom are therefore adjusted.

This adjustment matters for a practical reason. Comparing a residual test statistic with the wrong chi-square distribution can change the conclusion about model adequacy. In particular, failing to account for fitted AR and MA terms typically uses too many degrees of freedom and an inappropriate reference distribution. The adjustment is a convention for the approximate residual test, not a change to the Ljung–Box statistic itself.

Definition: For a series of \(n\) observations, let \(\hat{\rho}_k\) be the sample autocorrelation at lag \(k\). The Ljung–Box statistic through lag \(h\) is $$ Q^*=n(n+2)\sum_{k=1}^{h}\frac{\hat{\rho}_k^2}{n-k}. $$ For residuals from a fitted nonseasonal ARMA(\(p,q\)) model, the conventional approximate reference distribution under the null of no remaining autocorrelation is \(\chi^2_{h-p-q}\), provided \(h>p+q\). Here \(p\) and \(q\) are the numbers of fitted nonseasonal AR and MA parameters, respectively.

The null hypothesis is that the residual autocorrelations at the tested lags are jointly zero. The chi-square approximation is an asymptotic diagnostic, not an exact finite-sample result. It is most useful when the model is appropriately specified, the parameter estimates are regular, and the sample is large enough for the approximation to be reasonable. The choice of \(h\) should also leave positive reference degrees of freedom.

How the Adjustment Works

The lag limit \(h\) determines how many residual autocorrelations enter the statistic. In the unadjusted setting, those \(h\) autocorrelations correspond to \(h\) contributions to the diagnostic, giving the usual approximate \(\chi^2_h\) reference distribution. In a fitted ARMA model, estimating \(p+q\) dynamic parameters uses information about the same serial structure that the test assesses. The standard residual-test approximation consequently uses \(h-(p+q)\) degrees of freedom.

A useful way to understand the rule is through the effect of fitting. Under the null, the vector of residual autocorrelations does not behave like \(h\) wholly unrestricted, independent quantities: fitting the AR and MA parameters imposes constraints on its variation. In the large-sample quadratic-form approximation behind the test, those fitted dynamic directions reduce the effective dimension by \(p+q\). This yields the conventional chi-square reference distribution with \(h-p-q\) degrees of freedom. This explanation motivates the standard result; it is not a claim that each estimated parameter simply deletes one particular lag from the displayed sum.

1
Choose the diagnostic lag limit.
Record \(h\), the largest lag included in \(Q^*\).
2
Count fitted AR and MA terms.
For ordinary ARMA(\(p,q\)), count \(p+q\). For a seasonal ARIMA model, include both seasonal and nonseasonal AR and MA orders.
3
Calculate the reference degrees of freedom.
Use \(h\) minus the counted AR and MA parameters. Do not use this approximation if the resulting degrees of freedom are not positive.
4
Compare the statistic with the matching distribution.
Use \(\chi^2\) with the adjusted degrees of freedom to obtain a tail probability or compare with a critical value at the stated significance level.

For an ARIMA(\(p,d,q\)) model, the differencing order \(d\) is not included in the conventional adjustment. Differencing is not an estimated AR or MA coefficient. For a seasonal ARIMA(\(p,d,q\))(\(P,D,Q\))\(_s\) model, the usual adjustment is \(h-p-q-P-Q\): seasonal differencing order \(D\), ordinary differencing order \(d\), and seasonal period \(s\) do not themselves count as AR or MA parameters. The adjustment concerns the dynamic AR and MA terms fitted in the model.

Worked Calculations and Decisions

Worked Example: Correcting the Degrees of Freedom for a Fitted ARMA Model

A hypothetical monthly claim-count series has \(n=80\) observations. An ARMA(1,1) model is fitted, and residual autocorrelations through lag \(h=3\) are \(0.12\), \(0.16\), and \(0.0471606\). Calculate the Ljung–Box statistic and identify the reference distribution. Use a 5% significance level.

Method. First calculate the statistic from the three given residual autocorrelations. Then adjust the degrees of freedom by the two fitted dynamic parameters: one AR and one MA. This avoids the mistake of using \(\chi^2_3\) just because three lags appear in the sum.

Here \(n(n+2)=80(82)=6{,}560\). The three lag contributions are:

Lag 1: \(6{,}560(0.12^2)/79=6{,}560(0.0144)/79=94.464/79\approx1.1957\).

Lag 2: \(6{,}560(0.16^2)/78=6{,}560(0.0256)/78=167.936/78\approx2.1530\).

Lag 3: \(6{,}560(0.0471606^2)/77\approx6{,}560(0.00222412)/77\approx0.1895\).

Adding the unrounded contributions gives \(Q^*\approx3.5383\). The degrees of freedom are \(h-p-q=3-1-1=1\), so the approximate reference distribution is \(\chi^2_1\). Its 5% upper critical value is approximately \(3.841\). Since \(3.5383<3.841\), do not reject the null at the 5% level. The diagnostic does not provide sufficient evidence of residual autocorrelation through lag 3 at that level.

Check. The statistic is positive, as it must be because it is a sum of nonnegative terms. The reference degrees of freedom are positive, and they are one less than the number of included lags after accounting for the two fitted ARMA parameters.

Worked Example: Counting Seasonal AR and MA Parameters

A hypothetical quarterly operational series is fitted with ARIMA(1,1,1)(0,1,1)\(_4\). A residual Ljung–Box statistic through lag \(h=16\) is \(Q^*=21.0\). At the 5% level, determine the appropriate reference degrees of freedom and the test conclusion. Use the upper 5% critical value \(\chi^2_{13,0.95}=22.362\).

Method. Count the ordinary AR and MA terms and the seasonal AR and MA terms. Do not count the two differencing orders or the seasonal period as fitted AR or MA parameters.

The ordinary orders contribute \(p+q=1+1=2\). The seasonal orders contribute \(P+Q=0+1=1\). Thus, the total counted for the adjustment is \(2+1=3\). The ordinary differencing order \(d=1\) and seasonal differencing order \(D=1\) are not added.

The adjusted degrees of freedom are \(16-3=13\). Because \(Q^*=21.0<22.362\), do not reject the null at the 5% level. There is not sufficient evidence from this test to conclude that residual autocorrelation remains through lag 16.

Check. The seasonal MA term is counted once, so three AR and MA parameters are subtracted in total. If the differencing orders had incorrectly been counted too, the result would have been \(16-5=11\), which is not the conventional adjustment for this fitted model.

Worked Example: Recognizing an Unusable Lag Choice

A hypothetical weekly series is fitted with ARIMA(2,1,2). A practitioner proposes a Ljung–Box test through lag \(h=4\). Explain whether the conventional adjusted chi-square test can be used at this lag. Then state the degrees of freedom if the test is instead taken through lag \(h=8\).

Method. The model has \(p=2\) AR terms and \(q=2\) MA terms, so the parameter adjustment is \(p+q=4\). The differencing order \(d=1\) is not counted.

At \(h=4\), the nominal adjusted degrees of freedom are \(4-2-2=0\). A \(\chi^2_0\) distribution is not a usable reference distribution for this test, so the conventional approximation cannot be applied with this lag choice. Increasing the lag limit to \(h=8\) gives \(8-2-2=4\) degrees of freedom, with approximate reference distribution \(\chi^2_4\).

Check. The differencing order is excluded, but even if it were mistakenly counted, the result would be less defensible, not a positive valid degrees-of-freedom adjustment at \(h=4\). A zero result signals the need for a different diagnostic lag choice, not a chi-square test with zero degrees of freedom.

What the Adjustment Does—and Does Not Do

The adjustment changes the reference distribution used to interpret \(Q^*\); it does not change the residual autocorrelations, the lag limit, or the formula for \(Q^*\). For example, one calculates the statistic using every \(\hat{\rho}_k\) from \(k=1\) through \(h\), and only then uses the adjusted degrees of freedom for a tail probability or critical-value comparison.

The conventional rule for a nonseasonal ARMA model is \(h-p-q\). For a seasonal ARIMA model, count all fitted nonseasonal and seasonal AR and MA orders: \(h-p-q-P-Q\). The rule does not mean subtracting differencing orders, the seasonal period, or the number of lags at which a sample autocorrelation happens to be large. Nor does it say that \(Q^*\) itself should be reduced by \(p+q\).

In model diagnostics, a non-rejection is not proof that the errors are independent or that the model is correct. It means that this particular test, at the chosen lag limit and significance level, has not found enough evidence against its null. A rejection signals remaining serial dependence somewhere among the tested lags; it does not identify the cause. The later interpretation of specific residual patterns is a separate diagnostic task.

The degrees-of-freedom rule is an approximation used for the standard fitted-ARMA residual test. More complicated settings, such as additional estimated regression effects or specialized estimation procedures, may require a test-specific adjustment. Follow the convention specified for the diagnostic being used, and do not silently count every estimated model component as though it were an AR or MA order. The standard ARIMA adjustment described here counts the fitted AR and MA orders.

Common Exam Traps

  • Using \(h\) instead of adjusted degrees of freedom. For fitted ARMA(\(p,q\)) residuals, use \(h-p-q\), not \(h\), as the conventional reference degrees of freedom.
  • Subtracting differencing orders. In ARIMA(\(p,d,q\)), \(d\) is not part of the AR/MA adjustment. Seasonal differencing \(D\) is likewise not counted.
  • Forgetting seasonal dynamics. In a seasonal ARIMA model, include \(P\) and \(Q\) as well as \(p\) and \(q\).
  • Subtracting parameters from the statistic. Calculate \(Q^*\) from its stated formula; adjust only the chi-square degrees of freedom used for inference.
  • Using a nonpositive result. If \(h\) is no greater than the counted AR and MA orders, the usual adjusted chi-square approximation is not usable.
  • Rounding too early. Retain precision when calculating individual lag contributions, sum them, and round the final statistic only at the requested precision.
Key takeaway: For the conventional Ljung–Box residual test, calculate the statistic from all residual autocorrelations through lag \(h\), then use \(h-p-q\) degrees of freedom for ARMA(\(p,q\)). For seasonal ARIMA, use \(h-p-q-P-Q\). Differencing orders are not included, and the resulting degrees of freedom must be positive.

Check Your Understanding

For each problem, apply the fitted-model adjustment and distinguish the statistic from its reference degrees of freedom.

  1. A fitted ARMA(2,1) model is checked through lag \(h=8\). What are the adjusted degrees of freedom? (Answer: \(8-2-1=5\).)
  2. A fitted ARIMA(0,1,2)(1,0,1)\(_{12}\) model is checked through lag \(h=15\). Count the relevant terms and find the adjusted degrees of freedom. (Answer: \(p+q+P+Q=0+2+1+1=4\), so \(15-4=11\) degrees of freedom.)
  3. A fitted ARIMA(2,1,2) model is checked through lag \(h=5\). Is the conventional adjusted chi-square approximation available, and why? (Answer: Yes; the adjusted degrees of freedom are \(5-2-2=1\), which is positive.)
  4. A fitted ARMA(1,1) model is checked through lag \(h=2\). What issue arises? (Answer: The adjustment gives \(2-1-1=0\), so the conventional adjusted chi-square approximation is not usable at this lag.)
  5. For \(n=60\), residual autocorrelations through lag 3 are \(0.10\), \(0.05\), and \(0.10\), from a fitted ARMA(1,1) model. Calculate \(Q^*\) to four decimal places and give the reference degrees of freedom. (Answer: \(Q^*=60(62)[0.10^2/59+0.05^2/58+0.10^2/57]\approx1.4435\); reference degrees of freedom \(=3-1-1=1\).)
Clinical Biostats