This provides a post estimation goodness-of-fit test for the ordinal response models. Supported models include the proportional odds, adjacent-category, and constrained continuation-ratio models.

lipsitz(model, group = 10, customFreq = NULL)

Arguments

model

a model object or data.frame of observed and estimated values. The following class of objects can be directly passed to the lipsitz function: vglm(), serp(), polr(), and clm(). Other class of objects require providing a data.frame of observed and predicted values.

group

Default to 10. The number of groups to be formed from the original observations.

customFreq

a vector of custom group frequencies to be used instead of the default equal group frequencies. The vector should, however, sum up to the total number of original observations.

Value

LR

the realized value of the likelihood ratio statistic.

df

the degrees of freedom.

p.value

the p-value of the test.

newVar

a numeric vector of the newly generated variable.

Details

Similar to the ordinal Hosmer-Lemeshow test (hosmerlem), the Lipsitz test also group the observations into k separate groups using the ordinal scores of the estimated values. According to Lipsitz, Fitzmaurice, and Molenberghs (1996), the number of groups should be such that 6 <= k < n/5r, with r the number of response category. An indicator variable is used to denote the observations belonging to each group, producing additional pseudo variables with which the original model is updated. Supposing the original model fits correctly, then the coefficients of the pseudo variables all equal zero. The likelihood ratio statistic calculated from the log likelihoods of the original and the refitted models is subsequently compared with the chi-squared distribution with k - 1 degrees of freedom.

The Lipsitz test compliments the ordinal Hosmer-Lemeshow and the Pulkstenis-Robinson tests. Fagerland and Hosmer (2013, 2016, 2017) recommend comparing the three test.

References

Fagerland, M. W. and Hosmer, D. W. (2013). A goodness-of-fit test for the proportional odds regression model. Statistics in Medicine, 32, 2235-2249.

Fagerland, M. W. and Hosmer, D. W. (2016). Tests for goodness of fit in ordinal logistic regression models. Journal of Statistical Computation and Simulation, 86, 3398-3418.

Fagerland, M. W. and Hosmer, D. W. (2017). How to test for goodness of fit in ordinal logistic regression models. Stata Journal, 17, 668-686.

Examples


require(VGAM)

set.seed(1)
n <- 200
y <- ordered(rbinom(n, 2, 0.5))
x1 <- factor(rbinom(n, 1, 0.7))
x2 <- runif(n)

## proportional odds model
vg <- vglm(y ~ x1 + x2, model = TRUE,
           family = cumulative(link = "logitlink", parallel = TRUE))
lipsitz(vg, group=6)
#> 
#> Lipsitz Test:
#> 
#>                       LR   df   pr(>chi)
#> ordinal(lipsitz)  8.6367    5     0.1245
#> 
#> H0: No lack of fit dictated
#> 

## adjacent category model
ac <- update(vg, family = acat(parallel = TRUE))
lipsitz(ac)
#> 
#> Lipsitz Test:
#> 
#>                       LR   df   pr(>chi)
#> ordinal(lipsitz)  12.662    9     0.1785
#> 
#> H0: No lack of fit dictated
#> 

## continuation ratio model
cr <- update(vg, family = cratio(parallel = TRUE))
lipsitz(cr)
#> 
#> Lipsitz Test:
#> 
#>                       LR   df   pr(>chi)
#> ordinal(lipsitz)  13.047    9     0.1605
#> 
#> H0: No lack of fit dictated
#>