`clarke_test` returns results from Kevin Clarke's distribution-free test of non-nested models.

clarke_test(model1, model2, level=0.05, digits=2)

Arguments

model1

A fitted statistical model of a supported class

model2

A fitted statistical model of a supported class whose dependent variable is the same as that of model1

level

Numeric: significance level for the test.

digits

Integer: number of digits to print

Value

Typical use will be to run the function interactively and examine the printed output. The functions return an object of class "nonnest.test", which is a list containing:

stat

The test statistic

level

Significance level for the test

digits

Number of digits to print

loglik1

Vector of observationwise log-likelihoods for model1

loglik2

Vector of observationwise log-likelihoods for model2

nparams

Integer vector containing the number of parameters fitted in model1 and model2 respectively

nobs

Number of observations of the dependent variable being modeled

Details

`clarke_test` is a more modularized version of the [clarke()] function from the [games] package. The main innovation is that the `nonnest` function calls a generic `indivLogLiks` function, so additional methods can be easily written for different classes of models. The function currently supports binomial, poisson and negative binomial GLMs, ordinal models estimated with either polr from the MASS package or clm from the ordinal package and multinomial models estimated with either multinom from the nnet package or mlogit from the mlogit package. Users can also write new methods for both indivLogLiks and nparams that would get called by the generic function.

References

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

Examples

data(conflictData) ## Linear Model lm1 <- lm(riots ~ log(rgdpna_pc) + log(pop*1000) + polity2, data=conflictData) lm2 <- lm(riots ~ rgdpna_pc + pop + polity2, data=conflictData) clarke_test(lm1, lm2)
#> #> Clarke test for non-nested models #> #> Model 1 log-likelihood: -8446 #> Model 2 log-likelihood: -8433 #> Observations: 4381 #> Test statistic: 1830 (42%) #> #> Model 2 is preferred (p < 2e-16) #>
## Binomial GLM glm1 <- glm(conflict_binary ~ log(rgdpna_pc) + log(pop*1000) + polity2, data=conflictData, family=binomial) glm2 <- glm(conflict_binary ~ rgdpna_pc + pop + polity2, data=conflictData, family=binomial) clarke_test(glm1, glm2)
#> #> Clarke test for non-nested models #> #> Model 1 log-likelihood: -1982 #> Model 2 log-likelihood: -2164 #> Observations: 4381 #> Test statistic: 2655 (61%) #> #> Model 1 is preferred (p < 2e-16) #>
## Poisson GLM glm1a <- glm(riots ~ log(rgdpna_pc) + log(pop*1000) + polity2, data=conflictData, family=poisson) glm2a <- glm(riots ~ rgdpna_pc + pop + polity2, data=conflictData, family=poisson) clarke_test(glm1a, glm2a)
#> #> Clarke test for non-nested models #> #> Model 1 log-likelihood: -4778 #> Model 2 log-likelihood: -5065 #> Observations: 4381 #> Test statistic: 2750 (63%) #> #> Model 1 is preferred (p < 2e-16) #>
## Negative Binomial GLM library(MASS) glm1b <- glm.nb(riots ~ log(rgdpna_pc) + log(pop*1000) + polity2, data=conflictData) glm2b <- glm.nb(riots ~ rgdpna_pc + pop + polity2, data=conflictData) clarke_test(glm1b, glm2b)
#> #> Clarke test for non-nested models #> #> Model 1 log-likelihood: -3220 #> Model 2 log-likelihood: -3289 #> Observations: 4381 #> Test statistic: 2464 (56%) #> #> Model 1 is preferred (p < 2e-16) #>
## Ordered Logit: polr library(MASS) ol1 <- polr(as.factor(Amnesty) ~ log(rgdpna_pc) + log(pop*1000) + polity2, data=conflictData) ol2 <- polr(as.factor(Amnesty) ~ scale(rgdpna_pc) + scale(pop) + polity2, data=conflictData) clarke_test(ol1, ol2)
#> #> Clarke test for non-nested models #> #> Model 1 log-likelihood: -5744 #> Model 2 log-likelihood: -5910 #> Observations: 4381 #> Test statistic: 2714 (62%) #> #> Model 1 is preferred (p < 2e-16) #>
## Ordered Logit: clm library(ordinal) ol1a <- clm(as.factor(Amnesty) ~ log(rgdpna_pc) + log(pop*1000) + polity2, data=conflictData) ol2a <- clm(as.factor(Amnesty) ~ scale(rgdpna_pc) + scale(pop) + polity2, data=conflictData) clarke_test(ol1a, ol2a)
#> #> Clarke test for non-nested models #> #> Model 1 log-likelihood: -5744 #> Model 2 log-likelihood: -5910 #> Observations: 4381 #> Test statistic: 2714 (62%) #> #> Model 1 is preferred (p < 2e-16) #>
## Multinomial Logit: multinom library(nnet) ml1 <- multinom(as.factor(Amnesty) ~ log(rgdpna_pc) + log(pop*1000) + polity2, data=conflictData)
#> # weights: 25 (16 variable) #> initial value 7050.947494 #> iter 10 value 6206.776100 #> iter 20 value 5533.652479 #> final value 5532.122617 #> converged
ml2 <- multinom(as.factor(Amnesty) ~ scale(rgdpna_pc) + scale(pop) + polity2, data=conflictData)
#> # weights: 25 (16 variable) #> initial value 7050.947494 #> iter 10 value 6070.438657 #> iter 20 value 5653.224295 #> final value 5646.374665 #> converged
clarke_test(ml1, ml2)
#> #> Clarke test for non-nested models #> #> Model 1 log-likelihood: -5532 #> Model 2 log-likelihood: -5646 #> Observations: 4381 #> Test statistic: 2439 (56%) #> #> Model 1 is preferred (p = 6.3e-14) #>
## Multinomial Logit: multinom library(mlogit)
#> Loading required package: Formula
#> Loading required package: zoo
#> #> Attaching package: ‘zoo’
#> The following objects are masked from ‘package:base’: #> #> as.Date, as.Date.numeric
#> Loading required package: lmtest
mldat <- mlogit.data(conflictData, choice="Amnesty", shape="wide") ml1a <- mlogit(Amnesty ~1 | log(rgdpna_pc) + log(pop*1000) + polity2, data=mldat) ml2a <- mlogit(Amnesty ~ 1 | scale(rgdpna_pc) + scale(pop) + polity2, data=mldat) clarke_test(ml1a, ml2a)
#> #> Clarke test for non-nested models #> #> Model 1 log-likelihood: -5532 #> Model 2 log-likelihood: -5646 #> Observations: 4381 #> Test statistic: 2439 (56%) #> #> Model 1 is preferred (p = 6.3e-14) #>