These functions convert data sets containing multiple imputations in long format to objects of class mitml.list. The resulting object can be used in further analyses.

long2mitml.list(x, split, exclude = NULL)

jomo2mitml.list(x)

Arguments

x

A data frame in long format containing multiple imputations (see 'Details').

split

A character string denoting the column in x that identifies different imputations (see 'Details').

exclude

A vector denoting the values of split that should be excluded.

Details

The function long2mitml.list converts data frames from the long format to mitml.list (i.e., a list of imputed data sets). In long format, all imputations are contained in a single data frame, where different imputations are denoted by split. This function splits the data frame into a list of imputed data sets according to split, excluding the values specified by exclude (see the 'Examples').

The jomo2mitml.list function is a special case of long2mitml.list which converts imputations that have been generated with jomo (see the jomo package)).

Value

A list of imputed data sets with class mitml.list.

Author

Simon Grund

See also

Examples

data(studentratings)
require(jomo)
#> Loading required package: jomo

# impute data using jomo (native functions)
clus <- studentratings[, "ID"]
Y <- studentratings[, c("ReadAchiev", "ReadDis")]
imp <- jomo(Y = Y, clus = clus, nburn = 1000, nbetween = 100, nimp = 5)
#> Clustered data, using functions for two-level imputation.
#> Found  2 continuous outcomes and no categorical. Using function jomo1rancon. 
#> ..................................................
#> ..................................................
#> First imputation registered. 
#> ..........Imputation number  2 registered 
#> ..........Imputation number  3 registered 
#> ..........Imputation number  4 registered 
#> ..........Imputation number  5 registered 
#> The posterior mean of the fixed effects estimates is:
#>                    X1
#> ReadAchiev 490.241759
#> ReadDis      2.576419
#> 
#> The posterior mean of the random effects estimates is:
#>      ReadAchiev.Z1   ReadDis.Z1
#> 1001  19.556542308 -0.392606619
#> 1002   5.702009017  0.287692994
#> 1003   7.182495929 -0.032025764
#> 1004 -56.343936662  0.033621798
#> 1005 -31.663276331  0.271950656
#> 1006 -11.040296513  0.073537083
#> 1007  -7.234035434 -0.041832996
#> 1008   3.802871267 -0.066368822
#> 1009   5.983207413  0.097825324
#> 1010  24.943139431 -0.120733860
#> 1011 -22.710482820  0.182884275
#> 1012  -0.733253362  0.094288669
#> 1013 -17.263719141  0.205085931
#> 1014  -2.507948786 -0.021190559
#> 1015  -0.824495435 -0.305414021
#> 1016  23.931497531  0.312544516
#> 1017   0.006719634  0.001494993
#> 1018  20.682478632 -0.068219285
#> 1019 -24.176648861  0.032666285
#> 1020 -55.727074804  0.183073275
#> 1021  32.074970575  0.388137046
#> 1022  34.725924293 -0.180047015
#> 1023 -34.902463834  0.505623137
#> 1024  10.426060024  0.057251335
#> 1025  -5.931612523 -0.285209913
#> 2001 -10.866521388  0.002070899
#> 2002 -38.313099509  0.814281826
#> 2003 -38.448056105  0.125054705
#> 2004   3.045586582  0.069889294
#> 2005  50.906950269 -0.241348361
#> 2006  33.264103528 -0.625301283
#> 2007  28.721918655 -0.184719825
#> 2008  24.963342566 -0.387038543
#> 2009  15.656334264  0.014498920
#> 2010  39.469537976 -0.151313399
#> 2011   7.153069015  0.116840928
#> 2012  36.164349282 -0.487219522
#> 2013 -34.949068606  0.388214141
#> 2014 -12.070350442 -0.200161933
#> 2015  -5.549843355  0.172880502
#> 2016  -1.466150315 -0.076387573
#> 2017 -68.672332623  0.237383886
#> 2018   7.385790091 -0.226429268
#> 2019  32.221805718 -0.008320462
#> 2020 -13.105245503  0.127943303
#> 2021  20.918747873 -0.205702980
#> 2022  13.476550879  0.022211740
#> 2023  -0.091115346  0.240988191
#> 2024 -51.489995131  0.141899480
#> 2025  17.641111650 -0.290146790
#> 
#> The posterior mean of the level 1 covariance matrices is:
#>            ReadAchiev     ReadDis
#> ReadAchiev 7510.69425 -13.9469465
#> ReadDis     -13.94695   0.4082988
#> 
#> The posterior mean of the level 2 covariance matrix is:
#>               ReadAchiev.Z1 ReadDis.Z1
#> ReadAchiev*Z1    1116.26521 -5.1189105
#> ReadDis*Z1         -5.11891  0.1168438

# split imputations
impList <- long2mitml.list(imp, split = "Imputation", exclude = 0)
impList <- jomo2mitml.list(imp)