SUPPORT / SAMPLES & SAS NOTES
 

Support

Sample 42514: Tests for comparing nested and nonnested models

DetailsResultsDownloadsAboutRate It

Tests for comparing nested and nonnested models

Contents: Purpose / History / Requirements / Usage / Details / Limitations / Missing Values / See Also / References
PURPOSE:
Compare two nested or nonnested models fit by maximum likelihood. Nested models are compared using the likelihood ratio test. Nonnested models are compared using tests by Vuong or Clarke testing the hypothesis that both models are equally distant from the true model.
HISTORY:
Version
Update Notes
1.1 Added likelihood ratio test for nested models. Added FREQ= and WEIGHT= parameters for models fit to data containing frequencies and/or weights.
1.0 Initial version providing Vuong and Clarke tests for nonnested models.
REQUIREMENTS:
Only Base SAS is required.
USAGE:
Follow the instructions in the Downloads tab of this sample to save the %VUONG macro definition. Before calling the %VUONG macro, specify the following %INC statement in your SAS program or in the SAS editor window to define the macro and make it available for use. In the %INC statement, replace the text within quotes with the location of the %VUONG macro definition file on your system.

%inc "<location of your file containing the VUONG macro>";

Following this statement, you can call the %VUONG macro using the following syntax. Macro arguments can be listed in any order.

%vuong(<list of macro arguments separated by commas>)

Before running the %VUONG macro, fit both models that you want to compare and save the predicted values from each. The DATA= data set analyzed by the macro must contain the common response variable used in both models and one variable from each model containing predicted or probability values. Also, if one or both models is a binomial model fit using events/trials syntax (that is, fit to aggregated or summarized data), then the variable containing the numbers of trials must be included. If one or both models is a zero-inflated Poisson (ZIP) or zero-inflated negative binomial (ZINB) model, then the variable containing zero-inflation probabilities must be included.

The easiest way to generate the necessary input data set is to use the output data set from fitting the first model as the input data set for fitting the second model. Then the output data set from fitting the second model should have all the necessary variables. The examples in the Results tab use this technique.

The following macro arguments are required:

response=variable
Specifies the common response variable in both models. Note that exactly the same response values must be used in estimating both models.
p1=variable  and  p2=variable
These parameters specify the variables containing the predicted values from the first and second model. These variables are created by the P= or PRED= option in the OUTPUT statement in the LOGISTIC, PROBIT, GENMOD, or COUNTREG procedure. In PROC MIXED (fixed effects models only), specify the OUTP= option in the MODEL statement. For models with nonnormal distributions fit in PROC GLIMMIX, use the PRED(ILINK)= option to produce this variable.
dist1=NOR|BIN|MULT|GAM|IG|NB|POI|ZIP|ZINB|OTH  and
dist2=NOR|BIN|MULT|GAM|IG|NB|POI|ZIP|ZINB|OTH
These parameters specify the distributions of the response in the first model and second model: NOR=normal, BIN=binomial, MULT=multinomial, GAM=gamma, IG=inverse Gaussian, NB=negative binomial, POI=Poisson, ZIP=zero-inflated Poisson, ZINB=zero-inflated negative binomial, OTH=other. Specify OTH if the corresponding predicted values variable (P1= or P2=) contains the observation likelihood contributions (rather than predicted values) from any distribution. For a normal, negative binomial, zero-inflated negative binomial, gamma, or inverse Gaussian model, the scale value must be specified in the corresponding scale parameter (SCALE1= or SCALE2=). For a zero-inflated Poisson or zero-inflated negative binomial model, specify the zero-inflation probability variable in the corresponding parameter (PZERO1= or PZERO2=).

The following macro arguments are optional except as noted.

data=data-set-name
Specifies the name of the input data set that contains the response variable and two variables holding the predicted values from each of the two models to be compared. If omitted the last created data set is used.
model1=label
Specifies a label (up to 40 characters) for the first model defined by the DIST1= and P1= parameters. The default label is Model 1.
model2=label
Specifies a label (up to 40 characters) for the second model defined by the DIST2= and P2= parameters. The default label is Model 2.
test=BOTH|VUONG|CLARKE|LR
Species whether to compute Vuong's test, Clarke's test, or both when comparing nonnested models or the likelihood ratio test when comparing nested models. The default is both.
freq=variable
Species the variable containing frequency counts if such a variable was used to fit the models.
weight=variable
Species the variable containing weights if such a variable was used to fit the models.

The NPARM1= and NPARM2= parameters must both be specified in order for the Akaike- and Schwarz-adjusted tests to be computed. If only one or neither is specified, then only the unadjusted tests are provided.

nparm1=value
Specifies the number of parameters estimated in the first model.
nparm2=value
Specifies the number of parameters estimated in the second model.

If a binomial model is being tested, one of the following two parameters must be specified. If events/trials syntax was used to fit the model to summarized data, specify the events variable in the RESPONSE= parameter and the trials variable in the TRIALS= parameter. If single variable syntax was used to fit the model to binary data, specify the response variable in the RESPONSE= parameter and specify the EVENT= parameter to indicate which response level is the event level.

event=value | "value" | 'value'
Specifies the value of the RESPONSE= variable that represents the event level that was modeled. If the RESPONSE= variable is a character variable, value must be enclosed in quotes.
trials=variable
Specifies a variable containing the number of trials in each observation. This is the trials variable used when fitting a binomial model with events/trials syntax in the MODEL statement. Specify the events variable in the RESPONSE= parameter.

One of the following parameters is required for each zero-inflated Poisson (ZIP) or zero-inflated negative binomial (ZINB) model being tested. This variable can be created by the PZERO= option in the OUTPUT statement of PROC GENMOD or the PROBZERO= option in the OUTPUT statement of PROC COUNTREG.

pzero1=variable
Specifies the variable containing the zero-inflation probabilities for the first model.
pzero2=variable
Specifies the variable containing the zero-inflation probabilities for the second model.

One of the following parameters is required for each normal, negative binomial, zero-inflated negative binomial, gamma, or inverse Gaussian model being tested.

scale1=value
Specifies the scale parameter value for the first model according to the table below.
scale2=value
Specifies the scale parameter value for the second model according to the table below.
 
Distribution GENMOD GLIMMIX* MIXED** COUNTREG
Normal*** Scale Scale
Residual covariance
parameter estimate
 
Negative
binomial
Dispersion Scale   _Alpha
ZINB Dispersion     _Alpha
Gamma Scale Scale    
Inverse
Gaussian
Scale Scale    

* Specify the NOREML option in the PROC GLIMMIX statement, the SOLUTION option in the MODEL statement, and the PRED(ILINK)= option in the OUTPUT statement.

** Fixed effects models only. Specify the METHOD=ML option in the PROC MIXED statement and the OUTP= option in the MODEL statement.

*** With PROC REG or PROC GLM, specify the Root MSE value in SCALE1= or SCALE2=.

The version of the %VUONG macro that you are using is displayed in the SAS log when you specify version (or any string) as the first argument. For example:

    %vuong(version, ...other options...)
DETAILS:
The %VUONG macro can compare nested models using the likelihood ratio test or nonnested models using the Vuong and/or Clarke tests.

Nested models

Two nested models fit using maximum likelihood (ML) can be compared using a likelihood ratio (LR) test statistic. The LR statistic is computed as twice the positive difference of the models' log likelihood values and is chi-square distributed with degrees of freedom equal to the positive difference in the number of model parameters. The LR test cannot be used to compare models that are nonnested, or models fit by methods other than maximum likelihood such as Generalized Estimating Equations (GEE). See also "Limitations on constructing valid LR tests" in Example 4 of this note.

Nonnested models

The %VUONG macro performs the Vuong and Clarke tests of the null hypothesis that both models are equally distant from the true model against a two-sided alternative hypothesis that one of the models is closer to the true model. If the test statistic is positive and significant, the null hypothesis is rejected in favor of the first model being closer to the true model. If the test statistic is negative and significant, the null hypothesis is rejected in favor of the second model being closer to the true model. A one-sided test, that one of the models is closer to the true model, can be performed by simply halving the p-value if the sign of the statistic is in the hypothesized direction.

Both tests are based on the Kullback-Leibler information criteria (KLIC). KLIC is a measure of "distance" between a model and the true model. Both tests assume the models being compared are strictly nonnested. Tests exist for comparing partially nonnested (overlapping) models, but this macro does not provide them. Clarke (2001) notes two models with the same functional form and the same error structure are strictly nonnested "if no variables in the first model can be written as a linear combination of the variables in the second model."

Vuong (1989) also provides definitions of nesting. He notes that models are strictly nonnested if they have "different distributional assumptions on the errors, say normally or logistic distributed" or if they have "the same distributional assumption but different functional forms" such as if one is linear and the other is nonlinear. Suppose two models have the same error distribution and functional form, and have one or more predictors in common. These models are partially, not strictly, nonnested and cannot be compared using the tests provided by this macro.

This macro is intended to compare strictly nonnested models that are estimated by ML procedures such as GENMOD, LOGISTIC, PROBIT, GLIMMIX, and others. Observations are assumed to be independent, so this macro is not intended to be used with repeated measures models or time series models.

Clarke (2007) suggests that for small sample sizes and when the observation log likelihood ratios have a peaked (leptokurtic) distribution, Vuong's test has lower power than his test.

Clarke's statistic is reported as (n+ - n-)/2, that is, as the number of positive values minus its expectation.

Note that information criteria such as Akaike's (AIC), Schwarz's (SC, BIC), and QIC can be used to compare competing nonnested models, but do not provide a test of the comparison. Consequently, they cannot indicate whether one model is significantly better than another. The GENMOD, LOGISTIC, GLIMMIX, MIXED, and other procedures provide information criteria measures.

Macro Updates

The %VUONG macro attempts to check for a later version of itself. If it is unable to do this (such as if there is no active Internet connection available), the macro issues the following message:

   VUONG: Unable to check for newer version

The computations performed by the macro are not affected by the appearance of this message.

LIMITATIONS:
These tests require that both models are fit using exactly the same set of response values. This means more than just using the same response variable when fitting the models. See MISSING VALUES below. Data used to fit the competing models should consist of independent observations. When comparing nonnested models, the models must be strictly nonnested as described above. The Vuong and Clarke tests are not valid for nested or overlapping models. See Clarke (2001) and Vuong (1989) for details. The likelihood ratio test is not valid for nonnested models.

This macro cannot be used to analyze an input data set containing multiple BY groups. BY groups processing is not supported.

MISSING VALUES:
Missing values in the predictors or other variables involved in the model can cause one or more observations to be omitted when estimating the model. When competing models involve different variables, different observations might be omitted resulting in models not fit to exactly the same set of response values. The macro stops and issues an error message if it finds an observation in the input data set that has one predicted value missing and the other nonmissing. The macro proceeds with computations if both predicted values are either missing or nonmissing.
SEE ALSO:
For discussion and examples of comparing nested models using a CONTRAST statement, see Example 4 in "Examples of Writing CONTRAST and ESTIMATE Statements". See the %CLASSIFY macro that can help in constructing the input data set for the %VUONG macro when comparing ordinal logistic models as illustrated in Example 6 in the Results tab.
REFERENCES:
Clarke, K.A. (2001), "Testing Nonnested Models of International Relations: Reevaluating Realism," American Journal of Political Science, 45:3, 724-744.

Clarke, K.A. (2007), "A Simple Distribution-Free Test for Nonnested Hypotheses," Political Analysis, 15:3.

Clarke, K.A. and Signorino, C.S. (2010), "Discriminating Methods: Tests for Nonnested Discrete Choice Models," Political Studies, 58:2, 368-388.

Long, J. S.

Stokes, M. E., Davis, C. S., and Koch, G. G.

Vuong, Q. (1989), "Likelihood ratio tests for model selection and non-nested hypotheses," Econometrica, 57: 307-334.




These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.