linearmodels.panel.covariance.FamaMacBethCovariance¶
-
class linearmodels.panel.covariance.FamaMacBethCovariance(y: ndarray[tuple[int, ...], dtype[float64]], x: ndarray[tuple[int, ...], dtype[float64]], params: ndarray[tuple[int, ...], dtype[float64]], all_params: DataFrame, *, debiased: bool =
False, bandwidth: float | None =None, kernel: str | None =None)[source]¶ HAC estimator for Fama-MacBeth estimator.
- Parameters:¶
- y: ndarray[tuple[int, ...], dtype[float64]]¶
(entity x time) by 1 stacked array of the dependent variable.
- x: ndarray[tuple[int, ...], dtype[float64]]¶
(entity x time) by variables stacked array of the exogenous variables.
- params: ndarray[tuple[int, ...], dtype[float64]]¶
(variables by 1) array of estimated model parameters.
- all_params: DataFrame¶
(nobs by variables) array of all estimated model parameters.
- debiased: bool =
False¶ Flag indicating whether to debias the estimator. The default is False.
- bandwidth: float | None =
None¶ Non-negative bandwidth to use. It must be below T, the number of time periods that are used. The Bartlett and Parzen kernels use its integer part. Set to 0 to disable autocorrelation robustness. If not provided, it is computed from the T estimates and is at most T - 1. The computation needs at least 4 time periods with the Bartlett kernel, 5 with the Parzen kernel and 6 with the quadratic spectral kernel. See
kernel_optimal_bandwidth().- kernel: str | None =
None¶ Name of the kernel. If not provided, “newey-west”, which is the Bartlett kernel, is used. The names are not case sensitive. Supported kernels are:
”bartlett”, “newey-west” - Bartlett’s kernel
”parzen”, “gallant” - Parzen’s kernel
”qs”, “quadratic-spectral”, “andrews” - Quadratic spectral kernel
- Raises:¶
ValueError – If the bandwidth is not below the number of time periods that are used. It is also raised if the bandwidth is not provided and there are fewer time periods than the kernel needs to compute it, or if the bandwidth that is computed is not finite.
UnknownOptionError – If
kernelis not one of the supported names, whether or not the covariance is a kernel covariance. It is both aValueErrorand aKeyError.
Notes
Covariance is a Kernel covariance of all estimated parameters.
The \(T\) cross-sectional estimates, one for each time period that is used, have autocovariances up to lag \(T-1\), so the bandwidth must be below \(T\). The bandwidth is checked, or computed if it is not provided, when the estimator is created, so that the
fitmethod of the model raises the error.Changed in version 7.1: A bandwidth that is not below the number of time periods raises a
ValueError. Earlier versions raised “Length of w is larger than the number of elements in z” with the Bartlett and Parzen kernels, when the covariance was first used. The quadratic spectral kernel, which has no truncation, returned a covariance without an error. With a large bandwidth the weights of all of the lags are close to one, and the deviations of the estimates from their average sum to zero, so that the covariance was close to zero.Changed in version 7.1: The bandwidth that is computed from the estimates needs at least 4 time periods with the Bartlett kernel, 5 with the Parzen kernel and 6 with the quadratic spectral kernel, and a
ValueErroris raised for fewer, when the estimator is created. The deviations of the estimates from their average sum to zero. With fewer periods the rule divides by the sum of all of their autocovariances, which is zero, so that earlier versions raised “cannot convert float infinity to integer” (anOverflowError) or “cannot convert float NaN to integer” when the covariance was first used, or used a bandwidth of \(T-1\) because of the rounding error of the sum.Changed in version 7.1: A
kernelthat is not one of the supported names raises anUnknownOptionErrorwhen the estimator is created, so that thefitmethod of the model raises, also if the bandwidth is given. Earlier versions raised it when the covariance was first used, for example whenstd_errorsof the results was read, so thatfitreturned results that raised when the covariance was used.Methods
Covariance calculation deferred until executed.
Properties
The set of parameters estimated for each of the time periods.
Bandwidth of the kernel.
Estimated covariance.
Model residuals.
Covariance estimator name.
Error variance.