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) and bandwidth (float). The other covariance estimators do not use any. See Notes.

Returns:

Results class with parameter estimates, covariance and test statistics.

Return type:

linearmodels.asset_pricing.results.LinearFactorModelResults

Raises:
  • UnknownOptionError – If cov_type or kernel is not supported. It is both a KeyError and a ValueError.

  • ValueError – If debiased is 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 of cov_config that the covariance estimator that cov_type selects 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”, and bandwidth (a non-negative number). The names of the kernels are not case sensitive. The default kernel is “bartlett”. If bandwidth is 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. fit raises a ValueError for fewer observations, and if the selected bandwidth is not finite. Pass bandwidth to use the kernel with fewer observations. See kernel_optimal_bandwidth().

If debiased is 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 of cov for the risk premia and the source of risk_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. If debiased is False, the covariance is divided by nobs.

Changed in version 7.1: The block of cov for the risk premia was divided by nobs - nfactor - 1, while risk_premia_se used nobs - 1. Both use nobs - 1 now, so that the block of cov for 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 equals risk_premia_se squared. 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_se and the covariance with debiased=False do not change.