mitml.list2mids: Convert objects of class 'mitml.list' to 'mids'

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/mitml.list2mids.R

Description

This function converts a mitml.list class object to mids (as used in the mice package).

Usage

1
mitml.list2mids(x, data, fill = FALSE, where = NULL)

Arguments

x

A list of imputed data sets with class mitml.list (as produced by mitmlComplete, mids2mitml.list, or similar).

data

A data frame containing to original (incomplete) data (see 'Details').

fill

A logical flag indicating whether variables in the imputed data that are not in the original data should be added and filled with NA (default is FALSE).

where

(optional) A data frame or matrix of logicals indicating the location of missing values (see 'Details').

Details

This function converts objects of class mitml.list into mids objects (as used in the mice package). The conversion requires a list of imputed data sets and the original (incomplete) data set. If the imputed data sets have been appended with new variables (e.g., by within.mitml.list), the new variables can be added to the original data set by setting fill = TRUE.

This function is essentially a wrapper around as.mids that sets the case and imputation identifiers automatically and and passes the where argument as is (see also the documentation of as.mids).

Value

An object of class mids.

Author(s)

Simon Grund

See Also

mitmlComplete, mids2mitml.list, within.mitml.list

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
data(studentratings)

fml <- ReadDis + SES ~ ReadAchiev + (1|ID)
imp <- panImpute(studentratings, formula = fml, n.burn = 1000, n.iter = 100, m = 5)

implist <- mitmlComplete(imp)

# * Example 1: simple conversion

# convert to 'mids'
impmids <- mitml.list2mids(implist, data = studentratings)

# * Example 2: conversion with additional variables

# compute new variables
implist <- within(implist, {
  M.ReadAchiev <- clusterMeans(ReadAchiev, ID)
  C.ReadAchiev <- ReadAchiev - M.ReadAchiev
})

# convert to 'mids'
impmids <- mitml.list2mids(implist, data = studentratings, fill = TRUE)

mitml documentation built on Oct. 5, 2021, 5:07 p.m.