linearmodels.panel.results.PanelResults.loglik¶
- property PanelResults.loglik : float¶
Log-likelihood of model.
Notes
The Gaussian log-likelihood of the regression that the model estimates, at the estimates and the maximum likelihood estimate of the error variance,
\[-\frac{n}{2}\left(\ln 2\pi + \ln\hat{\sigma}^2 + 1\right) + \frac{1}{2}\sum_{i=1}^{n}\ln w_i\]where \(\hat{\sigma}^2 = \hat{\epsilon}'\hat{\epsilon}/n\) is the residual sum of squares of the regression divided by its number of observations \(n\), and \(\hat{\epsilon}_i\) are the weighted residuals, \(\sqrt{w_i}\) times the residuals. The last term is the Jacobian of the weights, which is 0 if the model is not weighted. The variance of the error of observation \(i\) is \(\sigma^2/w_i\), and so the log-likelihood is that of the weighted least squares regression of the original data, for example of
WLS(...).llfin statsmodels forPooledOLS. It does not depend on the scale of the weights, and the log-likelihoods of the models with different weights are comparable if they have the same observations, for example in an information criterion.The regression and its observations depend on the model.
PooledOLS- The regression of the observations. The weights are the weights of the model.PanelOLS- The regression on the dummy variables of the effects, with the effects as parameters that are estimated. It is computed from the regression of the observations with the effects removed. The weights are the weights of the model.BetweenOLS- The regression of the means of the entities. The observations are the entities, and the weights are the sums of the weights of the entities, scaled to a mean of one, if the model is weighted orreweightis True. Otherwise all of the weights are 1.FirstDifferenceOLS- The regression of the first differences. The weights are those of the differences, \(1/(1/w_{it}+1/w_{it-1})\).RandomEffects- The regression of the data that are weighted and quasi-demeaned. It is not the likelihood of the random effects model, which also depends on the variances of the effects.FamaMacBeth- The pooled regression at the average of the estimates of the periods.
Changed in version 7.1: The log-likelihood of a weighted model includes the Jacobian of the weights. Earlier versions omitted it, so that the log-likelihood was that of the regression of the weighted data, which is not the likelihood of the original data, and the log-likelihoods of models with different weights were not comparable. For the pooled regression of the log wages in the wage panel on a constant,
educ,marriedandunionwith the hours as weights it was -3065.75, whereWLSof statsmodels has -3153.16. The log-likelihoods of models without weights do not change.