简体   繁体   English

Zelig和Amelia的估算数据汇总统计

[英]Summary statistics for imputed data from Zelig & Amelia

I'm using Amelia to impute the missing values. 我正在使用Amelia来估算缺失的值。

While I'm able to use Zelig and Amelia to do some calculations... 虽然我可以使用Zelig和Amelia进行一些计算...

How do I use these packages to find the pooled means and standard deviations of the newly imputed data? 如何使用这些软件包查找新估算数据的合并平均值和标准偏差?

library(Amelia)
library(Zelig)

n= 100
x1= rnorm(n,0,1) #random normal distribution
x2= .4*x1+rnorm(n,0,sqrt(1-.4)^2) #x2 is correlated with x1, r=.4
x1= ifelse(rbinom(n,1,.2)==1,NA,x1) #randomly creating missing values
d= data.frame(cbind(x1,x2))

m=5 #set 5 imputed data frames
d.imp=amelia(d,m=m) #imputed data

summary(d.imp) #provides summary of imputation process

I couldn't figure out how to format the code in a comment so here it is. 我不知道如何格式化注释中的代码,就在这里。

foo <- function(x, fcn) apply(x, 2, fcn)
lapply(d.imp$imputations, foo, fcn = mean)
lapply(d.imp$imputations, foo, fcn = sd)

d.imp$imputations gives a list of all the imputed data sets. d.imp $ imputations给出了所有估算数据集的列表。 You can work with that list however you are comfortable with to get out the means and sds by column and then pool as you see fit. 您可以使用该列表,但可以轻松按列列出平均值和标准差,然后根据需要合并。 Same with correlations. 与相关性相同。

lapply(d.imp$imputations, cor)

Edit: After some discussion in the comments I see that what you are looking for is how to combine results using Rubin's rules for, for example, the mean of imputed data sets generated by Amelia. 编辑:在评论中进行了一些讨论之后,我看到您正在寻找的是如何使用Rubin规则(例如,由Amelia生成的估算数据集的均值)合并结果。 I think you should clarify in the title and body of your post that what you are looking for is how to combine results over imputations to get appropriate standard errors with Rubin's rules after imputing with package Amelia. 我认为您应该在帖子的标题和正文中阐明,您要寻找的是在对Amelia软件包进行估算后,如何将估算结果与Rubin规则相结合,以获取适当的标准错误。 This was not clear from the title or original description. 从标题或原始描述中并不清楚。 "Pooling" can mean different things, particularly wrt variances. “汇集”可能意味着不同的事情,尤其是不同的东西。

The mi.meld function is looking for aq matrix of estimates from each imputation, an se matrix of the corresponding se estimates, and a logical byrow argument. mi.meld函数正在从每个插补中寻找估计的q矩阵,相应的se估计的se矩阵以及逻辑byrow参数。 See ?mi.meld for an example. 有关示例,请参见?mi.meld。 In your case, you want the sample means and se_hat(sample means) for each of your imputed data sets in the q and se matrices to pass to mi_meld, respectively. 对于您的情况,您希望q和se矩阵中每个估算数据集的样本均值和se_hat(样本均值)分别传递给mi_meld。

q <- t(sapply(d.imp$imputations, foo, fcn = mean))
se <- t(sapply(d.imp$imputations, foo, fcn = sd)) / sqrt(100)
output <- mi.meld(q = q, se = se, byrow = TRUE)

should get you what you're looking for. 应该可以为您提供所需的东西。 For other statistics than the mean, you will need to get an SE either analytically, if available, or by, say, bootstrapping, if not. 对于除均值以外的其他统计信息,您将需要获得分析性SE(如果有),或者通过引导(如果没有)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用Amelia II / mitools / Zelig和lme4分析R中混合级别模型的估算数据 - analyzing imputed data for mixed-level models in R with Amelia II / mitools / Zelig and lme4 R中多重估算数据集的多级回归模型(Amelia,zelig,lme4) - Multi-level regression model on multiply imputed data set in R (Amelia, zelig, lme4) 结合Amelia估算数据的多个随机森林模型 - Combining Multiple Random Forest Models from Amelia Imputed Data 如何在zelig中获取模型推导的拟合值(AIC,F统计量)以用于多次插补数据? - How to get measures of model fit (AIC, F-statistics) in zelig for multiply imputed data? 将Zelig“ sim”函数与Amelia数据集结合使用,以获取跨R中的估算数据集汇总的估计值 - Using Zelig “sim” function with Amelia dataset to obtain estimates pooled across imputed datasets in R Amelia + CEM + Zelig错误 - Amelia + CEM + Zelig errors 用户定义的 function 用于来自推算数据的描述性统计问题 - Issue with user-defined function for descriptive statistics from imputed data 使用data.table来自汇总组的摘要统计信息 - Summary statistics from aggregated groups using data.table 如何从以下数据计算年龄的汇总统计量 - How to compute summary statistics for age from the following data 来自数据框列表的时间解析汇总统计 - Time resolved summary statistics from a list of data frames
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM