Elementary function: multinomial log-linear models to impute a ordered categorical variable.

Share:

Description

Imputes missing data in a categorical variable using multinomial Log-linear Models.

Usage

1
2
3
4
5
6
  mi.polr(formula, data = NULL, drop.unused.levels = TRUE, start = NULL,
    maxit = 100, missing.index = NULL, ...)
  ## S4 method for signature 'mi.polr'
residuals(object, y)
  ## S4 method for signature 'mi.polr,ANY'
plot( x, y, main=deparse( substitute( y ) ), gray.scale = FALSE, ... )

Arguments

formula

a formula expression as for regression models, of the form response ~ predictors. The response should be a factor (preferably an ordered factor), which will be interpreted as an ordinal response, with levels ordered as in the factor. The model must have an intercept: attempts to remove one will lead to a warning and be ignored. An offset may be used. See the documentation of 'formula' for other details.

data

A data frame containing the incomplete data and the matrix of the complete predictors.

drop.unused.levels

Drops unused levels.

start

Starting value for bayespolr.

maxit

Maximum number of iteration for bayespolr. The default is 100.

missing.index

The index of missing units of the outcome variable.

...

Currently not used.

object

mi.polr object.

x

mi.polr object.

y

Observed values.

main

main title of the plot.

gray.scale

When set to TRUE, makes the plot into gray scale with predefined color and line type.

Details

multinom calls the library nnet. See multinom for other details.

Value

model

A summary of the multinomial fitted model

expected

The expected values estimated by the model

random

Vector of length n.mis of random predicted values predicted by using the multinomial distribution

residual

The residual vector of length same as y

Author(s)

Masanao Yajima yajima@stat.columbia.edu, Yu-Sung Su ys463@stat.columbia.edu, M.Grazia Pittau grazia@stat.columbia.edu, Andrew Gelman gelman@stat.columbia.edu

References

Yu-Sung Su, Andrew Gelman, Jennifer Hill, Masanao Yajima. (2011). “Multiple Imputation with Diagnostics (mi) in R: Opening Windows into the Black Box”. Journal of Statistical Software 45(2).

Andrew Gelman and Jennifer Hill, Data Analysis Using Regression and Multilevel/Hierarchical Models, Cambridge University Press, 2007.

See Also

mi.info, mi.method, mi

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
  # true data
  x<-rnorm(100,0,1) # N(0,1)
  y<-(1+2*x)+rnorm(100,0,1)
  y<-round(y)
  y[y<0]<-0
  # create artificial missingness on y
  y[seq(1,100,10)]<-NA
  dat.xy <- data.frame(x,y)
  # imputation
  polr.imp <- mi.polr(y~x, data = dat.xy)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.