subset.mitml.list {mitml}R Documentation

Subset a list of imputed data sets

Description

The functions can be used for creating subsets for a list of multiply imputed data sets.

Usage


## S3 method for class 'mitml.list'
subset(x, subset, select, ...)

Arguments

x

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

subset

An R expression by which to subset each data set.

select

An R expression by which to select columns.

...

Not being used.

Details

This function can be used to create subsets and select variables for a list of multiply imputed data sets according to the R expressions given in the subset and select arguments. The function is similar to and adapted from the subset function for regular data sets. Note that subsetting is performed individually for each data set. Thus, the cases included may differ across data sets if the variables used for subsetting contain different values.

Value

A list of imputed data sets with an additional class attribute mitml.list.

Author(s)

Simon Grund

Examples

data(studentratings)

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

implist <- mitmlComplete(imp,"all")

# * Example 1: subset by SES, select variables by name
subset(implist, SES < 25, select = c(ID, FedState, Sex, SES, ReadAchiev, ReadDis))

# * Example 2: subset by FedState, select variables by column number
subset(implist, FedState == "SH", select = -c(6:7,9:10))

## Not run: 
# * Example 3: subset by ID and Sex
subset(implist, ID 

# * Example 4: select variables by name range
subset(implist, select = ID:Sex)

## End(Not run)

[Package mitml version 0.3-5 Index]