yatsm.regression package¶
Subpackages¶
Submodules¶
Module contents¶
-
yatsm.regression.
design_to_indices
(design_matrix, features)[source]¶ Return indices of coefficients for features in design matrix
Parameters: Returns: - list of indices and names for each feature specified in
features
Return type:
-
yatsm.regression.
find_packaged_regressor
(name)[source]¶ Find location of a regression method packaged with YATSM
See
packaged_regressions
for a list of available pre-packaged regressorsParameters: name¶ – name of packaged regression object
Returns: path to packaged regression method
Return type: Raises:
-
yatsm.regression.
recresid
(X, y, span=None)[source]¶ Return standardized recursive residuals for y ~ X
For a matrix \(X_t\) of \(T\) total observations of \(n\) variables, the \(t\) th recursive residual is the forecast prediction error for \(y_t\) using a regression fit on the first \(t - 1\) observations. Recursive residuals are scaled and standardized so they are N(0, 1) distributed.
Using notation from Brown, Durbin, and Evans (1975) and Judge, et al (1985):
\[ \begin{align}\begin{aligned}w_r = \frac{y_r - \boldsymbol{x}_r^{\prime}\boldsymbol{b}_{r-1}} {\sqrt{(1 + \boldsymbol{x}_r^{\prime} S_{r-1}\boldsymbol{x}_r)}} = \frac {y_r - \boldsymbol{x}_r^{\prime}\boldsymbol{b}_r} {\sqrt{1 - \boldsymbol{x}_r^{\prime}S_r\boldsymbol{x}_r}}\\r = k + 1, \ldots, T,\end{aligned}\end{align} \]where \(S_{r}\) is the residual sum of squares after fitting the model on \(r\) observations.
A quick way of calculating \(\boldsymbol{b}_r\) and \(S_r\) is using an update formula (Equations 4 and 5 in Brown, Durbin, and Evans; Equation 5.5.14 and 5.5.15 in Judge et al):
\[\boldsymbol{b}_r = b_{r-1} + \frac {S_{r-1}\boldsymbol{x}_j (y_r - \boldsymbol{x}_r^{\prime}\boldsymbol{b}_{r-1})} {1 + \boldsymbol{x}_r^{\prime}S_{r-1}x_r}\]\[S_r = S_{j-1} - \frac{S_{j-1}\boldsymbol{x}_r\boldsymbol{x}_r^{\prime}S_{j-1}} {1 + \boldsymbol{x}_r^{\prime}S_{j-1}\boldsymbol{x}_r}\]See the recursive residuals implementation that this follows, recursive_olsresiduals, within the statsmodels.stats.diagnostic module.
Parameters: Returns: - array containing recursive residuals standardized by
prediction error variance
Return type: np.ndarray