Learn R Programming

mi (version 0.10-2)

mi.binary: Elementary function: Bayesian logistic regression to impute a binary variable.

Description

Imputes univariate missing data using bayesglm, an R functions for generalized linear modeling with independent normal, t, or Cauchy prior distribution for the coefficients.

Usage

mi.binary(formula, data = NULL, start = NULL, maxit = 100,
  draw.from.beta = TRUE, missing.index = NULL, ...)
## S3 method for class 'mi.binary':
resid(object, y)
## S3 method for class 'mi.binary':
residuals(object, y)
## S3 method for class 'mi.binary,ANY':
plot( x, y, main=deparse( substitute( y ) ), gray.scale = FALSE, ...)

Arguments

formula
an object of class '"formula"' (or one that can be coerced to that class): a symbolic description of the model to be fitted. See bayesglm 'formula' for details.
data
A data frame containing the incomplete data and the matrix of the complete predictors.
start
Starting value for bayesglm.
maxit
Maximum number of iteration for bayesglm. The default is 100.
draw.from.beta
Draws from posterior distribution of the betas to add randomness.
missing.index
The index of missing units of the outcome variable.
...
Currently not used.
object
mi.binary object.
x
mi.binary 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.

Value

  • modelA summary of the bayesian fitted model.
  • expectedThe expected values estimated by the model.
  • randomVector of length n.mis of random predicted values predicted by using the binomial distribution.

Details

In bayesglm default the prior distribution is Cauchy with center 0 and scale 2.5 for all coefficients (except for the intercept, which has a prior scale of 10). See also glm for other details.

References

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

Run this code
# true data
  x <- rnorm(100,0,1) # N(0,1)
  y <- rbinom(100,1,invlogit(1+2*x)) # y ~ Bin(1,invlogit(1 + 2*x)
  # create artificial missingness on y
  y[seq(1,100,10)]<-NA
  dat.xy <- data.frame(x,y)
  # imputation
  mi.binary(y~x, data = dat.xy)

Run the code above in your browser using DataLab