mice.impute.eap: Imputation of a Variable with a Known Posterior Distribution

Description Usage Arguments Value Author(s) Examples

View source: R/mice.impute.eap.R

Description

This function imputes values of a variable for which the mean and the standard deviation of the posterior distribution is known.

Usage

1
mice.impute.eap(y, ry, x, eap, ...)

Arguments

y

Incomplete data vector of length n

ry

Vector of missing data pattern (FALSE – missing, TRUE – observed)

x

Matrix (n x p) of complete covariates.

eap

List with means and standard deviations of the posterior distribution (see Examples). If for multiple variables posterior distributions are known, then it is a list named in which each list entry is named according th variable to be imputed and each list entry contains the variable's EAP and standard deviation of the EAP.

...

Further arguments to be passed

Value

A vector of length nmis=sum(!ry) with imputed values.

Author(s)

Alexander Robitzsch

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
## Not run: 
#############################################################################
# EXAMPLE 1: Imputation based on known posterior distribution
#############################################################################	
	
data(data.ma03)
dat <- data.ma03

# definiere variable 'math_PV' as the plausible value imputation of math
dat$math_PV <- NA
vars <- colnames(dat)
dat1 <- as.matrix( dat[,vars] )

# define imputation methods
impmethod <- rep( "pmm" , length(vars ))
names(impmethod) <- vars
# define plausible value imputation based on EAP and SEEAP for 'math_PV'
impmethod[ "math_PV" ] <- "eap"
eap <- list( "math_PV" = list( "M" = dat$math_EAP  , "SE" = dat$math_SEEAP  ) )
# define predictor matrix
pM <- 1 - diag(1,length(vars))
rownames(pM) <- colnames(pM) <- vars
pM[,c("idstud","math_EAP" , "math_SEEAP") ] <- 0     
    # remove some variables from imputation model

# imputation using three parallel chains
imp1 <- mice::mice( dat1 , m=3 , maxit=5 , imputationMethod=impmethod ,  
               predictorMatrix = pM , allow.na =TRUE , eap=eap )
summary(imp1)   # summary

# imputation using one long chain
imp2 <- miceadds::mice.1chain( dat1 , burnin=10 , iter=20 , Nimp =3, 
            imputationMethod=impmethod, predictorMatrix = pM ,  allow.na =TRUE , eap=eap)
summary(imp2)    # summary

## End(Not run)

miceadds documentation built on June 20, 2017, 9:10 a.m.

Search within the miceadds package
Search all R packages, documentation and source code