Skip to content

OLS

from SymbolicDSGE.regression.ols import OLSResult, ols
ols(
    x: ndarray,
    y: ndarray,
    variables: list[str] | None = None,
    intercept: bool = True,
) -> OLSResult

Run Ordinary Least Squares regression on a one-dimensional response and a two-dimensional design matrix.

Inputs:

Name Description
x Design matrix. Shape (n, k).
y Response vector. Shape (n,).
variables Optional names for the columns of x. Defaults to x0, x1, ...
intercept If True, prepend an intercept column to the design matrix.

Returns:

Type Description
OLSResult Regression result with common fitted diagnostics and OLS inference outputs.

 

@dataclass(frozen=True)
class OLSResult(RegressionResult)

OLSResult extends RegressionResult with standard errors, coefficient tests, confidence intervals, and an F-test.

Additional Fields and Methods:

Name Type Description
se ndarray Coefficient standard errors.
t_stat ndarray Coefficient t-statistics.
partial_r2 ndarray Partial R-squared values implied by each t-statistic.
p_values ndarray Two-sided coefficient p-values under the t reference distribution.
confidence_intervals(alpha=0.05) ndarray Lower and upper coefficient bounds. Shape (k, 2).
summary(alpha=0.05) pandas.DataFrame Coefficient, interval, t-statistic, p-value, and partial R-squared table.
F_test(alpha=0.05) TestResult Regression F-test against the relevant F reference distribution.
Rank-Deficient Designs

OLS first attempts a Cholesky solve and falls back to least squares when needed. The status field records the solver status used by the result.