Learn R Programming

JointAI (version 0.1.0)

get_MIdat: Extract multiple imputed datasets (and export to SPSS)

Description

Extracts a dataset containing multiple imputed datasets. These data can be automatically exported to SPSS (i.e., a .txt file containing the data and a .sps file containing syntax to generate a .sav file). For the export function the foreign package needs to be installed.

Usage

get_MIdat(object, m = 10, start = NULL, seed = NULL, resdir = NULL,
  filename = NULL, export_to_SPSS = FALSE)

Arguments

object

object inheriting from class JointAI

m

number of imputed datasets

start

the first iteration of interest (see window.mcmc)

seed

optional seed

resdir

optional directory for results (if unspecified and export_to_SPSS = TRUE the current working directory is used)

filename

optional file name (without ending; if unspecified and export_to_SPSS = TRUE a name is generated automatically)

export_to_SPSS

logical

Value

A dataframe containing the imputed values (and original data) stacked. The variable Imputation_ identifies the imputations.

Examples

Run this code
# NOT RUN {
mod <- lm_imp(y~C1 + C2 + M2, data = wideDF, n.iter = 100)
MIs <- get_MIdat(mod, m = 3, seed = 123)

# }
# NOT RUN {
# or with export for SPSS (here: to the temporary directory "temp_dir")
temp_dir <- tempdir()
MIs <- get_MIdat(mod, m = 3, seed = 123, resdir = temp_dir,
                 filename = "example_imputation",
                 export_to_SPSS = TRUE)

# }

Run the code above in your browser using DataLab