Skip to content

Regression Results

from SymbolicDSGE.regression import RegressionResult
from SymbolicDSGE.regression.ols import MCRegressionResult

 

@dataclass(frozen=True)
class RegressionResult(
    variables: list[str],
    coefficients: ndarray,
    y: ndarray,
    X: ndarray,
    status: RegressionStatus,
)

RegressionResult is the shared result abstraction for standard linear regression outputs. Concrete result types inherit the common fitted-data diagnostics and add method-specific quantities.

Fields and Properties:

Name Type Description
variables list[str] Names of the design columns represented in coefficients.
coefficients ndarray Estimated coefficient vector. Shape (k,).
y ndarray Response vector. Shape (n,).
X ndarray Design matrix used by the regression. Shape (n, k).
x ndarray Alias for X.
status RegressionStatus Solver status.
n int Number of observations.
k int Number of design columns.
y_hat ndarray Fitted response vector.
residuals ndarray Response residuals, y - y_hat.
ssr float64 Sum of squared residuals.
sst float64 Total sum of squares around the sample mean of y.
mse float64 Mean squared error, ssr / n.
rmse float64 Root mean squared error.
r2 float64 Coefficient of determination.
r2_adj float64 Adjusted coefficient of determination.
to_dict() dict Dataclass dictionary representation.
Shape Contract

RegressionResult expects a one-dimensional response vector and a two-dimensional design matrix. Multivariate response regressions should be represented as separate result objects.

 

@dataclass(frozen=True)
class MCRegressionResult(
    variables: list[str],
    results: tuple[RegressionResult, ...],
)

MCRegressionResult aggregates per-replication RegressionResult objects produced by Monte Carlo regression steps.

Fields and Properties:

Name Type Description
variables list[str] Shared variable ordering across replications.
results tuple[RegressionResult, ...] Per-replication regression outputs.
coef_trace ndarray Coefficients stacked by replication. Shape (n_rep, k).
coefficients ndarray Alias for coef_trace.
status_trace tuple[RegressionStatus, ...] Solver status for each replication.
n_rep int Number of stored regression results.
n int Shared number of observations per replication.
k int Shared number of design columns.
y_trace ndarray Response vectors stacked by replication.
x_trace ndarray Design matrices stacked by replication.
y_hat_trace ndarray Fitted responses stacked by replication.
residual_trace ndarray Residual vectors stacked by replication.
ssr_trace ndarray Per-replication SSR values.
sst_trace ndarray Per-replication SST values.
mse_trace ndarray Per-replication MSE values.
rmse_trace ndarray Per-replication RMSE values.
r2_trace ndarray Per-replication R-squared values.
r2_adj_trace ndarray Per-replication adjusted R-squared values.
summary(alpha=0.05) pandas.DataFrame Coefficient trace summary. OLS results include inference columns.
to_dict() dict Compact dictionary representation.

OLS-Only Aggregate Diagnostics:

Name Type Description
se_trace ndarray OLS standard-error trace.
t_stat_trace ndarray OLS t-statistic trace.
partial_r2_trace ndarray OLS partial R-squared trace.
pval_trace ndarray OLS coefficient p-value trace.
F_stat_trace ndarray OLS F-statistic trace.
F_pval_trace ndarray OLS F-test p-value trace.
confidence_intervals(alpha=0.05) ndarray Per-replication OLS coefficient intervals.
F_test(alpha=0.05) MCResult Aggregate F-test result container.
OLS-Specific Diagnostics

OLS aggregate diagnostics require every stored result to be an OLSResult. For ridge, lasso, and elastic-net aggregates, summary() returns coefficient traces without OLS inference columns.