linearmodels.asset_pricing.model.LinearFactorModelGMM

class linearmodels.asset_pricing.model.LinearFactorModelGMM(portfolios: IVData | ndarray | DataArray | DataFrame | Series | list[Any] | tuple[Any, ...], factors: IVData | ndarray | DataArray | DataFrame | Series | list[Any] | tuple[Any, ...], *, risk_free: bool = False)[source]

GMM estimator of Linear factor models.

Parameters:
portfolios: IVData | ndarray | DataArray | DataFrame | Series | list[Any] | tuple[Any, ...]

Test portfolio returns (nobs by nportfolio).

factors: IVData | ndarray | DataArray | DataFrame | Series | list[Any] | tuple[Any, ...]

Priced factors values (nobs by nfactor).

risk_free: bool = False

Flag indicating whether the risk-free rate should be estimated from returns along other risk premia. If False, the returns are assumed to be excess returns using the correct risk-free rate. The default is False.

Notes

Suitable for traded or non-traded factors.

Implements a GMM estimator of risk premia, factor loadings and model tests.

The moments are

\[\begin{split}\left[\begin{array}{c} \epsilon_{t}\otimes f_{c,t}\\ f_{t}-\mu \end{array}\right]\end{split}\]

and

\[\epsilon_{t}=r_{t}-\left[1_{N}\;\beta\right]\lambda-\beta\left(f_{t}-\mu\right)\]

where \(r_{it}\) is the return on test portfolio i and \(f_t\) are the factor returns.

There are \(N (K + 1) + K\) moment conditions, where \(N\) is the number of test portfolios and \(K\) is the number of factors. The number of observations must exceed the number of moment conditions, since the covariance of the moment conditions, which weights them, is singular otherwise. A ValueError is raised if it does not.

Changed in version 7.1: A ValueError is raised if the number of observations does not exceed the number of moment conditions. The estimator raised a LinAlgError or returned a J-statistic that was NaN or arbitrary, such as -4.6e35.

The model is tested using the optimized objective function using the usual GMM J statistic.

The alphas are the averages of the moment conditions \(\epsilon_t\) that correspond to the intercept, and their standard errors account for the estimation of the parameters. If \(S\) is the covariance of the moment conditions and \(G\) is the Jacobian of their average, the covariance of the average moment conditions at the efficient GMM estimates is

\[\left(S - G (G^\prime S^{-1} G)^{-1} G^\prime\right) / (T - df)\]

where \(df\) is the number of factors if the covariance is debiased and 0 if it is not. This is the same \(S\), \(G\) and scale as the covariance of the parameters \((G^\prime S^{-1} G)^{-1} / (T - df)\), which depends on cov_type (and kernel and bandwidth for the kernel estimator), center and debiased of fit. The covariance of the alphas has rank equal to the number of degrees of freedom of the J-statistic. If the model is just identified, the alphas are zero and so is their variance.

Changed in version 7.1: The standard errors of the alphas were the square roots of the diagonal of the covariance of the average moment conditions, \(S / T\), which ignores that the parameters were estimated, and which did not depend on cov_type, center or debiased. This overstated the standard errors: in a simulation of 60 samples with 400 observations, 6 portfolios and 2 factors the mean standard error was 0.00143 to 0.00145 for all six alphas, where their sampling standard deviations were 0.00047 to 0.00136. The mean standard errors are now 0.00049 to 0.00133 and track them. The t-statistics and p-values of the alphas, which are in tstats and pvalues, change with them. The covariance of the parameters, the risk premia and the J-statistic do not change.

Rows are paired by position, so that the first row of factors is the factor return in the period of the first row of portfolios. If both portfolios and factors carry labels (a pandas Series or DataFrame with an index other than the default 0, 1, …, n-1, or an xarray DataArray with coordinates), factors must use the same index, in the same order, as portfolios, so that a return cannot be attached to the wrong period. A ValueError is raised if the index differs. Either reindex factors to the index of portfolios, or call to_numpy() to pair its values by position. NumPy arrays and pandas objects with a default index do not carry labels and are always paired by position. Dates and time deltas are compared by value, so that the same dates at different resolutions, e.g., datetime64[us] and datetime64[ns], are the same labels.

Methods

fit(*[, center, use_cue, steps, disp, ...])

Estimate model parameters.

from_formula(formula, data, *[, portfolios, ...])

Specify a model using the formula interface.

Properties

formula

Formula used to construct the model, if it was constructed using one.