LinearRegression

Guide & worked example · Source

LinearRegression(solver='torch', device=None)

Least squares with optional additive fixed effects.

X must include a constant if desired. weights are strictly positive analytic/WLS weights, not frequency counts. classical uses weighted SSE divided by residual degrees of freedom; HC0/HC1 use the weighted sandwich. HC1 counts the exact rank of the absorbed effects by default.

Absorbed columns (including an intercept) retain zero coefficient/SE slots. predict(X) returns the slope component only, not FE level predictions. fitted_values_ includes the fitted effects for the training observations.

Attributes

Name Description
device
params
solver

Methods

Name Description
fit Fit; optionally override absorbed rank for large multi-way FE designs.
predict Slope-only predictions; additive FE contributions are not included.
summary Print a summary of the model results.
to Move all model parameters to specified device.

fit

LinearRegression.fit(
    X,
    y,
    se=None,
    fe=None,
    weights=None,
    *,
    tol=1e-10,
    maxiter=100000,
    df_absorbed=None,
)

Fit; optionally override absorbed rank for large multi-way FE designs.

Rank-deficient non-absorbed columns raise instead of returning arbitrary coefficients. Failed absorption raises rather than returning a partial fit.

predict

LinearRegression.predict(X)

Slope-only predictions; additive FE contributions are not included.

summary

LinearRegression.summary()

Print a summary of the model results.

to

LinearRegression.to(device)

Move all model parameters to specified device.

Parameters

Name Type Description Default
device torch.device or str Target device (‘cuda’, ‘cpu’, etc.) required

Returns

Name Type Description
BaseEstimator Self for method chaining