Skip to content

Regression without a formula

In the app: Help → Help contents, Regression without a formula.

For code that runs many small regressions (loops, simulations, model building), pymetrix.ols(y, X) skips the formula and the dataset: y is a Series (or a 1-d array), X a DataFrame (or a 2-d array, with names= for its columns). The options are those of OLS: cov="classic", "white" (HC1), "hc0", "hc2" to "hc5", "hac" (with hac_lags and hac_correction), or Cluster(...) with clusters= (one- or two-way); constant=False leaves out the intercept; weights= gives weighted least squares; missing="raise" refuses missing values instead of dropping their rows.

The result is the fitted equation a formula fit gives on the same data (Equation("y ~ x1 + x2").fit(data, method=OLS(...))): the same numbers, views, tests and diagnostics, and the same provenance, except that it records the data as passed directly (vintage request "direct"). A PeriodIndex makes the data a time series. In a session the call is recorded as the code you typed; the arrays are kept with the project only if you keep them there yourself. There is no dialog: Estimate → Equation estimates by formula.

See also