Stata 15 help for lrtest

[R] lrtest -- Likelihood-ratio test after estimation


lrtest modelspec1 [modelspec2] [, options]

modelspec1 and modelspec2 specify the restricted and unrestricted model in any order. modelspec# is

name|.| (namelist)

name is the name under which estimation results were stored using estimates store, and "." refers to the last estimation results, whether or not these were already stored. If modelspec2 is not specified, the last estimation result is used; this is equivalent to specifying modelspec2 as ".".

If namelist is specified for a composite model, modelspec1 and modelspec2 cannot have names in common; for example, lrtest (A B C) (C D E) is not allowed because both model specifications include C.

options Description ------------------------------------------------------------------------- stats display statistical information about the two models dir display descriptive information about the two models df(#) override the automatic degrees-of-freedom calculation; seldom used force force testing even when apparently invalid -------------------------------------------------------------------------


Statistics > Postestimation


lrtest performs a likelihood-ratio test of the null hypothesis that the parameter vector of a statistical model satisfies some smooth constraint. To conduct the test, both the unrestricted and the restricted models must be fit using the maximum likelihood method (or some equivalent method), and the results of at least one must be stored using estimates store.

lrtest also supports composite models. In a composite model, we assume that the log likelihood and dimension (number of free parameters) of the full model are obtained as the sum of the log-likelihood values and dimensions of the constituting models.


stats displays statistical information about the unrestricted and restricted models, including the information indices of Akaike and Schwarz.

dir displays descriptive information about the unrestricted and restricted models; see estimates dir in [R] estimates store.

df(#) is seldom specified; it overrides the automatic degrees-of-freedom calculation.

force forces the likelihood-ratio test calculations to take place in situations where lrtest would normally refuse to do so and issue an error. Such situations arise when one or more assumptions of the test are violated, for example, if the models were fit with vce(robust), vce(cluster clustvar), or pweights; when the dependent variables in the two models differ; when the null log likelihoods differ; when the samples differ; or when the estimation commands differ. If you use the force option, there is no guarantee as to the validity or interpretability of the resulting test.


Under weak regularity conditions, the LR test statistic is approximately chi-square distributed with degrees of freedom equal to the difference of the dimensions of the unrestricted and restricted model (that is, the difference of the numbers of unrestricted and restricted parameters) if the true parameter vector indeed satisfies the restricted model and if we are not "on a boundary of the parameter space". The latter condition is not satisfied, for instance, if we are testing whether the variance of a mixing distribution equals zero (click here for more information). lrtest cannot discern whether it is being invoked under such conditions, and it always produces p-values assuming that the standard regularity conditions are satisfied.

lrtest provides an important alternative to Wald testing for models fit by maximum likelihood. Wald testing requires fitting only one model (the unrestricted model). Hence, it is computationally more attractive than likelihood-ratio testing. Most statisticians, however, favor using likelihood-ratio testing whenever feasible because the null-distribution of the LR test statistic is often more closely chi-squared distributed than the Wald test statistic.

Examples with nested models

. webuse lbw . logit low age lwt i.race smoke ptl ht ui . estimates store A . logit low lwt i.race smoke ht ui . estimates store B . lrtest A . . lrtest A (equivalent to above command) . lrtest A B (equivalent to above command) . logit low lwt smoke ht ui . estimates store C . lrtest B . lrtest C A, stats

Examples with composite models

We want to test in heckman that participation decision is stochastically independent of the outcome (wage rate). If this correlation is 0, Heckman's model is equivalent to the combination of a regress for the outcome and a probit model for participation.

. webuse womenwk . heckman wage educ age, select(married children educ age) . estimates store H . regress wage educ age . estimates store R . generate dinc = !missing(wage) . probit dinc married children educ age . estimates store P . lrtest H (R P), df(1)

Chow-type tests are appropriate for hypotheses that specify that all coefficients of a model do not vary between disjointed subsets of the data.

. webuse vote, clear . logit vote age moinc dependents . estimates store All . logit vote age moinc dependents if county==1 . estimates store A1 . logit vote age moinc dependents if county==2 . estimates store A2 . logit vote age moinc dependents if county==3 . estimates store A3 . lrtest (All) (A1 A2 A3), df(7)

Stored results

lrtest stores the following in r():

Scalars r(p) p-value for likelihood-ratio test r(df) degrees of freedom r(chi2) LR test statistic

Programmers wishing their estimation commands to be compatible with lrtest should note that lrtest requires that the following results be returned:

e(cmd) name of estimation command e(ll) log likelihood e(V) variance-covariance matrix of the estimators e(N) number of observations

lrtest also verifies that e(N), e(ll_0), and e(depvar) are consistent between two noncomposite models.

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index