我想对两个均值的相等性进行双样本(韦尔奇)t 检验,其中之一是使用简单随机抽样获得的(srsmean
),另一个是使用调查包的调查权重计算得出的(mean_weighted
)。我还进行了 t 检验mean_weighted
以及在调查设计中同时实施加权和分层时获得的平均值(mean_strat
).
我知道有一个svyttest()
函数,但是,据我所知,该函数仅测试两个样本的平均值within一种调查设计,并不意味着通过不同的调查设计获得。
我还尝试使用 rnorm 创建虚构样本,例如c(rnorm(9710, mean = 156958.8, sd = 364368))
,但这种方法的问题在于,在分层等复杂的抽样方法中,有效的n 通常小于nominaln,所以我不确定将什么作为 n。此外,这种方法感觉有点做作,因为我会将数据拟合到特定类型的分布。
最后,我尝试自己写出 t 统计量的方程,然而,在计算涉及复杂调查设计的“均值差异的标准误差”时,我也遇到了与“有效样本量”相关的问题。
是否有另一种方法适用于两者之间的 t 检验srsmean, mean_weighted
AND 之间的 t 检验mean_weighted, mean_strat
?
library(survey)
wel <- c(68008.19, 128504.61, 21347.69,
33272.95, 61828.96, 32764.44,
92545.62, 58431.89, 95596.82,
117734.27)
rmul <- c(16, 16, 16, 16, 16, 16, 16,
20, 20, 20)
strat <- c(101, 101, 101, 101, 101, 102, 102, 102, 102, 102)
survey.data <- data.frame(wel, rmul, strat)
srsmean <- mean(survey.data$wel)
survey_weighted <- svydesign(data = survey.data,
ids = ~wel,
weights = ~rmul,
nest = TRUE)
mean_weighted <- svymean(~wel, survey_weighted)
survey_strat <- survey_strat <- svydesign(data = surveydata,
ids= ~wel,
weights = ~rmul,
strata = ~strat,
nest = TRUE)
mean_strat <- svymean(~wel, survey_strat)