mice.impute.rlm.Rd
These functions impute from linear models using the functions
stats::lm
, MASS::rlm
or MASS::lqs
. The method mice.impute.lm_fun
allows the definition of a general linear regression fitting function for
which the methods predict
and residuals
are defined.
Parameters of the model are estimated by Bayesian bootstrap. Predicted values are computed and residuals are randomly drawn from the empirical distribution of residuals of observed data.
mice.impute.lm(y, ry, x, wy=NULL, lm_args=NULL, trafo=NULL, antitrafo=NULL, ...)
mice.impute.rlm(y, ry, x, wy=NULL, lm_args=NULL, trafo=NULL, antitrafo=NULL, ...)
mice.impute.lqs(y, ry, x, wy=NULL, lm_args=NULL, trafo=NULL, antitrafo=NULL, ...)
mice.impute.lm_fun(y, ry, x, wy=NULL, lm_args=NULL, lm_fun="lm", trafo=NULL,
antitrafo=NULL, ...)
Incomplete data vector of length n
Vector of missing data pattern (FALSE
-- missing,
TRUE
-- observed)
Matrix (n
x p
) of complete covariates.
Vector of logicals indicating which entries should be imputed
List of arguments for stats::lm
,
MASS::rlm
, MASS::lqs
or
a user-defined function.
Linear regression fitting function, e.g. stats::lm
for which
S3 methods predict
and residuals
are defined.
Optional function for transforming the outcome values
Optional function which is the inverse function of trafo
Further arguments to be passed
A vector of length nmis=sum(!ry)
with imputed values.
if (FALSE) {
#############################################################################
# EXAMPLE 1: Some toy example illustrating the methods
#############################################################################
library(MASS)
library(mice)
#-- simulate data
set.seed(98)
N <- 1000
x <- stats::rnorm(N)
z <- 0.5*x + stats::rnorm(N, sd=.7)
y <- stats::rnorm(N, mean=.3*x - .2*z, sd=1 )
dat <- data.frame(x,z,y)
dat[ seq(1,N,3), c("x","y") ] <- NA
dat[ seq(1,N,4), "z" ] <- NA
#-- define imputation methods
imp <- mice::mice(dat, maxit=0)
method <- imp$method
method["x"] <- "rlm"
method["z"] <- "lm"
method["y"] <- "lqs"
#-- impute data
imp <- mice::mice(dat, method=method)
summary(imp)
#--- example using transformations
dat1$x <- exp(dat1$x)
dat1$z <- stats::plogis(dat1$z)
trafo <- list(x=log, z=stats::qlogis)
antitrafo <- list(x=exp, z=stats::plogis)
#- impute with transformations
imp2 <- mice::mice(dat1, method=method, m=1, maxit=3, trafo=trafo, antitrafo=antitrafo)
print(imp2)
}