statsmodels.regression.linear_model.RegressionResults.predict

RegressionResults.predict(exog=None, transform=True, *args, **kwargs)

Call self.model.predict with self.params as the first argument.

Parameters:
  • exog (array-like, optional) – The values for which you want to predict. see Notes below.
  • transform (bool, optional) – If the model was fit via a formula, do you want to pass exog through the formula. Default is True. E.g., if you fit a model y ~ log(x1) + log(x2), and transform is True, then you can pass a data structure that contains x1 and x2 in their original form. Otherwise, you’d need to log the data first.
  • kwargs (args,) – Some models can take additional arguments or keywords, see the predict method of the model for the details.
Returns:

prediction – See self.model.predict

Return type:

ndarray, pandas.Series or pandas.DataFrame

Notes

The types of exog that are supported depends on whether a formula was used in the specification of the model.

If a formula was used, then exog is processed in the same way as the original data. This transformation needs to have key access to the same variable names, and can be a pandas DataFrame or a dict like object.

If no formula was used, then the provided exog needs to have the same number of columns as the original exog in the model. No transformation of the data is performed except converting it to a numpy array.

Row indices as in pandas data frames are supported, and added to the returned prediction.