How extract complete dataset from Amelia package

两盒软妹~` 提交于 2019-12-06 05:10:00

The str() function is always helpful here. You'll see that the complete datasets are stored in the imputations element of the object returned by amelia():

> str(imp2, 1)
List of 12
 $ imputations:List of 5
  ..- attr(*, "class")= chr [1:2] "mi" "list"
 $ m          : num 5
 $ missMatrix : logi [1:171, 1:10] FALSE FALSE FALSE FALSE FALSE FALSE ...
  ..- attr(*, "dimnames")=List of 2
 $ overvalues : NULL
 $ theta      : num [1:9, 1:9, 1:5] -1 -0.0161 0.199 -0.0368 -0.0868 ...
 $ mu         : num [1:8, 1:5] -0.0161 0.199 -0.0368 -0.0868 -0.0658 ...
 $ covMatrices: num [1:8, 1:8, 1:5] 0.8997 -0.3077 0.0926 0.2206 -0.1115 ...
 $ code       : num 1
 $ message    : chr "Normal EM convergence."
 $ iterHist   :List of 5
 $ arguments  :List of 23
  ..- attr(*, "class")= chr [1:2] "ameliaArgs" "list"
 $ orig.vars  : chr [1:10] "year" "country" "tariff" "polity" ...
 - attr(*, "class")= chr "amelia"

To get each imputation alone, just do imp2$imputations[[1]], etc. up through all imputations that you requested. In your example, there are five:

> str(imp2$imputations, 1)
List of 5
 $ imp1:'data.frame':   171 obs. of  10 variables:
 $ imp2:'data.frame':   171 obs. of  10 variables:
 $ imp3:'data.frame':   171 obs. of  10 variables:
 $ imp4:'data.frame':   171 obs. of  10 variables:
 $ imp5:'data.frame':   171 obs. of  10 variables:
 - attr(*, "class")= chr [1:2] "mi" "list"
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!