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

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

Description

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

Usage

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

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

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.

Author(s)

Matthew Alexander Jay

References

See Also

logitgof, pulkrob.chisq.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
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)

Example output

Loading required package: reshape
Loading required package: MASS

	Lipsitz goodness of fit test for ordinal response models

data:  formula:  gear ~ mpg + cyl
LR statistic = 13.148, df = 9, p-value = 0.156

Warning messages:
1: In lipsitz.test(mod1) :
  g >= n/5c. Running this test when g >= n/5c is not recommended.
2: glm.fit: fitted probabilities numerically 0 or 1 occurred 

	Lipsitz goodness of fit test for ordinal response models

data:  formula:  gear ~ mpg
LR statistic = 8.5871, df = 9, p-value = 0.4762

Warning messages:
1: In lipsitz.test(mod2) :
  g >= n/5c. Running this test when g >= n/5c is not recommended.
2: (1) Hessian is numerically singular: parameters are not uniquely determined 
In addition: Absolute convergence criterion was met, but relative criterion was not met 

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