clarke_test {clarkeTest}R Documentation

Clarke Test

Description

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

Usage

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

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. Users can also write new methods for both indivLogLiks and nparams that would get called by the generic function.

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

An object of class nonnest.test with the following values:

stat

The number of times model 1 is better than model 2

test

Will always be "clarke".

level

The chosen confidence level for the test

digits

The number of digits to print

loglik1

Individual log-likelihoods for model 1

loglik2

Individual log-likelihoods for model 2

nparams

A vector giving the number of parameters in models 1 and 2, respectively

nobs

Number of observations in the model

Author(s)

Brenton Kenkel (brenton.kenkel@gmail.com) modified by Dave Armstrong (dave@quantoid.net)

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)

## 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)

## 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)

## 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)

## 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)

## 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)

## Multinomial Logit: multinom

library(nnet)
ml1 <- multinom(as.factor(Amnesty) ~ log(rgdpna_pc) +
              log(pop*1000) + polity2,
            data=conflictData)
ml2 <- multinom(as.factor(Amnesty) ~ scale(rgdpna_pc) +
              scale(pop) + polity2,
            data=conflictData)
clarke_test(ml1, ml2)


## Multinomial Logit: multinom



[Package clarkeTest version 0.2.0 Index]