pulkrob: Pulkstenis-Robinson goodness of fit tests for ordinal...

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

Performs the Pulkstenis-Robinson goodness of fit chi-squared and deviance tests for ordinal logistic regression models.

Usage

1
2
pulkrob.chisq(model, catvars)
pulkrob.deviance(model, catvars)

Arguments

model

an ordinal response model. Must be an object of class polr or clm.

catvars

a character vector containing the names of the categorical covariates.

Details

The Pulkstenis-Robinson tests are goodness of fit tests for ordinal logistic regression models. They are capable of accommodating models with continuous as well as categorical predictors. The data are partitioned according to observed covariate patterns using the categorical covariates only. Any unobserved covariate patterns are discarded. Only categorical predictors are used to avoid partitioning among an unacceptably high number of covariate patterns. Each subject is assigned an ordinal response score by summing the predicted probabilities of each subject for each outcome level multiplied by equally spaced integer weights. The covariate patterns are then split into two at the median score within each.

Based on this partitioning, observed and expected frequencies are calculated and the test statistic computed. This statistic is distributed by the chi-squared distribution with (2I - 1)(J - 1) - k - 1 degress of freedom, where I is the number of covariate patterns, J is the number of of response categories and k is the number of categorical variables in the model.

It is recommended (Fagerland and Hosmer, 2016) that the Pulkstenis-Robinson tests be run alongside the Hosmer-Lemeshow test (logitgof) and the Lipsitz test (lipsitz.test).

Value

A list of class htest containing:

statistic

the chi-squared or deviance statistic.

parameter

degrees of freedom used.

p.value

the p-value.

method

a character string indicating the name of the test.

data.name

a character string indicating the model formula used.

observed

a cast generated data frame of observed frequencies.

expected

a cast generated data frame of expected frequencies.

stddiffs

a table of the standardised differences. See Hosmer, Lemeshow and Sturdivant (2013), p 162.

Author(s)

Matthew Alexander Jay, with code from epiR::epi.cp() by Mark Stevenson.

References

See Also

logitgof, lipsitz.test.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
data(mtcars)

# using polr
mod1 <- polr(as.factor(gear) ~ mpg + cyl + vs, data = mtcars)
pulkrob.chisq(mod1, c("vs"))
pulkrob.deviance(mod1, c("vs"))

# using clm - ensure outcome variable is a factor before fitting the model
library(ordinal)
mtcars$gear <- as.factor(mtcars$gear)
mod2 <- clm(gear ~ mpg + cyl + vs, data = mtcars)
pulkrob.chisq(mod2, c("vs"))
pulkrob.deviance(mod2, c("vs"))

Example output

Loading required package: reshape
Loading required package: MASS
Loading required package: epiR
Loading required package: survival
Package epiR 0.9-87 is loaded
Type help(epi.about) for summary information



	Pulkstenis-Robinson chi-squared test

data:  formula:  as.factor(gear) ~ mpg + cyl + vs
X-squared = 11.51, df = 4, p-value = 0.0214

Warning message:
In pulkrob.chisq(mod1, c("vs")) :
  At least one cell in the expected frequencies table is < 1. Chi-square approximation may be incorrect.

	Pulkstenis-Robinson deviance test

data:  formula:  as.factor(gear) ~ mpg + cyl + vs
Deviance-squared = 12.767, df = 4, p-value = 0.01247

Warning message:
In pulkrob.deviance(mod1, c("vs")) :
  At least one cell in the expected frequencies table is < 1. Chi-square approximation may be incorrect.

	Pulkstenis-Robinson chi-squared test

data:  formula:  gear ~ mpg + cyl + vs
X-squared = 11.51, df = 4, p-value = 0.0214

Warning message:
In pulkrob.chisq(mod2, c("vs")) :
  At least one cell in the expected frequencies table is < 1. Chi-square approximation may be incorrect.

	Pulkstenis-Robinson deviance test

data:  formula:  gear ~ mpg + cyl + vs
Deviance-squared = 12.768, df = 4, p-value = 0.01247

Warning message:
In pulkrob.deviance(mod2, c("vs")) :
  At least one cell in the expected frequencies table is < 1. Chi-square approximation may be incorrect.

generalhoslem documentation built on June 3, 2019, 5:03 p.m.