linearmodels.asset_pricing.model.TradedFactorModel.fit¶
-
TradedFactorModel.fit(cov_type: str =
'robust', debiased: bool =True, **cov_config: str | float) LinearFactorModelResults[source]¶ Estimate model parameters.
- Parameters:¶
- cov_type: str =
'robust'¶ Name of covariance estimator. The default is “robust”. The names are not case sensitive. “heteroskedastic” is an alias of “robust”. See Notes.
- debiased: bool =
True¶ Flag indicating whether to debias the covariance estimator using a degree of freedom adjustment. The default is True. See Notes.
- **cov_config: str | float¶
Additional covariance-specific options for the kernel covariance estimator:
kernel(str) andbandwidth(float). The other covariance estimators do not use any. See Notes.
- cov_type: str =
- Returns:¶
Results class with parameter estimates, covariance and test statistics.
- Return type:¶
- Raises:¶
UnknownOptionError – If
cov_typeorkernelis not supported. It is both aKeyErrorand aValueError.ValueError – If
debiasedis True and the number of observations is not larger than the number of factors plus one, or if the bandwidth is selected from the data and there are too few observations. See Notes. A key ofcov_configthat the covariance estimator thatcov_typeselects does not accept also raises it. The message names the key and lists the accepted keys. This is checked before the model is estimated. Releases before 7.1 ignored the key.
Notes
Supported covariance estimators are:
“robust”, “heteroskedastic” - Heteroskedasticity-robust covariance estimator
“kernel” - Heteroskedasticity and Autocorrelation consistent (HAC) covariance estimator
The kernel covariance estimator takes the optional arguments
kernel, which is one of “bartlett”, “newey-west”, “parzen”, “gallant”, “qs”, “quadratic-spectral” or “andrews”, andbandwidth(a non-negative number). The names of the kernels are not case sensitive. The default kernel is “bartlett”. Ifbandwidthis not given it is selected from the data, which needs at least 4 observations with the Bartlett kernel, 5 with the Parzen kernel and 6 with the quadratic spectral kernel.fitraises aValueErrorfor fewer observations, and if the selected bandwidth is not finite. Passbandwidthto use the kernel with fewer observations. Seekernel_optimal_bandwidth().If
debiasedis True, the covariance of the parameters of the time-series regressions (the alphas and the loadings) is divided by nobs - nfactor - 1, the number of observations less the number of regressors, instead of by nobs. The risk premia are the sample means of the factors, so that their covariance, which is the block ofcovfor the risk premia and the source ofrisk_premia_se, is divided by nobs - 1. The covariance between the two groups of parameters is divided by the geometric mean of the two scales, so that the covariance matrix remains positive semi-definite. Ifdebiasedis False, the covariance is divided by nobs.Changed in version 7.1: The block of
covfor the risk premia was divided by nobs - nfactor - 1, whilerisk_premia_seused nobs - 1. Both use nobs - 1 now, so that the block ofcovfor the risk premia is smaller by the factor (nobs - nfactor - 1) / (nobs - 1), for example by 5.1% with 60 observations and 3 factors, and equalsrisk_premia_sesquared. The covariance between the risk premia and the other parameters, which used nobs - nfactor - 1, is now smaller by the square root of the same factor. The covariance of the alphas and the loadings,risk_premia_seand the covariance withdebiased=Falsedo not change.