- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
作为 R 初学者,我发现弄清楚如何计算乘法插补数据的描述性统计数据非常困难(比运行其他一些基本分析更难,例如相关性和回归)。
这些类型的问题以道歉(Descriptive statistics (Means, StdDevs) using multiply imputed data: R)开头,但尚未得到回答(https://stats.stackexchange.com/questions/296193/pooling-basic-descriptives-from-several-multiply-imputed-datasets-using-mice)或很快投下反对票。
这里是 miceadds 函数 ( https://www.rdocumentation.org/packages/miceadds/versions/2.10-14/topics/stats0 ) 的描述,我发现很难理解以 mids 格式存储的数据。
我已经使用 summary(complete(imp)) 获得了一些输出,例如平均值、中位数、最小值、最大值,但很想知道如何获得额外的汇总输出(例如,偏斜/峰度、标准差、方差)。
从上面的以前的海报借来的插图:
> imp <- mice(nhanes, seed = 23109)
iter imp variable
1 1 bmi hyp chl
1 2 bmi hyp chl
1 3 bmi hyp chl
1 4 bmi hyp chl
1 5 bmi hyp chl
2 1 bmi hyp chl
2 2 bmi hyp chl
2 3 bmi hyp chl
> summary(complete(imp))
age bmi hyp chl
1:12 Min. :20.40 1:18 Min. :113
2: 7 1st Qu.:24.90 2: 7 1st Qu.:186
3: 6 Median :27.40 Median :199
Mean :27.37 Mean :194
3rd Qu.:30.10 3rd Qu.:218
Max. :35.30 Max. :284
有人会花时间说明如何使用 mids 对象来获得基本描述吗?
最佳答案
以下是您可以执行的一些步骤,以更好地了解每个步骤后 R 对象会发生什么。我还建议您查看本教程: https://gerkovink.github.io/miceVignettes/
library(mice)
# nhanes object is just a simple dataframe:
data(nhanes)
str(nhanes)
#'data.frame': 25 obs. of 4 variables:
# $ age: num 1 2 1 3 1 3 1 1 2 2 ...
#$ bmi: num NA 22.7 NA NA 20.4 NA 22.5 30.1 22 NA ...
#$ hyp: num NA 1 1 NA 1 NA 1 1 1 NA ...
#$ chl: num NA 187 187 NA 113 184 118 187 238 NA ...
# you can generate multivariate imputation using mice() function
imp <- mice(nhanes, seed=23109)
#The output variable is an object of class "mids" which you can explore using str() function
str(imp)
# List of 17
# $ call : language mice(data = nhanes)
# $ data :'data.frame': 25 obs. of 4 variables:
# ..$ age: num [1:25] 1 2 1 3 1 3 1 1 2 2 ...
# ..$ bmi: num [1:25] NA 22.7 NA NA 20.4 NA 22.5 30.1 22 NA ...
# ..$ hyp: num [1:25] NA 1 1 NA 1 NA 1 1 1 NA ...
# ..$ chl: num [1:25] NA 187 187 NA 113 184 118 187 238 NA ...
# $ m : num 5
# ...
# $ imp :List of 4
#..$ age: NULL
#..$ bmi:'data.frame': 9 obs. of 5 variables:
#.. ..$ 1: num [1:9] 28.7 30.1 22.7 24.9 30.1 35.3 27.5 29.6 33.2
#.. ..$ 2: num [1:9] 27.2 30.1 27.2 25.5 29.6 26.3 26.3 30.1 30.1
#.. ..$ 3: num [1:9] 22.5 30.1 20.4 22.5 27.4 22 26.3 27.4 35.3
#.. ..$ 4: num [1:9] 27.2 22 22.7 21.7 25.5 27.2 24.9 30.1 22
#.. ..$ 5: num [1:9] 28.7 28.7 20.4 21.7 25.5 22.5 22.5 25.5 22.7
#...
#You can extract individual components of this object using $, for example
#To view the actual imputation for bmi column
imp$imp$bmi
# 1 2 3 4 5
# 1 28.7 27.2 22.5 27.2 28.7
# 3 30.1 30.1 30.1 22.0 28.7
# 4 22.7 27.2 20.4 22.7 20.4
# 6 24.9 25.5 22.5 21.7 21.7
# 10 30.1 29.6 27.4 25.5 25.5
# 11 35.3 26.3 22.0 27.2 22.5
# 12 27.5 26.3 26.3 24.9 22.5
# 16 29.6 30.1 27.4 30.1 25.5
# 21 33.2 30.1 35.3 22.0 22.7
# The above output is again just a regular dataframe:
str(imp$imp$bmi)
# 'data.frame': 9 obs. of 5 variables:
# $ 1: num 28.7 30.1 22.7 24.9 30.1 35.3 27.5 29.6 33.2
# $ 2: num 27.2 30.1 27.2 25.5 29.6 26.3 26.3 30.1 30.1
# $ 3: num 22.5 30.1 20.4 22.5 27.4 22 26.3 27.4 35.3
# $ 4: num 27.2 22 22.7 21.7 25.5 27.2 24.9 30.1 22
# $ 5: num 28.7 28.7 20.4 21.7 25.5 22.5 22.5 25.5 22.7
# complete() function returns imputed dataset:
mat <- complete(imp)
# The output of this function is a regular data frame:
str(mat)
# 'data.frame': 25 obs. of 4 variables:
# $ age: num 1 2 1 3 1 3 1 1 2 2 ...
# $ bmi: num 28.7 22.7 30.1 22.7 20.4 24.9 22.5 30.1 22 30.1 ...
# $ hyp: num 1 1 1 2 1 2 1 1 1 1 ...
# $ chl: num 199 187 187 204 113 184 118 187 238 229 ...
# So you can run any descriptive statistics you need with this object
# Just like you would do with a regular dataframe:
> summary(mat)
# age bmi hyp chl
# Min. :1.00 Min. :20.40 Min. :1.00 Min. :113.0
# 1st Qu.:1.00 1st Qu.:24.90 1st Qu.:1.00 1st Qu.:187.0
# Median :2.00 Median :27.50 Median :1.00 Median :204.0
# Mean :1.76 Mean :27.48 Mean :1.24 Mean :204.9
# 3rd Qu.:2.00 3rd Qu.:30.10 3rd Qu.:1.00 3rd Qu.:229.0
# Max. :3.00 Max. :35.30 Max. :2.00 Max. :284.0
关于r - R : Take 3 中 MI 数据的描述性统计,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50143902/
我有一个代表每个年龄段的人口(M,F)的集合。 为了通过时间来预测人口,我必须首先对女性进行计算,以便我可以根据男性出生率的统计常数来计算新出生的男性和女性的百分比。 也就是说,我有一个包含每岁男性和
我正在尝试从队列中获取 n 条消息(使用 langohr)。我有一个工作版本,但我想知道是否有更好的 clojurist 方法来做到这一点: (def not-nil? (complement nil
我有这些结果用于分析一个简单的查询,该查询不会从少于 200 条记录的表中返回超过 150 条记录,因为我有一个存储最新值的表,而其他字段是数据的 FK . 更新:稍后查看同一查询的新结果。该网站未公
我正在使用 .Take() 来获取固定数量的结果。 获取 TotalCountBeforeTake 的最佳方法是什么(即好像我没有使用 .Take())? 我可以在不运行查询两次的情况下获得 Tota
我有一个 BatchConfigurable 类 public class BatchConfigurable() {} 我正在尝试为其编写一个包装器。这将是另一个类,它采用此类或任何扩展 Batch
byte[] result = memStream.ToArray(); memStream.Close(); byte[] temp = r
很简单的问题。我有一个值列表,我想用空值填充这些值,这样我总是会返回 X 个项目。 List list = new List() { 10, 20, 30 }; IEnumerable values
我正在构建一个购物车,并且我使用了一个购物车服务,在该服务中我将数量分配给产品/将产品添加到购物车。除了使用 take 获取可观察项 $ 的第一个实例之外,还有其他方法吗? 我正在正确导入 take
这是欧拉计划的问题 8。 我试图通过数字数组foreach,每次跳过最后一个数字并拉接下来的13个相邻数字数组。 我的代码: for(int x = 0; x product) {
我有 3 个 div 元素,一个是父元素,另外两个是子元素: dinesh pathak and their css are: #table {
我在 Hudson 上发现了异常行为。Hudson 作业大约需要 25 分钟,而当我在本地运行相同的作业时,需要 9 分钟。我在这里缺少什么? 我增加了 JAVA_OPTS、MAVEN_OPTS,甚至
let a = [1;2;3;] for i in (a |> Seq.take 10) do Console.WriteLine(i) for i in (a |> Seq.take 100) do
我正在尝试编写一些 LINQ To SQL 代码来生成类似 SQL 的代码 SELECT t.Name, g.Name FROM Theme t INNER JOIN ( SELECT TOP
给定这样的设置.. class Product { int Cost; // other properties unimportant } var products = new List
我有一个 List 类型的元素 public class FriendList { public List friends { get; set; } // List
给定以下 LINQ 语句,哪个更有效? 一个: public List GetLatestLogEntries() { var logEntries = from entry in db.Lo
我只是在尝试新的 kotlin 语言。我遇到了生成无限列表的序列。我生成了一个序列并尝试打印前 10 个元素。但是下面的代码没有打印任何东西: fun main(args: Array) {
我见过 sagas 以 3 种方式监听 Action : 1。 while(true) take() function* onUserDetailsRequest() { while(true)
假设我有一些神奇的分页黑盒类,它使用 pageIndex 和 pageSize 检索数据,如下所示: public class PaginatedList { // ... // Ch
我有两个 git 分支 b' 和 b" 具有完全相同的 SHA-1 和因此内容。我提交 b ' 并在提交时,我使用 -x 应用 cherry-pick 而不是 merge 或 rebase单个提交到我
我是一名优秀的程序员,十分优秀!