R: Class "categorical" and Inherited Classes

categorical {mi} | R Documentation

## Class "categorical" and Inherited Classes

### Description

The categorical class is a virtual class that inherits from the `missing_variable-class` and is the parent of the unordered-categorical and ordered-categorical classes. The ordered-categorical class is the parent of both the binary and interval classes. Aside from these facts, the rest of the documentation here is primarily directed toward developers.

### Objects from the Classes

The categorical class is virtual, so no objects may be created from it. However, the `missing_variable` generic function can be used to instantiate an object that inherits from the categorical class by specifying `type = "unordered-categorical"`, `type = "ordered-categorical"`, `type = "binary"`, `type = "grouped-binary"`, or `type = "interval"`.

### Slots

The unordered-categorical class inherits from the categorical class and has no additional slots but must have more than two uniquely observed values in its `raw_data` slot. The default `fit_model` method is a wrapper for the `multinom` function in the nnet package. The ordered-categorical class inherits from the categorical class and has one additional slot:

cutpoints

  Object of class `"numeric"` which is a vector of thresholds (sometimes estimated) that govern how an assumed latent variable is divided into observed ordered categories

The `fit_model` method for an ordered-categorical variable is, by default, a wrapper for `bayespolr`. The binary class inherits from the ordered-categorical class and has no additional slots. It must have exactly two uniquely observed values in its `raw_data` slot and its `fit_model` method is, by default, a wrapper for `bayespolr`. The grouped-binary class inherits from the binary class and has one additional slot:

strata

  Object of class `"character"` which is a vector (possibly of length one) of variable names that group the observations into strata. The named external variables should also be categorical.

The default `fit_model` method for a grouped-binary variable is a wrapper for the `clogit` function in the survival package and the variables named in the strata slot are passed to the `strata` function.

The interval class inherits from the ordered-categorical class, has no additional slots, and is intended for variables whose observed values are only known up to orderable intervals. Its `fit_model` method is, by default, a wrapper for `survreg` even though it may or may not be a “survival” model in any meaningful sense.

### Author(s)

Ben Goodrich and Jonathan Kropko, for this version, based on earlier versions written by Yu-Sung Su, Masanao Yajima, Maria Grazia Pittau, Jennifer Hill, and Andrew Gelman.

### See Also

`missing_variable`

### Examples

    # STEP 0: GET DATA
    data(nlsyV, package = "mi")

    # STEP 0.5 CREATE A missing_variable (you never need to actually do this)
    momrace <- missing_variable(as.factor(nlsyV$momrace), type = "unordered-categorical")
    show(momrace)

[Package mi version 1.0 Index]