Learn R Programming

clarkeTest (version 0.1.0)

clarke_test: 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

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. 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

Run this code
# NOT RUN {
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


# }

Run the code above in your browser using DataLab