linearmodels.iv.results.IVGMMResults.predict

IVGMMResults.predict(exog: IVData | ndarray | DataArray | DataFrame | Series | list[Any] | tuple[Any, ...] | None = None, endog: IVData | ndarray | DataArray | DataFrame | Series | list[Any] | tuple[Any, ...] | None = None, *, data: DataFrame | None = None, fitted: bool = True, idiosyncratic: bool = False, missing: bool = False) → DataFrame

In- and out-of-sample predictions.

Parameters:
exog: IVData | ndarray | DataArray | DataFrame | Series | list[Any] | tuple[Any, ...] | None = None

Exogenous values to use in out-of-sample prediction (nobs by nexog).

endog: IVData | ndarray | DataArray | DataFrame | Series | list[Any] | tuple[Any, ...] | None = None

Endogenous values to use in out-of-sample prediction (nobs by nendog).

data: DataFrame | None = None

DataFrame to use for out-of-sample predictions when model was constructed using a formula.

fitted: bool = True

Flag indicating whether to include the fitted values. The default is True.

idiosyncratic: bool = False

Flag indicating whether to include the estimated idiosyncratic shock. The default is False.

missing: bool = False

Flag indicating to adjust for dropped observations. If True, the values returned will have the same size as the original input data before filtering missing values. If False, then missing observations will not be returned. The default is False.

Returns:

DataFrame containing columns for all selected outputs.

Return type:

pandas.DataFrame

Raises:

ValueError – If neither fitted nor idiosyncratic is selected for an in-sample prediction, or if data is used with exog or endog. The errors of predict() are raised for an out-of-sample prediction.

Notes

If exog, endog and data are all None, in-sample predictions (fitted values) will be returned.

If data is not none, then exog and endog must be none. Predictions from models constructed using formulas can be computed using either exog and endog, which will treat these are arrays of values corresponding to the formula-process data, or using data which will be processed using the formula used to construct the values corresponding to the original model specification.