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

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

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

`model` |
an ordinal response model. Must be an object of class |

`catvars` |
a character vector containing the names of the categorical covariates. |

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`

).

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 |

`expected` |
a |

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

Matthew Alexander Jay, with code from `epiR::epi.cp()`

by Mark Stevenson.

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.

Hosmer DW, Lemeshow S, Sturdivant RX. Applied Logistic Regression, 3rd Edition. 2013. New York, USA: John Wiley and Sons.

Pulkstenis E, Robinson TJ. Goodness-of-fit tests for ordinal response regression models. Statistics in Medicine 2004;23:999-1014.

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"))
``` |

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

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.