如何将抽样权重纳入李克特量表调查问题的分析中?
How can I incorporate sampling weights into an analysis of Likert scale survey questions?
我正在分析调查数据,他们的问题是李克特量表的形式。我使用辅助人口普查数据来计算样本中不同年龄组的权重。我现在想使用这些权重来更正我的样本数据,然后显示针对每个年龄组区分的每个问题的分布。
感谢任何帮助!
在 R 中这样做的传统方法是使用 survey
package and/or the srvyr
包,它允许您使用 dplyr
风格的语法,同时依赖 survey
包来正确处理加权和复杂的调查设计。
下面是一个使用srvyr
包分析李克特数据的小例子。
# Create example data ----
library(survey)
library(srvyr)
set.seed(1999)
## Data frame of responses and grouping information
likert_response_options <- c("1 - Strongly Disagree", "2", "3", "4", "5 - Strongly Agree")
data_df <- data.frame(
group_vbl = factor(sample(LETTERS[1:4], 20, replace = TRUE), LETTERS[1:4]),
likert_item = factor(x = sample(likert_response_options, 20, replace = TRUE),
levels = likert_response_options),
weights = rnorm(20, mean = 1, sd = 0.1)
)
## Create a survey design object from the data frame
my_survey_design <- as_survey_design(data_df, weights = weights)
# Create weighted summaries ----
my_survey_design %>%
group_by(group_vbl, likert_item) %>%
summarize(proportion = survey_mean())
#> # A tibble: 20 x 5
#> group_vbl likert_item proportion proportion_low proportion_upp
#> <fct> <fct> <dbl> <dbl> <dbl>
#> 1 A 1 - Strongly Disagree 0.300 -0.252 0.851
#> 2 A 2 0 0 0
#> 3 A 3 0.700 0.149 1.25
#> 4 A 4 0 0 0
#> 5 A 5 - Strongly Agree 0 0 0
#> 6 B 1 - Strongly Disagree 0.127 -0.130 0.384
#> 7 B 2 0.146 -0.143 0.435
#> 8 B 3 0.259 -0.0872 0.606
#> 9 B 4 0.468 0.0577 0.878
#> 10 B 5 - Strongly Agree 0 0 0
#> 11 C 1 - Strongly Disagree 0 0 0
#> 12 C 2 0.241 -0.213 0.696
#> 13 C 3 0.292 -0.221 0.804
#> 14 C 4 0.250 -0.216 0.716
#> 15 C 5 - Strongly Agree 0.217 -0.205 0.639
#> 16 D 1 - Strongly Disagree 0 0 0
#> 17 D 2 0.529 0.0906 0.967
#> 18 D 3 0 0 0
#> 19 D 4 0.159 -0.156 0.474
#> 20 D 5 - Strongly Agree 0.312 -0.0888 0.713
我正在分析调查数据,他们的问题是李克特量表的形式。我使用辅助人口普查数据来计算样本中不同年龄组的权重。我现在想使用这些权重来更正我的样本数据,然后显示针对每个年龄组区分的每个问题的分布。
感谢任何帮助!
在 R 中这样做的传统方法是使用 survey
package and/or the srvyr
包,它允许您使用 dplyr
风格的语法,同时依赖 survey
包来正确处理加权和复杂的调查设计。
下面是一个使用srvyr
包分析李克特数据的小例子。
# Create example data ----
library(survey)
library(srvyr)
set.seed(1999)
## Data frame of responses and grouping information
likert_response_options <- c("1 - Strongly Disagree", "2", "3", "4", "5 - Strongly Agree")
data_df <- data.frame(
group_vbl = factor(sample(LETTERS[1:4], 20, replace = TRUE), LETTERS[1:4]),
likert_item = factor(x = sample(likert_response_options, 20, replace = TRUE),
levels = likert_response_options),
weights = rnorm(20, mean = 1, sd = 0.1)
)
## Create a survey design object from the data frame
my_survey_design <- as_survey_design(data_df, weights = weights)
# Create weighted summaries ----
my_survey_design %>%
group_by(group_vbl, likert_item) %>%
summarize(proportion = survey_mean())
#> # A tibble: 20 x 5
#> group_vbl likert_item proportion proportion_low proportion_upp
#> <fct> <fct> <dbl> <dbl> <dbl>
#> 1 A 1 - Strongly Disagree 0.300 -0.252 0.851
#> 2 A 2 0 0 0
#> 3 A 3 0.700 0.149 1.25
#> 4 A 4 0 0 0
#> 5 A 5 - Strongly Agree 0 0 0
#> 6 B 1 - Strongly Disagree 0.127 -0.130 0.384
#> 7 B 2 0.146 -0.143 0.435
#> 8 B 3 0.259 -0.0872 0.606
#> 9 B 4 0.468 0.0577 0.878
#> 10 B 5 - Strongly Agree 0 0 0
#> 11 C 1 - Strongly Disagree 0 0 0
#> 12 C 2 0.241 -0.213 0.696
#> 13 C 3 0.292 -0.221 0.804
#> 14 C 4 0.250 -0.216 0.716
#> 15 C 5 - Strongly Agree 0.217 -0.205 0.639
#> 16 D 1 - Strongly Disagree 0 0 0
#> 17 D 2 0.529 0.0906 0.967
#> 18 D 3 0 0 0
#> 19 D 4 0.159 -0.156 0.474
#> 20 D 5 - Strongly Agree 0.312 -0.0888 0.713