qis.fit_multivariate_ols

qis.fit_multivariate_ols(x, y, fit_intercept=True, verbose=True, beta_format='{0:+0.2f}', alpha_format='{0:+0.2f}')[source]

ordinary least squares of y on the columns of x, with a formatted summary of the fit.

Rows where any variable is missing are dropped before fitting, so the prediction is indexed on the rows that survived rather than on the full input.

Parameters:
  • x (DataFrame) – explanatory variables, one column per regressor

  • y (Series) – dependent variable, with the same index labels and order as x

  • fit_intercept (bool) – include an intercept, reported under the name 'intercept'

  • verbose (bool) – print the statsmodels summary

  • beta_format (str) – format for the slope coefficients in the returned label

  • alpha_format (str) – format for the intercept in the returned label

Returns:

the prediction indexed by the retained dates, the fitted parameters indexed by regressor name ('intercept' first when fit_intercept), and a formatted label of the fitted equation for a chart legend.

Return type:

A tuple (prediction, params, reg_label)

Raises:

ValueError – If x and y do not have matching index labels in the same order.