ramsey_reset#
- cultivars.diagnostics.nonlinearity.ramsey_reset(endog, *, order, powers=3)[source]#
Ramsey’s RESET on an autoregression: do powers of the fitted value explain the residual?
The AR(\(p\)) is fitted, its fitted values \(\hat y_t\) raised to the powers \(2, \ldots, k\), and those powers added to the regression,
\[y_t = \phi^\top w_t + \sum_{j = 2}^{k} \gamma_j\, \hat y_t^{\,j} + e_t,\]with the joint exclusion \(\gamma_2 = \cdots = \gamma_k = 0\) tested by \(F(k - 1,\; n - p - k)\) with \(n\) the rows of the autoregression. The test names no alternative: any smooth misspecification of the conditional mean, a missing regime, a nonlinear lag, an omitted regressor correlated with the fitted value, raises the powers of the fitted value, so it is the general-purpose check to run when the regime tests disagree, and a rejection here without one from
tsay()orterasvirta()points away from a regime model.- Parameters:
- Return type:
- Returns:
The
LinearityTestnamed"RESET", withalternative="smooth misspecification",delay=None, and no companions.- Raises:
SpecificationError – If the order is not positive,
powersis below 2, or the series is too short.NumericalError – If a value is not finite or the augmented regression is degenerate, which a series whose fitted values are nearly constant produces.
Note
High powers of the fitted value are nearly collinear with each other, so
powersabove 4 buys little and costs conditioning; the default of 3 is Ramsey’s.See also
terasvirta()andtsay()– the tests that name an alternative.LinearityTest– the record.
References
Ramsey, J. B. (1969). Tests for specification errors in classical linear least-squares regression analysis. Journal of the Royal Statistical Society B, 31(2), 350-371.
Thursby, J. G., & Schmidt, P. (1977). Some properties of tests for specification error in a linear regression model. Journal of the American Statistical Association, 72(359), 635-641.
Example
A linear AR(1) keeps the null; the two-regime series of the module examples rejects it:
>>> import numpy as np >>> rng = np.random.default_rng(0) >>> y = np.zeros(300) >>> for t in range(1, 300): ... y[t] = 0.5 * y[t - 1] + rng.standard_normal() >>> verdict = ramsey_reset(y, order=1) >>> verdict.reject(), verdict.df, verdict.delay (False, (2, 295), None) >>> z = np.zeros(300) >>> for t in range(1, 300): ... z[t] = (0.8 if z[t - 1] <= 0.0 else -0.5) * z[t - 1] + rng.standard_normal() >>> ramsey_reset(z, order=1).reject() True