library(kirkegaard)
## Loading required package: tidyverse
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ ggplot2 3.5.2 ✔ tibble 3.2.1
## ✔ lubridate 1.9.4 ✔ tidyr 1.3.1
## ✔ purrr 1.0.4
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
## Loading required package: magrittr
##
##
## Attaching package: 'magrittr'
##
##
## The following object is masked from 'package:purrr':
##
## set_names
##
##
## The following object is masked from 'package:tidyr':
##
## extract
##
##
## Loading required package: weights
##
## Loading required package: Hmisc
##
##
## Attaching package: 'Hmisc'
##
##
## The following objects are masked from 'package:dplyr':
##
## src, summarize
##
##
## The following objects are masked from 'package:base':
##
## format.pval, units
##
##
## Loading required package: assertthat
##
##
## Attaching package: 'assertthat'
##
##
## The following object is masked from 'package:tibble':
##
## has_name
##
##
## Loading required package: psych
##
##
## Attaching package: 'psych'
##
##
## The following object is masked from 'package:Hmisc':
##
## describe
##
##
## The following objects are masked from 'package:ggplot2':
##
## %+%, alpha
##
##
##
## Attaching package: 'kirkegaard'
##
##
## The following object is masked from 'package:psych':
##
## rescale
##
##
## The following object is masked from 'package:assertthat':
##
## are_equal
##
##
## The following object is masked from 'package:purrr':
##
## is_logical
##
##
## The following object is masked from 'package:base':
##
## +
load_packages(
mirt,
mgcv,
rms,
ggeffects,
pscl,
broom
)
## Loading required package: stats4
## Loading required package: lattice
## Loading required package: nlme
##
## Attaching package: 'nlme'
##
## The following object is masked from 'package:mirt':
##
## fixef
##
## The following object is masked from 'package:dplyr':
##
## collapse
##
## This is mgcv 1.9-1. For overview type 'help("mgcv-package")'.
## Classes and Methods for R originally developed in the
## Political Science Computational Laboratory
## Department of Political Science
## Stanford University (2002-2015),
## by and under the direction of Simon Jackman.
## hurdle and zeroinfl functions by Achim Zeileis.
theme_set(theme_bw())
options(
digits = 3
)
#multithreading
#library(future)
#plan(multisession(workers = 8))
#recode ordinal
recode_likert = function(x) {
x %>%
case_match(
"Strongly disagree" ~ 1,
"Disagree" ~ 2,
"Slightly disagree" ~ 3,
"Neutral/don't know" ~ 4,
"Slightly agree" ~ 5,
"Agree" ~ 6,
"Strongly agree" ~ 7
)
}
#tidy functions
tidy_pscl = function(x) {
x_coefs = summary(x) %>% .$coefficients
bind_rows(
x_coefs[[1]] %>% as.data.frame() %>% rownames_to_column() %>% set_colnames(c("term", "estimate", "std.error", "statistic", "p.value")) %>% mutate(submodel = "count"),
x_coefs[[2]] %>% as.data.frame() %>% rownames_to_column() %>% set_colnames(c("term", "estimate", "std.error", "statistic", "p.value")) %>% mutate(submodel = "hurdle")
) %>%
as_tibble()
}
#count variable models
fit_count_models = function(y, xs, data = d) {
#make forms
form1 = as.formula(str_glue("{y} ~ {str_c(xs, collapse = ' + ')}"))
form2 = as.formula(str_glue("{y} ~ {str_c(xs, collapse = ' + ')} + age + sex + ethnic3"))
#fit models
poisson1 = glm(form1, data = data, family = "poisson")
poisson2 = glm(form2, data = data, family = "poisson")
hurdle1 = pscl::hurdle(form1, data = data)
hurdle2 = pscl::hurdle(form2, data = data)
zeroinf1 = pscl::zeroinfl(form1, data = data)
zeroinf2 = pscl::zeroinfl(form2, data = data)
#extract model pars
poisson1_tidy = tidy(poisson1)
poisson2_tidy = tidy(poisson2)
hurdle1_tidy = tidy_pscl(hurdle1)
hurdle2_tidy = tidy_pscl(hurdle2)
zeroinf1_tidy = tidy_pscl(zeroinf1)
zeroinf2_tidy = tidy_pscl(zeroinf2)
#collect
y = list(
coefs = bind_rows(
poisson1_tidy %>% mutate(model = "poisson1"),
poisson2_tidy %>% mutate(model = "poisson2"),
hurdle1_tidy %>% mutate(model = "hurdle1"),
hurdle2_tidy %>% mutate(model = "hurdle2"),
zeroinf1_tidy %>% mutate(model = "zeroinf1"),
zeroinf2_tidy %>% mutate(model = "zeroinf2"),
),
models = list(
poisson1 = poisson1,
poisson2 = poisson2,
hurdle1 = hurdle1,
hurdle2 = hurdle2,
zeroinf1 = zeroinf1,
zeroinf2 = zeroinf2
)
)
y
}
#binomial models
fit_logistic_models = function(y, xs, data = d) {
#make forms
form1 = as.formula(str_glue("{y} ~ {str_c(xs, collapse = ' + ')}"))
form2 = as.formula(str_glue("{y} ~ {str_c(xs, collapse = ' + ')} + age + sex + ethnic3"))
#fit models
logistic1 = glm(form1, data = data, family = "binomial")
logistic2 = glm(form2, data = data, family = "binomial")
#tidy
logistic1_tidy = logistic1 %>% tidy()
logistic2_tidy = logistic2 %>% tidy()
#collect
y = list(
coefs = bind_rows(
logistic1_tidy %>% mutate(model = "logistic1"),
logistic2_tidy %>% mutate(model = "logistic2")
),
models = list(
logistic1 = logistic1,
logistic2 = logistic2
)
)
y
}
#predict nominal data frame from vector
#in order to potentially find random responders
predict_nominal_df = function(data, pred) {
#loop over each column, fit a multinomial model
pred_errors = map2_dfc(data, seq_along(data), function(x, i) {
#which column is this? write message
message(i)
# if (i == 2) browser()
#set levels to be the order they are in
x = factor(x, levels = unique(x))
#fit multinomial model
multinom_model = nnet::multinom(x ~ splines::ns(pred, df = 3), trace = F)
# multinom_model = nnet::multinom(x ~ pred, trace = F)
#get prediction error for chosen response by case
pred_probs = nnet:::predict.multinom(multinom_model, type = "probs")
#very annoying error, the function changes the output if there are only 2 levels
#it predicts the second level, so we need to manually construct the 1st level in a matrix
if (length(levels(x)) == 2) {
pred_probs = cbind(1 - pred_probs, pred_probs)
}
pred_probs_chosen = pred_probs[cbind(1:length(x), as.numeric(x))]
#get prediction error
pred_error = 1 - pred_probs_chosen
#return as data frame
tibble(
pred_error
)
}
)
colnames(pred_errors) = data %>% names()
pred_errors
}
# pol_know_errors = predict_nominal_df(
# d_pol_know_items,
# d$pol_knowledge
# )
#
# pol_know_errors$mean_error = rowMeans(pol_know_errors)
# #add to main
# d$pol_knowledge_mean_choice_pred_error = pol_know_errors$mean_error
#
# #how does this relate to score?
# d %>%
# GG_scatter("pol_knowledge", "pol_knowledge_mean_choice_pred_error") +
# geom_smooth() +
# labs(
# x = "Political knowledge (z)",
# y = "Mean choice prediction error"
# )
#read alchemer data
d_alch = read_csv("data_sensitive/20250530223807-SurveyExport final.csv") %>% df_legalize_names()
## New names:
## Rows: 516 Columns: 132
## ── Column specification
## ──────────────────────────────────────────────────────── Delimiter: "," chr
## (114): Status, Language, Referer, SessionID, User Agent, IP Address, Co... dbl
## (5): Response ID, Longitude, Latitude, In which year did the House of... lgl
## (11): Contact ID, Legacy Comments, Comments, Tags, Face/Head:On which ... dttm
## (2): Time Started, Date Submitted
## ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
## Specify the column types or set `show_col_types = FALSE` to quiet this message.
## • `Other - Write In:Do you have a doctor's diagnoses for any of the following
## mental illneses? Check all that apply` -> `Other - Write In:Do you have a
## doctor's diagnoses for any of the following mental illneses? Check all that
## apply...130`
## • `Other - Write In:Do you have a doctor's diagnoses for any of the following
## mental illneses? Check all that apply` -> `Other - Write In:Do you have a
## doctor's diagnoses for any of the following mental illneses? Check all that
## apply...132`
d_alch_vars = d_alch %>% df_var_table()
#read prolific data
d_prolific = read_csv("data_sensitive/prolific_export_68387a89e23f465bba4cc5e3 final.csv") %>% df_legalize_names()
## Rows: 515 Columns: 22
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (16): Submission id, Participant id, Status, Custom study tncs accepted...
## dbl (2): Time taken, Total approvals
## lgl (1): Reviewed at
## dttm (3): Started at, Completed at, Archived at
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
#join
d_raw = inner_join(
d_alch,
d_prolific,
by = c("Prolific_ID" = "Participant_id")
)
#no dups
d_raw$Prolific_ID %>%
table2() %>%
filter(Count > 1)
#remove sensitive vars
d_raw %<>% select(
-Contact_ID,Legacy_Comments,Comments,Referer,SessionID,User_Agent,Tags,IP_Address
)
#attention checks
d_attention = d_raw %>% select(Prolific_ID, Choose_King_of_England, Choose_slightly_agree_What_do_you_think_about_the_following_questions_Part_2) %>%
mutate(
attention_check_1 = case_when(
Choose_King_of_England %in% c("King of England", "William of Orange", "King Canute") ~ 1,
TRUE ~ 0
),
attention_check_2 = case_when(
Choose_slightly_agree_What_do_you_think_about_the_following_questions_Part_2 == "Slightly agree" ~ 1,
TRUE ~ 0
),
attention_pass = attention_check_1 == 1 & attention_check_2 == 1
)
#failed ids
failed_ids = d_attention %>% filter(!attention_pass) %>% pull(Prolific_ID)
#filter to pass
d = d_raw %>% filter(!Prolific_ID %in% failed_ids)
#any dups remaining?
d$Prolific_ID %>%
table2() %>%
filter(Count > 1)
#recode some vars
d %<>%
mutate(
sex = What_is_your_sex_Y_chromosome,
male = sex == "Male",
age = How_old_are_you %>% as.numeric(),
age_z = age %>% standardize(),
ethnic = What_is_your_ethnicity %>% fct_infreq(),
ethnic_common = ethnic %>% fct_lump_min(15),
ethnic3 = case_when(
ethnic %in% c("White: English, Welsh, Scottish, Northern Irish or British", "Any other White background") ~ "White",
ethnic %in% c("Black: African", "Any other Black, Black British, or Caribbean background") ~ "Black",
.default = "Other"
) %>% fct_infreq(),
unnatural_hair = (As_an_adult_have_you_ever_dyed_your_hair_with_an_unnatural_hair_color_pink_green_blue_purple_yellow_etc == "Yes") %>%
as.numeric(),
party = Who_would_you_vote_for_if_today_was_the_general_election,
pol_self_placement = Are_you_politically_left_wing_or_right_wing %>%
ordered(levels = c("Strongly left wing", "Moderately left wing", "Centrist", "Moderately right wing", "Strongly right wing")),
pol_self_placement_num = pol_self_placement %>% as.numeric(),
time_min = (d$Date_Submitted - d$Time_Started) %>% as.numeric()
)
#ethnic counts
d$ethnic %>%
table2()
#count tattoos
d_tattoos = d %>% select(
matches("tattoo"),
-I_don_t_have_any_tattoos_On_which_parts_of_your_body_do_you_have_tattoos_If_you_don_t_have_any_select_I_don_t_have_any_tattoos
) %>%
#code any string to 1, and 0 otherwise
map_df(~!is.na(.) %>% as.numeric())
#nicer names
colnames(d_tattoos) = colnames(d_tattoos) %>%
str_remove("_On_which_parts_of_your_body_do_you_have_tattoos_If_you_don_t_have_any_select_I_don_t_have_any_tattoos")
#sum tattoos
d$tattoos_count = d_tattoos %>% rowSums()
#distribution
d$tattoos_count %>%
GG_denhist()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#piercings
d_piercings = d %>% select(
matches("piercing"),
-I_don_t_have_any_piercings_Do_you_have_any_piercings_If_so_where_If_you_don_t_have_any_select_I_don_t_have_any_piercings
) %>%
#code any string to 1, and 0 otherwise
map_df(~!is.na(.) %>% as.numeric())
d_piercings %>% colMeans()
## Ears_Do_you_have_any_piercings_If_so_where_If_you_don_t_have_any_select_I_don_t_have_any_piercings
## 0.44082
## Eyebrow_Do_you_have_any_piercings_If_so_where_If_you_don_t_have_any_select_I_don_t_have_any_piercings
## 0.00408
## Nose_septum_not_included_Do_you_have_any_piercings_If_so_where_If_you_don_t_have_any_select_I_don_t_have_any_piercings
## 0.06122
## Septum_Do_you_have_any_piercings_If_so_where_If_you_don_t_have_any_select_I_don_t_have_any_piercings
## 0.00612
## Mouth_area_outside_the_mouth_Do_you_have_any_piercings_If_so_where_If_you_don_t_have_any_select_I_don_t_have_any_piercings
## 0.00204
## Mouth_area_inside_the_mouth_Do_you_have_any_piercings_If_so_where_If_you_don_t_have_any_select_I_don_t_have_any_piercings
## 0.01020
## Cheek_Do_you_have_any_piercings_If_so_where_If_you_don_t_have_any_select_I_don_t_have_any_piercings
## 0.00000
## Nipple_Do_you_have_any_piercings_If_so_where_If_you_don_t_have_any_select_I_don_t_have_any_piercings
## 0.00816
## Navel_Do_you_have_any_piercings_If_so_where_If_you_don_t_have_any_select_I_don_t_have_any_piercings
## 0.03265
## Genital_Do_you_have_any_piercings_If_so_where_If_you_don_t_have_any_select_I_don_t_have_any_piercings
## 0.00204
## Other_Do_you_have_any_piercings_If_so_where_If_you_don_t_have_any_select_I_don_t_have_any_piercings
## 0.00204
#nicer names
colnames(d_piercings) = colnames(d_piercings) %>%
str_remove("_Do_you_have_any_piercings_If_so_where_If_you_don_t_have_any_select_I_don_t_have_any_piercings")
#sum piercings
d$piercings_count = d_piercings %>% rowSums()
#distribution
d$piercings_count %>%
GG_denhist()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#non-ear piercings
d$nonear_piercings_count = d_piercings %>%
select(-Ears) %>%
rowSums()
#scoring key
pol_know_key = c("Keir Starmer", "Labour Party", "Kemi Badenoch", "Economic and financial matters",
"Scottish National Party", "House of Lords", "Four", "Scotland",
"By August 2029", "Sadiq Khan", "Liberal Democrats", "1911",
"Secretary of State for Health and Social Care", "David Cameron",
"Reducing regional inequalities", "Scotland", "Conservative Party",
"Immigration, policing, and security", "650", "To moderate debates and ensure order",
"Green Party", "Post-Brexit trade in Northern Ireland", "British, Irish, and qualifying Commonwealth citizens aged 18+",
"1215", "Northern Ireland")
d_pol_know_items = d %>% select(Who_is_the_current_Prime_Minister_of_the_United_Kingdom:Which_region_of_the_UK_has_seen_renewed_debate_about_reunification_with_a_neighbouring_country) %>%
select(-Choose_King_of_England)
#nicer names
colnames(d_pol_know_items) = c("prime_minister", "governing_party", "opposition_leader", "role_chan_exchequer",
"scottish_indep_party", "upper_house_name", "UK_nations", "location_scottish_parliament",
"next_election_date", "mayor_london", "ed_davey_role", "house_lords_veto_removed",
"who_oversees_NHS", "foreign_secretary_return", "levelling_up_meaning",
"region_voted_remain", "rural_england_party", "role_home_secretary",
"members_of_parliament", "role_speaker_of_house", "most_envir_party",
"windsor_framework", "who_can_vote", "magna_carta", "region_reunification_debate"
)
#scored
d_pol_know_items_scored = score_items(
d_pol_know_items,
key = pol_know_key
)
#plot pass rates
tibble(
item = d_pol_know_items_scored %>% names(),
pass_rate = d_pol_know_items_scored %>% colMeans()
) %>%
mutate(
item = fct_reorder(item, pass_rate)
) %>%
ggplot(aes(pass_rate, item)) +
geom_col() +
#add pass rate in % at the bar end
geom_text(aes(label = scales::percent(round(pass_rate, 2))), hjust = -0.1)
#subset to items with variance
# d_pol_know_items_scored_sub = d_pol_know_items_scored %>%
# select(where(~var(.) > 0))
#fit IRT
polknow_irt = mirt(
d_pol_know_items_scored,
model = 1,
itemtype = "2PL",
guess = rep(1/5, ncol(d_pol_know_items_scored)),
technical = list(NCYCLES = 5000),
verbose = F
)
polknow_irt
##
## Call:
## mirt(data = d_pol_know_items_scored, model = 1, itemtype = "2PL",
## guess = rep(1/5, ncol(d_pol_know_items_scored)), verbose = F,
## technical = list(NCYCLES = 5000))
##
## Full-information item factor analysis with 1 factor(s).
## Converged within 1e-04 tolerance after 2701 EM iterations.
## mirt version: 1.44.0
## M-step optimizer: BFGS
## EM acceleration: Ramsay
## Number of rectangular quadrature: 61
## Latent density type: Gaussian
##
## Log-likelihood = -4360
## Estimated parameters: 50
## AIC = 8821
## BIC = 9031; SABIC = 8872
## G2 (33554381) = 3242, p = 1
## RMSEA = 0, CFI = NaN, TLI = NaN
polknow_irt %>% summary()
## F1 h2
## prime_minister 0.188 0.0354
## governing_party 0.211 0.0444
## opposition_leader 0.886 0.7843
## role_chan_exchequer 0.866 0.7498
## scottish_indep_party 0.668 0.4458
## upper_house_name 0.641 0.4105
## UK_nations 0.361 0.1304
## location_scottish_parliament 0.809 0.6538
## next_election_date 0.638 0.4069
## mayor_london 0.671 0.4505
## ed_davey_role 0.924 0.8547
## house_lords_veto_removed 0.720 0.5186
## who_oversees_NHS 0.594 0.3531
## foreign_secretary_return 0.759 0.5768
## levelling_up_meaning 0.888 0.7886
## region_voted_remain 0.443 0.1961
## rural_england_party 0.453 0.2052
## role_home_secretary 0.717 0.5141
## members_of_parliament 0.693 0.4798
## role_speaker_of_house 0.649 0.4213
## most_envir_party 0.268 0.0718
## windsor_framework 0.653 0.4265
## who_can_vote 0.953 0.9086
## magna_carta 0.659 0.4344
## region_reunification_debate 0.523 0.2738
##
## SS loadings: 11.1
## Proportion Var: 0.445
##
## Factor correlations:
##
## F1
## F1 1
#item stats
polknow_irt_items = get_mirt_stats(polknow_irt)
#the guessing parameter messes this up, so we replace it with the observed pass rate
polknow_irt_items$pass_rate = d_pol_know_items_scored %>% colMeans()
#derive difficulty from inverse normal of pass rate
polknow_irt_items$difficulty = -qnorm(polknow_irt_items$pass_rate)
#adjust observed passrate for guessing chance
polknow_irt_items$pass_rate_adj = (polknow_irt_items$pass_rate - 1/5) / (4/5)
#scores
d_pol_know_scores = fscores(polknow_irt, full.scores.SE = T)
#reliability
empirical_rxx(d_pol_know_scores)
## F1
## 0.804
marginal_rxx(polknow_irt)
## [1] 0.807
get_reliabilities(polknow_irt) %>%
filter(
z > -2, z < 2
) %>%
ggplot(aes(z, rel)) +
geom_line() +
labs(
y = "Reliability",
x = "z score"
)
GG_save("figs/reliability_pol_knowledge.png")
#plot
d_pol_know_scores[, 1] %>%
GG_denhist()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#save to main
d$pol_knowledge = d_pol_know_scores[, 1] %>% standardize()
#also sum score
d$pol_knowledge_sum = d_pol_know_items_scored %>% rowSums()
d$pol_knowledge_sum %>%
GG_denhist(binwidth = 1)
d$pol_knowledge_sum %>% table2(sort_descending = NULL)
#compare scores
d %>%
GG_scatter(
"pol_knowledge_sum",
"pol_knowledge",
) +
geom_smooth()
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
#item stats
polknow_irt_items = get_mirt_stats(polknow_irt) %>%
mutate(
#replace pass rates
pass_rate = d_pol_know_items_scored %>% colMeans()
)
polknow_irt_items %>%
GG_scatter("pass_rate", "loading", case_names = "item") +
scale_x_continuous(labels = scales::percent)
## `geom_smooth()` using formula = 'y ~ x'
#time vs. score
d %>%
GG_scatter("time_min", "pol_knowledge_sum") +
geom_smooth() +
scale_x_continuous(limits = c(0, 50)) +
labs(
x = "Time spent on survey (minutes)",
y = "Political knowledge score"
)
## `geom_smooth()` using formula = 'y ~ x'
## Warning: Removed 7 rows containing non-finite outside the scale range
## (`stat_smooth()`).
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
## Warning: Removed 7 rows containing non-finite outside the scale range
## (`stat_smooth()`).
## Warning: Removed 7 rows containing missing values or values outside the scale range
## (`geom_point()`).
#compare real vs. blind guessing distributuions
set.seed(1)
d$pol_knowledge_sum_blind = rbinom(nrow(d), 25, prob = 1/5)
# Reshape data
d_polknow_long <- d %>%
select(pol_knowledge_sum, pol_knowledge_sum_blind) %>%
pivot_longer(
everything(),
names_to = "type",
values_to = "score"
) %>%
mutate(
type = case_when(
type == "pol_knowledge_sum" ~ "Real subjects",
type == "pol_knowledge_sum_blind" ~ "Blind guessing"
)
)
# Create histogram bins manually
binwidth <- 1 # or choose another value
breaks <- seq(floor(min(d_polknow_long$score, na.rm=TRUE)),
ceiling(max(d_polknow_long$score, na.rm=TRUE)),
by = binwidth)
d_polknow_long_binned <- d_polknow_long %>%
mutate(score_bin = cut(score, breaks = breaks, right = FALSE)) %>%
count(score_bin, type) %>%
complete(score_bin, type, fill = list(n = 0)) %>%
mutate(score_mid = as.numeric(sub("\\[|\\)", "", sub(",.*", "", score_bin))) + binwidth / 2)
# Plot using identity and dodge
ggplot(d_polknow_long_binned, aes(x = score_mid, y = n, fill = type)) +
geom_bar(stat = "identity", position = position_dodge(width = binwidth), width = binwidth * 0.9) +
scale_x_continuous(breaks = breaks) +
labs(x = "score", y = "count", fill = "type")
## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_bar()`).
GG_save("figs/pol_knowledge_guessing.png")
## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_bar()`).
#residualize for age
d$pol_knowledge_age_resid = lm(pol_knowledge ~ age, data = d)$residuals
#gap size
SMD_matrix(
d$pol_knowledge_age_resid,
d$sex,
reliability = empirical_rxx(d_pol_know_scores)
)
## Female Male
## Female NA -0.432
## Male -0.432 NA
SMD_matrix(
d$pol_knowledge_age_resid,
d$sex
)
## Female Male
## Female NA -0.386
## Male -0.386 NA
d_ideo_items = d %>% select(
The_UK_should_continue_to_provide_military_and_financial_support_to_Ukraine_in_its_war_with_Russia_What_do_you_think_about_the_following_questions:Public_policy_changes_do_not_need_to_be_made_to_deal_with_climate_change_What_do_you_think_about_the_following_questions_Part_3
) %>% select(-Choose_slightly_agree_What_do_you_think_about_the_following_questions_Part_2)
#nicer names
colnames(d_ideo_items) = colnames(d_ideo_items) %>% str_remove("_What_do_you_think_about_the_following_questions_Part_2") %>%
str_remove("_What_do_you_think_about_the_following_questions_Part_3") %>%
str_remove("_What_do_you_think_about_the_following_questions")
#recode to ordinals
d_ideo_items_ord = d_ideo_items %>%
map_df(recode_likert)
#numeric
d_ideo_items_num = d_ideo_items_ord %>% map_df(as.numeric)
#fit irt
ideo_irt = mirt(
d_ideo_items_num,
model = 1,
itemtype = "graded",
technical = list(NCYCLES = 5000),
verbose = F
)
ideo_irt
##
## Call:
## mirt(data = d_ideo_items_num, model = 1, itemtype = "graded",
## verbose = F, technical = list(NCYCLES = 5000))
##
## Full-information item factor analysis with 1 factor(s).
## Converged within 1e-04 tolerance after 116 EM iterations.
## mirt version: 1.44.0
## M-step optimizer: BFGS
## EM acceleration: Ramsay
## Number of rectangular quadrature: 61
## Latent density type: Gaussian
##
## Log-likelihood = -26953
## Estimated parameters: 245
## AIC = 54397
## BIC = 55424; SABIC = 54647
## G2 (1e+10) = 47836, p = 1
## RMSEA = 0, CFI = NaN, TLI = NaN
ideo_irt %>% summary()
## F1
## The_UK_should_continue_to_provide_military_and_financial_support_to_Ukraine_in_its_war_with_Russia 0.441
## Immigration_levels_in_the_UK_are_too_high_and_should_be_significantly_reduced -0.696
## The_NHS_should_remain_entirely_publicly_funded_and_free_at_the_point_of_use 0.382
## Wealthier_individuals_should_pay_significantly_higher_taxes_to_support_public_services 0.576
## The_UK_should_phase_out_fossil_fuels_entirely_by_2035_even_if_it_increases_energy_costs_in_the_short_term 0.627
## The_UK_should_invest_in_building_new_nuclear_power_plants_to_meet_future_energy_demands -0.265
## The_monarchy_is_an_outdated_institution_and_should_be_abolished 0.362
## Government_benefits_are_too_generous_and_discourage_people_from_working -0.557
## The_UK_should_rejoin_the_European_Union 0.636
## The_UK_should_recognize_a_Palestinian_state_and_reduce_military_cooperation_with_Israel 0.628
## Compared_to_other_civilizations_Western_civilization_is_uniquely_evil 0.156
## Strikes_by_public_sector_workers_are_justified_in_the_current_economic_climate 0.616
## Transgender_women_should_be_allowed_to_compete_in_women_s_sports_categories 0.663
## Local_councils_should_be_allowed_to_introduce_rent_controls_to_reduce_housing_costs 0.469
## The_UK_government_should_introduce_stricter_laws_to_prevent_online_hate_speech_even_at_the_expense_of_free_expression 0.364
## Climate_change_is_an_urgent_threat_that_requires_immediate_and_far_reaching_government_action 0.675
## Private_companies_should_be_allowed_to_run_parts_of_the_NHS_if_it_improves_efficiency -0.443
## The_UK_should_adopt_proportional_representation_for_general_elections 0.198
## Parents_should_be_allowed_to_send_their_children_to_grammar_or_private_schools_if_they_can_afford_it -0.383
## The_UK_should_deport_asylum_seekers_to_third_countries_like_Rwanda_if_they_arrive_through_irregular_routes -0.757
## National_service_military_or_civic_should_be_mandatory_for_young_adults_in_the_UK -0.470
## I_support_the_LGBT_community 0.861
## I_support_gay_marriage 0.818
## There_is_nothing_wrong_with_public_depictions_of_homosexual_relationships 0.716
## Everyone_should_be_addressed_by_their_desired_pronouns 0.777
## There_are_only_two_genders -0.815
## I_support_feminism 0.732
## Abortion_should_be_available_to_women_for_use_for_any_reason 0.432
## Children_should_be_taught_about_gay_sex_in_sex_education_classes 0.751
## There_is_nothing_wrong_with_attending_a_gay_orgy 0.657
## Men_should_be_masculine_and_women_should_be_feminine -0.736
## Immigration_policy_should_be_strict_and_heavily_meritorious -0.684
## Progressive_taxation_where_the_rich_are_taxed_at_a_higher_rate_is_the_best_way_to_structure_a_tax_system 0.622
## The_government_should_help_ensure_sexual_equality_by_making_sure_women_are_not_discriminated_against_in_private_hiring 0.602
## Public_policy_changes_do_not_need_to_be_made_to_deal_with_climate_change -0.631
## h2
## The_UK_should_continue_to_provide_military_and_financial_support_to_Ukraine_in_its_war_with_Russia 0.1942
## Immigration_levels_in_the_UK_are_too_high_and_should_be_significantly_reduced 0.4846
## The_NHS_should_remain_entirely_publicly_funded_and_free_at_the_point_of_use 0.1460
## Wealthier_individuals_should_pay_significantly_higher_taxes_to_support_public_services 0.3322
## The_UK_should_phase_out_fossil_fuels_entirely_by_2035_even_if_it_increases_energy_costs_in_the_short_term 0.3934
## The_UK_should_invest_in_building_new_nuclear_power_plants_to_meet_future_energy_demands 0.0701
## The_monarchy_is_an_outdated_institution_and_should_be_abolished 0.1311
## Government_benefits_are_too_generous_and_discourage_people_from_working 0.3100
## The_UK_should_rejoin_the_European_Union 0.4046
## The_UK_should_recognize_a_Palestinian_state_and_reduce_military_cooperation_with_Israel 0.3950
## Compared_to_other_civilizations_Western_civilization_is_uniquely_evil 0.0245
## Strikes_by_public_sector_workers_are_justified_in_the_current_economic_climate 0.3790
## Transgender_women_should_be_allowed_to_compete_in_women_s_sports_categories 0.4402
## Local_councils_should_be_allowed_to_introduce_rent_controls_to_reduce_housing_costs 0.2204
## The_UK_government_should_introduce_stricter_laws_to_prevent_online_hate_speech_even_at_the_expense_of_free_expression 0.1321
## Climate_change_is_an_urgent_threat_that_requires_immediate_and_far_reaching_government_action 0.4553
## Private_companies_should_be_allowed_to_run_parts_of_the_NHS_if_it_improves_efficiency 0.1964
## The_UK_should_adopt_proportional_representation_for_general_elections 0.0390
## Parents_should_be_allowed_to_send_their_children_to_grammar_or_private_schools_if_they_can_afford_it 0.1471
## The_UK_should_deport_asylum_seekers_to_third_countries_like_Rwanda_if_they_arrive_through_irregular_routes 0.5737
## National_service_military_or_civic_should_be_mandatory_for_young_adults_in_the_UK 0.2213
## I_support_the_LGBT_community 0.7415
## I_support_gay_marriage 0.6697
## There_is_nothing_wrong_with_public_depictions_of_homosexual_relationships 0.5130
## Everyone_should_be_addressed_by_their_desired_pronouns 0.6044
## There_are_only_two_genders 0.6648
## I_support_feminism 0.5364
## Abortion_should_be_available_to_women_for_use_for_any_reason 0.1863
## Children_should_be_taught_about_gay_sex_in_sex_education_classes 0.5641
## There_is_nothing_wrong_with_attending_a_gay_orgy 0.4312
## Men_should_be_masculine_and_women_should_be_feminine 0.5414
## Immigration_policy_should_be_strict_and_heavily_meritorious 0.4674
## Progressive_taxation_where_the_rich_are_taxed_at_a_higher_rate_is_the_best_way_to_structure_a_tax_system 0.3871
## The_government_should_help_ensure_sexual_equality_by_making_sure_women_are_not_discriminated_against_in_private_hiring 0.3628
## Public_policy_changes_do_not_need_to_be_made_to_deal_with_climate_change 0.3977
##
## SS loadings: 12.8
## Proportion Var: 0.365
##
## Factor correlations:
##
## F1
## F1 1
#item stats
ideo_irt_items = get_mirt_stats(ideo_irt)
#scores
d_ideo_scores = fscores(ideo_irt, full.scores.SE = T)
#reliability
empirical_rxx(d_ideo_scores)
## F1
## 0.952
marginal_rxx(ideo_irt)
## [1] 0.953
get_reliabilities(ideo_irt) %>%
filter(
z > -2, z < 2
) %>%
ggplot(aes(z, rel)) +
geom_line()
#plot
d_ideo_scores[, 1] %>%
GG_denhist()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#save to main
d$leftism = d_ideo_scores[, 1] %>% standardize()
d$leftism_SE = d_ideo_scores[, 2]
#self-placement vs. score
d %>%
GG_scatter("pol_self_placement_num", "leftism")
## `geom_smooth()` using formula = 'y ~ x'
#without discretization bias
d %>%
select(
pol_self_placement_num,
leftism) %>%
mixedCor()
## Call: mixedCor(data = .)
## pl___ lftsm
## pol_self_placement_num 1.00
## leftism -0.77 1.00
#SMD
SMD_matrix(
d$leftism,
d$Who_would_you_vote_for_if_today_was_the_general_election
)
## Conservatives
## Conservatives NA
## Democratic Unionist Party (DUP) -0.850
## Green party -2.192
## Labour -1.392
## Liberal Democrats -1.414
## Not vote -0.833
## Other party -0.192
## Plaid Cymru -2.188
## Reform UK 0.562
## Scottish National Party -1.823
## Sinn Féin -1.568
## Social Democratic and Labour Party (SDLP) -3.377
## Democratic Unionist Party (DUP)
## Conservatives -0.8497
## Democratic Unionist Party (DUP) NA
## Green party -1.3419
## Labour -0.5418
## Liberal Democrats -0.5646
## Not vote 0.0163
## Other party 0.6581
## Plaid Cymru -1.3381
## Reform UK 1.4114
## Scottish National Party -0.9731
## Sinn Féin -0.7186
## Social Democratic and Labour Party (SDLP) -2.5274
## Green party Labour Liberal Democrats
## Conservatives -2.19160 -1.3916 -1.4143
## Democratic Unionist Party (DUP) -1.34188 -0.5418 -0.5646
## Green party NA 0.8000 0.7773
## Labour 0.80005 NA -0.0228
## Liberal Democrats 0.77729 -0.0228 NA
## Not vote 1.35821 0.5582 0.5809
## Other party 2.00001 1.2000 1.2227
## Plaid Cymru 0.00374 -0.7963 -0.7735
## Reform UK 2.75330 1.9533 1.9760
## Scottish National Party 0.36875 -0.4313 -0.4085
## Sinn Féin 0.62326 -0.1768 -0.1540
## Social Democratic and Labour Party (SDLP) -1.18555 -1.9856 -1.9628
## Not vote Other party Plaid Cymru
## Conservatives -0.8334 -0.192 -2.18786
## Democratic Unionist Party (DUP) 0.0163 0.658 -1.33814
## Green party 1.3582 2.000 0.00374
## Labour 0.5582 1.200 -0.79631
## Liberal Democrats 0.5809 1.223 -0.77355
## Not vote NA 0.642 -1.35447
## Other party 0.6418 NA -1.99627
## Plaid Cymru -1.3545 -1.996 NA
## Reform UK 1.3951 0.753 2.74956
## Scottish National Party -0.9895 -1.631 0.36501
## Sinn Féin -0.7349 -1.377 0.61952
## Social Democratic and Labour Party (SDLP) -2.5438 -3.186 -1.18929
## Reform UK Scottish National Party
## Conservatives 0.562 -1.823
## Democratic Unionist Party (DUP) 1.411 -0.973
## Green party 2.753 0.369
## Labour 1.953 -0.431
## Liberal Democrats 1.976 -0.409
## Not vote 1.395 -0.989
## Other party 0.753 -1.631
## Plaid Cymru 2.750 0.365
## Reform UK NA -2.385
## Scottish National Party -2.385 NA
## Sinn Féin -2.130 0.255
## Social Democratic and Labour Party (SDLP) -3.939 -1.554
## Sinn Féin
## Conservatives -1.568
## Democratic Unionist Party (DUP) -0.719
## Green party 0.623
## Labour -0.177
## Liberal Democrats -0.154
## Not vote -0.735
## Other party -1.377
## Plaid Cymru 0.620
## Reform UK -2.130
## Scottish National Party 0.255
## Sinn Féin NA
## Social Democratic and Labour Party (SDLP) -1.809
## Social Democratic and Labour Party (SDLP)
## Conservatives -3.38
## Democratic Unionist Party (DUP) -2.53
## Green party -1.19
## Labour -1.99
## Liberal Democrats -1.96
## Not vote -2.54
## Other party -3.19
## Plaid Cymru -1.19
## Reform UK -3.94
## Scottish National Party -1.55
## Sinn Féin -1.81
## Social Democratic and Labour Party (SDLP) NA
#fit IRT models by intervals of pol knowledge
d$pol_knowledge_bins = d$pol_knowledge %>% discretize(breaks = 3, equal_range = F)
d$pol_knowledge_bins %>% table2()
#fit IRT within each bind, return empirical reliability
ideo_irt_bins = map_df(levels(d$pol_knowledge_bins), function(i) {
# browser()
#subset
d_sub = d_ideo_items_num %>%
mutate(
pol_knowledge_bin = d$pol_knowledge_bins
) %>%
filter(pol_knowledge_bin == i)
#fit IRT
ideo_irt_sub = mirt(
d_sub %>% select(-pol_knowledge_bin),
model = 1,
itemtype = "graded",
technical = list(NCYCLES = 5000),
verbose = F
)
#item stats
ideo_irt_sub_stats = get_mirt_stats(ideo_irt_sub)
#scores
ideo_scores_sub = fscores(ideo_irt_sub, full.scores.SE = T, full.scores = T)
#reliability
rel_sub = empirical_rxx(ideo_scores_sub)
#alpha
items_alpha = d_sub %>% select(-pol_knowledge_bin) %>%
psych::alpha(check.keys = T)
tibble(
n = nrow(d_sub),
pol_knowledge_bin = i,
rel = rel_sub,
mean_item_cor = items_alpha$total$average_r,
median_item_cor = items_alpha$total$median_r,
mean_abs_loading = mean(abs(ideo_irt_sub_stats$loading)),
)
})
## Warning in psych::alpha(., check.keys = T): Some items were negatively correlated with the first principal component and were automatically reversed.
## This is indicated by a negative sign for the variable name.
## Warning in psych::alpha(., check.keys = T): Some items were negatively correlated with the first principal component and were automatically reversed.
## This is indicated by a negative sign for the variable name.
## Warning in psych::alpha(., check.keys = T): Some items were negatively correlated with the first principal component and were automatically reversed.
## This is indicated by a negative sign for the variable name.
#plot reliabilities
ideo_irt_bins
#repeat the above, but use only 10 items
ideo_irt_bins_10 = map_df(levels(d$pol_knowledge_bins), function(i) {
# browser()
#subset
d_sub = d_ideo_items_num %>%
mutate(
pol_knowledge_bin = d$pol_knowledge_bins
) %>%
filter(pol_knowledge_bin == i) %>%
select(1:10)
#fit IRT
ideo_irt_sub = mirt(
d_sub,
model = 1,
itemtype = "graded",
technical = list(NCYCLES = 5000),
verbose = F
)
#item stats
ideo_irt_sub_stats = get_mirt_stats(ideo_irt_sub)
#scores
ideo_scores_sub = fscores(ideo_irt_sub, full.scores.SE = T, full.scores = T)
#reliability
rel_sub = empirical_rxx(ideo_scores_sub)
#alpha
items_alpha = d_sub %>%
psych::alpha(check.keys = T)
tibble(
n = nrow(d_sub),
pol_knowledge_bin = i,
rel = rel_sub,
mean_item_cor = items_alpha$total$average_r,
median_item_cor = items_alpha$total$median_r,
mean_abs_loading = mean(abs(ideo_irt_sub_stats$loading)),
)
})
## Warning in psych::alpha(., check.keys = T): Some items were negatively correlated with the first principal component and were automatically reversed.
## This is indicated by a negative sign for the variable name.
## Warning in psych::alpha(., check.keys = T): Some items were negatively correlated with the first principal component and were automatically reversed.
## This is indicated by a negative sign for the variable name.
## Warning in psych::alpha(., check.keys = T): Some items were negatively correlated with the first principal component and were automatically reversed.
## This is indicated by a negative sign for the variable name.
ideo_irt_bins_10
#predict SE of leftism directly
d %>%
GG_scatter("pol_knowledge", "leftism_SE") +
geom_smooth() +
labs(
x = "Political knowledge (z)",
y = "Leftism SE"
)
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
#regressions
gam(leftism_SE ~ pol_knowledge, data = d) %>% summary()
##
## Family: gaussian
## Link function: identity
##
## Formula:
## leftism_SE ~ pol_knowledge
##
## Parametric coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.21775 0.00144 150.98 <2e-16 ***
## pol_knowledge 0.00103 0.00144 0.71 0.48
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
##
## R-sq.(adj) = -0.001 Deviance explained = 0.104%
## GCV = 0.0010234 Scale est. = 0.0010192 n = 490
gam(leftism_SE ~ pol_knowledge + age + sex + ethnic3, data = d) %>% summary()
##
## Family: gaussian
## Link function: identity
##
## Formula:
## leftism_SE ~ pol_knowledge + age + sex + ethnic3
##
## Parametric coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.229782 0.005565 41.29 <2e-16 ***
## pol_knowledge 0.002342 0.001568 1.49 0.136
## age -0.000234 0.000104 -2.25 0.025 *
## sexMale -0.002187 0.002940 -0.74 0.457
## ethnic3Other -0.001224 0.005326 -0.23 0.818
## ethnic3Black 0.001196 0.006291 0.19 0.849
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
##
## R-sq.(adj) = 0.00351 Deviance explained = 1.37%
## GCV = 0.0010272 Scale est. = 0.0010146 n = 490
gam(leftism_SE ~ pol_knowledge + age + sex + ethnic3 + leftism, data = d) %>% summary()
##
## Family: gaussian
## Link function: identity
##
## Formula:
## leftism_SE ~ pol_knowledge + age + sex + ethnic3 + leftism
##
## Parametric coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.223281 0.005786 38.59 < 2e-16 ***
## pol_knowledge 0.001359 0.001573 0.86 0.38800
## age -0.000116 0.000108 -1.08 0.28231
## sexMale -0.000848 0.002928 -0.29 0.77209
## ethnic3Other -0.000596 0.005264 -0.11 0.90990
## ethnic3Black 0.005694 0.006339 0.90 0.36950
## leftism 0.005446 0.001512 3.60 0.00035 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
##
## R-sq.(adj) = 0.0276 Deviance explained = 3.95%
## GCV = 0.0010045 Scale est. = 0.00099015 n = 490
gam(leftism_SE ~ s(pol_knowledge) + age + sex + ethnic3 + s(leftism), data = d) %>% summary()
##
## Family: gaussian
## Link function: identity
##
## Formula:
## leftism_SE ~ s(pol_knowledge) + age + sex + ethnic3 + s(leftism)
##
## Parametric coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.18e-01 3.21e-03 68.13 < 2e-16 ***
## age -1.97e-05 5.99e-05 -0.33 0.74
## sexMale -1.93e-03 1.61e-03 -1.20 0.23
## ethnic3Other 1.20e-03 2.91e-03 0.41 0.68
## ethnic3Black 1.68e-02 3.55e-03 4.75 2.8e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Approximate significance of smooth terms:
## edf Ref.df F p-value
## s(pol_knowledge) 1.83 2.33 0.97 0.35
## s(leftism) 6.14 7.35 157.75 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## R-sq.(adj) = 0.708 Deviance explained = 71.5%
## GCV = 0.00030529 Scale est. = 0.00029721 n = 490
d_diags = d %>% select(
Attention_deficit_hyperactivity_disorder_ADHD_Do_you_have_a_doctor_s_diagnoses_for_any_of_the_following_mental_illneses_Check_all_that_apply:Sleeping_disorders_Do_you_have_a_doctor_s_diagnoses_for_any_of_the_following_mental_illneses_Check_all_that_apply
) %>%
#code any string to 1, and 0 otherwise
map_df(~!is.na(.)) %>%
map_df(as.numeric)
#nicer names
colnames(d_diags) = c(
"ADHD", "Alcoholism", "Drug_abuse", "Autism", "ASPD", "Bipolar", "BPD", "Depression", "Anxiety", "OCD", "Panic", "Paranoia", "Social_phobia", "Specific_phobia", "PTSD", "Schizophrenia", "Schioid", "Sleep_disorders"
)
#rates
d_diags %>%
colMeans() %>%
as.data.frame() %>%
rownames_to_column("diagnosis") %>%
set_colnames(c("diagnosis", "prop")) %>%
mutate(
diagnosis = fct_reorder(diagnosis, prop)
) %>%
ggplot(aes(prop, diagnosis)) +
geom_col() +
scale_x_continuous(labels = scales::percent)
#irt
#some diagnoses have 0 variance, so we cant fit IRT
# diags_irt = mirt(
# d_diags,
# model = 1,
# itemtype = "2PL",
# technical = list(NCYCLES = 5000)
# )
#diag count
d$diagnoses_count = d_diags %>% rowSums()
#dist
d %>%
ggplot(aes(diagnoses_count)) +
#bar as a proportion
geom_bar(aes(y = after_stat(prop))) +
scale_x_continuous(breaks = 0:10) +
scale_y_continuous(labels = scales::percent) +
labs(
x = "Number of diagnoses",
y = "Count"
)
GG_save("figs/diagnoses_count.png")
#standadized version
d$diagnoses_count_std = d$diagnoses_count %>% standardize()
#correlation matrix for non-zero diagnoses
d_diags %>%
select(where(~var(.) > 0)) %>%
GG_heatmap(reorder_vars = F)
#fit dif
pol_know_dif_sex = DIF_test(
d_pol_know_items_scored,
model = 1,
group = d$sex,
itemtype = "2PL",
technical = list(NCYCLES = 50000),
guess = rep(1/5, ncol(d_pol_know_items_scored)),
verbose = F
)
## There are 8 steps
## Step 1: Initial joint fit
##
## Step 2: Initial MI fit
##
## Step 3: Leave one out MI testing
##
## Step 4: Fit without DIF items, liberal threshold
##
## Step 5: Fit without DIF items, conservative threshold
##
## Step 6: Fit with anchor items, liberal threshold
##
## Step 7: Fit with anchor items, conservative threshold
##
## Step 8: Get scores
#summary
pol_know_dif_sex$effect_size_test
## $liberal
## Effect Size Value
## 1 STDS 0.0213
## 2 UTDS 0.2603
## 3 UETSDS 0.0704
## 4 ETSSD 0.0081
## 5 Starks.DTFR 0.0370
## 6 UDTFR 0.2505
## 7 UETSDN 0.0797
## 8 theta.of.max.test.D -1.8899
## 9 Test.Dmax 0.4406
##
## $conservative
## Effect Size Value
## 1 STDS 0.0359
## 2 UTDS 0.0422
## 3 UETSDS 0.0422
## 4 ETSSD 0.0139
## 5 Starks.DTFR 0.0351
## 6 UDTFR 0.0427
## 7 UETSDN 0.0427
## 8 theta.of.max.test.D -2.5284
## 9 Test.Dmax -0.7528
pol_know_dif_sex$effect_size_items
## $liberal
## SIDS UIDS SIDN UIDN ESSD theta.of.max.D
## prime_minister 0.000 0.000 0.000 0.000 0.000 -0.771
## governing_party 0.000 0.000 0.000 0.000 0.000 -0.771
## opposition_leader 0.000 0.000 0.000 0.000 0.000 -0.771
## role_chan_exchequer 0.000 0.000 0.000 0.000 0.000 -0.771
## scottish_indep_party 0.000 0.000 0.000 0.000 0.000 -0.771
## upper_house_name 0.000 0.000 0.000 0.000 0.000 -0.771
## UK_nations 0.000 0.000 0.000 0.000 0.000 -0.771
## location_scottish_parliament -0.067 0.111 -0.049 0.106 -0.285 0.269
## next_election_date 0.000 0.000 0.000 0.000 0.000 -0.771
## mayor_london -0.011 0.038 -0.006 0.039 -0.171 -2.647
## ed_davey_role 0.000 0.000 0.000 0.000 0.000 -0.771
## house_lords_veto_removed 0.000 0.000 0.000 0.000 0.000 -0.771
## who_oversees_NHS 0.000 0.000 0.000 0.000 0.000 -0.771
## foreign_secretary_return 0.000 0.000 0.000 0.000 0.000 -0.771
## levelling_up_meaning 0.000 0.000 0.000 0.000 0.000 -0.771
## region_voted_remain 0.000 0.000 0.000 0.000 0.000 -0.771
## rural_england_party 0.000 0.000 0.000 0.000 0.000 -0.771
## role_home_secretary 0.000 0.000 0.000 0.000 0.000 -0.771
## members_of_parliament 0.064 0.070 0.056 0.064 0.359 0.189
## role_speaker_of_house 0.000 0.000 0.000 0.000 0.000 -0.771
## most_envir_party 0.036 0.042 0.036 0.041 0.980 -2.647
## windsor_framework 0.000 0.000 0.000 0.000 0.000 -0.771
## who_can_vote 0.000 0.000 0.000 0.000 0.000 -0.771
## magna_carta 0.000 0.000 0.000 0.000 0.000 -0.771
## region_reunification_debate 0.000 0.000 0.000 0.000 0.000 -0.771
## max.D mean.ES.foc mean.ES.ref
## prime_minister 0.000 0.981 0.981
## governing_party 0.000 0.974 0.974
## opposition_leader 0.000 0.942 0.942
## role_chan_exchequer 0.000 0.965 0.965
## scottish_indep_party 0.000 0.986 0.986
## upper_house_name 0.000 0.867 0.867
## UK_nations 0.000 0.932 0.932
## location_scottish_parliament -0.186 0.743 0.811
## next_election_date 0.000 0.726 0.726
## mayor_london 0.542 0.960 0.971
## ed_davey_role 0.000 0.951 0.951
## house_lords_veto_removed 0.000 0.416 0.416
## who_oversees_NHS 0.000 0.978 0.978
## foreign_secretary_return 0.000 0.781 0.781
## levelling_up_meaning 0.000 0.855 0.855
## region_voted_remain 0.000 0.636 0.636
## rural_england_party 0.000 0.778 0.778
## role_home_secretary 0.000 0.972 0.972
## members_of_parliament 0.105 0.841 0.777
## role_speaker_of_house 0.000 0.971 0.971
## most_envir_party -0.751 0.997 0.961
## windsor_framework 0.000 0.740 0.740
## who_can_vote 0.000 0.254 0.254
## magna_carta 0.000 0.606 0.606
## region_reunification_debate 0.000 0.790 0.790
##
## $conservative
## SIDS UIDS SIDN UIDN ESSD theta.of.max.D
## prime_minister 0.000 0.000 0.000 0.000 0.000 -0.719
## governing_party 0.000 0.000 0.000 0.000 0.000 -0.719
## opposition_leader 0.000 0.000 0.000 0.000 0.000 -0.719
## role_chan_exchequer 0.000 0.000 0.000 0.000 0.000 -0.719
## scottish_indep_party 0.000 0.000 0.000 0.000 0.000 -0.719
## upper_house_name 0.000 0.000 0.000 0.000 0.000 -0.719
## UK_nations 0.000 0.000 0.000 0.000 0.000 -0.719
## location_scottish_parliament 0.000 0.000 0.000 0.000 0.000 -0.719
## next_election_date 0.000 0.000 0.000 0.000 0.000 -0.719
## mayor_london 0.000 0.000 0.000 0.000 0.000 -0.719
## ed_davey_role 0.000 0.000 0.000 0.000 0.000 -0.719
## house_lords_veto_removed 0.000 0.000 0.000 0.000 0.000 -0.719
## who_oversees_NHS 0.000 0.000 0.000 0.000 0.000 -0.719
## foreign_secretary_return 0.000 0.000 0.000 0.000 0.000 -0.719
## levelling_up_meaning 0.000 0.000 0.000 0.000 0.000 -0.719
## region_voted_remain 0.000 0.000 0.000 0.000 0.000 -0.719
## rural_england_party 0.000 0.000 0.000 0.000 0.000 -0.719
## role_home_secretary 0.000 0.000 0.000 0.000 0.000 -0.719
## members_of_parliament 0.000 0.000 0.000 0.000 0.000 -0.719
## role_speaker_of_house 0.000 0.000 0.000 0.000 0.000 -0.719
## most_envir_party 0.036 0.042 0.035 0.043 0.985 -2.528
## windsor_framework 0.000 0.000 0.000 0.000 0.000 -0.719
## who_can_vote 0.000 0.000 0.000 0.000 0.000 -0.719
## magna_carta 0.000 0.000 0.000 0.000 0.000 -0.719
## region_reunification_debate 0.000 0.000 0.000 0.000 0.000 -0.719
## max.D mean.ES.foc mean.ES.ref
## prime_minister 0.000 0.981 0.981
## governing_party 0.000 0.974 0.974
## opposition_leader 0.000 0.943 0.943
## role_chan_exchequer 0.000 0.967 0.967
## scottish_indep_party 0.000 0.986 0.986
## upper_house_name 0.000 0.866 0.866
## UK_nations 0.000 0.932 0.932
## location_scottish_parliament 0.000 0.770 0.770
## next_election_date 0.000 0.725 0.725
## mayor_london 0.000 0.964 0.964
## ed_davey_role 0.000 0.953 0.953
## house_lords_veto_removed 0.000 0.411 0.411
## who_oversees_NHS 0.000 0.978 0.978
## foreign_secretary_return 0.000 0.780 0.780
## levelling_up_meaning 0.000 0.854 0.854
## region_voted_remain 0.000 0.634 0.634
## rural_england_party 0.000 0.777 0.777
## role_home_secretary 0.000 0.973 0.973
## members_of_parliament 0.000 0.809 0.809
## role_speaker_of_house 0.000 0.972 0.972
## most_envir_party -0.753 0.997 0.961
## windsor_framework 0.000 0.738 0.738
## who_can_vote 0.000 0.253 0.253
## magna_carta 0.000 0.603 0.603
## region_reunification_debate 0.000 0.790 0.790
#plot a biased item
plot(
pol_know_dif_sex$fits$anchor_conservative,
tyoe = "trace",
which.items = (pol_know_dif_sex$DIF_stats$p_adj<.05) %>% which()
)
#test function
plot(
pol_know_dif_sex$fits$anchor_conservative,
type = "score"
)
#sex and knowledge
d %>%
GG_group_means(
"pol_knowledge",
groupvar = "sex",
type = "violin"
)
SMD_matrix(
d$pol_knowledge,
d$sex
)
## Female Male
## Female NA -0.353
## Male -0.353 NA
#median split
d$age50 = d$age >= 49
d$age50 %>% table2()
#fit dif
pol_know_dif_age = DIF_test(
d_pol_know_items_scored,
model = 1,
group = d$age50,
itemtype = "2PL",
technical = list(NCYCLES = 50000),
guess = rep(1/5, ncol(d_pol_know_items_scored)),
verbose = F
)
## There are 8 steps
## Step 1: Initial joint fit
##
## Step 2: Initial MI fit
##
## Step 3: Leave one out MI testing
##
## Step 4: Fit without DIF items, liberal threshold
##
## Step 5: Fit without DIF items, conservative threshold
##
## Step 6: Fit with anchor items, liberal threshold
##
## Step 7: Fit with anchor items, conservative threshold
##
## Step 8: Get scores
#summary
pol_know_dif_age$effect_size_test
## $liberal
## Effect Size Value
## 1 STDS -0.0246
## 2 UTDS 0.3723
## 3 UETSDS 0.0624
## 4 ETSSD -0.0122
## 5 Starks.DTFR 0.0132
## 6 UDTFR 0.4307
## 7 UETSDN 0.0756
## 8 theta.of.max.test.D -1.6480
## 9 Test.Dmax 0.2830
##
## $conservative
## Effect Size Value
## 1 STDS -0.1518
## 2 UTDS 0.1974
## 3 UETSDS 0.1578
## 4 ETSSD -0.0768
## 5 Starks.DTFR -0.1005
## 6 UDTFR 0.2163
## 7 UETSDN 0.1425
## 8 theta.of.max.test.D -1.6302
## 9 Test.Dmax 0.4351
pol_know_dif_age$effect_size_items
## $liberal
## SIDS UIDS SIDN UIDN ESSD theta.of.max.D
## prime_minister 0.000 0.000 0.000 0.000 0.000 0.686
## governing_party 0.048 0.048 0.046 0.046 20.226 1.348
## opposition_leader 0.000 0.000 0.000 0.000 0.000 0.686
## role_chan_exchequer 0.026 0.026 0.060 0.060 0.595 -1.648
## scottish_indep_party 0.000 0.000 0.000 0.000 0.000 0.686
## upper_house_name 0.000 0.000 0.000 0.000 0.000 0.686
## UK_nations 0.000 0.000 0.000 0.000 0.000 0.686
## location_scottish_parliament 0.000 0.000 0.000 0.000 0.000 0.686
## next_election_date 0.000 0.000 0.000 0.000 0.000 0.686
## mayor_london 0.000 0.000 0.000 0.000 0.000 0.686
## ed_davey_role 0.000 0.000 0.000 0.000 0.000 0.686
## house_lords_veto_removed 0.000 0.000 0.000 0.000 0.000 0.686
## who_oversees_NHS 0.000 0.000 0.000 0.000 0.000 0.686
## foreign_secretary_return 0.000 0.000 0.000 0.000 0.000 0.686
## levelling_up_meaning 0.055 0.056 0.073 0.075 0.344 -0.607
## region_voted_remain -0.167 0.167 -0.150 0.152 -1.262 -0.354
## rural_england_party 0.000 0.000 0.000 0.000 0.000 0.686
## role_home_secretary 0.000 0.000 0.000 0.000 0.000 0.686
## members_of_parliament 0.000 0.000 0.000 0.000 0.000 0.686
## role_speaker_of_house 0.000 0.000 0.000 0.000 0.000 0.686
## most_envir_party 0.000 0.000 0.000 0.000 0.000 0.686
## windsor_framework 0.000 0.000 0.000 0.000 0.000 0.686
## who_can_vote 0.000 0.000 0.000 0.000 0.000 0.686
## magna_carta 0.000 0.000 0.000 0.000 0.000 0.686
## region_reunification_debate 0.015 0.076 -0.016 0.097 0.115 -1.149
## max.D mean.ES.foc mean.ES.ref
## prime_minister 0.000 0.981 0.981
## governing_party 0.049 0.996 0.949
## opposition_leader 0.000 0.968 0.968
## role_chan_exchequer 0.597 1.000 0.974
## scottish_indep_party 0.000 0.990 0.990
## upper_house_name 0.000 0.887 0.887
## UK_nations 0.000 0.936 0.936
## location_scottish_parliament 0.000 0.799 0.799
## next_election_date 0.000 0.743 0.743
## mayor_london 0.000 0.974 0.974
## ed_davey_role 0.000 0.977 0.977
## house_lords_veto_removed 0.000 0.411 0.411
## who_oversees_NHS 0.000 0.984 0.984
## foreign_secretary_return 0.000 0.804 0.804
## levelling_up_meaning 0.288 0.920 0.865
## region_voted_remain -0.252 0.560 0.727
## rural_england_party 0.000 0.789 0.789
## role_home_secretary 0.000 0.982 0.982
## members_of_parliament 0.000 0.830 0.830
## role_speaker_of_house 0.000 0.980 0.980
## most_envir_party 0.000 0.981 0.981
## windsor_framework 0.000 0.757 0.757
## who_can_vote 0.000 0.250 0.250
## magna_carta 0.000 0.617 0.617
## region_reunification_debate -0.261 0.804 0.789
##
## $conservative
## SIDS UIDS SIDN UIDN ESSD theta.of.max.D
## prime_minister 0.000 0.000 0.000 0.000 0.000 0.720
## governing_party 0.000 0.000 0.000 0.000 0.000 0.720
## opposition_leader 0.000 0.000 0.000 0.000 0.000 0.720
## role_chan_exchequer 0.023 0.023 0.056 0.056 0.541 -1.630
## scottish_indep_party 0.000 0.000 0.000 0.000 0.000 0.720
## upper_house_name 0.000 0.000 0.000 0.000 0.000 0.720
## UK_nations 0.000 0.000 0.000 0.000 0.000 0.720
## location_scottish_parliament 0.000 0.000 0.000 0.000 0.000 0.720
## next_election_date 0.000 0.000 0.000 0.000 0.000 0.720
## mayor_london 0.000 0.000 0.000 0.000 0.000 0.720
## ed_davey_role 0.000 0.000 0.000 0.000 0.000 0.720
## house_lords_veto_removed 0.000 0.000 0.000 0.000 0.000 0.720
## who_oversees_NHS 0.000 0.000 0.000 0.000 0.000 0.720
## foreign_secretary_return 0.000 0.000 0.000 0.000 0.000 0.720
## levelling_up_meaning 0.000 0.000 0.000 0.000 0.000 0.720
## region_voted_remain -0.175 0.175 -0.157 0.160 -1.276 -0.311
## rural_england_party 0.000 0.000 0.000 0.000 0.000 0.720
## role_home_secretary 0.000 0.000 0.000 0.000 0.000 0.720
## members_of_parliament 0.000 0.000 0.000 0.000 0.000 0.720
## role_speaker_of_house 0.000 0.000 0.000 0.000 0.000 0.720
## most_envir_party 0.000 0.000 0.000 0.000 0.000 0.720
## windsor_framework 0.000 0.000 0.000 0.000 0.000 0.720
## who_can_vote 0.000 0.000 0.000 0.000 0.000 0.720
## magna_carta 0.000 0.000 0.000 0.000 0.000 0.720
## region_reunification_debate 0.000 0.000 0.000 0.000 0.000 0.720
## max.D mean.ES.foc mean.ES.ref
## prime_minister 0.000 0.982 0.982
## governing_party 0.000 0.975 0.975
## opposition_leader 0.000 0.969 0.969
## role_chan_exchequer 0.601 1.000 0.977
## scottish_indep_party 0.000 0.991 0.991
## upper_house_name 0.000 0.890 0.890
## UK_nations 0.000 0.937 0.937
## location_scottish_parliament 0.000 0.805 0.805
## next_election_date 0.000 0.747 0.747
## mayor_london 0.000 0.975 0.975
## ed_davey_role 0.000 0.978 0.978
## house_lords_veto_removed 0.000 0.415 0.415
## who_oversees_NHS 0.000 0.984 0.984
## foreign_secretary_return 0.000 0.810 0.810
## levelling_up_meaning 0.000 0.897 0.897
## region_voted_remain -0.273 0.560 0.735
## rural_england_party 0.000 0.792 0.792
## role_home_secretary 0.000 0.982 0.982
## members_of_parliament 0.000 0.834 0.834
## role_speaker_of_house 0.000 0.980 0.980
## most_envir_party 0.000 0.981 0.981
## windsor_framework 0.000 0.762 0.762
## who_can_vote 0.000 0.251 0.251
## magna_carta 0.000 0.622 0.622
## region_reunification_debate 0.000 0.807 0.807
pol_know_dif_age$DIF_stats
#plot a biased item
plot(
pol_know_dif_age$fits$anchor_conservative,
tyoe = "trace",
which.items = (pol_know_dif_age$DIF_stats$p_adj<.05) %>% which()
)
#test function
plot(
pol_know_dif_age$fits$anchor_conservative,
type = "score"
)
#age and knowledge
d %>%
GG_scatter("age", "pol_knowledge") +
geom_smooth()
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
#SMD
SMD_matrix(
d$pol_knowledge,
d$age50
)
## FALSE TRUE
## FALSE NA -0.552
## TRUE -0.552 NA
#median split
d$leftism50 = d$leftism >= 0
d$leftism50 %>% table2()
#fit dif
pol_know_dif_leftism = DIF_test(
d_pol_know_items_scored,
model = 1,
group = d$leftism50,
itemtype = "2PL",
technical = list(NCYCLES = 50000),
guess = rep(1/5, ncol(d_pol_know_items_scored)),
verbose = F
)
## There are 8 steps
## Step 1: Initial joint fit
##
## Step 2: Initial MI fit
##
## Step 3: Leave one out MI testing
##
## Step 4: Fit without DIF items, liberal threshold
##
## Step 5: Fit without DIF items, conservative threshold
##
## Step 6: Fit with anchor items, liberal threshold
##
## Step 7: Fit with anchor items, conservative threshold
##
## Step 8: Get scores
#summary
pol_know_dif_leftism$effect_size_test
## $liberal
## Effect Size Value
## 1 STDS 0.0000
## 2 UTDS 0.0000
## 3 UETSDS 0.0000
## 4 ETSSD 0.0000
## 5 Starks.DTFR 0.0000
## 6 UDTFR 0.0000
## 7 UETSDN 0.0000
## 8 theta.of.max.test.D 0.0148
## 9 Test.Dmax 0.0000
##
## $conservative
## Effect Size Value
## 1 STDS 0.0000
## 2 UTDS 0.0000
## 3 UETSDS 0.0000
## 4 ETSSD 0.0000
## 5 Starks.DTFR 0.0000
## 6 UDTFR 0.0000
## 7 UETSDN 0.0000
## 8 theta.of.max.test.D 0.0148
## 9 Test.Dmax 0.0000
pol_know_dif_leftism$effect_size_items
## $liberal
## SIDS UIDS SIDN UIDN ESSD theta.of.max.D max.D
## prime_minister 0 0 0 0 0 0.015 0
## governing_party 0 0 0 0 0 0.015 0
## opposition_leader 0 0 0 0 0 0.015 0
## role_chan_exchequer 0 0 0 0 0 0.015 0
## scottish_indep_party 0 0 0 0 0 0.015 0
## upper_house_name 0 0 0 0 0 0.015 0
## UK_nations 0 0 0 0 0 0.015 0
## location_scottish_parliament 0 0 0 0 0 0.015 0
## next_election_date 0 0 0 0 0 0.015 0
## mayor_london 0 0 0 0 0 0.015 0
## ed_davey_role 0 0 0 0 0 0.015 0
## house_lords_veto_removed 0 0 0 0 0 0.015 0
## who_oversees_NHS 0 0 0 0 0 0.015 0
## foreign_secretary_return 0 0 0 0 0 0.015 0
## levelling_up_meaning 0 0 0 0 0 0.015 0
## region_voted_remain 0 0 0 0 0 0.015 0
## rural_england_party 0 0 0 0 0 0.015 0
## role_home_secretary 0 0 0 0 0 0.015 0
## members_of_parliament 0 0 0 0 0 0.015 0
## role_speaker_of_house 0 0 0 0 0 0.015 0
## most_envir_party 0 0 0 0 0 0.015 0
## windsor_framework 0 0 0 0 0 0.015 0
## who_can_vote 0 0 0 0 0 0.015 0
## magna_carta 0 0 0 0 0 0.015 0
## region_reunification_debate 0 0 0 0 0 0.015 0
## mean.ES.foc mean.ES.ref
## prime_minister 0.981 0.981
## governing_party 0.973 0.973
## opposition_leader 0.933 0.933
## role_chan_exchequer 0.962 0.962
## scottish_indep_party 0.985 0.985
## upper_house_name 0.857 0.857
## UK_nations 0.929 0.929
## location_scottish_parliament 0.752 0.752
## next_election_date 0.711 0.711
## mayor_london 0.960 0.960
## ed_davey_role 0.942 0.942
## house_lords_veto_removed 0.404 0.404
## who_oversees_NHS 0.978 0.978
## foreign_secretary_return 0.763 0.763
## levelling_up_meaning 0.835 0.835
## region_voted_remain 0.625 0.625
## rural_england_party 0.769 0.769
## role_home_secretary 0.971 0.971
## members_of_parliament 0.794 0.794
## role_speaker_of_house 0.969 0.969
## most_envir_party 0.980 0.980
## windsor_framework 0.724 0.724
## who_can_vote 0.258 0.258
## magna_carta 0.590 0.590
## region_reunification_debate 0.781 0.781
##
## $conservative
## SIDS UIDS SIDN UIDN ESSD theta.of.max.D max.D
## prime_minister 0 0 0 0 0 0.015 0
## governing_party 0 0 0 0 0 0.015 0
## opposition_leader 0 0 0 0 0 0.015 0
## role_chan_exchequer 0 0 0 0 0 0.015 0
## scottish_indep_party 0 0 0 0 0 0.015 0
## upper_house_name 0 0 0 0 0 0.015 0
## UK_nations 0 0 0 0 0 0.015 0
## location_scottish_parliament 0 0 0 0 0 0.015 0
## next_election_date 0 0 0 0 0 0.015 0
## mayor_london 0 0 0 0 0 0.015 0
## ed_davey_role 0 0 0 0 0 0.015 0
## house_lords_veto_removed 0 0 0 0 0 0.015 0
## who_oversees_NHS 0 0 0 0 0 0.015 0
## foreign_secretary_return 0 0 0 0 0 0.015 0
## levelling_up_meaning 0 0 0 0 0 0.015 0
## region_voted_remain 0 0 0 0 0 0.015 0
## rural_england_party 0 0 0 0 0 0.015 0
## role_home_secretary 0 0 0 0 0 0.015 0
## members_of_parliament 0 0 0 0 0 0.015 0
## role_speaker_of_house 0 0 0 0 0 0.015 0
## most_envir_party 0 0 0 0 0 0.015 0
## windsor_framework 0 0 0 0 0 0.015 0
## who_can_vote 0 0 0 0 0 0.015 0
## magna_carta 0 0 0 0 0 0.015 0
## region_reunification_debate 0 0 0 0 0 0.015 0
## mean.ES.foc mean.ES.ref
## prime_minister 0.981 0.981
## governing_party 0.973 0.973
## opposition_leader 0.933 0.933
## role_chan_exchequer 0.962 0.962
## scottish_indep_party 0.985 0.985
## upper_house_name 0.857 0.857
## UK_nations 0.929 0.929
## location_scottish_parliament 0.752 0.752
## next_election_date 0.711 0.711
## mayor_london 0.960 0.960
## ed_davey_role 0.942 0.942
## house_lords_veto_removed 0.404 0.404
## who_oversees_NHS 0.978 0.978
## foreign_secretary_return 0.763 0.763
## levelling_up_meaning 0.835 0.835
## region_voted_remain 0.625 0.625
## rural_england_party 0.769 0.769
## role_home_secretary 0.971 0.971
## members_of_parliament 0.794 0.794
## role_speaker_of_house 0.969 0.969
## most_envir_party 0.980 0.980
## windsor_framework 0.724 0.724
## who_can_vote 0.258 0.258
## magna_carta 0.590 0.590
## region_reunification_debate 0.781 0.781
pol_know_dif_leftism$DIF_stats
#plot biased items (there are none)
# plot(
# pol_know_dif_leftism$fits$anchor_conservative,
# tyoe = "trace",
# which.items = (pol_know_dif_leftism$DIF_stats$p<.05) %>% which()
# )
#test function
plot(
pol_know_dif_leftism$fits$anchor_conservative,
type = "score"
)
#gap size
SMD_matrix(
d$pol_knowledge,
d$leftism50
)
## FALSE TRUE
## FALSE NA -0.246
## TRUE -0.246 NA
#pol know by party without controls
d %>%
mutate(
Who_would_you_vote_for_if_today_was_the_general_election = fct_reorder(Who_would_you_vote_for_if_today_was_the_general_election, pol_knowledge, .fun = mean) %>% fct_rev()
) %>%
GG_group_means(
"pol_knowledge",
groupvar = "party",
min_n = 10) +
labs(
x = 'Party vote in hypothetical election today',
y = "Political knowledge"
)
GG_save("figs/pol_knowledge_by_party.png")
#regression model
ols(pol_knowledge ~ party, data = d)
## Linear Regression Model
##
## ols(formula = pol_knowledge ~ party, data = d)
##
## Model Likelihood Discrimination
## Ratio Test Indexes
## Obs 490 LR chi2 15.38 R2 0.031
## sigma0.9957 d.f. 11 R2 adj 0.009
## d.f. 478 Pr(> chi2) 0.1657 g 0.166
##
## Residuals
##
## Min 1Q Median 3Q Max
## -3.44623 -0.58264 0.03459 0.69289 2.18237
##
##
## Coef S.E. t Pr(>|t|)
## Intercept -0.1309 0.1285 -1.02 0.3089
## party=Democratic Unionist Party (DUP) 0.0075 0.7157 0.01 0.9916
## party=Green party 0.0617 0.1842 0.33 0.7378
## party=Labour 0.1696 0.1493 1.14 0.2565
## party=Liberal Democrats 0.4604 0.1810 2.54 0.0113
## party=Not vote -0.0911 0.2338 -0.39 0.6971
## party=Other party 0.3563 1.0040 0.35 0.7229
## party=Plaid Cymru -0.0148 0.5142 -0.03 0.9770
## party=Reform UK 0.1121 0.1642 0.68 0.4952
## party=Scottish National Party -0.2984 0.3401 -0.88 0.3807
## party=Sinn Féin -1.6223 1.0040 -1.62 0.1068
## party=Social Democratic and Labour Party (SDLP) -0.5973 1.0040 -0.59 0.5521
#leftism by party
d %>%
mutate(
Who_would_you_vote_for_if_today_was_the_general_election = fct_reorder(Who_would_you_vote_for_if_today_was_the_general_election, leftism, .fun = mean) %>% fct_rev()
) %>%
GG_group_means(
"leftism",
groupvar = "party",
min_n = 10) +
labs(
x = 'Party vote in hypothetical election today',
y = "Leftism"
)
GG_save("figs/leftism_by_party.png")
ols(leftism ~ party, data = d)
## Linear Regression Model
##
## ols(formula = leftism ~ party, data = d)
##
## Model Likelihood Discrimination
## Ratio Test Indexes
## Obs 490 LR chi2 312.47 R2 0.471
## sigma0.7353 d.f. 11 R2 adj 0.459
## d.f. 478 Pr(> chi2) 0.0000 g 0.735
##
## Residuals
##
## Min 1Q Median 3Q Max
## -2.883e+00 -4.575e-01 -7.841e-16 4.654e-01 2.376e+00
##
##
## Coef S.E. t Pr(>|t|)
## Intercept -0.6793 0.0949 -7.16 <0.0001
## party=Democratic Unionist Party (DUP) 0.6248 0.5285 1.18 0.2377
## party=Green party 1.6115 0.1360 11.85 <0.0001
## party=Labour 1.0232 0.1102 9.28 <0.0001
## party=Liberal Democrats 1.0399 0.1337 7.78 <0.0001
## party=Not vote 0.6128 0.1726 3.55 0.0004
## party=Other party 0.1409 0.7414 0.19 0.8494
## party=Plaid Cymru 1.6087 0.3797 4.24 <0.0001
## party=Reform UK -0.4130 0.1213 -3.41 0.0007
## party=Scottish National Party 1.3403 0.2512 5.34 <0.0001
## party=Sinn Féin 1.1532 0.7414 1.56 0.1205
## party=Social Democratic and Labour Party (SDLP) 2.4832 0.7414 3.35 0.0009
lm(leftism ~ party, data = d) %>% broom::glance() %>% .[["adj.r.squared"]] %>% sqrt()
## [1] 0.678
#party level analysis
d_parties = d %>%
group_by(party) %>%
summarise(
leftism = mean(leftism),
polknow = mean(pol_knowledge),
diagnoses = mean(diagnoses_count),
n = n()
)
d_parties %>%
filter(n >= 10) %>%
GG_scatter("polknow", "leftism", case_names = "party")
## `geom_smooth()` using formula = 'y ~ x'
d_parties %>%
filter(n >= 10) %>%
GG_scatter("leftism", "diagnoses", case_names = "party")
## `geom_smooth()` using formula = 'y ~ x'
#leftism ~ pol_knowledge
d %>%
GG_scatter(
"pol_knowledge",
"leftism"
)
## `geom_smooth()` using formula = 'y ~ x'
#leftism ~ diagnoses
d %>%
GG_group_means(
"leftism",
"diagnoses_count"
)
#correlations
d %>% select(
leftism,
pol_knowledge,
age,
male,
tattoos_count,
piercings_count,
nonear_piercings_count,
unnatural_hair,
diagnoses_count
) %>%
GG_heatmap(cross_out_nonsig = T)
GG_save("figs/cors_main.png")
#ethnics
d %>%
GG_group_means(
"leftism",
groupvar = "ethnic3",
)
#regressions
leftism_models = list(
ols(leftism ~ pol_knowledge + diagnoses_count_std + age_z + sex + ethnic3, data = d),
ols(leftism ~ rcs(pol_knowledge) + diagnoses_count_std + age_z + sex + ethnic3, data = d),
ols(leftism ~ pol_knowledge * age_z + diagnoses_count_std + sex + ethnic3, data = d),
ols(leftism ~ pol_knowledge * sex + diagnoses_count_std + age_z + sex + ethnic3, data = d)
)
## number of knots in rcs defaulting to 5
lrtest(
leftism_models[[1]],
leftism_models[[2]]
)
##
## Model 1: leftism ~ pol_knowledge + diagnoses_count_std + age_z + sex +
## ethnic3
## Model 2: leftism ~ rcs(pol_knowledge) + diagnoses_count_std + age_z +
## sex + ethnic3
##
## L.R. Chisq d.f. P
## 0.839 3.000 0.840
leftism_models %>%
summarize_models(add_ref_level = F, asterisks_only = F) %>%
flextable::flextable()
Predictor/Model | 1 | 2 | 3 | 4 |
|---|---|---|---|---|
Intercept | 0.17 (0.063, 0.007*) | 0.34 (0.275, 0.224) | 0.15 (0.064, 0.02) | 0.17 (0.063, 0.008*) |
pol_knowledge | 0.19 (0.046, <0.001***) | (nonlinear) | 0.21 (0.049, <0.001***) | 0.19 (0.060, 0.002**) |
diagnoses_count_std | 0.11 (0.043, 0.008*) | 0.12 (0.043, 0.008*) | 0.12 (0.043, 0.006*) | 0.12 (0.043, 0.008*) |
age_z | -0.33 (0.048, <0.001***) | -0.33 (0.049, <0.001***) | -0.33 (0.048, <0.001***) | -0.33 (0.048, <0.001***) |
sex = Male | -0.23 (0.087, 0.008*) | -0.23 (0.087, 0.008*) | -0.24 (0.087, 0.007*) | -0.23 (0.087, 0.008*) |
ethnic3 = Other | -0.09 (0.158, 0.584) | -0.08 (0.158, 0.594) | -0.10 (0.157, 0.534) | -0.09 (0.158, 0.586) |
ethnic3 = Black | -0.79 (0.186, <0.001***) | -0.78 (0.187, <0.001***) | -0.78 (0.186, <0.001***) | -0.79 (0.186, <0.001***) |
pol_knowledge * age_z | 0.07 (0.044, 0.108) | |||
pol_knowledge * sex = Male | 0.01 (0.087, 0.918) | |||
R2 adj. | 0.116 | 0.112 | 0.119 | 0.115 |
N | 490 | 490 | 490 | 490 |
#plot nonlinear effect
leftism_models[[4]] %>%
ggpredict(terms = c("pol_knowledge")) %>%
plot()
#plot nonlinear effect
leftism_models[[2]] %>%
ggpredict(terms = c("pol_knowledge")) %>%
plot() +
theme_bw() +
labs(
title = NULL,
x = "Political knowledge (z)",
y = "Leftism (z)"
)
## number of knots in rcs defaulting to 5
## number of knots in rcs defaulting to 5
## number of knots in rcs defaulting to 5
#ethnics
d %>%
GG_group_means(
"pol_knowledge",
groupvar = "ethnic3",
)
#regressions
polknow_models = list(
ols(pol_knowledge ~ leftism + diagnoses_count_std + age_z + sex + ethnic3, data = d),
ols(pol_knowledge ~ rcs(leftism) + diagnoses_count_std + age_z + sex + ethnic3, data = d),
ols(pol_knowledge ~ leftism * age_z + diagnoses_count_std + sex + ethnic3, data = d),
ols(pol_knowledge ~ leftism * sex + diagnoses_count_std + age_z + sex + ethnic3, data = d)
)
## number of knots in rcs defaulting to 5
polknow_models %>%
summarize_models(add_ref_level = F, asterisks_only = F) %>%
flextable::flextable()
Predictor/Model | 1 | 2 | 3 | 4 |
|---|---|---|---|---|
Intercept | -0.20 (0.060, <0.001***) | -0.78 (0.225, <0.001***) | -0.19 (0.062, 0.002**) | -0.20 (0.061, <0.001***) |
leftism | 0.18 (0.043, <0.001***) | (nonlinear) | 0.18 (0.043, <0.001***) | 0.19 (0.061, 0.002**) |
diagnoses_count_std | -0.09 (0.042, 0.036) | -0.08 (0.041, 0.045) | -0.09 (0.042, 0.036) | -0.09 (0.042, 0.037) |
age_z | 0.38 (0.045, <0.001***) | 0.38 (0.045, <0.001***) | 0.37 (0.045, <0.001***) | 0.38 (0.045, <0.001***) |
sex = Male | 0.39 (0.082, <0.001***) | 0.37 (0.082, <0.001***) | 0.39 (0.083, <0.001***) | 0.39 (0.083, <0.001***) |
ethnic3 = Other | -0.28 (0.151, 0.061) | -0.25 (0.151, 0.094) | -0.29 (0.152, 0.057) | -0.29 (0.151, 0.06) |
ethnic3 = Black | 0.54 (0.181, 0.003**) | 0.64 (0.183, <0.001***) | 0.51 (0.184, 0.006*) | 0.54 (0.181, 0.003**) |
leftism * age_z | 0.03 (0.043, 0.441) | |||
leftism * sex = Male | -0.03 (0.082, 0.755) | |||
R2 adj. | 0.179 | 0.192 | 0.179 | 0.178 |
N | 490 | 490 | 490 | 490 |
#investigate nonlinear effect
lrtest(
polknow_models[[1]],
polknow_models[[2]]
)
##
## Model 1: pol_knowledge ~ leftism + diagnoses_count_std + age_z + sex +
## ethnic3
## Model 2: pol_knowledge ~ rcs(leftism) + diagnoses_count_std + age_z +
## sex + ethnic3
##
## L.R. Chisq d.f. P
## 10.8846 3.0000 0.0124
#plot nonlinear effect
polknow_models[[2]] %>%
ggpredict(terms = c("leftism")) %>%
plot() +
theme_bw() +
labs(
title = NULL,
y = "Political knowledge (z)",
x = "Leftism (z)"
)
## number of knots in rcs defaulting to 5
## number of knots in rcs defaulting to 5
## number of knots in rcs defaulting to 5
GG_save("figs/pol_know_leftism.png")
#we need special models for count variables
#percings ~ diagnoses
piercing_diagnoses_models = fit_count_models(
y = "piercings_count",
xs = "diagnoses_count"
)
nonear_piercing_diagnoses_models = fit_count_models(
y = "nonear_piercings_count",
xs = "diagnoses_count"
)
#tattoos ~ diagnoses
tattoos_diagnoses_models = fit_count_models(
y = "tattoos_count",
xs = "diagnoses_count"
)
#unnatural hair models
unnat_hair_diagnoses_models = fit_logistic_models(
y = "unnatural_hair",
xs = "diagnoses_count"
)
unnat_hair_diagnoses_models$coefs
#plot all together
bind_rows(
piercing_diagnoses_models$coefs %>% mutate(y = "piercings"),
nonear_piercing_diagnoses_models$coefs %>% mutate(y = "nonear piercings"),
tattoos_diagnoses_models$coefs %>% mutate(y = "tattoos"),
unnat_hair_diagnoses_models$coefs %>% mutate(y = "unnatural hair")
) %>%
filter(
term == "diagnoses_count"
) %>%
mutate(
nlog10_p = -log10(p.value),
controls = str_detect(model, "2"),
model_type = str_remove(model, "\\d+"),
submodel = mapvalues(submodel, from = NA, to = "count")
) %>%
ggplot(aes(controls, nlog10_p, color = model_type, shape = submodel)) +
geom_point(position = position_dodge(width = 0.1)) +
geom_hline(yintercept = 1.96, linetype = 2, alpha = 0.2) +
facet_wrap("y")
#combined body mod model
body_mod_fit = mirt(
d %>% select(tattoos_count, nonear_piercings_count, unnatural_hair),
model = 1,
itemtype = c("graded", "graded", "2PL"),
verbose = F
)
## "tattoos_count" re-mapped to ensure all categories have a distance of 1
body_mod_fit %>% summary()
## F1 h2
## tattoos_count 0.751 0.565
## nonear_piercings_count 0.782 0.612
## unnatural_hair 0.729 0.531
##
## SS loadings: 1.71
## Proportion Var: 0.569
##
## Factor correlations:
##
## F1
## F1 1
#scores
body_mod_score = fscores(body_mod_fit)
d$body_mod_score = body_mod_score[, 1] %>% standardize()
#compile body mod vars
d_body_mods = bind_cols(
d_tattoos %>% df_add_affix(prefix = "tat_"),
d_piercings %>% df_add_affix(prefix = "pier_"),
d["unnatural_hair"]
) %>%
map_df(as.numeric) %>%
#remove zero variance vars
select(where(~var(.) > 0)) %>%
{
colnames(.) = colnames(.) %>% str_to_lower()
.
}
#uni-dimensionality
psych::unidim(d_body_mods)
##
## A measure of unidimensionality
## Call: psych::unidim(keys = d_body_mods)
##
## Unidimensionality index =
## u tau rho_c alpha av.r median.r CFI ECV
## 0.27 0.41 0.67 0.67 0.10 0.07 0.48 0.55
## F1/F2 MAP
## 1.86 0.01
##
## unidim adjusted index reverses negatively scored items.
## alpha Based upon reverse scoring some items.
## average and median correlations are based upon reversed scored items
#correlations
d_body_mods_cors = d_body_mods %>%
as.data.frame() %>%
polycor::hetcor()
#compute p values from cors and standard errors
d_body_mods_cors$p = (d_body_mods_cors$correlations / d_body_mods_cors$std.errors) %>%
{
2 * (1 - pnorm(abs(.)))
}
#plot correlations
GG_heatmap(
d_body_mods_cors$correlations,
pairwise_n = matrix(d_body_mods_cors$n, ncol = ncol(d_body_mods_cors$correlations), nrow = ncol(d_body_mods_cors$correlations)),
pairwise_p = d_body_mods_cors$p,
reorder_vars = F,
cross_out_nonsig = T
)
#from items directly
body_mod_all_fit = mirt(
d_body_mods,
model = 1,
itemtype = "2PL"
)
## Iteration: 1, Log-Lik: -1501.700, Max-Change: 2.55982Iteration: 2, Log-Lik: -1448.645, Max-Change: 0.61107Iteration: 3, Log-Lik: -1438.104, Max-Change: 0.47202Iteration: 4, Log-Lik: -1434.286, Max-Change: 0.42885Iteration: 5, Log-Lik: -1432.702, Max-Change: 0.38738Iteration: 6, Log-Lik: -1431.931, Max-Change: 1.36128Iteration: 7, Log-Lik: -1431.244, Max-Change: 0.47066Iteration: 8, Log-Lik: -1431.067, Max-Change: 0.61818Iteration: 9, Log-Lik: -1430.964, Max-Change: 0.29670Iteration: 10, Log-Lik: -1430.907, Max-Change: 0.30278Iteration: 11, Log-Lik: -1430.867, Max-Change: 0.04016Iteration: 12, Log-Lik: -1430.844, Max-Change: 0.22305Iteration: 13, Log-Lik: -1430.822, Max-Change: 0.01572Iteration: 14, Log-Lik: -1430.813, Max-Change: 0.01110Iteration: 15, Log-Lik: -1430.807, Max-Change: 0.01058Iteration: 16, Log-Lik: -1430.797, Max-Change: 0.00641Iteration: 17, Log-Lik: -1430.795, Max-Change: 0.00423Iteration: 18, Log-Lik: -1430.795, Max-Change: 0.00342Iteration: 19, Log-Lik: -1430.794, Max-Change: 0.00091Iteration: 20, Log-Lik: -1430.793, Max-Change: 0.00079Iteration: 21, Log-Lik: -1430.793, Max-Change: 0.00089Iteration: 22, Log-Lik: -1430.793, Max-Change: 0.00023Iteration: 23, Log-Lik: -1430.793, Max-Change: 0.00059Iteration: 24, Log-Lik: -1430.793, Max-Change: 0.00016Iteration: 25, Log-Lik: -1430.793, Max-Change: 0.00067Iteration: 26, Log-Lik: -1430.793, Max-Change: 0.00030Iteration: 27, Log-Lik: -1430.793, Max-Change: 0.00056Iteration: 28, Log-Lik: -1430.793, Max-Change: 0.00037Iteration: 29, Log-Lik: -1430.793, Max-Change: 0.00013Iteration: 30, Log-Lik: -1430.793, Max-Change: 0.00038Iteration: 31, Log-Lik: -1430.793, Max-Change: 0.00016Iteration: 32, Log-Lik: -1430.793, Max-Change: 0.00032Iteration: 33, Log-Lik: -1430.793, Max-Change: 0.00012Iteration: 34, Log-Lik: -1430.793, Max-Change: 0.00010Iteration: 35, Log-Lik: -1430.793, Max-Change: 0.00028Iteration: 36, Log-Lik: -1430.793, Max-Change: 0.00041Iteration: 37, Log-Lik: -1430.793, Max-Change: 0.00015Iteration: 38, Log-Lik: -1430.793, Max-Change: 0.00026Iteration: 39, Log-Lik: -1430.793, Max-Change: 0.00012Iteration: 40, Log-Lik: -1430.793, Max-Change: 0.00010
body_mod_all_fit %>% summary()
## F1 h2
## tat_hand 0.758 0.5740
## tat_arm 0.725 0.5249
## tat_chest_or_stomach 0.809 0.6550
## tat_back 0.818 0.6687
## tat_neck 0.753 0.5671
## tat_leg 0.835 0.6969
## tat_feet 0.712 0.5076
## tat_other 0.384 0.1478
## pier_ears 0.623 0.3884
## pier_eyebrow 0.786 0.6171
## pier_nose_septum_not_included 0.755 0.5704
## pier_septum 0.951 0.9048
## pier_mouth_area_outside_the_mouth 0.729 0.5319
## pier_mouth_area_inside_the_mouth 0.832 0.6922
## pier_nipple 0.650 0.4223
## pier_navel 0.593 0.3517
## pier_genital 0.852 0.7256
## pier_other 0.209 0.0438
## unnatural_hair 0.699 0.4890
##
## SS loadings: 10.1
## Proportion Var: 0.53
##
## Factor correlations:
##
## F1
## F1 1
body_mod_all_fit_stats = body_mod_all_fit %>% get_mirt_stats()
body_mod_all_fit_stats$loading %>% describe2()
#by type
body_mod_all_fit_stats %>%
mutate(
type = case_when(
str_detect(item, "tat") ~ "tattoos",
str_detect(item, "pier") ~ "piercing",
item == "unnatural_hair" ~ "hair",
TRUE ~ NA_character_
)) %$%
describe2(loading, group = type)
## New names:
## • `` -> `...1`
#scores & reliability
body_mod_all_scores = fscores(body_mod_all_fit, full.scores.SE = T, full.scores = T)
empirical_rxx(body_mod_all_scores)
## F1
## 0.583
d$body_mod_all_score = body_mod_all_scores[, 1] %>% standardize()
d$body_mod_all_score %>%
GG_denhist()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
d %>%
ggplot(aes(body_mod_all_score)) +
geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#models
body_mod_models = list(
lm(body_mod_all_score ~ diagnoses_count_std, data = d),
lm(body_mod_all_score ~ leftism, data = d),
lm(body_mod_all_score ~ pol_knowledge, data = d),
lm(body_mod_all_score ~ diagnoses_count_std + age_z + sex + ethnic3, data = d),
lm(body_mod_all_score ~ leftism + age_z + sex + ethnic3, data = d),
lm(body_mod_all_score ~ pol_knowledge + age_z + sex + ethnic3, data = d),
lm(body_mod_all_score ~ diagnoses_count_std + leftism + pol_knowledge + age_z + sex + ethnic3, data = d)
)
body_mod_models %>% summarize_models(asterisks_only = F)
#hierarchical approach
body_mod2_models = list(
lm(body_mod_score ~ diagnoses_count_std, data = d),
lm(body_mod_score ~ leftism, data = d),
lm(body_mod_score ~ pol_knowledge, data = d),
lm(body_mod_score ~ diagnoses_count_std + age_z + sex + ethnic3, data = d),
lm(body_mod_score ~ leftism + age_z + sex + ethnic3, data = d),
lm(body_mod_score ~ pol_knowledge + age_z + sex + ethnic3, data = d),
lm(body_mod_score ~ diagnoses_count_std + leftism + pol_knowledge + age_z + sex + ethnic3, data = d)
)
body_mod2_models %>% summarize_models(asterisks_only = F)
#number of body modifications
d$body_mods_count = d_body_mods %>%
rowSums()
#distribution
d %>%
ggplot(aes(body_mods_count)) +
geom_bar(aes(y = after_stat(prop))) +
scale_x_continuous(breaks = 0:20) +
scale_y_continuous(labels = scales::percent) +
labs(
x = "Number of body modifications",
y = "Count"
)
GG_save("figs/body_mods_count.png")
#with poisson
glm(body_mods_count ~ diagnoses_count_std + leftism + pol_knowledge + age_z + sex + ethnic3, data = d, family = "poisson") %>% summary()
##
## Call:
## glm(formula = body_mods_count ~ diagnoses_count_std + leftism +
## pol_knowledge + age_z + sex + ethnic3, family = "poisson",
## data = d)
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 0.6182 0.0515 12.00 < 2e-16 ***
## diagnoses_count_std 0.1281 0.0328 3.91 9.3e-05 ***
## leftism 0.0321 0.0442 0.73 0.46820
## pol_knowledge -0.1908 0.0440 -4.34 1.4e-05 ***
## age_z -0.1654 0.0495 -3.34 0.00084 ***
## sexMale -1.3542 0.1078 -12.57 < 2e-16 ***
## ethnic3Other -0.2842 0.1607 -1.77 0.07704 .
## ethnic3Black -0.6395 0.2214 -2.89 0.00388 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for poisson family taken to be 1)
##
## Null deviance: 966.85 on 489 degrees of freedom
## Residual deviance: 644.30 on 482 degrees of freedom
## AIC: 1344
##
## Number of Fisher Scoring iterations: 6
#individual body mods as predictors
body_mod_form1 = str_glue("diagnoses_count_std ~ {str_c(names(d_body_mods), collapse = ' + ')}") %>% as.formula()
body_mod_form2 = str_glue("diagnoses_count_std ~ {str_c(names(d_body_mods), collapse = ' + ')} + age_z + sex + ethnic3") %>% as.formula()
body_mod_form1b = body_mod_form1 %>% update(diagnoses_count ~ .)
body_mod_form2b = body_mod_form2 %>% update(diagnoses_count ~ .)
#fit models
d_body_mods2 = bind_cols(
d_body_mods,
d %>% select(age, age_z, sex, ethnic3, diagnoses_count, diagnoses_count_std)
)
body_mod_all_models = list(
lm(body_mod_form1, data = d_body_mods2),
lm(body_mod_form2, data = d_body_mods2),
glm(body_mod_form1b, data = d_body_mods2, family = "poisson"),
glm(body_mod_form2b, data = d_body_mods2, family = "poisson")
)
bind_rows(
body_mod_all_models[[1]] %>% tidy() %>% mutate(controls = F, model = "lm"),
body_mod_all_models[[2]] %>% tidy() %>% mutate(controls = T, model = "lm"),
body_mod_all_models[[3]] %>% tidy() %>% mutate(controls = F, model = "poisson"),
body_mod_all_models[[4]] %>% tidy() %>% mutate(controls = T, model = "poisson")
) %>%
filter(
term != "(Intercept)"
) %>%
mutate(
estimate_upper = estimate + 1.96 * std.error,
estimate_lower = estimate - 1.96 * std.error
) %>%
ggplot(aes(estimate, term, color = controls)) +
geom_point(position = position_dodge(width = 0.1)) +
geom_errorbarh(aes(xmin = estimate_lower, xmax = estimate_upper), position = position_dodge(width = 0.1)) +
# scale_x_continuous(limits = c(-5, 5)) +
coord_cartesian(xlim = c(-5, 5)) +
facet_wrap("model")
#all items
d_items = bind_cols(
d_pol_know_items_scored,
d_ideo_items_num,
d_diags
)
#clustering
hclust_fit = hclust(
dist(d_items)
)
hclust_fit
##
## Call:
## hclust(d = dist(d_items))
##
## Cluster method : complete
## Distance : euclidean
## Number of objects: 490
hclust_fit %>% plot()
#pca
#items with variance
d_items_nzv = d_items %>%
select(where(~var(.) > 0))
#how many factors
psych::fa.parallel(d_items_nzv)
## Parallel analysis suggests that the number of factors = 10 and the number of components = 8
fa_fit = fa(d_items_nzv, nfactors = 11, rotate = "oblimin")
fa_fit
## Factor Analysis using method = minres
## Call: fa(r = d_items_nzv, nfactors = 11, rotate = "oblimin")
## Standardized loadings (pattern matrix) based upon correlation matrix
## MR1
## prime_minister 0.11
## governing_party 0.02
## opposition_leader -0.01
## role_chan_exchequer -0.02
## scottish_indep_party -0.09
## upper_house_name -0.05
## UK_nations -0.02
## location_scottish_parliament 0.06
## next_election_date 0.02
## mayor_london -0.05
## ed_davey_role -0.03
## house_lords_veto_removed -0.01
## who_oversees_NHS 0.05
## foreign_secretary_return 0.03
## levelling_up_meaning -0.01
## region_voted_remain 0.02
## rural_england_party 0.00
## role_home_secretary 0.02
## members_of_parliament -0.07
## role_speaker_of_house 0.12
## most_envir_party 0.06
## windsor_framework -0.03
## who_can_vote 0.04
## magna_carta -0.03
## region_reunification_debate 0.11
## The_UK_should_continue_to_provide_military_and_financial_support_to_Ukraine_in_its_war_with_Russia 0.23
## Immigration_levels_in_the_UK_are_too_high_and_should_be_significantly_reduced 0.00
## The_NHS_should_remain_entirely_publicly_funded_and_free_at_the_point_of_use -0.03
## Wealthier_individuals_should_pay_significantly_higher_taxes_to_support_public_services -0.04
## The_UK_should_phase_out_fossil_fuels_entirely_by_2035_even_if_it_increases_energy_costs_in_the_short_term 0.10
## The_UK_should_invest_in_building_new_nuclear_power_plants_to_meet_future_energy_demands 0.01
## The_monarchy_is_an_outdated_institution_and_should_be_abolished 0.02
## Government_benefits_are_too_generous_and_discourage_people_from_working -0.02
## The_UK_should_rejoin_the_European_Union 0.14
## The_UK_should_recognize_a_Palestinian_state_and_reduce_military_cooperation_with_Israel 0.11
## Compared_to_other_civilizations_Western_civilization_is_uniquely_evil -0.13
## Strikes_by_public_sector_workers_are_justified_in_the_current_economic_climate 0.02
## Transgender_women_should_be_allowed_to_compete_in_women_s_sports_categories 0.19
## Local_councils_should_be_allowed_to_introduce_rent_controls_to_reduce_housing_costs -0.07
## The_UK_government_should_introduce_stricter_laws_to_prevent_online_hate_speech_even_at_the_expense_of_free_expression 0.01
## Climate_change_is_an_urgent_threat_that_requires_immediate_and_far_reaching_government_action 0.09
## Private_companies_should_be_allowed_to_run_parts_of_the_NHS_if_it_improves_efficiency -0.13
## The_UK_should_adopt_proportional_representation_for_general_elections -0.06
## Parents_should_be_allowed_to_send_their_children_to_grammar_or_private_schools_if_they_can_afford_it 0.00
## The_UK_should_deport_asylum_seekers_to_third_countries_like_Rwanda_if_they_arrive_through_irregular_routes -0.07
## National_service_military_or_civic_should_be_mandatory_for_young_adults_in_the_UK -0.16
## I_support_the_LGBT_community 0.84
## I_support_gay_marriage 0.90
## There_is_nothing_wrong_with_public_depictions_of_homosexual_relationships 0.72
## Everyone_should_be_addressed_by_their_desired_pronouns 0.44
## There_are_only_two_genders -0.39
## I_support_feminism 0.48
## Abortion_should_be_available_to_women_for_use_for_any_reason 0.41
## Children_should_be_taught_about_gay_sex_in_sex_education_classes 0.69
## There_is_nothing_wrong_with_attending_a_gay_orgy 0.67
## Men_should_be_masculine_and_women_should_be_feminine -0.61
## Immigration_policy_should_be_strict_and_heavily_meritorious 0.02
## Progressive_taxation_where_the_rich_are_taxed_at_a_higher_rate_is_the_best_way_to_structure_a_tax_system 0.09
## The_government_should_help_ensure_sexual_equality_by_making_sure_women_are_not_discriminated_against_in_private_hiring 0.35
## Public_policy_changes_do_not_need_to_be_made_to_deal_with_climate_change -0.15
## ADHD 0.12
## Alcoholism -0.01
## Drug_abuse 0.02
## Autism 0.10
## Bipolar 0.04
## BPD -0.07
## Depression 0.10
## Anxiety 0.09
## OCD 0.06
## Panic 0.05
## Social_phobia 0.14
## Specific_phobia 0.01
## PTSD 0.00
## Schioid -0.26
## Sleep_disorders -0.15
## MR5
## prime_minister 0.09
## governing_party -0.03
## opposition_leader 0.09
## role_chan_exchequer 0.05
## scottish_indep_party -0.10
## upper_house_name -0.05
## UK_nations -0.08
## location_scottish_parliament -0.01
## next_election_date 0.04
## mayor_london -0.05
## ed_davey_role -0.08
## house_lords_veto_removed 0.02
## who_oversees_NHS -0.04
## foreign_secretary_return -0.07
## levelling_up_meaning 0.05
## region_voted_remain -0.14
## rural_england_party -0.14
## role_home_secretary -0.14
## members_of_parliament -0.12
## role_speaker_of_house 0.05
## most_envir_party -0.09
## windsor_framework 0.02
## who_can_vote 0.00
## magna_carta -0.01
## region_reunification_debate 0.00
## The_UK_should_continue_to_provide_military_and_financial_support_to_Ukraine_in_its_war_with_Russia -0.04
## Immigration_levels_in_the_UK_are_too_high_and_should_be_significantly_reduced 0.78
## The_NHS_should_remain_entirely_publicly_funded_and_free_at_the_point_of_use 0.01
## Wealthier_individuals_should_pay_significantly_higher_taxes_to_support_public_services -0.05
## The_UK_should_phase_out_fossil_fuels_entirely_by_2035_even_if_it_increases_energy_costs_in_the_short_term -0.13
## The_UK_should_invest_in_building_new_nuclear_power_plants_to_meet_future_energy_demands 0.27
## The_monarchy_is_an_outdated_institution_and_should_be_abolished -0.24
## Government_benefits_are_too_generous_and_discourage_people_from_working 0.38
## The_UK_should_rejoin_the_European_Union -0.32
## The_UK_should_recognize_a_Palestinian_state_and_reduce_military_cooperation_with_Israel -0.30
## Compared_to_other_civilizations_Western_civilization_is_uniquely_evil -0.07
## Strikes_by_public_sector_workers_are_justified_in_the_current_economic_climate -0.18
## Transgender_women_should_be_allowed_to_compete_in_women_s_sports_categories -0.22
## Local_councils_should_be_allowed_to_introduce_rent_controls_to_reduce_housing_costs 0.04
## The_UK_government_should_introduce_stricter_laws_to_prevent_online_hate_speech_even_at_the_expense_of_free_expression 0.00
## Climate_change_is_an_urgent_threat_that_requires_immediate_and_far_reaching_government_action -0.05
## Private_companies_should_be_allowed_to_run_parts_of_the_NHS_if_it_improves_efficiency 0.20
## The_UK_should_adopt_proportional_representation_for_general_elections 0.08
## Parents_should_be_allowed_to_send_their_children_to_grammar_or_private_schools_if_they_can_afford_it 0.40
## The_UK_should_deport_asylum_seekers_to_third_countries_like_Rwanda_if_they_arrive_through_irregular_routes 0.75
## National_service_military_or_civic_should_be_mandatory_for_young_adults_in_the_UK 0.54
## I_support_the_LGBT_community 0.02
## I_support_gay_marriage 0.03
## There_is_nothing_wrong_with_public_depictions_of_homosexual_relationships -0.05
## Everyone_should_be_addressed_by_their_desired_pronouns -0.07
## There_are_only_two_genders 0.28
## I_support_feminism -0.14
## Abortion_should_be_available_to_women_for_use_for_any_reason 0.01
## Children_should_be_taught_about_gay_sex_in_sex_education_classes -0.02
## There_is_nothing_wrong_with_attending_a_gay_orgy -0.07
## Men_should_be_masculine_and_women_should_be_feminine 0.19
## Immigration_policy_should_be_strict_and_heavily_meritorious 0.80
## Progressive_taxation_where_the_rich_are_taxed_at_a_higher_rate_is_the_best_way_to_structure_a_tax_system 0.04
## The_government_should_help_ensure_sexual_equality_by_making_sure_women_are_not_discriminated_against_in_private_hiring 0.04
## Public_policy_changes_do_not_need_to_be_made_to_deal_with_climate_change 0.23
## ADHD -0.01
## Alcoholism -0.10
## Drug_abuse 0.06
## Autism 0.05
## Bipolar -0.01
## BPD -0.02
## Depression 0.11
## Anxiety 0.04
## OCD -0.13
## Panic 0.05
## Social_phobia 0.01
## Specific_phobia 0.02
## PTSD 0.04
## Schioid -0.05
## Sleep_disorders -0.03
## MR2
## prime_minister 0.07
## governing_party 0.02
## opposition_leader 0.63
## role_chan_exchequer 0.48
## scottish_indep_party 0.17
## upper_house_name 0.40
## UK_nations 0.14
## location_scottish_parliament 0.46
## next_election_date 0.38
## mayor_london 0.41
## ed_davey_role 0.58
## house_lords_veto_removed 0.34
## who_oversees_NHS 0.16
## foreign_secretary_return 0.51
## levelling_up_meaning 0.58
## region_voted_remain 0.21
## rural_england_party 0.31
## role_home_secretary 0.26
## members_of_parliament 0.42
## role_speaker_of_house 0.27
## most_envir_party -0.03
## windsor_framework 0.33
## who_can_vote 0.19
## magna_carta 0.45
## region_reunification_debate 0.21
## The_UK_should_continue_to_provide_military_and_financial_support_to_Ukraine_in_its_war_with_Russia 0.07
## Immigration_levels_in_the_UK_are_too_high_and_should_be_significantly_reduced -0.01
## The_NHS_should_remain_entirely_publicly_funded_and_free_at_the_point_of_use 0.04
## Wealthier_individuals_should_pay_significantly_higher_taxes_to_support_public_services 0.03
## The_UK_should_phase_out_fossil_fuels_entirely_by_2035_even_if_it_increases_energy_costs_in_the_short_term -0.02
## The_UK_should_invest_in_building_new_nuclear_power_plants_to_meet_future_energy_demands 0.15
## The_monarchy_is_an_outdated_institution_and_should_be_abolished -0.09
## Government_benefits_are_too_generous_and_discourage_people_from_working -0.03
## The_UK_should_rejoin_the_European_Union -0.07
## The_UK_should_recognize_a_Palestinian_state_and_reduce_military_cooperation_with_Israel -0.01
## Compared_to_other_civilizations_Western_civilization_is_uniquely_evil -0.15
## Strikes_by_public_sector_workers_are_justified_in_the_current_economic_climate -0.10
## Transgender_women_should_be_allowed_to_compete_in_women_s_sports_categories -0.05
## Local_councils_should_be_allowed_to_introduce_rent_controls_to_reduce_housing_costs -0.06
## The_UK_government_should_introduce_stricter_laws_to_prevent_online_hate_speech_even_at_the_expense_of_free_expression -0.06
## Climate_change_is_an_urgent_threat_that_requires_immediate_and_far_reaching_government_action 0.04
## Private_companies_should_be_allowed_to_run_parts_of_the_NHS_if_it_improves_efficiency -0.02
## The_UK_should_adopt_proportional_representation_for_general_elections 0.06
## Parents_should_be_allowed_to_send_their_children_to_grammar_or_private_schools_if_they_can_afford_it -0.01
## The_UK_should_deport_asylum_seekers_to_third_countries_like_Rwanda_if_they_arrive_through_irregular_routes -0.04
## National_service_military_or_civic_should_be_mandatory_for_young_adults_in_the_UK 0.20
## I_support_the_LGBT_community -0.01
## I_support_gay_marriage -0.07
## There_is_nothing_wrong_with_public_depictions_of_homosexual_relationships 0.05
## Everyone_should_be_addressed_by_their_desired_pronouns 0.04
## There_are_only_two_genders 0.03
## I_support_feminism 0.11
## Abortion_should_be_available_to_women_for_use_for_any_reason -0.09
## Children_should_be_taught_about_gay_sex_in_sex_education_classes 0.07
## There_is_nothing_wrong_with_attending_a_gay_orgy -0.01
## Men_should_be_masculine_and_women_should_be_feminine 0.00
## Immigration_policy_should_be_strict_and_heavily_meritorious -0.03
## Progressive_taxation_where_the_rich_are_taxed_at_a_higher_rate_is_the_best_way_to_structure_a_tax_system 0.05
## The_government_should_help_ensure_sexual_equality_by_making_sure_women_are_not_discriminated_against_in_private_hiring -0.04
## Public_policy_changes_do_not_need_to_be_made_to_deal_with_climate_change -0.04
## ADHD 0.00
## Alcoholism 0.09
## Drug_abuse -0.06
## Autism 0.00
## Bipolar 0.09
## BPD -0.05
## Depression 0.02
## Anxiety -0.03
## OCD 0.01
## Panic -0.15
## Social_phobia 0.18
## Specific_phobia -0.12
## PTSD 0.06
## Schioid -0.05
## Sleep_disorders -0.02
## MR3
## prime_minister 0.03
## governing_party 0.04
## opposition_leader 0.04
## role_chan_exchequer 0.05
## scottish_indep_party 0.05
## upper_house_name 0.01
## UK_nations 0.00
## location_scottish_parliament 0.00
## next_election_date 0.08
## mayor_london 0.03
## ed_davey_role -0.05
## house_lords_veto_removed 0.02
## who_oversees_NHS 0.09
## foreign_secretary_return 0.04
## levelling_up_meaning -0.01
## region_voted_remain 0.04
## rural_england_party -0.06
## role_home_secretary 0.06
## members_of_parliament 0.04
## role_speaker_of_house 0.04
## most_envir_party 0.00
## windsor_framework 0.14
## who_can_vote 0.10
## magna_carta 0.00
## region_reunification_debate 0.15
## The_UK_should_continue_to_provide_military_and_financial_support_to_Ukraine_in_its_war_with_Russia -0.04
## Immigration_levels_in_the_UK_are_too_high_and_should_be_significantly_reduced 0.01
## The_NHS_should_remain_entirely_publicly_funded_and_free_at_the_point_of_use 0.50
## Wealthier_individuals_should_pay_significantly_higher_taxes_to_support_public_services 0.80
## The_UK_should_phase_out_fossil_fuels_entirely_by_2035_even_if_it_increases_energy_costs_in_the_short_term 0.15
## The_UK_should_invest_in_building_new_nuclear_power_plants_to_meet_future_energy_demands 0.08
## The_monarchy_is_an_outdated_institution_and_should_be_abolished 0.36
## Government_benefits_are_too_generous_and_discourage_people_from_working -0.31
## The_UK_should_rejoin_the_European_Union 0.27
## The_UK_should_recognize_a_Palestinian_state_and_reduce_military_cooperation_with_Israel 0.27
## Compared_to_other_civilizations_Western_civilization_is_uniquely_evil 0.14
## Strikes_by_public_sector_workers_are_justified_in_the_current_economic_climate 0.46
## Transgender_women_should_be_allowed_to_compete_in_women_s_sports_categories 0.07
## Local_councils_should_be_allowed_to_introduce_rent_controls_to_reduce_housing_costs 0.56
## The_UK_government_should_introduce_stricter_laws_to_prevent_online_hate_speech_even_at_the_expense_of_free_expression 0.03
## Climate_change_is_an_urgent_threat_that_requires_immediate_and_far_reaching_government_action 0.18
## Private_companies_should_be_allowed_to_run_parts_of_the_NHS_if_it_improves_efficiency -0.40
## The_UK_should_adopt_proportional_representation_for_general_elections 0.29
## Parents_should_be_allowed_to_send_their_children_to_grammar_or_private_schools_if_they_can_afford_it -0.16
## The_UK_should_deport_asylum_seekers_to_third_countries_like_Rwanda_if_they_arrive_through_irregular_routes -0.09
## National_service_military_or_civic_should_be_mandatory_for_young_adults_in_the_UK 0.04
## I_support_the_LGBT_community 0.00
## I_support_gay_marriage 0.02
## There_is_nothing_wrong_with_public_depictions_of_homosexual_relationships -0.04
## Everyone_should_be_addressed_by_their_desired_pronouns 0.06
## There_are_only_two_genders -0.05
## I_support_feminism 0.08
## Abortion_should_be_available_to_women_for_use_for_any_reason 0.18
## Children_should_be_taught_about_gay_sex_in_sex_education_classes -0.01
## There_is_nothing_wrong_with_attending_a_gay_orgy 0.06
## Men_should_be_masculine_and_women_should_be_feminine 0.03
## Immigration_policy_should_be_strict_and_heavily_meritorious 0.00
## Progressive_taxation_where_the_rich_are_taxed_at_a_higher_rate_is_the_best_way_to_structure_a_tax_system 0.76
## The_government_should_help_ensure_sexual_equality_by_making_sure_women_are_not_discriminated_against_in_private_hiring 0.26
## Public_policy_changes_do_not_need_to_be_made_to_deal_with_climate_change -0.03
## ADHD 0.05
## Alcoholism -0.07
## Drug_abuse 0.00
## Autism 0.02
## Bipolar -0.01
## BPD -0.02
## Depression 0.06
## Anxiety 0.02
## OCD -0.19
## Panic 0.16
## Social_phobia -0.16
## Specific_phobia 0.10
## PTSD 0.02
## Schioid -0.02
## Sleep_disorders 0.03
## MR8
## prime_minister -0.04
## governing_party -0.04
## opposition_leader 0.00
## role_chan_exchequer -0.02
## scottish_indep_party -0.01
## upper_house_name 0.03
## UK_nations -0.02
## location_scottish_parliament 0.06
## next_election_date -0.05
## mayor_london -0.05
## ed_davey_role 0.00
## house_lords_veto_removed -0.06
## who_oversees_NHS -0.12
## foreign_secretary_return 0.01
## levelling_up_meaning 0.10
## region_voted_remain -0.11
## rural_england_party -0.01
## role_home_secretary -0.07
## members_of_parliament -0.07
## role_speaker_of_house -0.02
## most_envir_party 0.01
## windsor_framework -0.03
## who_can_vote -0.06
## magna_carta 0.03
## region_reunification_debate -0.15
## The_UK_should_continue_to_provide_military_and_financial_support_to_Ukraine_in_its_war_with_Russia 0.38
## Immigration_levels_in_the_UK_are_too_high_and_should_be_significantly_reduced -0.07
## The_NHS_should_remain_entirely_publicly_funded_and_free_at_the_point_of_use 0.08
## Wealthier_individuals_should_pay_significantly_higher_taxes_to_support_public_services 0.02
## The_UK_should_phase_out_fossil_fuels_entirely_by_2035_even_if_it_increases_energy_costs_in_the_short_term 0.52
## The_UK_should_invest_in_building_new_nuclear_power_plants_to_meet_future_energy_demands -0.16
## The_monarchy_is_an_outdated_institution_and_should_be_abolished -0.23
## Government_benefits_are_too_generous_and_discourage_people_from_working 0.03
## The_UK_should_rejoin_the_European_Union 0.16
## The_UK_should_recognize_a_Palestinian_state_and_reduce_military_cooperation_with_Israel 0.14
## Compared_to_other_civilizations_Western_civilization_is_uniquely_evil 0.00
## Strikes_by_public_sector_workers_are_justified_in_the_current_economic_climate 0.13
## Transgender_women_should_be_allowed_to_compete_in_women_s_sports_categories 0.00
## Local_councils_should_be_allowed_to_introduce_rent_controls_to_reduce_housing_costs 0.20
## The_UK_government_should_introduce_stricter_laws_to_prevent_online_hate_speech_even_at_the_expense_of_free_expression 0.53
## Climate_change_is_an_urgent_threat_that_requires_immediate_and_far_reaching_government_action 0.70
## Private_companies_should_be_allowed_to_run_parts_of_the_NHS_if_it_improves_efficiency 0.18
## The_UK_should_adopt_proportional_representation_for_general_elections 0.07
## Parents_should_be_allowed_to_send_their_children_to_grammar_or_private_schools_if_they_can_afford_it 0.12
## The_UK_should_deport_asylum_seekers_to_third_countries_like_Rwanda_if_they_arrive_through_irregular_routes -0.07
## National_service_military_or_civic_should_be_mandatory_for_young_adults_in_the_UK 0.07
## I_support_the_LGBT_community 0.09
## I_support_gay_marriage -0.03
## There_is_nothing_wrong_with_public_depictions_of_homosexual_relationships -0.01
## Everyone_should_be_addressed_by_their_desired_pronouns 0.22
## There_are_only_two_genders -0.03
## I_support_feminism 0.22
## Abortion_should_be_available_to_women_for_use_for_any_reason -0.06
## Children_should_be_taught_about_gay_sex_in_sex_education_classes 0.12
## There_is_nothing_wrong_with_attending_a_gay_orgy -0.11
## Men_should_be_masculine_and_women_should_be_feminine -0.08
## Immigration_policy_should_be_strict_and_heavily_meritorious -0.01
## Progressive_taxation_where_the_rich_are_taxed_at_a_higher_rate_is_the_best_way_to_structure_a_tax_system 0.05
## The_government_should_help_ensure_sexual_equality_by_making_sure_women_are_not_discriminated_against_in_private_hiring 0.24
## Public_policy_changes_do_not_need_to_be_made_to_deal_with_climate_change -0.48
## ADHD -0.15
## Alcoholism -0.10
## Drug_abuse 0.00
## Autism -0.03
## Bipolar 0.01
## BPD 0.06
## Depression -0.02
## Anxiety -0.08
## OCD 0.00
## Panic -0.19
## Social_phobia 0.00
## Specific_phobia -0.08
## PTSD 0.06
## Schioid 0.25
## Sleep_disorders 0.14
## MR4
## prime_minister 0.00
## governing_party 0.00
## opposition_leader -0.01
## role_chan_exchequer 0.03
## scottish_indep_party 0.03
## upper_house_name 0.02
## UK_nations -0.03
## location_scottish_parliament -0.03
## next_election_date -0.03
## mayor_london 0.04
## ed_davey_role -0.02
## house_lords_veto_removed 0.03
## who_oversees_NHS -0.02
## foreign_secretary_return -0.08
## levelling_up_meaning 0.03
## region_voted_remain -0.07
## rural_england_party 0.02
## role_home_secretary 0.00
## members_of_parliament -0.07
## role_speaker_of_house -0.06
## most_envir_party -0.03
## windsor_framework 0.01
## who_can_vote -0.01
## magna_carta -0.06
## region_reunification_debate -0.07
## The_UK_should_continue_to_provide_military_and_financial_support_to_Ukraine_in_its_war_with_Russia 0.06
## Immigration_levels_in_the_UK_are_too_high_and_should_be_significantly_reduced 0.07
## The_NHS_should_remain_entirely_publicly_funded_and_free_at_the_point_of_use -0.01
## Wealthier_individuals_should_pay_significantly_higher_taxes_to_support_public_services 0.01
## The_UK_should_phase_out_fossil_fuels_entirely_by_2035_even_if_it_increases_energy_costs_in_the_short_term 0.01
## The_UK_should_invest_in_building_new_nuclear_power_plants_to_meet_future_energy_demands 0.04
## The_monarchy_is_an_outdated_institution_and_should_be_abolished -0.02
## Government_benefits_are_too_generous_and_discourage_people_from_working -0.15
## The_UK_should_rejoin_the_European_Union 0.04
## The_UK_should_recognize_a_Palestinian_state_and_reduce_military_cooperation_with_Israel 0.01
## Compared_to_other_civilizations_Western_civilization_is_uniquely_evil -0.04
## Strikes_by_public_sector_workers_are_justified_in_the_current_economic_climate 0.03
## Transgender_women_should_be_allowed_to_compete_in_women_s_sports_categories 0.07
## Local_councils_should_be_allowed_to_introduce_rent_controls_to_reduce_housing_costs 0.03
## The_UK_government_should_introduce_stricter_laws_to_prevent_online_hate_speech_even_at_the_expense_of_free_expression 0.02
## Climate_change_is_an_urgent_threat_that_requires_immediate_and_far_reaching_government_action -0.02
## Private_companies_should_be_allowed_to_run_parts_of_the_NHS_if_it_improves_efficiency 0.02
## The_UK_should_adopt_proportional_representation_for_general_elections 0.02
## Parents_should_be_allowed_to_send_their_children_to_grammar_or_private_schools_if_they_can_afford_it 0.00
## The_UK_should_deport_asylum_seekers_to_third_countries_like_Rwanda_if_they_arrive_through_irregular_routes -0.07
## National_service_military_or_civic_should_be_mandatory_for_young_adults_in_the_UK -0.03
## I_support_the_LGBT_community 0.02
## I_support_gay_marriage -0.02
## There_is_nothing_wrong_with_public_depictions_of_homosexual_relationships 0.00
## Everyone_should_be_addressed_by_their_desired_pronouns -0.02
## There_are_only_two_genders -0.06
## I_support_feminism -0.07
## Abortion_should_be_available_to_women_for_use_for_any_reason -0.03
## Children_should_be_taught_about_gay_sex_in_sex_education_classes 0.01
## There_is_nothing_wrong_with_attending_a_gay_orgy 0.08
## Men_should_be_masculine_and_women_should_be_feminine -0.04
## Immigration_policy_should_be_strict_and_heavily_meritorious 0.04
## Progressive_taxation_where_the_rich_are_taxed_at_a_higher_rate_is_the_best_way_to_structure_a_tax_system 0.03
## The_government_should_help_ensure_sexual_equality_by_making_sure_women_are_not_discriminated_against_in_private_hiring 0.03
## Public_policy_changes_do_not_need_to_be_made_to_deal_with_climate_change 0.01
## ADHD 0.08
## Alcoholism 0.36
## Drug_abuse -0.07
## Autism 0.13
## Bipolar 0.03
## BPD 0.03
## Depression 0.55
## Anxiety 0.70
## OCD 0.26
## Panic 0.29
## Social_phobia 0.19
## Specific_phobia 0.13
## PTSD 0.12
## Schioid 0.33
## Sleep_disorders 0.60
## MR6
## prime_minister 0.61
## governing_party 0.72
## opposition_leader 0.16
## role_chan_exchequer 0.19
## scottish_indep_party 0.26
## upper_house_name -0.01
## UK_nations 0.08
## location_scottish_parliament -0.17
## next_election_date -0.02
## mayor_london 0.12
## ed_davey_role 0.08
## house_lords_veto_removed -0.24
## who_oversees_NHS -0.02
## foreign_secretary_return 0.01
## levelling_up_meaning -0.03
## region_voted_remain -0.09
## rural_england_party -0.05
## role_home_secretary -0.10
## members_of_parliament -0.04
## role_speaker_of_house 0.09
## most_envir_party 0.06
## windsor_framework -0.17
## who_can_vote -0.23
## magna_carta -0.16
## region_reunification_debate -0.08
## The_UK_should_continue_to_provide_military_and_financial_support_to_Ukraine_in_its_war_with_Russia 0.05
## Immigration_levels_in_the_UK_are_too_high_and_should_be_significantly_reduced 0.02
## The_NHS_should_remain_entirely_publicly_funded_and_free_at_the_point_of_use 0.13
## Wealthier_individuals_should_pay_significantly_higher_taxes_to_support_public_services 0.05
## The_UK_should_phase_out_fossil_fuels_entirely_by_2035_even_if_it_increases_energy_costs_in_the_short_term -0.06
## The_UK_should_invest_in_building_new_nuclear_power_plants_to_meet_future_energy_demands -0.08
## The_monarchy_is_an_outdated_institution_and_should_be_abolished -0.06
## Government_benefits_are_too_generous_and_discourage_people_from_working 0.03
## The_UK_should_rejoin_the_European_Union 0.03
## The_UK_should_recognize_a_Palestinian_state_and_reduce_military_cooperation_with_Israel -0.01
## Compared_to_other_civilizations_Western_civilization_is_uniquely_evil -0.08
## Strikes_by_public_sector_workers_are_justified_in_the_current_economic_climate 0.01
## Transgender_women_should_be_allowed_to_compete_in_women_s_sports_categories -0.20
## Local_councils_should_be_allowed_to_introduce_rent_controls_to_reduce_housing_costs 0.04
## The_UK_government_should_introduce_stricter_laws_to_prevent_online_hate_speech_even_at_the_expense_of_free_expression -0.08
## Climate_change_is_an_urgent_threat_that_requires_immediate_and_far_reaching_government_action -0.06
## Private_companies_should_be_allowed_to_run_parts_of_the_NHS_if_it_improves_efficiency -0.11
## The_UK_should_adopt_proportional_representation_for_general_elections 0.02
## Parents_should_be_allowed_to_send_their_children_to_grammar_or_private_schools_if_they_can_afford_it -0.07
## The_UK_should_deport_asylum_seekers_to_third_countries_like_Rwanda_if_they_arrive_through_irregular_routes 0.00
## National_service_military_or_civic_should_be_mandatory_for_young_adults_in_the_UK -0.10
## I_support_the_LGBT_community 0.02
## I_support_gay_marriage 0.02
## There_is_nothing_wrong_with_public_depictions_of_homosexual_relationships -0.03
## Everyone_should_be_addressed_by_their_desired_pronouns -0.01
## There_are_only_two_genders 0.00
## I_support_feminism -0.02
## Abortion_should_be_available_to_women_for_use_for_any_reason 0.12
## Children_should_be_taught_about_gay_sex_in_sex_education_classes 0.02
## There_is_nothing_wrong_with_attending_a_gay_orgy -0.01
## Men_should_be_masculine_and_women_should_be_feminine -0.09
## Immigration_policy_should_be_strict_and_heavily_meritorious 0.06
## Progressive_taxation_where_the_rich_are_taxed_at_a_higher_rate_is_the_best_way_to_structure_a_tax_system -0.06
## The_government_should_help_ensure_sexual_equality_by_making_sure_women_are_not_discriminated_against_in_private_hiring 0.03
## Public_policy_changes_do_not_need_to_be_made_to_deal_with_climate_change 0.03
## ADHD -0.13
## Alcoholism 0.00
## Drug_abuse 0.00
## Autism 0.01
## Bipolar 0.00
## BPD 0.04
## Depression 0.01
## Anxiety -0.03
## OCD 0.03
## Panic -0.06
## Social_phobia -0.01
## Specific_phobia -0.01
## PTSD -0.02
## Schioid 0.07
## Sleep_disorders 0.05
## MR7
## prime_minister 0.00
## governing_party 0.00
## opposition_leader 0.02
## role_chan_exchequer -0.14
## scottish_indep_party -0.01
## upper_house_name 0.13
## UK_nations 0.05
## location_scottish_parliament -0.05
## next_election_date -0.04
## mayor_london -0.20
## ed_davey_role -0.08
## house_lords_veto_removed 0.00
## who_oversees_NHS 0.00
## foreign_secretary_return 0.04
## levelling_up_meaning 0.01
## region_voted_remain 0.08
## rural_england_party 0.01
## role_home_secretary -0.23
## members_of_parliament 0.13
## role_speaker_of_house -0.04
## most_envir_party 0.01
## windsor_framework -0.01
## who_can_vote 0.02
## magna_carta 0.01
## region_reunification_debate 0.08
## The_UK_should_continue_to_provide_military_and_financial_support_to_Ukraine_in_its_war_with_Russia 0.01
## Immigration_levels_in_the_UK_are_too_high_and_should_be_significantly_reduced -0.02
## The_NHS_should_remain_entirely_publicly_funded_and_free_at_the_point_of_use 0.08
## Wealthier_individuals_should_pay_significantly_higher_taxes_to_support_public_services -0.06
## The_UK_should_phase_out_fossil_fuels_entirely_by_2035_even_if_it_increases_energy_costs_in_the_short_term 0.00
## The_UK_should_invest_in_building_new_nuclear_power_plants_to_meet_future_energy_demands 0.01
## The_monarchy_is_an_outdated_institution_and_should_be_abolished 0.10
## Government_benefits_are_too_generous_and_discourage_people_from_working -0.05
## The_UK_should_rejoin_the_European_Union 0.08
## The_UK_should_recognize_a_Palestinian_state_and_reduce_military_cooperation_with_Israel 0.01
## Compared_to_other_civilizations_Western_civilization_is_uniquely_evil -0.03
## Strikes_by_public_sector_workers_are_justified_in_the_current_economic_climate 0.10
## Transgender_women_should_be_allowed_to_compete_in_women_s_sports_categories -0.05
## Local_councils_should_be_allowed_to_introduce_rent_controls_to_reduce_housing_costs 0.11
## The_UK_government_should_introduce_stricter_laws_to_prevent_online_hate_speech_even_at_the_expense_of_free_expression 0.03
## Climate_change_is_an_urgent_threat_that_requires_immediate_and_far_reaching_government_action -0.05
## Private_companies_should_be_allowed_to_run_parts_of_the_NHS_if_it_improves_efficiency -0.05
## The_UK_should_adopt_proportional_representation_for_general_elections 0.05
## Parents_should_be_allowed_to_send_their_children_to_grammar_or_private_schools_if_they_can_afford_it -0.03
## The_UK_should_deport_asylum_seekers_to_third_countries_like_Rwanda_if_they_arrive_through_irregular_routes 0.00
## National_service_military_or_civic_should_be_mandatory_for_young_adults_in_the_UK 0.04
## I_support_the_LGBT_community -0.03
## I_support_gay_marriage 0.00
## There_is_nothing_wrong_with_public_depictions_of_homosexual_relationships 0.03
## Everyone_should_be_addressed_by_their_desired_pronouns 0.03
## There_are_only_two_genders 0.02
## I_support_feminism -0.02
## Abortion_should_be_available_to_women_for_use_for_any_reason -0.03
## Children_should_be_taught_about_gay_sex_in_sex_education_classes 0.02
## There_is_nothing_wrong_with_attending_a_gay_orgy 0.04
## Men_should_be_masculine_and_women_should_be_feminine -0.04
## Immigration_policy_should_be_strict_and_heavily_meritorious 0.06
## Progressive_taxation_where_the_rich_are_taxed_at_a_higher_rate_is_the_best_way_to_structure_a_tax_system -0.06
## The_government_should_help_ensure_sexual_equality_by_making_sure_women_are_not_discriminated_against_in_private_hiring -0.06
## Public_policy_changes_do_not_need_to_be_made_to_deal_with_climate_change -0.02
## ADHD -0.05
## Alcoholism 0.47
## Drug_abuse 0.78
## Autism 0.00
## Bipolar 0.50
## BPD 0.24
## Depression 0.09
## Anxiety -0.10
## OCD -0.04
## Panic -0.05
## Social_phobia 0.10
## Specific_phobia -0.06
## PTSD -0.14
## Schioid -0.02
## Sleep_disorders 0.04
## MR9
## prime_minister 0.10
## governing_party -0.06
## opposition_leader 0.08
## role_chan_exchequer -0.01
## scottish_indep_party -0.22
## upper_house_name -0.15
## UK_nations -0.13
## location_scottish_parliament -0.15
## next_election_date -0.02
## mayor_london 0.11
## ed_davey_role 0.02
## house_lords_veto_removed 0.16
## who_oversees_NHS -0.21
## foreign_secretary_return -0.04
## levelling_up_meaning -0.15
## region_voted_remain -0.05
## rural_england_party -0.05
## role_home_secretary -0.16
## members_of_parliament -0.06
## role_speaker_of_house -0.13
## most_envir_party -0.22
## windsor_framework -0.16
## who_can_vote 0.02
## magna_carta 0.03
## region_reunification_debate -0.34
## The_UK_should_continue_to_provide_military_and_financial_support_to_Ukraine_in_its_war_with_Russia -0.18
## Immigration_levels_in_the_UK_are_too_high_and_should_be_significantly_reduced -0.07
## The_NHS_should_remain_entirely_publicly_funded_and_free_at_the_point_of_use 0.05
## Wealthier_individuals_should_pay_significantly_higher_taxes_to_support_public_services -0.02
## The_UK_should_phase_out_fossil_fuels_entirely_by_2035_even_if_it_increases_energy_costs_in_the_short_term 0.06
## The_UK_should_invest_in_building_new_nuclear_power_plants_to_meet_future_energy_demands -0.14
## The_monarchy_is_an_outdated_institution_and_should_be_abolished 0.17
## Government_benefits_are_too_generous_and_discourage_people_from_working 0.14
## The_UK_should_rejoin_the_European_Union 0.18
## The_UK_should_recognize_a_Palestinian_state_and_reduce_military_cooperation_with_Israel 0.09
## Compared_to_other_civilizations_Western_civilization_is_uniquely_evil 0.50
## Strikes_by_public_sector_workers_are_justified_in_the_current_economic_climate 0.12
## Transgender_women_should_be_allowed_to_compete_in_women_s_sports_categories 0.14
## Local_councils_should_be_allowed_to_introduce_rent_controls_to_reduce_housing_costs 0.08
## The_UK_government_should_introduce_stricter_laws_to_prevent_online_hate_speech_even_at_the_expense_of_free_expression 0.22
## Climate_change_is_an_urgent_threat_that_requires_immediate_and_far_reaching_government_action 0.00
## Private_companies_should_be_allowed_to_run_parts_of_the_NHS_if_it_improves_efficiency -0.03
## The_UK_should_adopt_proportional_representation_for_general_elections 0.05
## Parents_should_be_allowed_to_send_their_children_to_grammar_or_private_schools_if_they_can_afford_it 0.04
## The_UK_should_deport_asylum_seekers_to_third_countries_like_Rwanda_if_they_arrive_through_irregular_routes 0.06
## National_service_military_or_civic_should_be_mandatory_for_young_adults_in_the_UK 0.00
## I_support_the_LGBT_community 0.02
## I_support_gay_marriage -0.03
## There_is_nothing_wrong_with_public_depictions_of_homosexual_relationships 0.03
## Everyone_should_be_addressed_by_their_desired_pronouns 0.09
## There_are_only_two_genders 0.04
## I_support_feminism 0.07
## Abortion_should_be_available_to_women_for_use_for_any_reason -0.03
## Children_should_be_taught_about_gay_sex_in_sex_education_classes -0.01
## There_is_nothing_wrong_with_attending_a_gay_orgy -0.01
## Men_should_be_masculine_and_women_should_be_feminine 0.14
## Immigration_policy_should_be_strict_and_heavily_meritorious 0.00
## Progressive_taxation_where_the_rich_are_taxed_at_a_higher_rate_is_the_best_way_to_structure_a_tax_system -0.04
## The_government_should_help_ensure_sexual_equality_by_making_sure_women_are_not_discriminated_against_in_private_hiring 0.11
## Public_policy_changes_do_not_need_to_be_made_to_deal_with_climate_change 0.21
## ADHD 0.01
## Alcoholism 0.11
## Drug_abuse -0.06
## Autism -0.01
## Bipolar 0.08
## BPD -0.05
## Depression 0.13
## Anxiety -0.02
## OCD 0.17
## Panic -0.09
## Social_phobia 0.25
## Specific_phobia -0.15
## PTSD 0.05
## Schioid -0.13
## Sleep_disorders -0.06
## MR11
## prime_minister 0.00
## governing_party -0.02
## opposition_leader -0.01
## role_chan_exchequer 0.15
## scottish_indep_party 0.00
## upper_house_name 0.22
## UK_nations 0.05
## location_scottish_parliament -0.08
## next_election_date 0.01
## mayor_london 0.04
## ed_davey_role -0.05
## house_lords_veto_removed 0.02
## who_oversees_NHS 0.01
## foreign_secretary_return -0.06
## levelling_up_meaning -0.03
## region_voted_remain -0.03
## rural_england_party -0.04
## role_home_secretary -0.17
## members_of_parliament -0.02
## role_speaker_of_house -0.04
## most_envir_party -0.05
## windsor_framework -0.07
## who_can_vote -0.12
## magna_carta 0.05
## region_reunification_debate 0.06
## The_UK_should_continue_to_provide_military_and_financial_support_to_Ukraine_in_its_war_with_Russia 0.08
## Immigration_levels_in_the_UK_are_too_high_and_should_be_significantly_reduced -0.06
## The_NHS_should_remain_entirely_publicly_funded_and_free_at_the_point_of_use 0.00
## Wealthier_individuals_should_pay_significantly_higher_taxes_to_support_public_services 0.01
## The_UK_should_phase_out_fossil_fuels_entirely_by_2035_even_if_it_increases_energy_costs_in_the_short_term 0.09
## The_UK_should_invest_in_building_new_nuclear_power_plants_to_meet_future_energy_demands 0.00
## The_monarchy_is_an_outdated_institution_and_should_be_abolished 0.07
## Government_benefits_are_too_generous_and_discourage_people_from_working -0.06
## The_UK_should_rejoin_the_European_Union -0.11
## The_UK_should_recognize_a_Palestinian_state_and_reduce_military_cooperation_with_Israel 0.01
## Compared_to_other_civilizations_Western_civilization_is_uniquely_evil 0.12
## Strikes_by_public_sector_workers_are_justified_in_the_current_economic_climate 0.08
## Transgender_women_should_be_allowed_to_compete_in_women_s_sports_categories 0.46
## Local_councils_should_be_allowed_to_introduce_rent_controls_to_reduce_housing_costs 0.06
## The_UK_government_should_introduce_stricter_laws_to_prevent_online_hate_speech_even_at_the_expense_of_free_expression 0.01
## Climate_change_is_an_urgent_threat_that_requires_immediate_and_far_reaching_government_action 0.03
## Private_companies_should_be_allowed_to_run_parts_of_the_NHS_if_it_improves_efficiency -0.01
## The_UK_should_adopt_proportional_representation_for_general_elections 0.19
## Parents_should_be_allowed_to_send_their_children_to_grammar_or_private_schools_if_they_can_afford_it -0.07
## The_UK_should_deport_asylum_seekers_to_third_countries_like_Rwanda_if_they_arrive_through_irregular_routes 0.02
## National_service_military_or_civic_should_be_mandatory_for_young_adults_in_the_UK 0.15
## I_support_the_LGBT_community 0.07
## I_support_gay_marriage -0.07
## There_is_nothing_wrong_with_public_depictions_of_homosexual_relationships -0.03
## Everyone_should_be_addressed_by_their_desired_pronouns 0.32
## There_are_only_two_genders -0.41
## I_support_feminism -0.12
## Abortion_should_be_available_to_women_for_use_for_any_reason -0.11
## Children_should_be_taught_about_gay_sex_in_sex_education_classes 0.17
## There_is_nothing_wrong_with_attending_a_gay_orgy 0.02
## Men_should_be_masculine_and_women_should_be_feminine -0.07
## Immigration_policy_should_be_strict_and_heavily_meritorious -0.09
## Progressive_taxation_where_the_rich_are_taxed_at_a_higher_rate_is_the_best_way_to_structure_a_tax_system -0.02
## The_government_should_help_ensure_sexual_equality_by_making_sure_women_are_not_discriminated_against_in_private_hiring -0.23
## Public_policy_changes_do_not_need_to_be_made_to_deal_with_climate_change 0.08
## ADHD 0.10
## Alcoholism -0.09
## Drug_abuse 0.02
## Autism 0.01
## Bipolar -0.04
## BPD -0.01
## Depression 0.01
## Anxiety 0.04
## OCD -0.13
## Panic -0.08
## Social_phobia -0.17
## Specific_phobia 0.11
## PTSD 0.03
## Schioid -0.03
## Sleep_disorders 0.01
## MR10
## prime_minister -0.02
## governing_party 0.03
## opposition_leader 0.05
## role_chan_exchequer -0.09
## scottish_indep_party 0.10
## upper_house_name -0.11
## UK_nations 0.02
## location_scottish_parliament 0.00
## next_election_date 0.03
## mayor_london 0.08
## ed_davey_role 0.04
## house_lords_veto_removed -0.02
## who_oversees_NHS 0.08
## foreign_secretary_return -0.05
## levelling_up_meaning -0.09
## region_voted_remain -0.07
## rural_england_party -0.12
## role_home_secretary 0.05
## members_of_parliament -0.10
## role_speaker_of_house 0.16
## most_envir_party 0.05
## windsor_framework 0.03
## who_can_vote -0.03
## magna_carta 0.04
## region_reunification_debate -0.02
## The_UK_should_continue_to_provide_military_and_financial_support_to_Ukraine_in_its_war_with_Russia -0.09
## Immigration_levels_in_the_UK_are_too_high_and_should_be_significantly_reduced -0.02
## The_NHS_should_remain_entirely_publicly_funded_and_free_at_the_point_of_use 0.02
## Wealthier_individuals_should_pay_significantly_higher_taxes_to_support_public_services -0.01
## The_UK_should_phase_out_fossil_fuels_entirely_by_2035_even_if_it_increases_energy_costs_in_the_short_term 0.02
## The_UK_should_invest_in_building_new_nuclear_power_plants_to_meet_future_energy_demands -0.13
## The_monarchy_is_an_outdated_institution_and_should_be_abolished -0.04
## Government_benefits_are_too_generous_and_discourage_people_from_working -0.11
## The_UK_should_rejoin_the_European_Union -0.05
## The_UK_should_recognize_a_Palestinian_state_and_reduce_military_cooperation_with_Israel 0.01
## Compared_to_other_civilizations_Western_civilization_is_uniquely_evil 0.02
## Strikes_by_public_sector_workers_are_justified_in_the_current_economic_climate 0.00
## Transgender_women_should_be_allowed_to_compete_in_women_s_sports_categories 0.04
## Local_councils_should_be_allowed_to_introduce_rent_controls_to_reduce_housing_costs -0.04
## The_UK_government_should_introduce_stricter_laws_to_prevent_online_hate_speech_even_at_the_expense_of_free_expression 0.04
## Climate_change_is_an_urgent_threat_that_requires_immediate_and_far_reaching_government_action 0.01
## Private_companies_should_be_allowed_to_run_parts_of_the_NHS_if_it_improves_efficiency -0.03
## The_UK_should_adopt_proportional_representation_for_general_elections -0.04
## Parents_should_be_allowed_to_send_their_children_to_grammar_or_private_schools_if_they_can_afford_it 0.11
## The_UK_should_deport_asylum_seekers_to_third_countries_like_Rwanda_if_they_arrive_through_irregular_routes 0.06
## National_service_military_or_civic_should_be_mandatory_for_young_adults_in_the_UK 0.11
## I_support_the_LGBT_community 0.00
## I_support_gay_marriage -0.01
## There_is_nothing_wrong_with_public_depictions_of_homosexual_relationships -0.05
## Everyone_should_be_addressed_by_their_desired_pronouns -0.08
## There_are_only_two_genders 0.02
## I_support_feminism 0.06
## Abortion_should_be_available_to_women_for_use_for_any_reason 0.02
## Children_should_be_taught_about_gay_sex_in_sex_education_classes -0.01
## There_is_nothing_wrong_with_attending_a_gay_orgy 0.04
## Men_should_be_masculine_and_women_should_be_feminine -0.05
## Immigration_policy_should_be_strict_and_heavily_meritorious -0.06
## Progressive_taxation_where_the_rich_are_taxed_at_a_higher_rate_is_the_best_way_to_structure_a_tax_system 0.00
## The_government_should_help_ensure_sexual_equality_by_making_sure_women_are_not_discriminated_against_in_private_hiring -0.03
## Public_policy_changes_do_not_need_to_be_made_to_deal_with_climate_change -0.10
## ADHD 0.04
## Alcoholism -0.01
## Drug_abuse 0.10
## Autism 0.08
## Bipolar 0.00
## BPD 0.65
## Depression 0.20
## Anxiety 0.12
## OCD 0.27
## Panic 0.01
## Social_phobia -0.04
## Specific_phobia 0.21
## PTSD 0.45
## Schioid -0.14
## Sleep_disorders -0.21
## h2
## prime_minister 0.421
## governing_party 0.545
## opposition_leader 0.429
## role_chan_exchequer 0.355
## scottish_indep_party 0.183
## upper_house_name 0.276
## UK_nations 0.060
## location_scottish_parliament 0.312
## next_election_date 0.166
## mayor_london 0.232
## ed_davey_role 0.355
## house_lords_veto_removed 0.162
## who_oversees_NHS 0.110
## foreign_secretary_return 0.302
## levelling_up_meaning 0.427
## region_voted_remain 0.099
## rural_england_party 0.144
## role_home_secretary 0.229
## members_of_parliament 0.234
## role_speaker_of_house 0.167
## most_envir_party 0.069
## windsor_framework 0.199
## who_can_vote 0.096
## magna_carta 0.223
## region_reunification_debate 0.245
## The_UK_should_continue_to_provide_military_and_financial_support_to_Ukraine_in_its_war_with_Russia 0.334
## Immigration_levels_in_the_UK_are_too_high_and_should_be_significantly_reduced 0.698
## The_NHS_should_remain_entirely_publicly_funded_and_free_at_the_point_of_use 0.303
## Wealthier_individuals_should_pay_significantly_higher_taxes_to_support_public_services 0.692
## The_UK_should_phase_out_fossil_fuels_entirely_by_2035_even_if_it_increases_energy_costs_in_the_short_term 0.546
## The_UK_should_invest_in_building_new_nuclear_power_plants_to_meet_future_energy_demands 0.176
## The_monarchy_is_an_outdated_institution_and_should_be_abolished 0.311
## Government_benefits_are_too_generous_and_discourage_people_from_working 0.420
## The_UK_should_rejoin_the_European_Union 0.464
## The_UK_should_recognize_a_Palestinian_state_and_reduce_military_cooperation_with_Israel 0.390
## Compared_to_other_civilizations_Western_civilization_is_uniquely_evil 0.403
## Strikes_by_public_sector_workers_are_justified_in_the_current_economic_climate 0.477
## Transgender_women_should_be_allowed_to_compete_in_women_s_sports_categories 0.583
## Local_councils_should_be_allowed_to_introduce_rent_controls_to_reduce_housing_costs 0.436
## The_UK_government_should_introduce_stricter_laws_to_prevent_online_hate_speech_even_at_the_expense_of_free_expression 0.400
## Climate_change_is_an_urgent_threat_that_requires_immediate_and_far_reaching_government_action 0.734
## Private_companies_should_be_allowed_to_run_parts_of_the_NHS_if_it_improves_efficiency 0.299
## The_UK_should_adopt_proportional_representation_for_general_elections 0.143
## Parents_should_be_allowed_to_send_their_children_to_grammar_or_private_schools_if_they_can_afford_it 0.247
## The_UK_should_deport_asylum_seekers_to_third_countries_like_Rwanda_if_they_arrive_through_irregular_routes 0.735
## National_service_military_or_civic_should_be_mandatory_for_young_adults_in_the_UK 0.377
## I_support_the_LGBT_community 0.810
## I_support_gay_marriage 0.768
## There_is_nothing_wrong_with_public_depictions_of_homosexual_relationships 0.519
## Everyone_should_be_addressed_by_their_desired_pronouns 0.599
## There_are_only_two_genders 0.695
## I_support_feminism 0.477
## Abortion_should_be_available_to_women_for_use_for_any_reason 0.242
## Children_should_be_taught_about_gay_sex_in_sex_education_classes 0.650
## There_is_nothing_wrong_with_attending_a_gay_orgy 0.514
## Men_should_be_masculine_and_women_should_be_feminine 0.618
## Immigration_policy_should_be_strict_and_heavily_meritorious 0.707
## Progressive_taxation_where_the_rich_are_taxed_at_a_higher_rate_is_the_best_way_to_structure_a_tax_system 0.651
## The_government_should_help_ensure_sexual_equality_by_making_sure_women_are_not_discriminated_against_in_private_hiring 0.400
## Public_policy_changes_do_not_need_to_be_made_to_deal_with_climate_change 0.495
## ADHD 0.064
## Alcoholism 0.411
## Drug_abuse 0.648
## Autism 0.035
## Bipolar 0.261
## BPD 0.542
## Depression 0.444
## Anxiety 0.544
## OCD 0.231
## Panic 0.158
## Social_phobia 0.160
## Specific_phobia 0.115
## PTSD 0.241
## Schioid 0.206
## Sleep_disorders 0.409
## u2
## prime_minister 0.58
## governing_party 0.45
## opposition_leader 0.57
## role_chan_exchequer 0.65
## scottish_indep_party 0.82
## upper_house_name 0.72
## UK_nations 0.94
## location_scottish_parliament 0.69
## next_election_date 0.83
## mayor_london 0.77
## ed_davey_role 0.64
## house_lords_veto_removed 0.84
## who_oversees_NHS 0.89
## foreign_secretary_return 0.70
## levelling_up_meaning 0.57
## region_voted_remain 0.90
## rural_england_party 0.86
## role_home_secretary 0.77
## members_of_parliament 0.77
## role_speaker_of_house 0.83
## most_envir_party 0.93
## windsor_framework 0.80
## who_can_vote 0.90
## magna_carta 0.78
## region_reunification_debate 0.75
## The_UK_should_continue_to_provide_military_and_financial_support_to_Ukraine_in_its_war_with_Russia 0.67
## Immigration_levels_in_the_UK_are_too_high_and_should_be_significantly_reduced 0.30
## The_NHS_should_remain_entirely_publicly_funded_and_free_at_the_point_of_use 0.70
## Wealthier_individuals_should_pay_significantly_higher_taxes_to_support_public_services 0.31
## The_UK_should_phase_out_fossil_fuels_entirely_by_2035_even_if_it_increases_energy_costs_in_the_short_term 0.45
## The_UK_should_invest_in_building_new_nuclear_power_plants_to_meet_future_energy_demands 0.82
## The_monarchy_is_an_outdated_institution_and_should_be_abolished 0.69
## Government_benefits_are_too_generous_and_discourage_people_from_working 0.58
## The_UK_should_rejoin_the_European_Union 0.54
## The_UK_should_recognize_a_Palestinian_state_and_reduce_military_cooperation_with_Israel 0.61
## Compared_to_other_civilizations_Western_civilization_is_uniquely_evil 0.60
## Strikes_by_public_sector_workers_are_justified_in_the_current_economic_climate 0.52
## Transgender_women_should_be_allowed_to_compete_in_women_s_sports_categories 0.42
## Local_councils_should_be_allowed_to_introduce_rent_controls_to_reduce_housing_costs 0.56
## The_UK_government_should_introduce_stricter_laws_to_prevent_online_hate_speech_even_at_the_expense_of_free_expression 0.60
## Climate_change_is_an_urgent_threat_that_requires_immediate_and_far_reaching_government_action 0.27
## Private_companies_should_be_allowed_to_run_parts_of_the_NHS_if_it_improves_efficiency 0.70
## The_UK_should_adopt_proportional_representation_for_general_elections 0.86
## Parents_should_be_allowed_to_send_their_children_to_grammar_or_private_schools_if_they_can_afford_it 0.75
## The_UK_should_deport_asylum_seekers_to_third_countries_like_Rwanda_if_they_arrive_through_irregular_routes 0.27
## National_service_military_or_civic_should_be_mandatory_for_young_adults_in_the_UK 0.62
## I_support_the_LGBT_community 0.19
## I_support_gay_marriage 0.23
## There_is_nothing_wrong_with_public_depictions_of_homosexual_relationships 0.48
## Everyone_should_be_addressed_by_their_desired_pronouns 0.40
## There_are_only_two_genders 0.31
## I_support_feminism 0.52
## Abortion_should_be_available_to_women_for_use_for_any_reason 0.76
## Children_should_be_taught_about_gay_sex_in_sex_education_classes 0.35
## There_is_nothing_wrong_with_attending_a_gay_orgy 0.49
## Men_should_be_masculine_and_women_should_be_feminine 0.38
## Immigration_policy_should_be_strict_and_heavily_meritorious 0.29
## Progressive_taxation_where_the_rich_are_taxed_at_a_higher_rate_is_the_best_way_to_structure_a_tax_system 0.35
## The_government_should_help_ensure_sexual_equality_by_making_sure_women_are_not_discriminated_against_in_private_hiring 0.60
## Public_policy_changes_do_not_need_to_be_made_to_deal_with_climate_change 0.51
## ADHD 0.94
## Alcoholism 0.59
## Drug_abuse 0.35
## Autism 0.96
## Bipolar 0.74
## BPD 0.46
## Depression 0.56
## Anxiety 0.46
## OCD 0.77
## Panic 0.84
## Social_phobia 0.84
## Specific_phobia 0.88
## PTSD 0.76
## Schioid 0.79
## Sleep_disorders 0.59
## com
## prime_minister 1.2
## governing_party 1.0
## opposition_leader 1.2
## role_chan_exchequer 1.9
## scottish_indep_party 3.9
## upper_house_name 2.4
## UK_nations 4.2
## location_scottish_parliament 1.7
## next_election_date 1.2
## mayor_london 2.1
## ed_davey_role 1.2
## house_lords_veto_removed 2.4
## who_oversees_NHS 3.7
## foreign_secretary_return 1.2
## levelling_up_meaning 1.3
## region_voted_remain 4.1
## rural_england_party 2.0
## role_home_secretary 4.9
## members_of_parliament 1.8
## role_speaker_of_house 3.3
## most_envir_party 2.2
## windsor_framework 2.6
## who_can_vote 3.3
## magna_carta 1.4
## region_reunification_debate 3.4
## The_UK_should_continue_to_provide_military_and_financial_support_to_Ukraine_in_its_war_with_Russia 2.7
## Immigration_levels_in_the_UK_are_too_high_and_should_be_significantly_reduced 1.1
## The_NHS_should_remain_entirely_publicly_funded_and_free_at_the_point_of_use 1.3
## Wealthier_individuals_should_pay_significantly_higher_taxes_to_support_public_services 1.0
## The_UK_should_phase_out_fossil_fuels_entirely_by_2035_even_if_it_increases_energy_costs_in_the_short_term 1.5
## The_UK_should_invest_in_building_new_nuclear_power_plants_to_meet_future_energy_demands 4.2
## The_monarchy_is_an_outdated_institution_and_should_be_abolished 3.6
## Government_benefits_are_too_generous_and_discourage_people_from_working 2.9
## The_UK_should_rejoin_the_European_Union 4.3
## The_UK_should_recognize_a_Palestinian_state_and_reduce_military_cooperation_with_Israel 2.9
## Compared_to_other_civilizations_Western_civilization_is_uniquely_evil 1.8
## Strikes_by_public_sector_workers_are_justified_in_the_current_economic_climate 2.0
## Transgender_women_should_be_allowed_to_compete_in_women_s_sports_categories 2.8
## Local_councils_should_be_allowed_to_introduce_rent_controls_to_reduce_housing_costs 1.5
## The_UK_government_should_introduce_stricter_laws_to_prevent_online_hate_speech_even_at_the_expense_of_free_expression 1.5
## Climate_change_is_an_urgent_threat_that_requires_immediate_and_far_reaching_government_action 1.2
## Private_companies_should_be_allowed_to_run_parts_of_the_NHS_if_it_improves_efficiency 2.5
## The_UK_should_adopt_proportional_representation_for_general_elections 2.5
## Parents_should_be_allowed_to_send_their_children_to_grammar_or_private_schools_if_they_can_afford_it 1.9
## The_UK_should_deport_asylum_seekers_to_third_countries_like_Rwanda_if_they_arrive_through_irregular_routes 1.1
## National_service_military_or_civic_should_be_mandatory_for_young_adults_in_the_UK 1.9
## I_support_the_LGBT_community 1.0
## I_support_gay_marriage 1.0
## There_is_nothing_wrong_with_public_depictions_of_homosexual_relationships 1.0
## Everyone_should_be_addressed_by_their_desired_pronouns 2.7
## There_are_only_two_genders 2.9
## I_support_feminism 2.1
## Abortion_should_be_available_to_women_for_use_for_any_reason 2.0
## Children_should_be_taught_about_gay_sex_in_sex_education_classes 1.2
## There_is_nothing_wrong_with_attending_a_gay_orgy 1.1
## Men_should_be_masculine_and_women_should_be_feminine 1.5
## Immigration_policy_should_be_strict_and_heavily_meritorious 1.1
## Progressive_taxation_where_the_rich_are_taxed_at_a_higher_rate_is_the_best_way_to_structure_a_tax_system 1.1
## The_government_should_help_ensure_sexual_equality_by_making_sure_women_are_not_discriminated_against_in_private_hiring 4.0
## Public_policy_changes_do_not_need_to_be_made_to_deal_with_climate_change 2.3
## ADHD 5.2
## Alcoholism 2.5
## Drug_abuse 1.1
## Autism 3.2
## Bipolar 1.2
## BPD 1.3
## Depression 1.6
## Anxiety 1.2
## OCD 4.8
## Panic 3.9
## Social_phobia 5.7
## Specific_phobia 5.3
## PTSD 1.5
## Schioid 3.9
## Sleep_disorders 1.6
##
## MR1 MR5 MR2 MR3 MR8 MR4 MR6 MR7 MR9 MR11 MR10
## SS loadings 5.35 4.00 3.71 3.62 2.57 1.82 1.51 1.48 1.42 1.18 1.16
## Proportion Var 0.07 0.05 0.05 0.05 0.03 0.02 0.02 0.02 0.02 0.02 0.02
## Cumulative Var 0.07 0.12 0.17 0.22 0.26 0.28 0.30 0.32 0.34 0.36 0.37
## Proportion Explained 0.19 0.14 0.13 0.13 0.09 0.07 0.05 0.05 0.05 0.04 0.04
## Cumulative Proportion 0.19 0.34 0.47 0.60 0.69 0.76 0.81 0.86 0.92 0.96 1.00
##
## With factor correlations of
## MR1 MR5 MR2 MR3 MR8 MR4 MR6 MR7 MR9 MR11 MR10
## MR1 1.00 -0.44 -0.01 0.32 0.36 0.10 0.09 0.00 -0.01 0.21 0.07
## MR5 -0.44 1.00 0.00 -0.40 -0.30 -0.06 0.11 -0.02 -0.03 -0.29 0.00
## MR2 -0.01 0.00 1.00 0.06 0.04 -0.05 0.06 -0.10 -0.27 -0.01 -0.06
## MR3 0.32 -0.40 0.06 1.00 0.35 0.11 0.04 -0.04 0.08 0.17 -0.02
## MR8 0.36 -0.30 0.04 0.35 1.00 0.04 -0.08 -0.01 0.07 0.15 -0.03
## MR4 0.10 -0.06 -0.05 0.11 0.04 1.00 0.07 0.09 0.05 0.01 0.13
## MR6 0.09 0.11 0.06 0.04 -0.08 0.07 1.00 0.02 -0.06 -0.13 0.00
## MR7 0.00 -0.02 -0.10 -0.04 -0.01 0.09 0.02 1.00 0.05 0.00 0.18
## MR9 -0.01 -0.03 -0.27 0.08 0.07 0.05 -0.06 0.05 1.00 0.08 0.07
## MR11 0.21 -0.29 -0.01 0.17 0.15 0.01 -0.13 0.00 0.08 1.00 -0.01
## MR10 0.07 0.00 -0.06 -0.02 -0.03 0.13 0.00 0.18 0.07 -0.01 1.00
##
## Mean item complexity = 2.3
## Test of the hypothesis that 11 factors are sufficient.
##
## df null model = 2775 with the objective function = 29.1 with Chi Square = 13496
## df of the model are 2005 and the objective function was 6.75
##
## The root mean square of the residuals (RMSR) is 0.03
## The df corrected root mean square of the residuals is 0.04
##
## The harmonic n.obs is 490 with the empirical chi square 2472 with prob < 2.9e-12
## The total n.obs was 490 with Likelihood Chi Square = 3076 with prob < 1.4e-48
##
## Tucker Lewis Index of factoring reliability = 0.859
## RMSEA index = 0.033 and the 90 % confidence intervals are 0.031 0.035
## BIC = -9344
## Fit based upon off diagonal values = 0.97
## Measures of factor score adequacy
## MR1 MR5 MR2 MR3 MR8 MR4
## Correlation of (regression) scores with factors 0.97 0.95 0.92 0.93 0.91 0.87
## Multiple R square of scores with factors 0.93 0.90 0.84 0.87 0.83 0.76
## Minimum correlation of possible factor scores 0.87 0.80 0.68 0.74 0.66 0.52
## MR6 MR7 MR9 MR11 MR10
## Correlation of (regression) scores with factors 0.86 0.87 0.82 0.83 0.82
## Multiple R square of scores with factors 0.73 0.76 0.67 0.68 0.67
## Minimum correlation of possible factor scores 0.47 0.52 0.34 0.37 0.33
#save scores
d$dim1 = fa_fit$scores[, 1]
d$dim2 = fa_fit$scores[, 2]
d$dim3 = fa_fit$scores[, 3]
d$dim4 = fa_fit$scores[, 4]
d$dim5 = fa_fit$scores[, 5]
d$dim6 = fa_fit$scores[, 6]
d$dim7 = fa_fit$scores[, 7]
d$dim8 = fa_fit$scores[, 8]
d$dim9 = fa_fit$scores[, 9]
d$dim10 = fa_fit$scores[, 10]
d$dim11 = fa_fit$scores[, 11]
#plots
d %>%
ggplot(aes(dim1, dim2, color = party)) +
geom_point()
d %>%
ggplot(aes(dim1, dim2, color = leftism)) +
geom_point() +
scale_color_gradient2(
low = "blue", mid = "white", high = "red",
midpoint = 0,
limits = c(-3, 3)
)
d %>%
ggplot(aes(dim1, dim2, color = pol_knowledge)) +
geom_point() +
scale_color_gradient2(
low = "blue", mid = "white", high = "red",
midpoint = 0,
limits = c(-3, 3)
)
#var cors
d %>%
select(
matches("dim\\d+"),
leftism, pol_knowledge, age, diagnoses_count, tattoos_count, piercings_count, nonear_piercings_count
) %>%
GG_heatmap(reorder_vars = F)
#versions
write_sessioninfo()
## R version 4.5.1 (2025-06-13)
## Platform: x86_64-pc-linux-gnu
## Running under: Linux Mint 21.1
##
## Matrix products: default
## BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.10.0
## LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0 LAPACK version 3.10.0
##
## locale:
## [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
## [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
## [5] LC_MONETARY=en_DK.UTF-8 LC_MESSAGES=en_US.UTF-8
## [7] LC_PAPER=en_DK.UTF-8 LC_NAME=C
## [9] LC_ADDRESS=C LC_TELEPHONE=C
## [11] LC_MEASUREMENT=en_DK.UTF-8 LC_IDENTIFICATION=C
##
## time zone: Europe/Brussels
## tzcode source: system (glibc)
##
## attached base packages:
## [1] stats4 stats graphics grDevices utils datasets methods
## [8] base
##
## other attached packages:
## [1] broom_1.0.8 pscl_1.5.9 ggeffects_2.2.1
## [4] rms_8.0-0 mgcv_1.9-1 nlme_3.1-168
## [7] mirt_1.44.0 lattice_0.22-5 kirkegaard_2025-09-01
## [10] psych_2.5.3 assertthat_0.2.1 weights_1.0.4
## [13] Hmisc_5.2-3 magrittr_2.0.3 lubridate_1.9.4
## [16] forcats_1.0.0 stringr_1.5.1 dplyr_1.1.4
## [19] purrr_1.0.4 readr_2.1.5 tidyr_1.3.1
## [22] tibble_3.2.1 ggplot2_3.5.2 tidyverse_2.0.0
##
## loaded via a namespace (and not attached):
## [1] splines_4.5.1 polspline_1.1.25 R.oo_1.27.0
## [4] datawizard_1.2.0 rpart_4.1.24 lifecycle_1.0.4
## [7] Rdpack_2.6.4 globals_0.17.0 vroom_1.6.5
## [10] MASS_7.3-65 insight_1.3.1 backports_1.5.0
## [13] sass_0.4.10 rmarkdown_2.29 jquerylib_0.1.4
## [16] yaml_2.3.10 zip_2.3.2 askpass_1.2.1
## [19] sessioninfo_1.2.3 pbapply_1.7-2 minqa_1.2.8
## [22] multcomp_1.4-28 audio_0.1-11 R.utils_2.13.0
## [25] nnet_7.3-20 TH.data_1.1-3 sandwich_3.1-1
## [28] gdtools_0.4.2 listenv_0.9.1 gdata_3.0.1
## [31] testthat_3.2.3 vegan_2.6-10 MatrixModels_0.5-4
## [34] parallelly_1.43.0 permute_0.9-7 codetools_0.2-19
## [37] xml2_1.3.8 tidyselect_1.2.1 shape_1.4.6.1
## [40] farver_2.1.2 lme4_1.1-37 base64enc_0.1-3
## [43] jsonlite_2.0.0 polycor_0.8-1 mitml_0.4-5
## [46] progressr_0.15.1 Formula_1.2-5 survival_3.8-3
## [49] iterators_1.0.14 systemfonts_1.2.2 foreach_1.5.2
## [52] tools_4.5.1 ragg_1.4.0 Rcpp_1.0.14
## [55] glue_1.8.0 mnormt_2.1.1 gridExtra_2.3
## [58] pan_1.9 xfun_0.52 admisc_0.38
## [61] withr_3.0.2 beepr_2.0 fastmap_1.2.0
## [64] boot_1.3-32 SparseM_1.84-2 openssl_2.3.2
## [67] digest_0.6.37 timechange_0.3.0 R6_2.6.1
## [70] mice_3.17.0 textshaping_1.0.0 colorspace_2.1-1
## [73] gtools_3.9.5 R.methodsS3_1.8.2 generics_0.1.3
## [76] fontLiberation_0.1.0 data.table_1.17.0 SimDesign_2.19.2
## [79] htmlwidgets_1.6.4 pkgconfig_2.0.3 gtable_0.3.6
## [82] brio_1.1.5 htmltools_0.5.8.1 fontBitstreamVera_0.1.1
## [85] scales_1.3.0 reformulas_0.4.0 knitr_1.50
## [88] rstudioapi_0.17.1 tzdb_0.5.0 uuid_1.2-1
## [91] checkmate_2.3.2 nloptr_2.2.1 cachem_1.1.0
## [94] zoo_1.8-14 flextable_0.9.7 parallel_4.5.1
## [97] foreign_0.8-90 pillar_1.10.2 grid_4.5.1
## [100] vctrs_0.6.5 jomo_2.7-6 Deriv_4.1.6
## [103] cluster_2.1.8.1 dcurver_0.9.2 archive_1.1.12
## [106] GPArotation_2025.3-1 htmlTable_2.4.3 evaluate_1.0.3
## [109] mvtnorm_1.3-3 cli_3.6.4 compiler_4.5.1
## [112] rlang_1.1.6 crayon_1.5.3 future.apply_1.11.3
## [115] labeling_0.4.3 plyr_1.8.9 stringi_1.8.7
## [118] munsell_0.5.1 glmnet_4.1-8 quantreg_6.1
## [121] fontquiver_0.2.1 Matrix_1.7-4 hms_1.1.3
## [124] bit64_4.6.0-1 future_1.40.0 haven_2.5.4
## [127] rbibutils_2.3 bslib_0.9.0 bit_4.6.0
## [130] officer_0.6.8
#write data to file for reuse
d %>%
select(
-SessionID,
-Referer,
-User_Agent,
-IP_Address
) %>%
write_rds("data/data_for_reuse.rds")
#OSF
if (F) {
library(osfr)
#login
osf_auth(readr::read_lines("~/.config/osf_token"))
#the project we will use
osf_proj = osf_retrieve_node("https://osf.io/2tjgb/")
#upload all files in project
#overwrite existing (versioning)
osf_upload(
osf_proj,
path = c("data", "figures", "papers", "notebook.Rmd", "notebook.html", "sessions_info.txt"),
conflicts = "overwrite"
)
}