原文链接:http://tecdat.cn/?p=10134
我进行一个小型仿真,以在不同样本量下测试Little的MCAR检验1。我可以研究线性回归中的异方差。我能够找到一些使用Little‘s MCAR检验的小样本研究人员的例子,因此我进行了仿真。
library(BaylorEdPsych)
library(simglm)
library(ggplot2)
library(dplyr)
library(mice)
fixed <- ~1 + age + income
fixed_param <- c(2, 0.3, 1.3)
cov_param <- list(dist_fun = c(‘rnorm‘, ‘rnorm‘),
var_type = c("single", "single"),
opts = list(list(mean = 0, sd = 4),
list(mean = 0, sd = 3)))
ggplot(little.mcar.p, aes(x = n, y = p)) + geom_boxplot() +
geom_crossbar(aes(ymin = q025, y = q05, ymax = q075), data = summarise(
group_by(little.mcar.p, n), q025 = quantile(p, .025, na.rm = TRUE),
q05 = quantile(p, .05, na.rm = TRUE), q075 = quantile(p, .075, na.rm = TRUE)
)) +
geom_hline(yintercept = .05) +
scale_y_continuous(breaks = seq(0, 1, .05), limits = c(0, 1)) +
labs(x = "Sample size", y = "p-value",
title = "Little‘s MCAR test for data that are MCAR",
subtitle = "2000 replications",
caption = paste(paste("For the narrow boxes, going from top to bottom, lines",
"represent 7.5th, 5th and 2.5th percentiles of p-values."),
"Test maintains nominal error rate across wide range of sample sizes.",
sep = "\n"))
?
ggplot(little.mcar.p.mar, aes(x = n, y = p)) + geom_boxplot() +
geom_crossbar(aes(ymin = q925, y = q95, ymax = q975), data = summarise(
group_by(little.mcar.p.mar, n), q925 = quantile(p, .925, na.rm = TRUE),
q95 = quantile(p, .95, na.rm = TRUE), q975 = quantile(p, .975, na.rm = TRUE)
), linetype = 2) +
geom_hline(yintercept = .05) +
scale_y_continuous(breaks = seq(0, 1, .05), limits = c(0, 1)) +
labs(x = "Sample size", y = "p-value",
title = "Little‘s MCAR test for data that are MAR",
subtitle = "2000 replications",
caption = paste(paste("For the dashed boxes, going from top to bottom, lines",
"represent 97.5th, 95th and 92.5th percentiles of p-values."),
"Test only maintains nominal error rate around sample size of 120.",
sep = "\n"))
?
回归接近完美(没有多重共线性)。
如果您有任何疑问,请在下面发表评论。
大数据部落 -中国专业的第三方数据服务提供商,提供定制化的一站式数据挖掘和统计分析咨询服务
统计分析和数据挖掘咨询服务:y0.cn/teradat(咨询服务请联系官网客服)
?QQ:3025393450
?QQ交流群:186388004
【服务场景】
科研项目; 公司项目外包;线上线下一对一培训;数据爬虫采集;学术研究;报告撰写;市场调查。
【大数据部落】提供定制化的一站式数据挖掘和统计分析咨询
欢迎关注微信公众号,了解更多数据干货资讯!
欢迎选修我们的R语言数据分析挖掘必知必会课程!
R语言在不同样本量下的Little's MCAR检验
原文地址:https://www.cnblogs.com/tecdat/p/12205097.html
时间: 2024-10-09 12:21:40