generalhoslem (version 1.3.4)

lipsitz.test: Lipsitz goodness of fit test for ordinal logistic models.

Description

Performs the Lipsitz goodness of fit test for ordinal logistic regression models.

Usage

lipsitz.test(model, g = 10)

Arguments

model

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

g

number of quantiles of risk, defaults to 10.

Value

A list of class htest containing:

statistic

the value of the likelihood ratio 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.

newmoddata

a data frame containing the data used in fitting the updated model (the original data plus the dummy variables).

predictedprobs

a data frame of predicted probabilities from the original model.

Details

The Lipsitz test is a goodness of fit test for ordinal response logistic regression models. It involves binning the observed data into equally sized g groups based on an ordinal response score. This score is computed by summing the predicted probabilities of each subject for each outcome level multiplied by equally spaced integer weights. The user can specify the number of groups by assigning an integer value to g, which is 10 by default.

Given this partitioning of the data, dummy variables, I, are derived such that, for each group, I = 1 if the subject is in region g and I = 0 if not. The model is then re-fit with these dummy variables. If the model has good fit, then the coefficients for all these dummy variables simultaneously = 0. Lipsitz et al (1996) suggest that likelihood ratio, Wald or score tests can be used; lipsitz.test just uses the likelihood ratio test with g-1 degrees of freedom.

Note that the outcome variable MUST be converted to a factor before running the model. Using as.factor() within the model function will cause an error because of the way in which lipsitz.test uses the update() function to re-fit the model.

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

References

  • Fagerland MW, Hosmer DW. A goodness-of-fit test for the proportional odds regression model. Statistics in Medicine 2013;32:2235-2249.

  • Fagerland MW, Hosmer DW. Tests for goodness of fit in ordinal logistic regression models. Journal of Statistical Computation and Simulation 2016. DOI: 10.1080/00949655.2016.1156682.

  • Lipsitz SR, Fitzmaurice GM, Molenberghs G. Goodness-of-Fit Tests for Ordinal Response Regression Models. Journal of the Royal Statistical Society 1996;45(2):175-190.

See Also

logitgof, pulkrob.chisq.

Examples

Run this code
# NOT RUN {
data(mtcars)
mtcars$gear <- as.factor(mtcars$gear) # Outcome must be converted to factor 
                                      # before fitting model otherwise 
                                      # lipsitz.test() will fail.
mod1 <- polr(gear ~ mpg + cyl, data = mtcars)
lipsitz.test(mod1)
  
library(ordinal)
mod2 <- clm(gear ~ mpg, data = mtcars)
lipsitz.test(mod2)
# }

Run the code above in your browser using DataLab