Init

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.1     ✔ tibble    3.2.1
## ✔ lubridate 1.9.3     ✔ tidyr     1.3.1
## ✔ purrr     1.0.2     
## ── 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,
  ordinal
)
## Loading required package: stats4
## Loading required package: lattice
## 
## Attaching package: 'ordinal'
## 
## The following object is masked from 'package:dplyr':
## 
##     slice
theme_set(theme_bw())

options(
    digits = 3
)

Functions

#get question text
get_question_text = function(x, which = "text") {
  #doesnt exist
  assert_that(x %in% names(d), msg = str_glue("Variable {x} not found in data."))
  
  #not in dictionary
  assert_that(x %in% d_table$question, msg = str_glue("Variable {x} not found in dictionary."))
  
  #try
  d_table %>% filter(question == x) %>% pull(!!which)
}

#fit models
fit_models = function(outcomes, min_questions, pred, sex_interact = F, control_location = F, data = d) {
  #alternative subset to use
  dd = data %>% filter(questions_per_user >= min_questions)
  
  map_df(outcomes, \(outcome) {
    #kind of predictors
    if (pred == "combined") {
      preds = "dog_cat"
      if (sex_interact) preds = "dog_cat * gender2"
    } else if (pred == "binary") {
      preds = "likes_dogs + likes_cats"
      if (sex_interact) preds = "likes_dogs * gender2 + likes_cats * gender2"
    } else if (pred == "interaction") {
      preds = "likes_dogs * likes_cats"
      if (sex_interact) preds = "likes_dogs * likes_cats * gender2"
    }
    
    #control for location as well
    if (control_location) {
      preds = str_glue("{preds} + location")
    }
    
    #make formula
    form = as.formula(str_glue("{outcome} ~ {preds} + age + gender2"))

    #fit linear or logistic or ordinal
    if (is.numeric(d[[outcome]])) {
      m = lm(form, data = dd)
    } else if (is.logical(d[[outcome]]) | length(na.omit(d[[outcome]])) == 2) {
      #binary, logistic
      m = glm(form, data = dd, family = "binomial")
    } else if (is.ordered(d[[outcome]])) {
      #ordinal
      m = clm(form, data = dd)
    }
    
    #make tidy
    #add outcome and model data
    m %<>% 
      broom::tidy() %>% 
      mutate(
        y = outcome,
        sample_size = nobs(m)
        )
  })
}

Data

d = read_rds("data/data_out.rds")

d_table = read_csv2("data/question_data.csv")
## ℹ Using "','" as decimal and "'.'" as grouping mark. Use `read_delim()` for more control.
## Rows: 2620 Columns: 10
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ";"
## chr (9): question, text, option_1, option_2, option_3, option_4, Type, Order...
## dbl (1): N
## 
## ℹ 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.
#encode location a bit better
d$d_country %>% table2()
d$location = d$d_country %>% 
  fct_lump_min(min = 20)

d$location %>% table2()
#add an id
d$row_id = 1:nrow(d)

Recode

#questions per user
d$questions_per_user = d %>% select(starts_with("q")) %>% miss_by_case(reverse = T)

d$questions_per_user %>% 
  GG_denhist(vline = NULL)
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

#the 500 questions minimum subset
min500_idx = d %>% filter(questions_per_user >= 500) %>% pull(row_id)

#dog cat people
d$dog_cat = d$q997 %>% fct_relevel("Neither")
get_question_text("q997")
## [1] "Are you a cat person or a dog person?"
#binary
d$likes_dogs = d$q997 %in% c("Dogs", "Both")
d$likes_cats = d$q997 %in% c("Cats", "Both")

#reverse coding of orientation so that het male is ref
d$sex_orientation %<>% fct_rev()

d$d_gender %>% table2()
d$d_gender %>% table2(include_NA = F)
d$gender3 = d$d_gender %>% mapvalues(from = c("Cis Man", "Man, Cis Man", "Cis Woman, Woman", "Cis Woman", "Woman, Cis Woman"), to = c(rep("Man", 2), rep("Woman", 3))) %>% fct_lump(prop = .03) %>% fct_relevel("Man")
d$gender3 %>% table2()
d$gender2 = d$gender3 %>% mapvalues(from = "Other", to = NA)

d$d_orientation %>% table2()
d$orientation4 = d$d_orientation %>% fct_lump(prop = 0.01) %>% fct_relevel("Straight")
d$orientation3 = d$orientation4 %>% mapvalues(from = "Other", to = NA)
d$orientation3 %>% table2()
d$sapiosexual = str_detect(d$d_orientation, "apiosexual")

#resource conservation/prudence
d$recycles = d$q167 %>% fct_rev()
d$conserves_resources = d$q33602 %>% fct_rev()
d$reuseable_bags = d$q64022 %>% fct_rev()
d$keeps_a_budget = d$q20418
d$careful_with_money = d$q16713 %>% fct_rev()
d$likes_random_important_decisions = d$q55
d$regrets_decisions = d$q23811
d$impulsive_shopping = d$q488

#coordination
d$am_on_time = d$q94 %>% fct_rev()
d$other_people_being_late_bothers_me = d$q62140
d$lets_others_in_front = d$q36790 %>% fct_rev()
d$bags_own_wares = d$q35102 %>% fct_rev()
d$responsible = d$q320

#littering
d$picks_up_after_self = d$q21488
d$puts_wares_back = d$q17056 %>% fct_rev()
d$puts_cart_back = d$q32057 %>% fct_rev()
d$litters = d$q17017
d$against_cigaret_littering = (ifelse(as.numeric(d$q20950) == 2, 1, 0)) %>% ordered()
d$cigaret_littering_is_littering = d$q74381 %>% fct_rev()

#antisocial criminal
d %<>% mutate(
  arrested = (q252 == "Yes"),
  prison = (q1138 == "Yes"),
  punched_in_face = (q196 == "Yes"),
  cheated_exam = (q400 == "Yes"),
  would_tax_cheat = (q180 == "Yes"),
  stole_glass_from_bar = (q59919 == "Yes."),
  used_fake_id = (q22569 == "Yes"),
  torture_animal_for_fun = (q19928 != "NO WAY!"),
  steal_newspapers = (q39226 != "Pay for a paper and close the dispenser."),
  litter = (q17017 != "Never"),
  cigaret_littering = (q74381 == "No."),
  hit_SO_in_anger = (q81783 == "Yes.")
)

#fertility
d$ideal_number_children = d$q979
d$have_children = d$q105 == "Yes"

#conservatism
d %<>% mutate(
  political_views = q212813,
  flag_burning = q175,
  abortion = q838,
  gun_control = q27921,
  gay_parents = q37708,
  cannabis = q59457,
  food_stamps = q34113,
  prostitution = q218,
  welfare_system = q486,
  capitalism = q214,
  communism = q174,
  cons_talk_radio = q244,
  death_penalty = q169,
  healthcare_public = q52719,
  higher_taxes_rich = q15751
)

#extroversion

d %<>% mutate(
  wild_parties = q307,
  social_private = q63,
  socially_awkward = q60577,
  concerts = q18857,
  countries_visited = q23305,
  willing_to_meet = q16053,
  alcohol = q77,
  flight_invisibility = q445141,
  like_beer = q1112,
  clubbing = q81,
  like_being_drunk = q78,
  enjoy_big_party = q365,
  go_out_often = q84,
  party_size = q1309,
  dance_party = q60318,
  
)

#intellectualism
d %<>% mutate(
  discussing_politics = q403,
  enjoy_intense_conversions = q358084,
  enjoy_debates = q21411,
  partner_must_read = q1119,
  read_vs_tv = q91,
  partner_philosopical_discussion = q40194,
  preference_talk = q49107,
  books_own = q34662,
  books_last_year = q542,
  like_to_argue = q57,
)

#drugs
d %<>% mutate(
  ok_partner_does_drugs = q9688,
  harder_drugs = q80,
  cannabis = q79,
  drugs_romantic = q25228,
  would_smoke_weed = q62254,
  psychedelics = q15414,
  could_obtain_drugs = q40319,
  drugs_wrong = q868
)

#religiousness
d %<>% mutate(
  god_religion_importance = q41,
  contraception_wrong = q24125,
  homosexuality_sin = q70,
  evolution_creationism = q612,
  christian = q156913,
  believe_in_god = q210,
  power_of_prayer = q48372,
  gay_marriage = q219,
  creationism = q411,
  some_religions_more_correct = q44,
  who_is_smartest = q265,
  curse_christ = q34641,
  duty_god = q42,
  atheist = q156917,
  atheist_morals = q47764
)

#kinkiness sex interest
d %<>% mutate(
  sex_frequency = q12605,
  same_sex_tried = q1401,
  open_new_things_in_bed = q35355,
  sex_drive = q63114,
  partner_kinkier_than_you = q18530,
  gentle_rough = q1028,
  partner_experienced = q23993,
  slut_ok = q393,
  enjoy_oral = q30169,
  group_sex = q32,
  partner_gentle_love = q72086,
  confidence = q323,
  public_sex = q637,
  masturbation = q321556,
  fetish_friendly = q665,
  sex_toys = q26,
  porn_hardcore = q18966,
)

Results

Simple

d$dog_cat %>% 
  table2()

IRT models

Intelligence

#save updated version for easier use later
g_items = read_csv("data/g_items.csv")
## Rows: 14 Columns: 9
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (7): var, text, option_1, option_2, option_3, option_4, correct
## dbl (2): ID, option_correct
## 
## ℹ 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.
#score items
scored_items = score_items(d[g_items$var], g_items$correct)
scored_items_count = miss_by_case(scored_items, reverse = T)

#nicer names
names(scored_items) = c(
  "which_bigger_earth_sun",
  "stale_steal",
  "number_series",
  "left_handed_glove",
  "wherefore_art_thou",
  "fortnights",
  "syllogism",
  "mile_kilometer",
  "birds_electricity",
  "etymology",
  "syllogism2",
  "ideal_gas_law",
  "coin_flips",
  "day_before_after"
)

#mirt
mirt_g = mirt(
  scored_items,
  model = 1,
  itemtype = "2PL"
)
## Warning: data contains response patterns with only NAs
## Iteration: 1, Log-Lik: -188768.194, Max-Change: 5.04127Iteration: 2, Log-Lik: -167586.674, Max-Change: 0.93778Iteration: 3, Log-Lik: -163943.799, Max-Change: 0.34531Iteration: 4, Log-Lik: -162360.344, Max-Change: 0.28657Iteration: 5, Log-Lik: -161709.787, Max-Change: 0.22768Iteration: 6, Log-Lik: -161353.642, Max-Change: 0.16053Iteration: 7, Log-Lik: -161173.781, Max-Change: 0.09737Iteration: 8, Log-Lik: -161064.493, Max-Change: 0.22971Iteration: 9, Log-Lik: -160991.363, Max-Change: 0.12791Iteration: 10, Log-Lik: -160959.392, Max-Change: 0.07594Iteration: 11, Log-Lik: -160939.094, Max-Change: 0.04297Iteration: 12, Log-Lik: -160925.798, Max-Change: 0.04225Iteration: 13, Log-Lik: -160916.474, Max-Change: 0.02643Iteration: 14, Log-Lik: -160913.117, Max-Change: 0.01116Iteration: 15, Log-Lik: -160909.698, Max-Change: 0.00764Iteration: 16, Log-Lik: -160907.840, Max-Change: 0.00427Iteration: 17, Log-Lik: -160907.466, Max-Change: 0.00338Iteration: 18, Log-Lik: -160907.281, Max-Change: 0.00242Iteration: 19, Log-Lik: -160907.163, Max-Change: 0.00138Iteration: 20, Log-Lik: -160907.136, Max-Change: 0.00128Iteration: 21, Log-Lik: -160907.121, Max-Change: 0.00118Iteration: 22, Log-Lik: -160907.111, Max-Change: 0.00045Iteration: 23, Log-Lik: -160907.109, Max-Change: 0.00028Iteration: 24, Log-Lik: -160907.108, Max-Change: 0.00025Iteration: 25, Log-Lik: -160907.108, Max-Change: 0.00024Iteration: 26, Log-Lik: -160907.107, Max-Change: 0.00008
mirt_g %>% summary()
##                           F1    h2
## which_bigger_earth_sun 0.716 0.513
## stale_steal            0.699 0.489
## number_series          0.748 0.560
## left_handed_glove      0.363 0.131
## wherefore_art_thou     0.713 0.508
## fortnights             0.747 0.558
## syllogism              0.586 0.344
## mile_kilometer         0.607 0.369
## birds_electricity      0.374 0.140
## etymology              0.752 0.565
## syllogism2             0.481 0.231
## ideal_gas_law          0.701 0.491
## coin_flips             0.685 0.470
## day_before_after       0.699 0.489
## 
## SS loadings:  5.86 
## Proportion Var:  0.418 
## 
## Factor correlations: 
## 
##    F1
## F1  1
mirt_g_scores = fscores(mirt_g, full.scores = T, full.scores.SE = T)

#reliability
empirical_rxx(mirt_g_scores)
##    F1 
## 0.549
(rel_g = empirical_rxx(mirt_g_scores[min500_idx, ]))
##   F1 
## 0.61
marginal_rxx(mirt_g)
## [1] 0.764
#save to main
d$g = mirt_g_scores[, 1] %>% standardize(focal_group = d$race=="White")
## Warning in standardize(., focal_group = d$race == "White"): `focal_group`
## contains `NA` values. These were converted to `FALSE` following tidyverse
## convention.
d$g_items_count = scored_items_count

Mental health

#reverse coding on one item
d$q50 %<>% fct_rev()

#items
mental_health_items = c(
  seen_therapist = "q50",
  much_depression = "q1552",
  emotional_diversity = "q6021",
  happy_with_life = "q4018",
  exp_mental_illness = "q1287"
)

#output var data
d_table %>% filter(question %in% (!!mental_health_items)) %>% select(question, text, option_1:option_4, N)
#copy to new names
for (v in mental_health_items) {
  d[[names(mental_health_items)[which(v == mental_health_items)]]] = d[[v]]
} 

#print items
for (v in mental_health_items) {
  print(str_glue("{v} - {names(mental_health_items)[which(v == mental_health_items)]}: {get_question_text(v)}"))
  print(table2(d[[v]], include_NA = F, sort_descending = NULL))
  cat("\n")
}
## q50 - seen_therapist: Have you ever seen a therapist?
## # A tibble: 2 × 3
##   Group Count Percent
##   <fct> <dbl>   <dbl>
## 1 No     3826    40.2
## 2 Yes    5681    59.8
## 
## q1552 - much_depression: Do you get depressed much?
## # A tibble: 3 × 3
##   Group                          Count Percent
##   <fct>                          <dbl>   <dbl>
## 1 Almost never, I'm happy!        3261   32.7 
## 2 Sometimes, when it's a bad day  6295   63.2 
## 3 Yeah, despair is my life         402    4.04
## 
## q6021 - emotional_diversity: How would you describe your emotional diversity?
## # A tibble: 4 × 3
##   Group                                          Count Percent
##   <fct>                                          <dbl>   <dbl>
## 1 I get extremely happy but rarely depressed      1428   32.7 
## 2 I get extremely depressed and I'm rarely happy   202    4.63
## 3 I don't feel much of either                      731   16.7 
## 4 I feel both often                               2006   45.9 
## 
## q4018 - happy_with_life: Are you happy with your life?
## # A tibble: 2 × 3
##   Group Count Percent
##   <fct> <dbl>   <dbl>
## 1 Yes   49586   92.5 
## 2 No     4039    7.53
## 
## q1287 - exp_mental_illness: Have you experienced mental illness?
## # A tibble: 4 × 3
##   Group           Count Percent
##   <fct>           <dbl>   <dbl>
## 1 No              10501   58.5 
## 2 I'm not sure     2540   14.2 
## 3 Yes - low grade  3843   21.4 
## 4 Yes - severely   1061    5.91
#factor analyze with default mirt settings, some items are binary, some are ordinal, one is categorical
mirt_mh = mirt(
  data = d %>% select(!!mental_health_items) %>% map_df(as.numeric),
  model = 1,
  itemtype = c("2PL", "nominal", "nominal", "2PL", "nominal"),
  technical = list(removeEmptyRows = T)
)
## Warning: removeEmptyRows option has been deprecated. Complete NA response
## vectors now supported by using NA placeholders
## Warning: data contains response patterns with only NAs
## Iteration: 1, Log-Lik: -67060.043, Max-Change: 2.38811Iteration: 2, Log-Lik: -53004.128, Max-Change: 1.49423Iteration: 3, Log-Lik: -51422.869, Max-Change: 0.75200Iteration: 4, Log-Lik: -51096.832, Max-Change: 0.87695Iteration: 5, Log-Lik: -50907.603, Max-Change: 0.55862Iteration: 6, Log-Lik: -50797.116, Max-Change: 0.53455Iteration: 7, Log-Lik: -50725.979, Max-Change: 0.39774Iteration: 8, Log-Lik: -50680.333, Max-Change: 0.18697Iteration: 9, Log-Lik: -50650.731, Max-Change: 0.17559Iteration: 10, Log-Lik: -50630.990, Max-Change: 0.08875Iteration: 11, Log-Lik: -50618.058, Max-Change: 0.12700Iteration: 12, Log-Lik: -50609.103, Max-Change: 0.08946Iteration: 13, Log-Lik: -50603.099, Max-Change: 0.05713Iteration: 14, Log-Lik: -50598.924, Max-Change: 0.03379Iteration: 15, Log-Lik: -50596.081, Max-Change: 0.03510Iteration: 16, Log-Lik: -50592.013, Max-Change: 0.02334Iteration: 17, Log-Lik: -50590.756, Max-Change: 0.02099Iteration: 18, Log-Lik: -50590.010, Max-Change: 0.01844Iteration: 19, Log-Lik: -50588.529, Max-Change: 0.00654Iteration: 20, Log-Lik: -50588.415, Max-Change: 0.00544Iteration: 21, Log-Lik: -50588.354, Max-Change: 0.00406Iteration: 22, Log-Lik: -50588.302, Max-Change: 0.00391Iteration: 23, Log-Lik: -50588.273, Max-Change: 0.00342Iteration: 24, Log-Lik: -50588.252, Max-Change: 0.00339Iteration: 25, Log-Lik: -50588.171, Max-Change: 0.00172Iteration: 26, Log-Lik: -50588.167, Max-Change: 0.00344Iteration: 27, Log-Lik: -50588.158, Max-Change: 0.00067Iteration: 28, Log-Lik: -50588.158, Max-Change: 0.00049Iteration: 29, Log-Lik: -50588.156, Max-Change: 0.00189Iteration: 30, Log-Lik: -50588.152, Max-Change: 0.00009
mirt_mh
## 
## Call:
## mirt(data = d %>% select(!!mental_health_items) %>% map_df(as.numeric), 
##     model = 1, itemtype = c("2PL", "nominal", "nominal", "2PL", 
##         "nominal"), technical = list(removeEmptyRows = T))
## 
## Full-information item factor analysis with 1 factor(s).
## Converged within 1e-04 tolerance after 30 EM iterations.
## mirt version: 1.42 
## M-step optimizer: BFGS 
## EM acceleration: Ramsay 
## Number of rectangular quadrature: 61
## Latent density type: Gaussian 
## 
## Log-likelihood = -50588
## Estimated parameters: 20 
## AIC = 101216
## BIC = 101395; SABIC = 101331
mirt_mh %>% summary()
##                        F1    h2
## seen_therapist      0.483 0.233
## much_depression     0.881 0.776
## emotional_diversity 0.505 0.255
## happy_with_life     0.630 0.397
## exp_mental_illness  0.433 0.188
## 
## SS loadings:  1.85 
## Proportion Var:  0.37 
## 
## Factor correlations: 
## 
##    F1
## F1  1
#score
mirt_mh_scores = fscores(mirt_mh, full.scores = T, full.scores.SE = T)

#reliability
empirical_rxx(mirt_mh_scores)
##    F1 
## 0.261
(rel_mh = empirical_rxx(mirt_mh_scores[min500_idx, ]))
##    F1 
## 0.429
marginal_rxx(mirt_mh)
## [1] 0.72
#save scores
d$mental_health = mirt_mh_scores[, 1] %>% standardize() %>% multiply_by(-1)

Antisocial behavior

mirt_antisocial = mirt(
  data = d %>% select(
    cheated_exam, would_tax_cheat, stole_glass_from_bar, used_fake_id, steal_newspapers, litter, cigaret_littering, picks_up_after_self, puts_wares_back, puts_cart_back, against_cigaret_littering, arrested, prison, punched_in_face, torture_animal_for_fun, hit_SO_in_anger) %>% 
    map_df(as.numeric),
  model = 1
)
## Warning: data contains response patterns with only NAs
## Iteration: 1, Log-Lik: -191576.992, Max-Change: 10.58678Iteration: 2, Log-Lik: -147599.892, Max-Change: 2.93212Iteration: 3, Log-Lik: -135356.291, Max-Change: 1.65466Iteration: 4, Log-Lik: -131812.794, Max-Change: 1.30852Iteration: 5, Log-Lik: -130295.655, Max-Change: 0.46061Iteration: 6, Log-Lik: -129734.967, Max-Change: 0.47967Iteration: 7, Log-Lik: -129392.740, Max-Change: 0.42417Iteration: 8, Log-Lik: -129201.580, Max-Change: 0.19169Iteration: 9, Log-Lik: -129092.282, Max-Change: 0.26791Iteration: 10, Log-Lik: -128977.673, Max-Change: 0.15638Iteration: 11, Log-Lik: -128898.884, Max-Change: 0.12733Iteration: 12, Log-Lik: -128850.235, Max-Change: 0.11712Iteration: 13, Log-Lik: -128813.810, Max-Change: 0.09658Iteration: 14, Log-Lik: -128789.625, Max-Change: 0.08316Iteration: 15, Log-Lik: -128771.789, Max-Change: 0.07764Iteration: 16, Log-Lik: -128758.609, Max-Change: 0.08311Iteration: 17, Log-Lik: -128747.136, Max-Change: 0.06445Iteration: 18, Log-Lik: -128739.646, Max-Change: 0.06057Iteration: 19, Log-Lik: -128734.008, Max-Change: 0.06539Iteration: 20, Log-Lik: -128729.218, Max-Change: 0.05012Iteration: 21, Log-Lik: -128726.131, Max-Change: 0.05080Iteration: 22, Log-Lik: -128717.165, Max-Change: 0.01513Iteration: 23, Log-Lik: -128716.716, Max-Change: 0.01400Iteration: 24, Log-Lik: -128716.603, Max-Change: 0.01332Iteration: 25, Log-Lik: -128716.520, Max-Change: 0.00566Iteration: 26, Log-Lik: -128716.408, Max-Change: 0.00243Iteration: 27, Log-Lik: -128716.395, Max-Change: 0.00118Iteration: 28, Log-Lik: -128716.391, Max-Change: 0.00038Iteration: 29, Log-Lik: -128716.390, Max-Change: 0.00040Iteration: 30, Log-Lik: -128716.389, Max-Change: 0.00043Iteration: 31, Log-Lik: -128716.389, Max-Change: 0.00028Iteration: 32, Log-Lik: -128716.388, Max-Change: 0.00027Iteration: 33, Log-Lik: -128716.388, Max-Change: 0.00030Iteration: 34, Log-Lik: -128716.387, Max-Change: 0.00021Iteration: 35, Log-Lik: -128716.387, Max-Change: 0.00021Iteration: 36, Log-Lik: -128716.387, Max-Change: 0.00023Iteration: 37, Log-Lik: -128716.387, Max-Change: 0.00015Iteration: 38, Log-Lik: -128716.386, Max-Change: 0.00016Iteration: 39, Log-Lik: -128716.386, Max-Change: 0.00018Iteration: 40, Log-Lik: -128716.386, Max-Change: 0.00013Iteration: 41, Log-Lik: -128716.386, Max-Change: 0.00014Iteration: 42, Log-Lik: -128716.386, Max-Change: 0.00015Iteration: 43, Log-Lik: -128716.386, Max-Change: 0.00011Iteration: 44, Log-Lik: -128716.386, Max-Change: 0.00012Iteration: 45, Log-Lik: -128716.385, Max-Change: 0.00013Iteration: 46, Log-Lik: -128716.385, Max-Change: 0.00010Iteration: 47, Log-Lik: -128716.385, Max-Change: 0.00011Iteration: 48, Log-Lik: -128716.385, Max-Change: 0.00012Iteration: 49, Log-Lik: -128716.385, Max-Change: 0.00010
mirt_antisocial %>% summary()
##                               F1     h2
## cheated_exam               0.524 0.2748
## would_tax_cheat            0.301 0.0905
## stole_glass_from_bar       0.342 0.1168
## used_fake_id               0.347 0.1206
## steal_newspapers           0.600 0.3605
## litter                     0.536 0.2876
## cigaret_littering          0.856 0.7327
## picks_up_after_self       -0.104 0.0109
## puts_wares_back           -0.428 0.1830
## puts_cart_back            -0.258 0.0663
## against_cigaret_littering -0.868 0.7530
## arrested                   0.507 0.2567
## prison                     0.508 0.2583
## punched_in_face            0.400 0.1601
## torture_animal_for_fun     0.414 0.1713
## hit_SO_in_anger            0.403 0.1626
## 
## SS loadings:  4.01 
## Proportion Var:  0.25 
## 
## Factor correlations: 
## 
##    F1
## F1  1
#scores
mirt_antisocial_scores = fscores(mirt_antisocial, full.scores = T, full.scores.SE = T)

#reliability
empirical_rxx(mirt_antisocial_scores)
##    F1 
## 0.415
(rel_antisocial = empirical_rxx(mirt_antisocial_scores[min500_idx, ]))
##    F1 
## 0.496
marginal_rxx(mirt_antisocial)
## [1] 0.66
#save scores
d$antisocial = mirt_antisocial_scores[, 1] %>% standardize()

GG_group_means(d, "antisocial", "gender_orientation")
## Missing values were removed.

Prudence

mirt_prudence = mirt(
  data = d %>% select(
    recycles, conserves_resources, reuseable_bags, keeps_a_budget, careful_with_money, likes_random_important_decisions, regrets_decisions, impulsive_shopping) %>% 
    map_df(as.numeric),
  model = 1
)
## Warning: data contains response patterns with only NAs
## Iteration: 1, Log-Lik: -169407.370, Max-Change: 5.59158Iteration: 2, Log-Lik: -152392.215, Max-Change: 2.70879Iteration: 3, Log-Lik: -149363.877, Max-Change: 0.43758Iteration: 4, Log-Lik: -148525.273, Max-Change: 0.25807Iteration: 5, Log-Lik: -148164.156, Max-Change: 0.26926Iteration: 6, Log-Lik: -147988.329, Max-Change: 0.25548Iteration: 7, Log-Lik: -147868.963, Max-Change: 0.14015Iteration: 8, Log-Lik: -147801.517, Max-Change: 0.04375Iteration: 9, Log-Lik: -147790.789, Max-Change: 0.01258Iteration: 10, Log-Lik: -147788.871, Max-Change: 0.00733Iteration: 11, Log-Lik: -147788.443, Max-Change: 0.00446Iteration: 12, Log-Lik: -147788.296, Max-Change: 0.00332Iteration: 13, Log-Lik: -147788.213, Max-Change: 0.00169Iteration: 14, Log-Lik: -147788.204, Max-Change: 0.00171Iteration: 15, Log-Lik: -147788.190, Max-Change: 0.00058Iteration: 16, Log-Lik: -147788.190, Max-Change: 0.00043Iteration: 17, Log-Lik: -147788.189, Max-Change: 0.00009
mirt_prudence %>% summary()
##                                     F1     h2
## recycles                         0.527 0.2773
## conserves_resources              0.567 0.3218
## reuseable_bags                   0.453 0.2053
## keeps_a_budget                   0.478 0.2289
## careful_with_money               0.657 0.4313
## likes_random_important_decisions 0.234 0.0548
## regrets_decisions                0.183 0.0334
## impulsive_shopping               0.537 0.2884
## 
## SS loadings:  1.84 
## Proportion Var:  0.23 
## 
## Factor correlations: 
## 
##    F1
## F1  1
#scores
mirt_prudence_scores = fscores(mirt_prudence, full.scores = T, full.scores.SE = T)

#reliability
empirical_rxx(mirt_prudence_scores)
##    F1 
## 0.416
empirical_rxx(mirt_prudence_scores[min500_idx, ])
##    F1 
## 0.485
marginal_rxx(mirt_prudence)
## [1] 0.571
#save scores
d$prudence = mirt_prudence_scores[, 1] %>% standardize()

Conservatism

#pol item types
d %>% select(political_views:higher_taxes_rich) %>% map(~table2(.x, include_NA = F))
## $political_views
## # A tibble: 4 × 3
##   Group                     Count Percent
##   <chr>                     <dbl>   <dbl>
## 1 Liberal / Left-wing       20017   44.4 
## 2 Other                     14137   31.3 
## 3 Centrist                   7861   17.4 
## 4 Conservative / Right-wing  3092    6.85
## 
## $flag_burning
## # A tibble: 2 × 3
##   Group Count Percent
##   <chr> <dbl>   <dbl>
## 1 No    29898    65.4
## 2 Yes   15822    34.6
## 
## $abortion
## # A tibble: 2 × 3
##   Group Count Percent
##   <chr> <dbl>   <dbl>
## 1 Yes   33069    74.4
## 2 No    11392    25.6
## 
## $gun_control
## # A tibble: 3 × 3
##   Group            Count Percent
##   <chr>            <dbl>   <dbl>
## 1 Less safe        26022    61.5
## 2 Neither / unsure  9954    23.5
## 3 More safe         6331    15.0
## 
## $gay_parents
## # A tibble: 2 × 3
##   Group           Count Percent
##   <chr>           <dbl>   <dbl>
## 1 Acceptable.     35455   94.1 
## 2 Not acceptable.  2206    5.86
## 
## $cannabis
## # A tibble: 4 × 3
##   Group                                Count Percent
##   <chr>                                <dbl>   <dbl>
## 1 Never.                               20517   41.2 
## 2 I smoked in the past, but no longer. 15863   31.9 
## 3 I smoke occasionally.                10287   20.7 
## 4 I smoke regularly.                    3129    6.28
## 
## $food_stamps
## # A tibble: 4 × 3
##   Group                          Count Percent
##   <chr>                          <dbl>   <dbl>
## 1 Never - Get a job              37271   54.5 
## 2 It's okay, if it is not abused 18029   26.4 
## 3 No problem                      9395   13.7 
## 4 Okay for short amounts of time  3676    5.38
## 
## $prostitution
## # A tibble: 4 × 3
##   Group                          Count Percent
##   <chr>                          <dbl>   <dbl>
## 1 Yes, only if it were regulated 14749   57.4 
## 2 Yes, absolutely                 5427   21.1 
## 3 I don't think so                3587   14.0 
## 4 ABSOLUTELY NOT                  1931    7.52
## 
## $welfare_system
## # A tibble: 2 × 3
##   Group                  Count Percent
##   <chr>                  <dbl>   <dbl>
## 1 Welfare is mostly good 18707    77.3
## 2 Welfare is mostly bad   5484    22.7
## 
## $capitalism
## # A tibble: 2 × 3
##   Group Count Percent
##   <chr> <dbl>   <dbl>
## 1 No    11599    53.1
## 2 Yes   10239    46.9
## 
## $communism
## # A tibble: 4 × 3
##   Group                                       Count Percent
##   <chr>                                       <dbl>   <dbl>
## 1 Good                                         7990    41.2
## 2 Bad                                          5526    28.5
## 3 Same as capitalism                           3130    16.1
## 4 No idea / this question doesn't interest me  2760    14.2
## 
## $cons_talk_radio
## # A tibble: 2 × 3
##   Group Count Percent
##   <chr> <dbl>   <dbl>
## 1 No    15519    86.8
## 2 Yes    2359    13.2
## 
## $death_penalty
## # A tibble: 2 × 3
##   Group Count Percent
##   <chr> <dbl>   <dbl>
## 1 Yes    8539    50.6
## 2 No     8345    49.4
## 
## $healthcare_public
## # A tibble: 4 × 3
##   Group                             Count Percent
##   <chr>                             <dbl>   <dbl>
## 1 Yes, for everyone.                 9178   70.2 
## 2 No.                                1491   11.4 
## 3 Yes, but only for certain people.  1322   10.1 
## 4 I'm not sure.                      1090    8.33
## 
## $higher_taxes_rich
## # A tibble: 2 × 3
##   Group Count Percent
##   <chr> <dbl>   <dbl>
## 1 Yes   18704    81.9
## 2 No     4123    18.1
mirt_conservatism = mirt(
  data = d %>% select(
    political_views:higher_taxes_rich) %>% 
    map_df(as.numeric),
  model = 1,
  itemtype = rep("nominal", 15)
)
## Iteration: 1, Log-Lik: -523695.026, Max-Change: 7.36963Iteration: 2, Log-Lik: -428302.127, Max-Change: 3.69748Iteration: 3, Log-Lik: -397785.054, Max-Change: 2.75165Iteration: 4, Log-Lik: -392538.236, Max-Change: 0.41790Iteration: 5, Log-Lik: -391045.424, Max-Change: 0.30442Iteration: 6, Log-Lik: -390338.989, Max-Change: 0.55380Iteration: 7, Log-Lik: -390018.440, Max-Change: 2.75224Iteration: 8, Log-Lik: -389714.288, Max-Change: 1.23875Iteration: 9, Log-Lik: -389447.665, Max-Change: 2.48457Iteration: 10, Log-Lik: -388832.501, Max-Change: 0.75019Iteration: 11, Log-Lik: -388340.501, Max-Change: 0.50547Iteration: 12, Log-Lik: -388223.975, Max-Change: 0.15849Iteration: 13, Log-Lik: -388175.762, Max-Change: 0.21567Iteration: 14, Log-Lik: -388153.211, Max-Change: 0.08997Iteration: 15, Log-Lik: -388145.456, Max-Change: 0.10185Iteration: 16, Log-Lik: -388141.046, Max-Change: 0.03438Iteration: 17, Log-Lik: -388139.215, Max-Change: 0.01147Iteration: 18, Log-Lik: -388138.412, Max-Change: 0.03064Iteration: 19, Log-Lik: -388137.607, Max-Change: 0.05542Iteration: 20, Log-Lik: -388137.024, Max-Change: 0.00041Iteration: 21, Log-Lik: -388137.016, Max-Change: 0.00041Iteration: 22, Log-Lik: -388137.010, Max-Change: 0.00021Iteration: 23, Log-Lik: -388137.006, Max-Change: 0.00007
mirt_conservatism %>% summary()
##                        F1      h2
## political_views    0.3635 0.13215
## flag_burning      -0.6287 0.39529
## abortion           0.5979 0.35750
## gun_control        0.5131 0.26322
## gay_parents        0.7002 0.49027
## cannabis           0.0793 0.00629
## food_stamps        0.2620 0.06864
## prostitution       0.2307 0.05321
## welfare_system     0.7858 0.61741
## capitalism        -0.3553 0.12627
## communism          0.2233 0.04985
## cons_talk_radio   -0.5644 0.31856
## death_penalty      0.6973 0.48626
## healthcare_public -0.5830 0.33993
## higher_taxes_rich  0.6344 0.40241
## 
## SS loadings:  4.11 
## Proportion Var:  0.274 
## 
## Factor correlations: 
## 
##    F1
## F1  1
#scores
mirt_conservatism_scores = fscores(mirt_conservatism, full.scores = T, full.scores.SE = T)

#reliability
empirical_rxx(mirt_conservatism_scores)
##    F1 
## 0.586
empirical_rxx(mirt_conservatism_scores[min500_idx, ])
##    F1 
## 0.764
marginal_rxx(mirt_conservatism)
## [1] 0.804
#save scores
d$conservatism = mirt_conservatism_scores[, 1] %>% standardize()

Extroversion

mirt_extroversion = mirt(
  data = d %>% select(
    wild_parties, social_private, socially_awkward, concerts, alcohol, like_beer, clubbing, like_being_drunk, enjoy_big_party, go_out_often, dance_party) %>% 
    map_df(as.numeric),
  model = 1,
  itemtype = "nominal"
)
## Warning: data contains response patterns with only NAs
## Iteration: 1, Log-Lik: -310137.025, Max-Change: 3.01315Iteration: 2, Log-Lik: -255389.762, Max-Change: 0.89493Iteration: 3, Log-Lik: -245120.199, Max-Change: 0.50456Iteration: 4, Log-Lik: -241832.276, Max-Change: 0.40570Iteration: 5, Log-Lik: -241153.576, Max-Change: 0.16488Iteration: 6, Log-Lik: -240771.615, Max-Change: 0.12749Iteration: 7, Log-Lik: -240544.268, Max-Change: 0.08660Iteration: 8, Log-Lik: -240420.196, Max-Change: 0.04650Iteration: 9, Log-Lik: -240347.040, Max-Change: 0.03915Iteration: 10, Log-Lik: -240302.316, Max-Change: 0.02716Iteration: 11, Log-Lik: -240274.005, Max-Change: 0.03905Iteration: 12, Log-Lik: -240243.952, Max-Change: 0.01995Iteration: 13, Log-Lik: -240234.039, Max-Change: 0.01559Iteration: 14, Log-Lik: -240226.543, Max-Change: 0.02285Iteration: 15, Log-Lik: -240218.309, Max-Change: 0.01851Iteration: 16, Log-Lik: -240212.949, Max-Change: 0.01456Iteration: 17, Log-Lik: -240210.527, Max-Change: 0.01251Iteration: 18, Log-Lik: -240208.461, Max-Change: 0.01134Iteration: 19, Log-Lik: -240205.839, Max-Change: 0.00497Iteration: 20, Log-Lik: -240205.651, Max-Change: 0.00293Iteration: 21, Log-Lik: -240205.548, Max-Change: 0.00174Iteration: 22, Log-Lik: -240205.498, Max-Change: 0.00098Iteration: 23, Log-Lik: -240205.464, Max-Change: 0.00057Iteration: 24, Log-Lik: -240205.452, Max-Change: 0.00147Iteration: 25, Log-Lik: -240205.434, Max-Change: 0.00067Iteration: 26, Log-Lik: -240205.421, Max-Change: 0.00017Iteration: 27, Log-Lik: -240205.419, Max-Change: 0.00058Iteration: 28, Log-Lik: -240205.414, Max-Change: 0.00027Iteration: 29, Log-Lik: -240205.412, Max-Change: 0.00051Iteration: 30, Log-Lik: -240205.410, Max-Change: 0.00026Iteration: 31, Log-Lik: -240205.409, Max-Change: 0.00016Iteration: 32, Log-Lik: -240205.407, Max-Change: 0.00051Iteration: 33, Log-Lik: -240205.405, Max-Change: 0.00023Iteration: 34, Log-Lik: -240205.404, Max-Change: 0.00015Iteration: 35, Log-Lik: -240205.403, Max-Change: 0.00040Iteration: 36, Log-Lik: -240205.401, Max-Change: 0.00014Iteration: 37, Log-Lik: -240205.401, Max-Change: 0.00011Iteration: 38, Log-Lik: -240205.400, Max-Change: 0.00043Iteration: 39, Log-Lik: -240205.398, Max-Change: 0.00013Iteration: 40, Log-Lik: -240205.397, Max-Change: 0.00009
mirt_extroversion %>% summary()
##                      F1     h2
## wild_parties      0.851 0.7241
## social_private   -0.519 0.2695
## socially_awkward -0.254 0.0646
## concerts          0.290 0.0840
## alcohol           0.536 0.2872
## like_beer         0.550 0.3024
## clubbing          0.564 0.3178
## like_being_drunk  0.629 0.3953
## enjoy_big_party   0.603 0.3640
## go_out_often      0.750 0.5627
## dance_party       0.677 0.4584
## 
## SS loadings:  3.83 
## Proportion Var:  0.348 
## 
## Factor correlations: 
## 
##    F1
## F1  1
#scores
mirt_extroversion_scores = fscores(mirt_extroversion, full.scores = T, full.scores.SE = T)

#reliability
empirical_rxx(mirt_extroversion_scores)
##    F1 
## 0.598
empirical_rxx(mirt_extroversion_scores[min500_idx, ])
##    F1 
## 0.762
marginal_rxx(mirt_extroversion)
## [1] 0.807
#save scores
d$extroversion = mirt_extroversion_scores[, 1] %>% standardize() %>% multiply_by(-1)

GG_group_means(d, "extroversion", "social_private")
## Missing values were removed.

Reading

mirt_reading = mirt(
  data = d %>% select(
    partner_must_read, read_vs_tv, books_own, books_last_year) %>% 
    map_df(as.numeric),
  model = 1,
  itemtype = "nominal"
)
## Warning: data contains response patterns with only NAs
## Iteration: 1, Log-Lik: -98347.494, Max-Change: 2.99811Iteration: 2, Log-Lik: -82847.063, Max-Change: 0.81416Iteration: 3, Log-Lik: -80883.323, Max-Change: 1.30028Iteration: 4, Log-Lik: -77958.786, Max-Change: 0.68391Iteration: 5, Log-Lik: -77382.832, Max-Change: 0.38969Iteration: 6, Log-Lik: -77106.630, Max-Change: 0.25569Iteration: 7, Log-Lik: -76970.822, Max-Change: 0.15959Iteration: 8, Log-Lik: -76897.895, Max-Change: 0.08990Iteration: 9, Log-Lik: -76856.520, Max-Change: 0.04911Iteration: 10, Log-Lik: -76832.926, Max-Change: 0.09552Iteration: 11, Log-Lik: -76820.497, Max-Change: 0.04088Iteration: 12, Log-Lik: -76812.501, Max-Change: 0.05868Iteration: 13, Log-Lik: -76807.769, Max-Change: 0.04769Iteration: 14, Log-Lik: -76804.764, Max-Change: 0.02635Iteration: 15, Log-Lik: -76802.691, Max-Change: 0.01765Iteration: 16, Log-Lik: -76799.990, Max-Change: 0.01360Iteration: 17, Log-Lik: -76799.396, Max-Change: 0.01289Iteration: 18, Log-Lik: -76798.901, Max-Change: 0.00956Iteration: 19, Log-Lik: -76798.193, Max-Change: 0.00685Iteration: 20, Log-Lik: -76798.029, Max-Change: 0.00584Iteration: 21, Log-Lik: -76797.906, Max-Change: 0.00595Iteration: 22, Log-Lik: -76797.502, Max-Change: 0.00152Iteration: 23, Log-Lik: -76797.482, Max-Change: 0.00118Iteration: 24, Log-Lik: -76797.477, Max-Change: 0.00018Iteration: 25, Log-Lik: -76797.477, Max-Change: 0.00016Iteration: 26, Log-Lik: -76797.476, Max-Change: 0.00081Iteration: 27, Log-Lik: -76797.473, Max-Change: 0.00071Iteration: 28, Log-Lik: -76797.471, Max-Change: 0.00018Iteration: 29, Log-Lik: -76797.471, Max-Change: 0.00073Iteration: 30, Log-Lik: -76797.469, Max-Change: 0.00057Iteration: 31, Log-Lik: -76797.468, Max-Change: 0.00013Iteration: 32, Log-Lik: -76797.467, Max-Change: 0.00043Iteration: 33, Log-Lik: -76797.466, Max-Change: 0.00009
mirt_reading %>% summary()
##                       F1    h2
## partner_must_read -0.723 0.522
## read_vs_tv         0.717 0.515
## books_own          0.627 0.393
## books_last_year    0.732 0.536
## 
## SS loadings:  1.97 
## Proportion Var:  0.491 
## 
## Factor correlations: 
## 
##    F1
## F1  1
#scores
mirt_reading_scores = fscores(mirt_reading, full.scores = T, full.scores.SE = T)

#reliability
empirical_rxx(mirt_reading_scores)
##    F1 
## 0.625
empirical_rxx(mirt_reading_scores[min500_idx, ])
##    F1 
## 0.665
marginal_rxx(mirt_reading)
## [1] 0.73
#save scores
d$reading = mirt_reading_scores[, 1] %>% standardize()

Enjoy discussion

mirt_enjoys_discussion = mirt(
  data = d %>% select(
    discussing_politics, enjoy_intense_conversions, enjoy_debates, partner_philosopical_discussion) %>% 
    map_df(as.numeric),
  model = 1,
  itemtype = "nominal"
)
## Warning: data contains response patterns with only NAs
## Iteration: 1, Log-Lik: -160095.589, Max-Change: 2.96569Iteration: 2, Log-Lik: -111754.725, Max-Change: 1.53298Iteration: 3, Log-Lik: -108321.255, Max-Change: 1.04331Iteration: 4, Log-Lik: -106391.351, Max-Change: 1.07515Iteration: 5, Log-Lik: -105625.239, Max-Change: 0.43033Iteration: 6, Log-Lik: -105305.384, Max-Change: 0.43640Iteration: 7, Log-Lik: -105149.629, Max-Change: 0.25867Iteration: 8, Log-Lik: -105077.242, Max-Change: 0.11535Iteration: 9, Log-Lik: -105022.615, Max-Change: 0.15031Iteration: 10, Log-Lik: -104996.482, Max-Change: 0.07950Iteration: 11, Log-Lik: -104981.438, Max-Change: 0.05005Iteration: 12, Log-Lik: -104972.426, Max-Change: 0.02448Iteration: 13, Log-Lik: -104966.634, Max-Change: 0.02124Iteration: 14, Log-Lik: -104962.682, Max-Change: 0.02098Iteration: 15, Log-Lik: -104959.673, Max-Change: 0.04343Iteration: 16, Log-Lik: -104957.089, Max-Change: 0.02246Iteration: 17, Log-Lik: -104955.651, Max-Change: 0.01502Iteration: 18, Log-Lik: -104954.821, Max-Change: 0.03513Iteration: 19, Log-Lik: -104953.963, Max-Change: 0.00918Iteration: 20, Log-Lik: -104953.451, Max-Change: 0.00977Iteration: 21, Log-Lik: -104953.053, Max-Change: 0.00734Iteration: 22, Log-Lik: -104952.718, Max-Change: 0.00498Iteration: 23, Log-Lik: -104952.529, Max-Change: 0.00516Iteration: 24, Log-Lik: -104952.362, Max-Change: 0.00389Iteration: 25, Log-Lik: -104952.095, Max-Change: 0.00347Iteration: 26, Log-Lik: -104952.022, Max-Change: 0.00272Iteration: 27, Log-Lik: -104951.970, Max-Change: 0.00217Iteration: 28, Log-Lik: -104951.937, Max-Change: 0.01638Iteration: 29, Log-Lik: -104951.866, Max-Change: 0.00236Iteration: 30, Log-Lik: -104951.835, Max-Change: 0.00222Iteration: 31, Log-Lik: -104951.762, Max-Change: 0.00054Iteration: 32, Log-Lik: -104951.753, Max-Change: 0.00059Iteration: 33, Log-Lik: -104951.749, Max-Change: 0.00127Iteration: 34, Log-Lik: -104951.739, Max-Change: 0.00068Iteration: 35, Log-Lik: -104951.735, Max-Change: 0.00028Iteration: 36, Log-Lik: -104951.734, Max-Change: 0.00016Iteration: 37, Log-Lik: -104951.733, Max-Change: 0.00067Iteration: 38, Log-Lik: -104951.730, Max-Change: 0.00072Iteration: 39, Log-Lik: -104951.728, Max-Change: 0.00013Iteration: 40, Log-Lik: -104951.727, Max-Change: 0.00063Iteration: 41, Log-Lik: -104951.726, Max-Change: 0.00016Iteration: 42, Log-Lik: -104951.725, Max-Change: 0.00041Iteration: 43, Log-Lik: -104951.724, Max-Change: 0.00009
mirt_enjoys_discussion %>% summary()
##                                    F1    h2
## discussing_politics             0.709 0.503
## enjoy_intense_conversions       0.830 0.688
## enjoy_debates                   0.774 0.599
## partner_philosopical_discussion 0.622 0.387
## 
## SS loadings:  2.18 
## Proportion Var:  0.544 
## 
## Factor correlations: 
## 
##    F1
## F1  1
#scores
mirt_enjoys_discussion_scores = fscores(mirt_enjoys_discussion, full.scores = T, full.scores.SE = T)

#reliability
empirical_rxx(mirt_enjoys_discussion_scores)
##    F1 
## 0.559
empirical_rxx(mirt_enjoys_discussion_scores[min500_idx, ])
##    F1 
## 0.645
marginal_rxx(mirt_enjoys_discussion)
## [1] 0.668
#save scores
d$enjoys_discussion = mirt_enjoys_discussion_scores[, 1] %>% standardize() %>% multiply_by(-1)

#verify
GG_scatter(d, "enjoys_discussion", "g")
## `geom_smooth()` using formula = 'y ~ x'

Religiousness

mirt_religiousness = mirt(
  data = d %>% select(
    god_religion_importance, contraception_wrong, homosexuality_sin, christian, believe_in_god, power_of_prayer, gay_marriage, some_religions_more_correct, who_is_smartest, duty_god) %>%
    map_df(as.numeric),
  model = 1,
  itemtype = "nominal"
  )
## Warning: data contains response patterns with only NAs
## Iteration: 1, Log-Lik: -309656.248, Max-Change: 6.73712Iteration: 2, Log-Lik: -186917.813, Max-Change: 1.57192Iteration: 3, Log-Lik: -177184.958, Max-Change: 3.88082Iteration: 4, Log-Lik: -171766.235, Max-Change: 1.70272Iteration: 5, Log-Lik: -167337.608, Max-Change: 1.10720Iteration: 6, Log-Lik: -164523.873, Max-Change: 0.49859Iteration: 7, Log-Lik: -164066.709, Max-Change: 0.38956Iteration: 8, Log-Lik: -163754.253, Max-Change: 0.34711Iteration: 9, Log-Lik: -163644.226, Max-Change: 0.29506Iteration: 10, Log-Lik: -163568.988, Max-Change: 0.14455Iteration: 11, Log-Lik: -163495.320, Max-Change: 0.17918Iteration: 12, Log-Lik: -163455.994, Max-Change: 0.12501Iteration: 13, Log-Lik: -163431.749, Max-Change: 0.15479Iteration: 14, Log-Lik: -163409.259, Max-Change: 0.10296Iteration: 15, Log-Lik: -163396.203, Max-Change: 0.08258Iteration: 16, Log-Lik: -163387.268, Max-Change: 0.06076Iteration: 17, Log-Lik: -163383.644, Max-Change: 0.05957Iteration: 18, Log-Lik: -163378.614, Max-Change: 0.04502Iteration: 19, Log-Lik: -163376.215, Max-Change: 0.03864Iteration: 20, Log-Lik: -163374.226, Max-Change: 0.03875Iteration: 21, Log-Lik: -163371.912, Max-Change: 0.02154Iteration: 22, Log-Lik: -163369.641, Max-Change: 0.02743Iteration: 23, Log-Lik: -163368.521, Max-Change: 0.02952Iteration: 24, Log-Lik: -163367.433, Max-Change: 0.02459Iteration: 25, Log-Lik: -163364.158, Max-Change: 0.00699Iteration: 26, Log-Lik: -163363.712, Max-Change: 0.00471Iteration: 27, Log-Lik: -163363.614, Max-Change: 0.00297Iteration: 28, Log-Lik: -163363.517, Max-Change: 0.00346Iteration: 29, Log-Lik: -163363.467, Max-Change: 0.00096Iteration: 30, Log-Lik: -163363.442, Max-Change: 0.00146Iteration: 31, Log-Lik: -163363.418, Max-Change: 0.00148Iteration: 32, Log-Lik: -163363.401, Max-Change: 0.00084Iteration: 33, Log-Lik: -163363.391, Max-Change: 0.00315Iteration: 34, Log-Lik: -163363.353, Max-Change: 0.00053Iteration: 35, Log-Lik: -163363.347, Max-Change: 0.00013Iteration: 36, Log-Lik: -163363.346, Max-Change: 0.00020Iteration: 37, Log-Lik: -163363.344, Max-Change: 0.00016Iteration: 38, Log-Lik: -163363.342, Max-Change: 0.00025Iteration: 39, Log-Lik: -163363.340, Max-Change: 0.00012Iteration: 40, Log-Lik: -163363.340, Max-Change: 0.00009
mirt_religiousness %>% summary()
##                                 F1    h2
## god_religion_importance      0.898 0.806
## contraception_wrong          0.633 0.401
## homosexuality_sin            0.854 0.729
## christian                    0.859 0.738
## believe_in_god               0.976 0.953
## power_of_prayer              0.928 0.861
## gay_marriage                -0.777 0.603
## some_religions_more_correct  0.499 0.249
## who_is_smartest             -0.503 0.253
## duty_god                     0.938 0.880
## 
## SS loadings:  6.47 
## Proportion Var:  0.647 
## 
## Factor correlations: 
## 
##    F1
## F1  1
#scores
mirt_religiousness_scores = fscores(mirt_religiousness, full.scores = T, full.scores.SE = T)

#reliability
empirical_rxx(mirt_religiousness_scores)
##    F1 
## 0.743
empirical_rxx(mirt_religiousness_scores[min500_idx, ])
##    F1 
## 0.791
marginal_rxx(mirt_religiousness)
## [1] 0.759
#save scores
d$religiousness = mirt_religiousness_scores[, 1] %>% standardize() %>% multiply_by(-1)

GG_group_means(d, "religiousness", "d_religion_type")
## Missing values were removed.

Drugs

mirt_drugs = mirt(
  data = d %>% select(
    ok_partner_does_drugs, harder_drugs, cannabis, drugs_romantic, would_smoke_weed, psychedelics, could_obtain_drugs) %>%
    map_df(as.numeric),
  model = 1,
  itemtype = "nominal"
)
## Warning: data contains response patterns with only NAs
## Iteration: 1, Log-Lik: -318768.761, Max-Change: 2.85052Iteration: 2, Log-Lik: -243213.465, Max-Change: 1.91393Iteration: 3, Log-Lik: -213820.369, Max-Change: 1.08234Iteration: 4, Log-Lik: -207606.424, Max-Change: 0.99469Iteration: 5, Log-Lik: -205843.680, Max-Change: 0.47962Iteration: 6, Log-Lik: -205138.641, Max-Change: 0.20173Iteration: 7, Log-Lik: -204731.095, Max-Change: 0.14972Iteration: 8, Log-Lik: -204525.948, Max-Change: 0.11644Iteration: 9, Log-Lik: -204412.094, Max-Change: 0.15801Iteration: 10, Log-Lik: -204335.741, Max-Change: 0.09345Iteration: 11, Log-Lik: -204291.165, Max-Change: 0.17349Iteration: 12, Log-Lik: -204257.856, Max-Change: 0.13617Iteration: 13, Log-Lik: -204239.281, Max-Change: 0.27992Iteration: 14, Log-Lik: -204225.193, Max-Change: 0.08350Iteration: 15, Log-Lik: -204217.659, Max-Change: 0.11862Iteration: 16, Log-Lik: -204212.307, Max-Change: 0.06879Iteration: 17, Log-Lik: -204208.897, Max-Change: 0.18603Iteration: 18, Log-Lik: -204204.960, Max-Change: 0.02461Iteration: 19, Log-Lik: -204204.541, Max-Change: 0.29261Iteration: 20, Log-Lik: -204200.269, Max-Change: 0.06368Iteration: 21, Log-Lik: -204198.916, Max-Change: 0.20387Iteration: 22, Log-Lik: -204196.739, Max-Change: 0.02462Iteration: 23, Log-Lik: -204195.592, Max-Change: 0.00661Iteration: 24, Log-Lik: -204195.133, Max-Change: 0.00520Iteration: 25, Log-Lik: -204194.528, Max-Change: 0.00235Iteration: 26, Log-Lik: -204194.399, Max-Change: 0.00241Iteration: 27, Log-Lik: -204194.309, Max-Change: 0.00267Iteration: 28, Log-Lik: -204194.144, Max-Change: 0.02235Iteration: 29, Log-Lik: -204193.960, Max-Change: 0.00056Iteration: 30, Log-Lik: -204193.949, Max-Change: 0.00043Iteration: 31, Log-Lik: -204193.948, Max-Change: 0.00062Iteration: 32, Log-Lik: -204193.940, Max-Change: 0.00030Iteration: 33, Log-Lik: -204193.938, Max-Change: 0.00021Iteration: 34, Log-Lik: -204193.937, Max-Change: 0.00058Iteration: 35, Log-Lik: -204193.933, Max-Change: 0.00012Iteration: 36, Log-Lik: -204193.931, Max-Change: 0.00032Iteration: 37, Log-Lik: -204193.932, Max-Change: 0.00014Iteration: 38, Log-Lik: -204193.930, Max-Change: 0.00008
mirt_drugs %>% summary()
##                           F1    h2
## ok_partner_does_drugs -0.813 0.661
## harder_drugs           0.727 0.529
## cannabis               0.742 0.551
## drugs_romantic         0.902 0.813
## would_smoke_weed       0.848 0.719
## psychedelics          -0.735 0.540
## could_obtain_drugs    -0.506 0.256
## 
## SS loadings:  4.07 
## Proportion Var:  0.581 
## 
## Factor correlations: 
## 
##    F1
## F1  1
#scores
mirt_drugs_scores = fscores(mirt_drugs, full.scores = T, full.scores.SE = T)

#reliability
empirical_rxx(mirt_drugs_scores)
##    F1 
## 0.768
empirical_rxx(mirt_drugs_scores[min500_idx, ])
##    F1 
## 0.815
marginal_rxx(mirt_drugs)
## [1] 0.813
#save scores
d$drugs = mirt_drugs_scores[, 1] %>% standardize() %>% multiply_by(-1)

GG_group_means(d, "drugs", "gender_orientation")
## Missing values were removed.

Kink, sex interest

mirt_sex_kink = mirt(
  d %>% select(sex_frequency, open_new_things_in_bed, sex_drive, gentle_rough, partner_experienced, slut_ok, group_sex, partner_gentle_love, confidence, public_sex, masturbation, fetish_friendly, sex_toys, porn_hardcore) %>% 
    map_df(as.numeric),
  model = 1,
  itemtype = "nominal"
)
## Warning: data contains response patterns with only NAs
## Iteration: 1, Log-Lik: -547777.971, Max-Change: 5.05030Iteration: 2, Log-Lik: -432076.763, Max-Change: 2.00497Iteration: 3, Log-Lik: -406861.894, Max-Change: 3.11939Iteration: 4, Log-Lik: -394321.575, Max-Change: 3.97740Iteration: 5, Log-Lik: -388477.743, Max-Change: 0.90366Iteration: 6, Log-Lik: -386597.970, Max-Change: 1.78009Iteration: 7, Log-Lik: -384579.048, Max-Change: 0.71853Iteration: 8, Log-Lik: -383765.153, Max-Change: 0.86356Iteration: 9, Log-Lik: -383455.969, Max-Change: 0.32219Iteration: 10, Log-Lik: -383242.200, Max-Change: 0.25373Iteration: 11, Log-Lik: -383100.395, Max-Change: 0.20288Iteration: 12, Log-Lik: -383003.368, Max-Change: 0.18973Iteration: 13, Log-Lik: -382935.177, Max-Change: 0.16366Iteration: 14, Log-Lik: -382886.011, Max-Change: 0.15443Iteration: 15, Log-Lik: -382849.928, Max-Change: 0.12131Iteration: 16, Log-Lik: -382823.667, Max-Change: 0.10870Iteration: 17, Log-Lik: -382804.430, Max-Change: 0.08723Iteration: 18, Log-Lik: -382790.415, Max-Change: 0.08274Iteration: 19, Log-Lik: -382780.234, Max-Change: 0.03914Iteration: 20, Log-Lik: -382768.939, Max-Change: 0.03713Iteration: 21, Log-Lik: -382762.000, Max-Change: 0.07055Iteration: 22, Log-Lik: -382759.546, Max-Change: 0.00957Iteration: 23, Log-Lik: -382756.586, Max-Change: 0.07167Iteration: 24, Log-Lik: -382755.227, Max-Change: 0.00643Iteration: 25, Log-Lik: -382754.882, Max-Change: 0.00585Iteration: 26, Log-Lik: -382753.726, Max-Change: 0.00826Iteration: 27, Log-Lik: -382753.114, Max-Change: 0.00528Iteration: 28, Log-Lik: -382752.474, Max-Change: 0.00381Iteration: 29, Log-Lik: -382752.360, Max-Change: 0.00115Iteration: 30, Log-Lik: -382752.281, Max-Change: 0.03512Iteration: 31, Log-Lik: -382752.132, Max-Change: 0.00156Iteration: 32, Log-Lik: -382752.060, Max-Change: 0.00097Iteration: 33, Log-Lik: -382752.026, Max-Change: 0.00121Iteration: 34, Log-Lik: -382751.999, Max-Change: 0.00032Iteration: 35, Log-Lik: -382751.994, Max-Change: 0.00083Iteration: 36, Log-Lik: -382751.989, Max-Change: 0.00017Iteration: 37, Log-Lik: -382751.988, Max-Change: 0.00017Iteration: 38, Log-Lik: -382751.987, Max-Change: 0.00082Iteration: 39, Log-Lik: -382751.983, Max-Change: 0.00081Iteration: 40, Log-Lik: -382751.981, Max-Change: 0.00016Iteration: 41, Log-Lik: -382751.979, Max-Change: 0.00081Iteration: 42, Log-Lik: -382751.977, Max-Change: 0.00016Iteration: 43, Log-Lik: -382751.976, Max-Change: 0.00016Iteration: 44, Log-Lik: -382751.975, Max-Change: 0.00080Iteration: 45, Log-Lik: -382751.972, Max-Change: 0.00079Iteration: 46, Log-Lik: -382751.971, Max-Change: 0.00016Iteration: 47, Log-Lik: -382751.969, Max-Change: 0.00079Iteration: 48, Log-Lik: -382751.967, Max-Change: 0.00016Iteration: 49, Log-Lik: -382751.967, Max-Change: 0.00016Iteration: 50, Log-Lik: -382751.966, Max-Change: 0.00079Iteration: 51, Log-Lik: -382751.963, Max-Change: 0.00079Iteration: 52, Log-Lik: -382751.962, Max-Change: 0.00016Iteration: 53, Log-Lik: -382751.960, Max-Change: 0.00078Iteration: 54, Log-Lik: -382751.958, Max-Change: 0.00016Iteration: 55, Log-Lik: -382751.958, Max-Change: 0.00016Iteration: 56, Log-Lik: -382751.957, Max-Change: 0.00078Iteration: 57, Log-Lik: -382751.955, Max-Change: 0.00078Iteration: 58, Log-Lik: -382751.954, Max-Change: 0.00016Iteration: 59, Log-Lik: -382751.952, Max-Change: 0.00078Iteration: 60, Log-Lik: -382751.950, Max-Change: 0.00015Iteration: 61, Log-Lik: -382751.950, Max-Change: 0.00015Iteration: 62, Log-Lik: -382751.949, Max-Change: 0.00077Iteration: 63, Log-Lik: -382751.947, Max-Change: 0.00077Iteration: 64, Log-Lik: -382751.946, Max-Change: 0.00015Iteration: 65, Log-Lik: -382751.944, Max-Change: 0.00077Iteration: 66, Log-Lik: -382751.943, Max-Change: 0.00015Iteration: 67, Log-Lik: -382751.942, Max-Change: 0.00015Iteration: 68, Log-Lik: -382751.941, Max-Change: 0.00077Iteration: 69, Log-Lik: -382751.939, Max-Change: 0.00077Iteration: 70, Log-Lik: -382751.938, Max-Change: 0.00015Iteration: 71, Log-Lik: -382751.936, Max-Change: 0.00076Iteration: 72, Log-Lik: -382751.935, Max-Change: 0.00015Iteration: 73, Log-Lik: -382751.935, Max-Change: 0.00015Iteration: 74, Log-Lik: -382751.934, Max-Change: 0.00076Iteration: 75, Log-Lik: -382751.932, Max-Change: 0.00076Iteration: 76, Log-Lik: -382751.931, Max-Change: 0.00016Iteration: 77, Log-Lik: -382751.929, Max-Change: 0.00076Iteration: 78, Log-Lik: -382751.928, Max-Change: 0.00015Iteration: 79, Log-Lik: -382751.927, Max-Change: 0.00015Iteration: 80, Log-Lik: -382751.926, Max-Change: 0.00076Iteration: 81, Log-Lik: -382751.925, Max-Change: 0.00075Iteration: 82, Log-Lik: -382751.924, Max-Change: 0.00016Iteration: 83, Log-Lik: -382751.922, Max-Change: 0.00075Iteration: 84, Log-Lik: -382751.921, Max-Change: 0.00015Iteration: 85, Log-Lik: -382751.920, Max-Change: 0.00015Iteration: 86, Log-Lik: -382751.919, Max-Change: 0.00075Iteration: 87, Log-Lik: -382751.918, Max-Change: 0.00075Iteration: 88, Log-Lik: -382751.917, Max-Change: 0.00017Iteration: 89, Log-Lik: -382751.915, Max-Change: 0.00075Iteration: 90, Log-Lik: -382751.914, Max-Change: 0.00015Iteration: 91, Log-Lik: -382751.913, Max-Change: 0.00015Iteration: 92, Log-Lik: -382751.912, Max-Change: 0.00074Iteration: 93, Log-Lik: -382751.911, Max-Change: 0.00015Iteration: 94, Log-Lik: -382751.910, Max-Change: 0.00074Iteration: 95, Log-Lik: -382751.909, Max-Change: 0.00016Iteration: 96, Log-Lik: -382751.908, Max-Change: 0.00074Iteration: 97, Log-Lik: -382751.907, Max-Change: 0.00021Iteration: 98, Log-Lik: -382751.905, Max-Change: 0.00074Iteration: 99, Log-Lik: -382751.904, Max-Change: 0.00016Iteration: 100, Log-Lik: -382751.903, Max-Change: 0.00015Iteration: 101, Log-Lik: -382751.902, Max-Change: 0.00074Iteration: 102, Log-Lik: -382751.901, Max-Change: 0.00015Iteration: 103, Log-Lik: -382751.900, Max-Change: 0.00074Iteration: 104, Log-Lik: -382751.900, Max-Change: 0.00019Iteration: 105, Log-Lik: -382751.898, Max-Change: 0.00073Iteration: 106, Log-Lik: -382751.898, Max-Change: 0.00026Iteration: 107, Log-Lik: -382751.895, Max-Change: 0.00015Iteration: 108, Log-Lik: -382751.894, Max-Change: 0.00073Iteration: 109, Log-Lik: -382751.892, Max-Change: 0.00015Iteration: 110, Log-Lik: -382751.891, Max-Change: 0.00073Iteration: 111, Log-Lik: -382751.890, Max-Change: 0.00073Iteration: 112, Log-Lik: -382751.889, Max-Change: 0.00018Iteration: 113, Log-Lik: -382751.888, Max-Change: 0.00072Iteration: 114, Log-Lik: -382751.886, Max-Change: 0.00014Iteration: 115, Log-Lik: -382751.886, Max-Change: 0.00014Iteration: 116, Log-Lik: -382751.885, Max-Change: 0.00072Iteration: 117, Log-Lik: -382751.884, Max-Change: 0.00072Iteration: 118, Log-Lik: -382751.883, Max-Change: 0.00018Iteration: 119, Log-Lik: -382751.881, Max-Change: 0.00072Iteration: 120, Log-Lik: -382751.880, Max-Change: 0.00014Iteration: 121, Log-Lik: -382751.880, Max-Change: 0.00014Iteration: 122, Log-Lik: -382751.879, Max-Change: 0.00072Iteration: 123, Log-Lik: -382751.877, Max-Change: 0.00014Iteration: 124, Log-Lik: -382751.877, Max-Change: 0.00072Iteration: 125, Log-Lik: -382751.876, Max-Change: 0.00017Iteration: 126, Log-Lik: -382751.875, Max-Change: 0.00071Iteration: 127, Log-Lik: -382751.874, Max-Change: 0.00022Iteration: 128, Log-Lik: -382751.872, Max-Change: 0.00071Iteration: 129, Log-Lik: -382751.871, Max-Change: 0.00017Iteration: 130, Log-Lik: -382751.871, Max-Change: 0.00014Iteration: 131, Log-Lik: -382751.870, Max-Change: 0.00071Iteration: 132, Log-Lik: -382751.868, Max-Change: 0.00014Iteration: 133, Log-Lik: -382751.868, Max-Change: 0.00014Iteration: 134, Log-Lik: -382751.868, Max-Change: 0.00071Iteration: 135, Log-Lik: -382751.866, Max-Change: 0.00070Iteration: 136, Log-Lik: -382751.865, Max-Change: 0.00017Iteration: 137, Log-Lik: -382751.864, Max-Change: 0.00070Iteration: 138, Log-Lik: -382751.863, Max-Change: 0.00014Iteration: 139, Log-Lik: -382751.862, Max-Change: 0.00014Iteration: 140, Log-Lik: -382751.862, Max-Change: 0.00070Iteration: 141, Log-Lik: -382751.860, Max-Change: 0.00070Iteration: 142, Log-Lik: -382751.859, Max-Change: 0.00017Iteration: 143, Log-Lik: -382751.858, Max-Change: 0.00070Iteration: 144, Log-Lik: -382751.857, Max-Change: 0.00014Iteration: 145, Log-Lik: -382751.857, Max-Change: 0.00014Iteration: 146, Log-Lik: -382751.856, Max-Change: 0.00070Iteration: 147, Log-Lik: -382751.854, Max-Change: 0.00014Iteration: 148, Log-Lik: -382751.854, Max-Change: 0.00069Iteration: 149, Log-Lik: -382751.853, Max-Change: 0.00016Iteration: 150, Log-Lik: -382751.852, Max-Change: 0.00069Iteration: 151, Log-Lik: -382751.851, Max-Change: 0.00021Iteration: 152, Log-Lik: -382751.849, Max-Change: 0.00069Iteration: 153, Log-Lik: -382751.849, Max-Change: 0.00016Iteration: 154, Log-Lik: -382751.848, Max-Change: 0.00014Iteration: 155, Log-Lik: -382751.847, Max-Change: 0.00069Iteration: 156, Log-Lik: -382751.846, Max-Change: 0.00014Iteration: 157, Log-Lik: -382751.846, Max-Change: 0.00014Iteration: 158, Log-Lik: -382751.845, Max-Change: 0.00069Iteration: 159, Log-Lik: -382751.844, Max-Change: 0.00069Iteration: 160, Log-Lik: -382751.843, Max-Change: 0.00016Iteration: 161, Log-Lik: -382751.842, Max-Change: 0.00068Iteration: 162, Log-Lik: -382751.840, Max-Change: 0.00014Iteration: 163, Log-Lik: -382751.840, Max-Change: 0.00014Iteration: 164, Log-Lik: -382751.839, Max-Change: 0.00068Iteration: 165, Log-Lik: -382751.838, Max-Change: 0.00068Iteration: 166, Log-Lik: -382751.837, Max-Change: 0.00017Iteration: 167, Log-Lik: -382751.836, Max-Change: 0.00068Iteration: 168, Log-Lik: -382751.835, Max-Change: 0.00014Iteration: 169, Log-Lik: -382751.835, Max-Change: 0.00014Iteration: 170, Log-Lik: -382751.834, Max-Change: 0.00068Iteration: 171, Log-Lik: -382751.833, Max-Change: 0.00014Iteration: 172, Log-Lik: -382751.833, Max-Change: 0.00068Iteration: 173, Log-Lik: -382751.832, Max-Change: 0.00016Iteration: 174, Log-Lik: -382751.831, Max-Change: 0.00067Iteration: 175, Log-Lik: -382751.830, Max-Change: 0.00020Iteration: 176, Log-Lik: -382751.828, Max-Change: 0.00067Iteration: 177, Log-Lik: -382751.827, Max-Change: 0.00016Iteration: 178, Log-Lik: -382751.827, Max-Change: 0.00013Iteration: 179, Log-Lik: -382751.826, Max-Change: 0.00067Iteration: 180, Log-Lik: -382751.825, Max-Change: 0.00013Iteration: 181, Log-Lik: -382751.825, Max-Change: 0.00013Iteration: 182, Log-Lik: -382751.824, Max-Change: 0.00067Iteration: 183, Log-Lik: -382751.823, Max-Change: 0.00066Iteration: 184, Log-Lik: -382751.822, Max-Change: 0.00016Iteration: 185, Log-Lik: -382751.821, Max-Change: 0.00066Iteration: 186, Log-Lik: -382751.820, Max-Change: 0.00013Iteration: 187, Log-Lik: -382751.820, Max-Change: 0.00013Iteration: 188, Log-Lik: -382751.819, Max-Change: 0.00066Iteration: 189, Log-Lik: -382751.818, Max-Change: 0.00066Iteration: 190, Log-Lik: -382751.817, Max-Change: 0.00016Iteration: 191, Log-Lik: -382751.816, Max-Change: 0.00066Iteration: 192, Log-Lik: -382751.815, Max-Change: 0.00013Iteration: 193, Log-Lik: -382751.814, Max-Change: 0.00013Iteration: 194, Log-Lik: -382751.814, Max-Change: 0.00066Iteration: 195, Log-Lik: -382751.813, Max-Change: 0.00013Iteration: 196, Log-Lik: -382751.812, Max-Change: 0.00065Iteration: 197, Log-Lik: -382751.812, Max-Change: 0.00015Iteration: 198, Log-Lik: -382751.811, Max-Change: 0.00065Iteration: 199, Log-Lik: -382751.810, Max-Change: 0.00019Iteration: 200, Log-Lik: -382751.808, Max-Change: 0.00065Iteration: 201, Log-Lik: -382751.808, Max-Change: 0.00015Iteration: 202, Log-Lik: -382751.807, Max-Change: 0.00013Iteration: 203, Log-Lik: -382751.806, Max-Change: 0.00065Iteration: 204, Log-Lik: -382751.805, Max-Change: 0.00013Iteration: 205, Log-Lik: -382751.805, Max-Change: 0.00013Iteration: 206, Log-Lik: -382751.804, Max-Change: 0.00065Iteration: 207, Log-Lik: -382751.803, Max-Change: 0.00065Iteration: 208, Log-Lik: -382751.802, Max-Change: 0.00015Iteration: 209, Log-Lik: -382751.801, Max-Change: 0.00064Iteration: 210, Log-Lik: -382751.800, Max-Change: 0.00013Iteration: 211, Log-Lik: -382751.800, Max-Change: 0.00013Iteration: 212, Log-Lik: -382751.799, Max-Change: 0.00064Iteration: 213, Log-Lik: -382751.798, Max-Change: 0.00064Iteration: 214, Log-Lik: -382751.798, Max-Change: 0.00016Iteration: 215, Log-Lik: -382751.797, Max-Change: 0.00064Iteration: 216, Log-Lik: -382751.796, Max-Change: 0.00013Iteration: 217, Log-Lik: -382751.795, Max-Change: 0.00013Iteration: 218, Log-Lik: -382751.795, Max-Change: 0.00064Iteration: 219, Log-Lik: -382751.794, Max-Change: 0.00013Iteration: 220, Log-Lik: -382751.793, Max-Change: 0.00064Iteration: 221, Log-Lik: -382751.793, Max-Change: 0.00015Iteration: 222, Log-Lik: -382751.792, Max-Change: 0.00063Iteration: 223, Log-Lik: -382751.791, Max-Change: 0.00019Iteration: 224, Log-Lik: -382751.790, Max-Change: 0.00063Iteration: 225, Log-Lik: -382751.789, Max-Change: 0.00015Iteration: 226, Log-Lik: -382751.788, Max-Change: 0.00013Iteration: 227, Log-Lik: -382751.788, Max-Change: 0.00063Iteration: 228, Log-Lik: -382751.787, Max-Change: 0.00013Iteration: 229, Log-Lik: -382751.786, Max-Change: 0.00013Iteration: 230, Log-Lik: -382751.786, Max-Change: 0.00063Iteration: 231, Log-Lik: -382751.785, Max-Change: 0.00063Iteration: 232, Log-Lik: -382751.784, Max-Change: 0.00015Iteration: 233, Log-Lik: -382751.783, Max-Change: 0.00063Iteration: 234, Log-Lik: -382751.782, Max-Change: 0.00012Iteration: 235, Log-Lik: -382751.782, Max-Change: 0.00012Iteration: 236, Log-Lik: -382751.781, Max-Change: 0.00062Iteration: 237, Log-Lik: -382751.780, Max-Change: 0.00062Iteration: 238, Log-Lik: -382751.780, Max-Change: 0.00015Iteration: 239, Log-Lik: -382751.779, Max-Change: 0.00062Iteration: 240, Log-Lik: -382751.778, Max-Change: 0.00012Iteration: 241, Log-Lik: -382751.777, Max-Change: 0.00012Iteration: 242, Log-Lik: -382751.777, Max-Change: 0.00062Iteration: 243, Log-Lik: -382751.776, Max-Change: 0.00012Iteration: 244, Log-Lik: -382751.776, Max-Change: 0.00062Iteration: 245, Log-Lik: -382751.775, Max-Change: 0.00014Iteration: 246, Log-Lik: -382751.774, Max-Change: 0.00062Iteration: 247, Log-Lik: -382751.773, Max-Change: 0.00018Iteration: 248, Log-Lik: -382751.772, Max-Change: 0.00061Iteration: 249, Log-Lik: -382751.771, Max-Change: 0.00014Iteration: 250, Log-Lik: -382751.771, Max-Change: 0.00012Iteration: 251, Log-Lik: -382751.770, Max-Change: 0.00061Iteration: 252, Log-Lik: -382751.769, Max-Change: 0.00012Iteration: 253, Log-Lik: -382751.769, Max-Change: 0.00012Iteration: 254, Log-Lik: -382751.769, Max-Change: 0.00061Iteration: 255, Log-Lik: -382751.767, Max-Change: 0.00061Iteration: 256, Log-Lik: -382751.767, Max-Change: 0.00014Iteration: 257, Log-Lik: -382751.766, Max-Change: 0.00061Iteration: 258, Log-Lik: -382751.765, Max-Change: 0.00012Iteration: 259, Log-Lik: -382751.765, Max-Change: 0.00012Iteration: 260, Log-Lik: -382751.764, Max-Change: 0.00061Iteration: 261, Log-Lik: -382751.763, Max-Change: 0.00060Iteration: 262, Log-Lik: -382751.763, Max-Change: 0.00015Iteration: 263, Log-Lik: -382751.762, Max-Change: 0.00060Iteration: 264, Log-Lik: -382751.761, Max-Change: 0.00012Iteration: 265, Log-Lik: -382751.760, Max-Change: 0.00012Iteration: 266, Log-Lik: -382751.760, Max-Change: 0.00060Iteration: 267, Log-Lik: -382751.759, Max-Change: 0.00012Iteration: 268, Log-Lik: -382751.759, Max-Change: 0.00060Iteration: 269, Log-Lik: -382751.758, Max-Change: 0.00014Iteration: 270, Log-Lik: -382751.757, Max-Change: 0.00060Iteration: 271, Log-Lik: -382751.757, Max-Change: 0.00018Iteration: 272, Log-Lik: -382751.755, Max-Change: 0.00060Iteration: 273, Log-Lik: -382751.755, Max-Change: 0.00014Iteration: 274, Log-Lik: -382751.754, Max-Change: 0.00012Iteration: 275, Log-Lik: -382751.754, Max-Change: 0.00060Iteration: 276, Log-Lik: -382751.753, Max-Change: 0.00012Iteration: 277, Log-Lik: -382751.753, Max-Change: 0.00012Iteration: 278, Log-Lik: -382751.752, Max-Change: 0.00059Iteration: 279, Log-Lik: -382751.751, Max-Change: 0.00059Iteration: 280, Log-Lik: -382751.750, Max-Change: 0.00014Iteration: 281, Log-Lik: -382751.749, Max-Change: 0.00059Iteration: 282, Log-Lik: -382751.749, Max-Change: 0.00012Iteration: 283, Log-Lik: -382751.748, Max-Change: 0.00012Iteration: 284, Log-Lik: -382751.748, Max-Change: 0.00059Iteration: 285, Log-Lik: -382751.747, Max-Change: 0.00059Iteration: 286, Log-Lik: -382751.746, Max-Change: 0.00014Iteration: 287, Log-Lik: -382751.746, Max-Change: 0.00059Iteration: 288, Log-Lik: -382751.745, Max-Change: 0.00012Iteration: 289, Log-Lik: -382751.745, Max-Change: 0.00012Iteration: 290, Log-Lik: -382751.744, Max-Change: 0.00059Iteration: 291, Log-Lik: -382751.743, Max-Change: 0.00012Iteration: 292, Log-Lik: -382751.743, Max-Change: 0.00058Iteration: 293, Log-Lik: -382751.742, Max-Change: 0.00013Iteration: 294, Log-Lik: -382751.741, Max-Change: 0.00058Iteration: 295, Log-Lik: -382751.741, Max-Change: 0.00017Iteration: 296, Log-Lik: -382751.740, Max-Change: 0.00058Iteration: 297, Log-Lik: -382751.739, Max-Change: 0.00014Iteration: 298, Log-Lik: -382751.739, Max-Change: 0.00012Iteration: 299, Log-Lik: -382751.738, Max-Change: 0.00058Iteration: 300, Log-Lik: -382751.737, Max-Change: 0.00012Iteration: 301, Log-Lik: -382751.737, Max-Change: 0.00012Iteration: 302, Log-Lik: -382751.737, Max-Change: 0.00058Iteration: 303, Log-Lik: -382751.736, Max-Change: 0.00058Iteration: 304, Log-Lik: -382751.735, Max-Change: 0.00013Iteration: 305, Log-Lik: -382751.734, Max-Change: 0.00057Iteration: 306, Log-Lik: -382751.733, Max-Change: 0.00011Iteration: 307, Log-Lik: -382751.733, Max-Change: 0.00011Iteration: 308, Log-Lik: -382751.733, Max-Change: 0.00057Iteration: 309, Log-Lik: -382751.732, Max-Change: 0.00057Iteration: 310, Log-Lik: -382751.731, Max-Change: 0.00014Iteration: 311, Log-Lik: -382751.730, Max-Change: 0.00057Iteration: 312, Log-Lik: -382751.730, Max-Change: 0.00011Iteration: 313, Log-Lik: -382751.729, Max-Change: 0.00011Iteration: 314, Log-Lik: -382751.729, Max-Change: 0.00057Iteration: 315, Log-Lik: -382751.728, Max-Change: 0.00011Iteration: 316, Log-Lik: -382751.728, Max-Change: 0.00057Iteration: 317, Log-Lik: -382751.727, Max-Change: 0.00013Iteration: 318, Log-Lik: -382751.727, Max-Change: 0.00057Iteration: 319, Log-Lik: -382751.726, Max-Change: 0.00017Iteration: 320, Log-Lik: -382751.725, Max-Change: 0.00056Iteration: 321, Log-Lik: -382751.724, Max-Change: 0.00013Iteration: 322, Log-Lik: -382751.724, Max-Change: 0.00011Iteration: 323, Log-Lik: -382751.723, Max-Change: 0.00056Iteration: 324, Log-Lik: -382751.723, Max-Change: 0.00011Iteration: 325, Log-Lik: -382751.722, Max-Change: 0.00011Iteration: 326, Log-Lik: -382751.722, Max-Change: 0.00056Iteration: 327, Log-Lik: -382751.721, Max-Change: 0.00056Iteration: 328, Log-Lik: -382751.721, Max-Change: 0.00013Iteration: 329, Log-Lik: -382751.720, Max-Change: 0.00056Iteration: 330, Log-Lik: -382751.719, Max-Change: 0.00011Iteration: 331, Log-Lik: -382751.719, Max-Change: 0.00011Iteration: 332, Log-Lik: -382751.718, Max-Change: 0.00056Iteration: 333, Log-Lik: -382751.717, Max-Change: 0.00056Iteration: 334, Log-Lik: -382751.717, Max-Change: 0.00014Iteration: 335, Log-Lik: -382751.716, Max-Change: 0.00055Iteration: 336, Log-Lik: -382751.716, Max-Change: 0.00011Iteration: 337, Log-Lik: -382751.715, Max-Change: 0.00011Iteration: 338, Log-Lik: -382751.715, Max-Change: 0.00055Iteration: 339, Log-Lik: -382751.714, Max-Change: 0.00011Iteration: 340, Log-Lik: -382751.714, Max-Change: 0.00055Iteration: 341, Log-Lik: -382751.713, Max-Change: 0.00013Iteration: 342, Log-Lik: -382751.713, Max-Change: 0.00055Iteration: 343, Log-Lik: -382751.712, Max-Change: 0.00016Iteration: 344, Log-Lik: -382751.711, Max-Change: 0.00055Iteration: 345, Log-Lik: -382751.710, Max-Change: 0.00013Iteration: 346, Log-Lik: -382751.710, Max-Change: 0.00011Iteration: 347, Log-Lik: -382751.710, Max-Change: 0.00055Iteration: 348, Log-Lik: -382751.709, Max-Change: 0.00011Iteration: 349, Log-Lik: -382751.709, Max-Change: 0.00011Iteration: 350, Log-Lik: -382751.708, Max-Change: 0.00054Iteration: 351, Log-Lik: -382751.707, Max-Change: 0.00054Iteration: 352, Log-Lik: -382751.707, Max-Change: 0.00013Iteration: 353, Log-Lik: -382751.706, Max-Change: 0.00054Iteration: 354, Log-Lik: -382751.705, Max-Change: 0.00011Iteration: 355, Log-Lik: -382751.705, Max-Change: 0.00011Iteration: 356, Log-Lik: -382751.705, Max-Change: 0.00054Iteration: 357, Log-Lik: -382751.704, Max-Change: 0.00054Iteration: 358, Log-Lik: -382751.704, Max-Change: 0.00013Iteration: 359, Log-Lik: -382751.703, Max-Change: 0.00054Iteration: 360, Log-Lik: -382751.702, Max-Change: 0.00011Iteration: 361, Log-Lik: -382751.702, Max-Change: 0.00011Iteration: 362, Log-Lik: -382751.701, Max-Change: 0.00054Iteration: 363, Log-Lik: -382751.701, Max-Change: 0.00011Iteration: 364, Log-Lik: -382751.701, Max-Change: 0.00054Iteration: 365, Log-Lik: -382751.700, Max-Change: 0.00012Iteration: 366, Log-Lik: -382751.699, Max-Change: 0.00053Iteration: 367, Log-Lik: -382751.699, Max-Change: 0.00016Iteration: 368, Log-Lik: -382751.698, Max-Change: 0.00053Iteration: 369, Log-Lik: -382751.697, Max-Change: 0.00012Iteration: 370, Log-Lik: -382751.697, Max-Change: 0.00011Iteration: 371, Log-Lik: -382751.697, Max-Change: 0.00053Iteration: 372, Log-Lik: -382751.696, Max-Change: 0.00011Iteration: 373, Log-Lik: -382751.696, Max-Change: 0.00011Iteration: 374, Log-Lik: -382751.695, Max-Change: 0.00053Iteration: 375, Log-Lik: -382751.694, Max-Change: 0.00053Iteration: 376, Log-Lik: -382751.694, Max-Change: 0.00012Iteration: 377, Log-Lik: -382751.693, Max-Change: 0.00053Iteration: 378, Log-Lik: -382751.693, Max-Change: 0.00011Iteration: 379, Log-Lik: -382751.692, Max-Change: 0.00011Iteration: 380, Log-Lik: -382751.692, Max-Change: 0.00053Iteration: 381, Log-Lik: -382751.691, Max-Change: 0.00053Iteration: 382, Log-Lik: -382751.691, Max-Change: 0.00013Iteration: 383, Log-Lik: -382751.690, Max-Change: 0.00052Iteration: 384, Log-Lik: -382751.689, Max-Change: 0.00010Iteration: 385, Log-Lik: -382751.689, Max-Change: 0.00010Iteration: 386, Log-Lik: -382751.689, Max-Change: 0.00052Iteration: 387, Log-Lik: -382751.688, Max-Change: 0.00010Iteration: 388, Log-Lik: -382751.688, Max-Change: 0.00052Iteration: 389, Log-Lik: -382751.687, Max-Change: 0.00012Iteration: 390, Log-Lik: -382751.687, Max-Change: 0.00052Iteration: 391, Log-Lik: -382751.686, Max-Change: 0.00015Iteration: 392, Log-Lik: -382751.685, Max-Change: 0.00052Iteration: 393, Log-Lik: -382751.685, Max-Change: 0.00012Iteration: 394, Log-Lik: -382751.685, Max-Change: 0.00010Iteration: 395, Log-Lik: -382751.684, Max-Change: 0.00052Iteration: 396, Log-Lik: -382751.683, Max-Change: 0.00010Iteration: 397, Log-Lik: -382751.683, Max-Change: 0.00010Iteration: 398, Log-Lik: -382751.683, Max-Change: 0.00051Iteration: 399, Log-Lik: -382751.682, Max-Change: 0.00051Iteration: 400, Log-Lik: -382751.682, Max-Change: 0.00012Iteration: 401, Log-Lik: -382751.681, Max-Change: 0.00051Iteration: 402, Log-Lik: -382751.680, Max-Change: 0.00010Iteration: 403, Log-Lik: -382751.680, Max-Change: 0.00010Iteration: 404, Log-Lik: -382751.680, Max-Change: 0.00051Iteration: 405, Log-Lik: -382751.679, Max-Change: 0.00051Iteration: 406, Log-Lik: -382751.679, Max-Change: 0.00013Iteration: 407, Log-Lik: -382751.678, Max-Change: 0.00051Iteration: 408, Log-Lik: -382751.678, Max-Change: 0.00010Iteration: 409, Log-Lik: -382751.677, Max-Change: 0.00010Iteration: 410, Log-Lik: -382751.677, Max-Change: 0.00051Iteration: 411, Log-Lik: -382751.676, Max-Change: 0.00010Iteration: 412, Log-Lik: -382751.676, Max-Change: 0.00051Iteration: 413, Log-Lik: -382751.676, Max-Change: 0.00012Iteration: 414, Log-Lik: -382751.675, Max-Change: 0.00050Iteration: 415, Log-Lik: -382751.675, Max-Change: 0.00015Iteration: 416, Log-Lik: -382751.674, Max-Change: 0.00050Iteration: 417, Log-Lik: -382751.673, Max-Change: 0.00012Iteration: 418, Log-Lik: -382751.673, Max-Change: 0.00010Iteration: 419, Log-Lik: -382751.673, Max-Change: 0.00050Iteration: 420, Log-Lik: -382751.672, Max-Change: 0.00010Iteration: 421, Log-Lik: -382751.672, Max-Change: 0.00010Iteration: 422, Log-Lik: -382751.671, Max-Change: 0.00050Iteration: 423, Log-Lik: -382751.671, Max-Change: 0.00050Iteration: 424, Log-Lik: -382751.670, Max-Change: 0.00012Iteration: 425, Log-Lik: -382751.670, Max-Change: 0.00050Iteration: 426, Log-Lik: -382751.669, Max-Change: 0.00010
mirt_sex_kink %>% summary()
##                            F1     h2
## sex_frequency           0.470 0.2212
## open_new_things_in_bed  0.646 0.4172
## sex_drive               0.545 0.2966
## gentle_rough            0.576 0.3323
## partner_experienced    -0.492 0.2424
## slut_ok                -0.441 0.1948
## group_sex               0.467 0.2183
## partner_gentle_love    -0.561 0.3142
## confidence              0.590 0.3477
## public_sex              0.535 0.2859
## masturbation            0.276 0.0761
## fetish_friendly         0.545 0.2966
## sex_toys                0.574 0.3298
## porn_hardcore           0.289 0.0837
## 
## SS loadings:  3.66 
## Proportion Var:  0.261 
## 
## Factor correlations: 
## 
##    F1
## F1  1
#scores
mirt_sex_kink_scores = fscores(mirt_sex_kink, full.scores = T, full.scores.SE = T)

#reliability
empirical_rxx(mirt_sex_kink_scores)
##    F1 
## 0.656
empirical_rxx(mirt_sex_kink_scores[min500_idx, ])
##    F1 
## 0.776
marginal_rxx(mirt_sex_kink)
## [1] 0.815
#save scores
d$kink_sex = mirt_sex_kink_scores[, 1] %>% standardize() %>% multiply_by(-1)

GG_group_means(d, "kink_sex", "gender_orientation")
## Missing values were removed.

Main results

#outcomes list
outcomes = c("g", "mental_health", "antisocial", "prudence", "conservatism", "extroversion", "reading", "enjoys_discussion", "religiousness", "drugs", "kink_sex", "ideal_number_children", "have_children")

#cohen's d for each dimension
pet_results_combined_500 = fit_models(
  outcomes,
  min_questions = 500,
  pred = "combined"
)

#sample sizes by outcome
pet_results_combined_500 %>% 
  filter(term == "age") %>% 
  select(y, sample_size)
#plot results
pet_results_combined_500 %>% 
  filter(str_detect(term, "dog_cat")) %>% 
  mutate(
    term = str_remove(term, "dog_cat")
  ) %>% 
  ggplot(aes(y, estimate, color = term, ymin = estimate - 2*std.error, ymax = estimate + 2*std.error)) +
  geom_pointrange(position  = position_dodge(width = 0.2)) +
  geom_hline(yintercept = 0, linetype = 2) +
  labs(
    x = "Dimension",
    y = "Standardized difference",
    # title = "Pet preferences and personality dimensions",
    # subtitle = str_glue("Subset to users with a minimum of 500 questions answered. Controlled for age and sex."),
    color = "Do you like dogs and cats?"
  ) +
  theme(
    axis.text.x = element_text(angle = 10, hjust = 1)
  )

GG_save("figs/pet_results_nominal_min500.png")

#binary approach
pet_results_binary_500 = fit_models(
  outcomes,
  min_questions = 500,
  pred = "binary"
)

#plot results
pet_results_binary_500 %>% 
  filter(str_detect(term, "likes_")) %>%
  mutate(
    term = str_remove(term, "likes_") %>% str_remove("TRUE")
  ) %>% 
  ggplot(aes(y, estimate, color = term, ymin = estimate - 2*std.error, ymax = estimate + 2*std.error)) +
  geom_pointrange(position  = position_dodge(width = 0.2)) +
  geom_hline(yintercept = 0, linetype = 2) +
  labs(
    x = "Dimension",
    y = "Standardized difference",
    title = "Pet preferences and personality dimensions",
    subtitle = str_glue("Subset to users with a minimum of 500 questions answered. Controlled for age and sex."),
    color = "Do you like dogs and cats?"
  ) +
  theme(
    axis.text.x = element_text(angle = 10, hjust = 1)
  )

#combined approach, control location
pet_results_combined_500_location = fit_models(
  outcomes,
  min_questions = 500,
  pred = "combined",
  control_location = T
)
## Warning: (3) Model is nearly unidentifiable: large eigenvalue ratio
##  - Rescale variables? 
## In addition: Absolute and relative convergence criteria were met
#plot results
pet_results_combined_500_location %>% 
  filter(str_detect(term, "dog_cat")) %>%
  mutate(
    term = str_remove(term, "dog_cat") %>% str_remove("TRUE")
  ) %>% 
  ggplot(aes(y, estimate, color = term, ymin = estimate - 2*std.error, ymax = estimate + 2*std.error)) +
  geom_pointrange(position  = position_dodge(width = 0.2)) +
  geom_hline(yintercept = 0, linetype = 2) +
  labs(
    x = "Dimension",
    y = "Standardized difference",
    # title = "Pet preferences and personality dimensions",
    # subtitle = str_glue("Subset to users with a minimum of 500 questions answered. Controlled for age, sex, location."),
    color = "Do you like dogs and cats?"
  ) +
  theme(
    axis.text.x = element_text(angle = 10, hjust = 1)
  )

GG_save("figs/pet_results_nominal_min500_location.png")

#interaction approach to see confirm that the predictors aren't independent
pet_results_interaction_500 = fit_models(
  outcomes,
  min_questions = 500,
  pred = "interaction"
)

#plot
pet_results_interaction_500 %>% 
  filter(str_detect(term, "likes_")) %>%
  mutate(
    term = str_remove(term, "likes_") %>% str_remove_all("TRUE")
  ) %>% 
  ggplot(aes(y, estimate, color = term, ymin = estimate - 2*std.error, ymax = estimate + 2*std.error)) +
  geom_pointrange(position  = position_dodge(width = 0.2)) +
  geom_hline(yintercept = 0, linetype = 2) +
  labs(
    x = "Dimension",
    y = "Standardized difference",
    # title = "Pet preferences and personality dimensions",
    # subtitle = str_glue("Subset to users with a minimum of 500 questions answered. Controlled for age and sex."),
    color = "Do you like dogs and cats?"
  ) +
  theme(
    axis.text.x = element_text(angle = 10, hjust = 1)
  )

GG_save("figs/pet_results_interaction_min500.png")

#children
pet_results_interaction_500 %>% 
  filter(y == "have_children")
#p values for interaction term
pet_results_interaction_500 %>% 
  filter(
    str_detect(term, "likes_"),
    str_detect(term, ":")
    ) %>%
  mutate(
    log10_p = log10(p.value),
    p5 = p.value < .05,
    adj_p = p.adjust(p.value, method = "bonf"),
    adj_p5 = adj_p < .05,
    adj_log10_p = log10(adj_p)
  )
#sex interaction too?
pet_results_combined_500_sex_interaction = fit_models(
  outcomes,
  min_questions = 500,
  pred = "combined",
  sex_interact = T
)

pet_results_combined_500_sex_interaction %>% 
  filter(
    str_detect(term, "dog_cat") | str_detect(term, "gender")) %>% 
  mutate(
    term = str_remove(term, "dog_cat") %>% str_remove("gender2"),
    interact = str_detect(term, ":")
  ) %>% 
  ggplot(aes(y, estimate, color = term, ymin = estimate - 2*std.error, ymax = estimate + 2*std.error, shape = interact)) +
  geom_pointrange(position  = position_dodge(width = 0.2)) +
  geom_hline(yintercept = 0, linetype = 2) +
  labs(
    x = "Dimension",
    y = "Standardized difference",
    title = "Pet preferences and personality dimensions",
    subtitle = str_glue("Subset to users with a minimum of 500 questions answered. Controlled for age and sex."),
    color = "Do you like dogs and cats?"
  ) +
  theme(
    axis.text.x = element_text(angle = 10, hjust = 1)
  )

#are interactions significant?
pet_results_combined_500_sex_interaction %>% 
  filter(
    str_detect(term, ":")
  ) %>%
  mutate(
    log10_p = log10(p.value),
    p5 = p.value < .05,
    adj_p = p.adjust(p.value, method = "bonf"),
    adj_p5 = adj_p < .05,
    adj_log10_p = log10(adj_p)
  ) %>% arrange(adj_p)
#without minimum question counts
pet_results_combined = fit_models(
  outcomes,
  min_questions = 0,
  pred = "combined"
)

#plot results
pet_results_combined %>% 
  filter(str_detect(term, "dog_cat")) %>% 
  mutate(
    term = str_remove(term, "dog_cat")
  ) %>% 
  ggplot(aes(y, estimate, color = term, ymin = estimate - 2*std.error, ymax = estimate + 2*std.error)) +
  geom_pointrange(position  = position_dodge(width = 0.2)) +
  geom_hline(yintercept = 0, linetype = 2) +
  labs(
    x = "Dimension",
    y = "Standardized difference",
    # title = "Pet preferences and personality dimensions",
    # subtitle = str_glue("Subset to users with a minimum of 500 questions answered. Controlled for age
    color = "Do you like dogs and cats?"
  ) +
  theme(
    axis.text.x = element_text(angle = 10, hjust = 1)
  )

#non-western
d_nonwestern = d %>% 
  filter(
    !location %in% c(datasets::state.abb, "UK", "Australia", "Ontario", "Germany", "Netherlands", "Denmark", "Italy", "Ireland", "Israel", "British Columbia", "Sweden", "France", "DC", "Alberta", "Quebec", "Finland", "Spain", "Belgium", "Austria", "Switzerland", "Norway", "New Zealand", "Greece", "Russia", "Romania", "Portugal", "Manitoba", "Nova Scotia", "Croatia")
  )

d_nonwestern$location %>% table2() %>% print(n=20)
## # A tibble: 116 × 3
##    Group                Count Percent
##    <chr>                <dbl>   <dbl>
##  1 <NA>                  2006  35.6  
##  2 Singapore              547   9.72 
##  3 Other                  396   7.03 
##  4 India                  391   6.95 
##  5 Philippines            293   5.21 
##  6 Brazil                 216   3.84 
##  7 Turkey                 169   3.00 
##  8 China                  147   2.61 
##  9 Mexico                 114   2.03 
## 10 Japan                  112   1.99 
## 11 Indonesia              108   1.92 
## 12 Malaysia               108   1.92 
## 13 South Africa            85   1.51 
## 14 Hong Kong               81   1.44 
## 15 United Arab Emirates    79   1.40 
## 16 South Korea             73   1.30 
## 17 Taiwan                  71   1.26 
## 18 Thailand                66   1.17 
## 19 Argentina               46   0.817
## 20 Saudi Arabia            45   0.799
## # ℹ 96 more rows
d_nonwestern %>% nrow()
## [1] 5629
pet_results_combined_nonwestern = fit_models(
  outcomes,
  min_questions = 0,
  pred = "combined",
  data = d_nonwestern
)

#plot results
pet_results_combined_nonwestern %>% 
  filter(str_detect(term, "dog_cat")) %>% 
  mutate(
    term = str_remove(term, "dog_cat")
  ) %>% 
  ggplot(aes(y, estimate, color = term, ymin = estimate - 2*std.error, ymax = estimate + 2*std.error)) +
  geom_pointrange(position  = position_dodge(width = 0.2)) +
  geom_hline(yintercept = 0, linetype = 2) +
  labs(
    x = "Dimension",
    y = "Standardized difference",
    # title = "Pet preferences and personality dimensions",
    # subtitle = str_glue("Subset to users with a minimum of 500 questions answered. Controlled for age
    color = "Do you like dogs and cats?"
  ) +
  theme(
    axis.text.x = element_text(angle = 10, hjust = 1)
  )

GG_save("figs/pet_results_nominal_nonwestern.png")

Output items used

items_used = tibble(
  trait = c("g", "mental_health", "antisocial", "prudence", "conservatism", "extroversion", "reading", "enjoys_discussion", "religiousness", "drugs", "kink/sex"),
  item = list(
    mirt_g@Fit$h2 %>% names(),
    mirt_mh@Fit$h2 %>% names(),
    mirt_antisocial@Fit$h2 %>% names(),
    mirt_prudence@Fit$h2 %>% names(),
    mirt_conservatism@Fit$h2 %>% names(),
    mirt_extroversion@Fit$h2 %>% names(),
    mirt_reading@Fit$h2 %>% names(),
    mirt_enjoys_discussion@Fit$h2 %>% names(),
    mirt_religiousness@Fit$h2 %>% names(),
    mirt_drugs@Fit$h2 %>% names(),
    mirt_sex_kink@Fit$h2 %>% names()
  ),
  item_code = list(
    g_items$var,
    mental_health_items,
    #antisocial
    c("q400", "q180", "q59919", "q22569", "q39226", "q17017", "q74381", "q21488", "q17056", "q32057", "q20950", "q252", "q1138", "q196", "q19928", "q81783"),
    #prudence
    c("q167", "q33602", "q64022", "q20418", "q16713", "q55", "q23811", "q488"),
    #conservatism
    c("q212813", "q175", "q838", "q27921", "q37708", "q59457", "q34113", "q218", "q486", "q214", "q174", "q244", "q169", "q52719", "q15751"),
    #extroversion
    c("q307", "q63", "q60577", "q18857", "q77", "q1112", "q81", "q78", "q365", "q84", "q60318"),
    #reading
    c("q1119", "q91", "q34662", "q542"),
    #enjoys discussion
    c("q403", "q358084", "q21411", "q40194"),
    #religiousness
    c("q41", "q24125", "q70", "q156913", "q210", "q48372", "q219", "q44", "q265", "q42"),
    #drugs
    c("q9688", "q80", "q79", "q25228", "q62254", "q15414", "q40319"),
    #kink/sex
    c("q12605", "q35355", "q63114", "q1028", "q23993", "q393", "q32", "q72086", "q323", "q637", "q321556", "q665", "q26", "q18966")
  ),
  factor_loading = list(
    mirt_g@Fit$`F` %>% as.numeric(),
    mirt_mh@Fit$`F` %>% as.numeric(),
    mirt_antisocial@Fit$`F` %>% as.numeric(),
    mirt_prudence@Fit$`F` %>% as.numeric(),
    mirt_conservatism@Fit$`F` %>% as.numeric(),
    mirt_extroversion@Fit$`F` %>% as.numeric(),
    mirt_reading@Fit$`F` %>% as.numeric(),
    mirt_enjoys_discussion@Fit$`F` %>% as.numeric(),
    mirt_religiousness@Fit$`F` %>% as.numeric(),
    mirt_drugs@Fit$`F` %>% as.numeric(),
    mirt_sex_kink@Fit$`F` %>% as.numeric()
  ),
) %>% tidyr::unnest(cols = c(item, factor_loading, item_code)) %>% bind_rows(
  tibble(
    trait = rep("fertility", 2),
    item = c("ideal_number_children", "have_children"),
    item_code = c("q979", "q105"),
  ),
  tibble(
    trait = "pet_preference",
    item = c("dog_cat"),
    item_code = "q997"
  )
)

#join with questions and answers
items_used %<>% 
  left_join(d_table, by = c("item_code" = "question"))

#write to disk
items_used %>% write_csv("data/items_used.csv")

Meta

#versions
write_sessioninfo()
## R version 4.4.2 (2024-10-31)
## 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
## 
## 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] ordinal_2023.12-4     mirt_1.42             lattice_0.22-5       
##  [4] kirkegaard_2025-01-08 psych_2.4.6.26        assertthat_0.2.1     
##  [7] weights_1.0.4         Hmisc_5.1-3           magrittr_2.0.3       
## [10] lubridate_1.9.3       forcats_1.0.0         stringr_1.5.1        
## [13] dplyr_1.1.4           purrr_1.0.2           readr_2.1.5          
## [16] tidyr_1.3.1           tibble_3.2.1          ggplot2_3.5.1        
## [19] tidyverse_2.0.0      
## 
## loaded via a namespace (and not attached):
##   [1] rstudioapi_0.16.0    audio_0.1-11         jsonlite_1.8.8      
##   [4] shape_1.4.6.1        jomo_2.7-6           farver_2.1.2        
##   [7] nloptr_2.1.1         rmarkdown_2.28       ragg_1.3.2          
##  [10] vctrs_0.6.5          minqa_1.2.8          base64enc_0.1-3     
##  [13] htmltools_0.5.8.1    curl_5.2.2           broom_1.0.6         
##  [16] Formula_1.2-5        mitml_0.4-5          dcurver_0.9.2       
##  [19] sass_0.4.9           parallelly_1.38.0    bslib_0.8.0         
##  [22] htmlwidgets_1.6.4    plyr_1.8.9           testthat_3.2.1.1    
##  [25] cachem_1.1.0         lifecycle_1.0.4      iterators_1.0.14    
##  [28] pkgconfig_2.0.3      Matrix_1.7-1         R6_2.5.1            
##  [31] fastmap_1.2.0        future_1.34.0        digest_0.6.37       
##  [34] numDeriv_2016.8-1.1  colorspace_2.1-1     textshaping_0.4.0   
##  [37] vegan_2.6-6.1        labeling_0.4.3       progressr_0.14.0    
##  [40] fansi_1.0.6          timechange_0.3.0     gdata_3.0.0         
##  [43] mgcv_1.9-1           compiler_4.4.2       bit64_4.0.5         
##  [46] withr_3.0.1          htmlTable_2.4.3      backports_1.5.0     
##  [49] highr_0.11           R.utils_2.12.3       pan_1.9             
##  [52] MASS_7.3-61          sessioninfo_1.2.2    GPArotation_2024.3-1
##  [55] ucminf_1.2.2         gtools_3.9.5         permute_0.9-7       
##  [58] tools_4.4.2          foreign_0.8-87       future.apply_1.11.2 
##  [61] nnet_7.3-19          R.oo_1.26.0          glue_1.7.0          
##  [64] nlme_3.1-166         grid_4.4.2           checkmate_2.3.2     
##  [67] cluster_2.1.8        generics_0.1.3       snow_0.4-4          
##  [70] gtable_0.3.5         RPushbullet_0.3.4    tzdb_0.4.0          
##  [73] R.methodsS3_1.8.2    data.table_1.16.0    hms_1.1.3           
##  [76] Deriv_4.1.3          utf8_1.2.4           foreach_1.5.2       
##  [79] pillar_1.9.0         vroom_1.6.5          splines_4.4.2       
##  [82] survival_3.7-0       bit_4.0.5            tidyselect_1.2.1    
##  [85] pbapply_1.7-2        knitr_1.48           gridExtra_2.3       
##  [88] xfun_0.47            brio_1.1.5           stringi_1.8.4       
##  [91] yaml_2.3.10          boot_1.3-31          evaluate_0.24.0     
##  [94] codetools_0.2-19     beepr_2.0            cli_3.6.3           
##  [97] rpart_4.1.23         systemfonts_1.1.0    munsell_0.5.1       
## [100] jquerylib_0.1.4      Rcpp_1.0.13          globals_0.16.3      
## [103] parallel_4.4.2       lme4_1.1-35.5        listenv_0.9.1       
## [106] glmnet_4.1-8         SimDesign_2.17.1     scales_1.3.0        
## [109] crayon_1.5.3         rlang_1.1.4          mnormt_2.1.1        
## [112] mice_3.16.0
#write data to file for reuse
d %>% 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/rav59/")
  
  #upload all files in project
  #overwrite existing (versioning)
  osf_upload(
    osf_proj,
    path = c("figs", "notebook.Rmd", "notebook.html", "sessions_info.txt"), 
    conflicts = "overwrite"
    )
}