Init

#global options
options(
  digits = 2,
  contrasts = c("contr.treatment", "contr.treatment")
)

#packages
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,
  rms,
  patchwork
)
## Loading required package: stats4
## Loading required package: lattice
#ggplot2
theme_set(theme_bw())

Functions

#wrapper function to get reliability from model fit
get_empirical_rxx = function(fit) {
  fit %>% 
    fscores(full.scores = T, full.scores.SE = T) %>%
    empirical_rxx()
}

#do DIF testing
#we have to run this quite a few times, so it makes sense to functionalize it
do_DIF_testing = function(data, scales) {
  # browser()
  #find items in the present dataset
  p_items = c()
  if ("gad" %in% scales) {
    p_items = c(p_items, data %>% select(matches("gad\\d")) %>% names())
  }
  if ("dep" %in% scales) {
    p_items = c(p_items, data %>% select(matches("bdi\\d")) %>% names())
  }
  
  #get items
  p_data = data %>% select(
      !!p_items
    ) %>% #drop variables without any data, but keep those with at least 5% data
      miss_filter(
        missing = 0.95,
        by_case = F
      )
  
  woke_data = data %>% select(
      matches("csjas\\d")
    ) %>% #drop variables without any data, but keep those with at least 5% data
      miss_filter(
        missing = 0.95,
        by_case = F
      )
  
  #fit overall models
  p_fit = mirt(
    p_data,
    model = 1,
    itemtype = "graded",
    verbose = F
  )
  
  woke_fit = mirt(
    woke_data,
    model = 1,
    itemtype = "graded",
    verbose = F
  )
  
  #create median splits for DIF testing
  data %<>% mutate(
    p_score = fscores(p_fit, full.scores = T, full.scores.SE = T)[, 1] %>% standardize(),
    woke_score = fscores(woke_fit, full.scores = T, full.scores.SE = T)[, 1] %>% standardize(),
    p_highlow = if_else(p_score > 0, true = "high p", false = "low p") %>% factor(levels = c("low p", "high p")),
    woke_highlow = if_else(woke_score > 0, true = "high woke", false = "low woke") %>% factor(levels = c("low woke", "high woke")),
  )
  
  #run DIF tests
  p_DIF = DIF_test(
    p_data,
    model = 1,
    group = data$woke_highlow,
    itemtype = "graded",
    technical = list(NCYCLES = 10e3),
    accelerate = "none",
    verbose = F
  )
  
  woke_DIF = DIF_test(
    woke_data,
    model = 1,
    group = data$p_highlow,
    itemtype = "graded",
    technical = list(NCYCLES = 10e3),
    accelerate = "none",
    verbose = F
  )
  
  #return results
  list(
    #models
    p_fit = p_fit,
    woke_fit = woke_fit,
    
    #DIF results
    p_DIF = p_DIF,
    woke_DIF = woke_DIF
  )
  
}

Data

#uni data
d1 = read_csv("data/data1.csv")
## Rows: 848 Columns: 55
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## dbl (55): sp, opisk, ophlo, opnumer, normal, gad, bdi, who, vakival, sorto, ...
## 
## ℹ 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.
d1_orig = d1

#recode d1 specific variables
d1 %<>% mutate(
  academic = ophlo %>% mapvalues(
    from = 0:2,
    to = c("student", "unspec work at uni", "non-uni")
  )
)

#filter cases with no data for scales
d1 %<>% miss_filter(
  missing = 0.3,
  vars = names(d1) %>% str_subset("csjas\\d")
  ) %>% 
  miss_filter(
    missing = 0.3,
    vars = names(d1) %>% str_subset("gad\\d")
  ) %>%
  miss_filter(
    missing = 0.3,
    vars = names(d1) %>% str_subset("bdi\\d")
  )

#recode items from "n" to without
str_subset(colnames(d1), "csjas\\d")
##  [1] "csjas1"  "csjas2"  "csjas4"  "csjas5"  "csjas6"  "csjas8"  "csjas9" 
##  [8] "csjas13" "csjas14" "csjas15" "csjas16" "csjas17" "csjas18" "csjas19"
## [15] "csjas20" "csjas21" "csjas22" "csjas23" "csjas24" "csjas25" "csjas26"
#recode items from 1-4 format to 1-5 format
#move option 3 to 4, and 4 to 5
for (v in str_subset(colnames(d1), "csjas\\d")) {
  d1[[v]] = d1[[v]] %>% mapvalues(
    from = 1:4,
    to = c(1, 2, 4, 5)
  )
}

#confirm
d1$csjas26 %>% table2()
#genral pop
d2 = read_csv("data/data2.csv")
## Rows: 5030 Columns: 52
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## dbl (52): sp, koulutustaso, korkeakoulu, ophlo, ala, puolue, asun, gad, mas,...
## 
## ℹ 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.
d2_orig = d2

#extra age data for d2
d2age = read_csv("data/data2withage2.csv")
## Rows: 5030 Columns: 50
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## dbl (50): sp, age, koulutustaso, korkeakoulu, ophlö, ala, puolue, gad, mas, ...
## 
## ℹ 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.
d2$age = d2age$age

#recode d1 specific variables
d2 %<>% mutate(
  academic = ophlo %>% mapvalues(
    from = 1:4,
    to = c("non-uni", "student", "teach at uni", "work at uni")
  )
)

#filter cases for missingness in key scales
d2 %<>% miss_filter(
  missing = 0.3,
  vars = names(d2) %>% str_subset("csjas\\d")
) %>% 
  miss_filter(
    missing = 0.3,
    vars = names(d2) %>% str_subset("gad\\d")
  ) %>%
  miss_filter(
    missing = 0.3,
    vars = names(d2) %>% str_subset("bdi\\d")
  )

#rename items to remove added "n"
str_subset(colnames(d2), "csjas\\d+n")
## [1] "csjas4n"  "csjas5n"  "csjas7n"  "csjas11n" "csjas14n" "csjas15n" "csjas18n"
## [8] "csjas20n"
d2 %<>% rename(
  csjas4 = csjas4n,
  csjas5 = csjas5n,
  csjas7 = csjas7n,
  csjas11 = csjas11n,
  csjas14 = csjas14n,
  csjas15 = csjas15n,
  csjas18 = csjas18n,
  csjas20 = csjas20n
)

#combine overlap
d = bind_rows(
  d1 %>% mutate(dataset = "uni"),
  d2 %>% mutate(dataset = "general")
)

#add an id for later joins and merges
d %<>% mutate(
  id = dataset + row_number()
)

#fix coding error
d$gad7 = d$gad7 %>% mapvalues(from = -1, to = NA)

#sex coding
d %<>% mutate(
  gender = sp %>% mapvalues(
    from = 1:4,
    to = c("male", "female", "other", "refuse")
  ) %>% fct_relevel("male")
)

#party vote
d %<>% mutate(
  vote = puolue %>% mapvalues(
    from = 1:9,
    to = c("Left Alliance", "Green Party", "Social Democratic Party", "Swedish People’s Party", "Centre Party", "National Coalition Party", "Finns Party", "other party", "cant/won't vote")
  ),
  
  #rating scales
  democracy = demokratia %>% standardize(),
  welfare_state = hyvinvointivaltio %>% standardize(),
  capitalism = kapitalismi %>% standardize(),
  individualism = individualismi %>% standardize(),
  thunberg = thunberg %>% standardize(),
  obama = obama %>% standardize(),
  rowling = rowling %>% standardize(),
  self_rated_conservatism = vasoik %>% standardize()

)

#var list
vars = df_var_table(d)

#filter back to uni subset
d1 = d %>% 
  filter(dataset == "uni")

#filter back to uni subset
d2 = d %>% 
  filter(dataset == "general")

Analysis

Main models

#run models and DIF tests
#pooled dataset, both scales
pooled_results_p = do_DIF_testing(d, scales = c("gad", "dep"))
## "csjas21" re-mapped to ensure all categories have a distance of 1
## "csjas22" re-mapped to ensure all categories have a distance of 1
## "csjas23" re-mapped to ensure all categories have a distance of 1
## "csjas24" re-mapped to ensure all categories have a distance of 1
## "csjas25" re-mapped to ensure all categories have a distance of 1
## "csjas26" re-mapped to ensure all categories have a distance of 1
## 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
## There are 8 steps
## Step 1: Initial joint fit
## "csjas21" re-mapped to ensure all categories have a distance of 1
## "csjas22" re-mapped to ensure all categories have a distance of 1
## "csjas23" re-mapped to ensure all categories have a distance of 1
## "csjas24" re-mapped to ensure all categories have a distance of 1
## "csjas25" re-mapped to ensure all categories have a distance of 1
## "csjas26" re-mapped to ensure all categories have a distance of 1
## 
## Step 2: Initial MI fit
## "csjas21" re-mapped to ensure all categories have a distance of 1
## "csjas22" re-mapped to ensure all categories have a distance of 1
## "csjas23" re-mapped to ensure all categories have a distance of 1
## "csjas24" re-mapped to ensure all categories have a distance of 1
## "csjas25" re-mapped to ensure all categories have a distance of 1
## "csjas26" re-mapped to ensure all categories have a distance of 1
## 
## Step 3: Leave one out MI testing
## 
## Step 4: Fit without DIF items, liberal threshold
## "csjas21" re-mapped to ensure all categories have a distance of 1
## "csjas22" re-mapped to ensure all categories have a distance of 1
## "csjas23" re-mapped to ensure all categories have a distance of 1
## "csjas24" re-mapped to ensure all categories have a distance of 1
## "csjas25" re-mapped to ensure all categories have a distance of 1
## "csjas26" re-mapped to ensure all categories have a distance of 1
## 
## Step 5: Fit without DIF items, conservative threshold
## "csjas21" re-mapped to ensure all categories have a distance of 1
## "csjas22" re-mapped to ensure all categories have a distance of 1
## "csjas23" re-mapped to ensure all categories have a distance of 1
## "csjas24" re-mapped to ensure all categories have a distance of 1
## "csjas25" re-mapped to ensure all categories have a distance of 1
## "csjas26" re-mapped to ensure all categories have a distance of 1
## 
## Step 6: Fit with anchor items, liberal threshold
## "csjas21" re-mapped to ensure all categories have a distance of 1
## "csjas22" re-mapped to ensure all categories have a distance of 1
## "csjas23" re-mapped to ensure all categories have a distance of 1
## "csjas24" re-mapped to ensure all categories have a distance of 1
## "csjas25" re-mapped to ensure all categories have a distance of 1
## "csjas26" re-mapped to ensure all categories have a distance of 1
## 
## Step 7: Fit with anchor items, conservative threshold
## "csjas21" re-mapped to ensure all categories have a distance of 1
## "csjas22" re-mapped to ensure all categories have a distance of 1
## "csjas23" re-mapped to ensure all categories have a distance of 1
## "csjas24" re-mapped to ensure all categories have a distance of 1
## "csjas25" re-mapped to ensure all categories have a distance of 1
## "csjas26" re-mapped to ensure all categories have a distance of 1
## 
## Step 8: Get scores
#pooled dataset, gad scale
pooled_results_gad = do_DIF_testing(d, scales = c("gad"))
## "csjas21" re-mapped to ensure all categories have a distance of 1
## "csjas22" re-mapped to ensure all categories have a distance of 1
## "csjas23" re-mapped to ensure all categories have a distance of 1
## "csjas24" re-mapped to ensure all categories have a distance of 1
## "csjas25" re-mapped to ensure all categories have a distance of 1
## "csjas26" re-mapped to ensure all categories have a distance of 1
## 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
## There are 8 steps
## Step 1: Initial joint fit
## "csjas21" re-mapped to ensure all categories have a distance of 1
## "csjas22" re-mapped to ensure all categories have a distance of 1
## "csjas23" re-mapped to ensure all categories have a distance of 1
## "csjas24" re-mapped to ensure all categories have a distance of 1
## "csjas25" re-mapped to ensure all categories have a distance of 1
## "csjas26" re-mapped to ensure all categories have a distance of 1
## 
## Step 2: Initial MI fit
## "csjas21" re-mapped to ensure all categories have a distance of 1
## "csjas22" re-mapped to ensure all categories have a distance of 1
## "csjas23" re-mapped to ensure all categories have a distance of 1
## "csjas24" re-mapped to ensure all categories have a distance of 1
## "csjas25" re-mapped to ensure all categories have a distance of 1
## "csjas26" re-mapped to ensure all categories have a distance of 1
## 
## Step 3: Leave one out MI testing
## 
## Step 4: Fit without DIF items, liberal threshold
## "csjas21" re-mapped to ensure all categories have a distance of 1
## "csjas22" re-mapped to ensure all categories have a distance of 1
## "csjas23" re-mapped to ensure all categories have a distance of 1
## "csjas24" re-mapped to ensure all categories have a distance of 1
## "csjas25" re-mapped to ensure all categories have a distance of 1
## "csjas26" re-mapped to ensure all categories have a distance of 1
## 
## Step 5: Fit without DIF items, conservative threshold
## "csjas21" re-mapped to ensure all categories have a distance of 1
## "csjas22" re-mapped to ensure all categories have a distance of 1
## "csjas23" re-mapped to ensure all categories have a distance of 1
## "csjas24" re-mapped to ensure all categories have a distance of 1
## "csjas25" re-mapped to ensure all categories have a distance of 1
## "csjas26" re-mapped to ensure all categories have a distance of 1
## 
## Step 6: Fit with anchor items, liberal threshold
## "csjas21" re-mapped to ensure all categories have a distance of 1
## "csjas22" re-mapped to ensure all categories have a distance of 1
## "csjas23" re-mapped to ensure all categories have a distance of 1
## "csjas24" re-mapped to ensure all categories have a distance of 1
## "csjas25" re-mapped to ensure all categories have a distance of 1
## "csjas26" re-mapped to ensure all categories have a distance of 1
## 
## Step 7: Fit with anchor items, conservative threshold
## "csjas21" re-mapped to ensure all categories have a distance of 1
## "csjas22" re-mapped to ensure all categories have a distance of 1
## "csjas23" re-mapped to ensure all categories have a distance of 1
## "csjas24" re-mapped to ensure all categories have a distance of 1
## "csjas25" re-mapped to ensure all categories have a distance of 1
## "csjas26" re-mapped to ensure all categories have a distance of 1
## 
## Step 8: Get scores
#save scores
d$p_score = pooled_results_p$p_fit %>% fscores(full.scores = T, full.scores.SE = T) %>% .[, 1] %>% standardize()
d$gad_score = pooled_results_gad$p_fit %>% fscores(full.scores = T, full.scores.SE = T) %>% .[, 1] %>% standardize()
d$woke_score = pooled_results_p$woke_fit %>% fscores(full.scores = T, full.scores.SE = T) %>% .[, 1] %>% standardize()


#university sample, both scales
uni_results_p = do_DIF_testing(d1, scales = c("gad", "dep"))
## "csjas1" re-mapped to ensure all categories have a distance of 1
## "csjas2" re-mapped to ensure all categories have a distance of 1
## "csjas4" re-mapped to ensure all categories have a distance of 1
## "csjas5" re-mapped to ensure all categories have a distance of 1
## "csjas6" re-mapped to ensure all categories have a distance of 1
## "csjas8" re-mapped to ensure all categories have a distance of 1
## "csjas9" re-mapped to ensure all categories have a distance of 1
## "csjas13" re-mapped to ensure all categories have a distance of 1
## "csjas14" re-mapped to ensure all categories have a distance of 1
## "csjas15" re-mapped to ensure all categories have a distance of 1
## "csjas16" re-mapped to ensure all categories have a distance of 1
## "csjas17" re-mapped to ensure all categories have a distance of 1
## "csjas18" re-mapped to ensure all categories have a distance of 1
## "csjas19" re-mapped to ensure all categories have a distance of 1
## "csjas20" re-mapped to ensure all categories have a distance of 1
## "csjas21" re-mapped to ensure all categories have a distance of 1
## "csjas22" re-mapped to ensure all categories have a distance of 1
## "csjas23" re-mapped to ensure all categories have a distance of 1
## "csjas24" re-mapped to ensure all categories have a distance of 1
## "csjas25" re-mapped to ensure all categories have a distance of 1
## "csjas26" re-mapped to ensure all categories have a distance of 1
## 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
## There are 8 steps
## Step 1: Initial joint fit
## "csjas1" re-mapped to ensure all categories have a distance of 1
## "csjas2" re-mapped to ensure all categories have a distance of 1
## "csjas4" re-mapped to ensure all categories have a distance of 1
## "csjas5" re-mapped to ensure all categories have a distance of 1
## "csjas6" re-mapped to ensure all categories have a distance of 1
## "csjas8" re-mapped to ensure all categories have a distance of 1
## "csjas9" re-mapped to ensure all categories have a distance of 1
## "csjas13" re-mapped to ensure all categories have a distance of 1
## "csjas14" re-mapped to ensure all categories have a distance of 1
## "csjas15" re-mapped to ensure all categories have a distance of 1
## "csjas16" re-mapped to ensure all categories have a distance of 1
## "csjas17" re-mapped to ensure all categories have a distance of 1
## "csjas18" re-mapped to ensure all categories have a distance of 1
## "csjas19" re-mapped to ensure all categories have a distance of 1
## "csjas20" re-mapped to ensure all categories have a distance of 1
## "csjas21" re-mapped to ensure all categories have a distance of 1
## "csjas22" re-mapped to ensure all categories have a distance of 1
## "csjas23" re-mapped to ensure all categories have a distance of 1
## "csjas24" re-mapped to ensure all categories have a distance of 1
## "csjas25" re-mapped to ensure all categories have a distance of 1
## "csjas26" re-mapped to ensure all categories have a distance of 1
## 
## Step 2: Initial MI fit
## "csjas1" re-mapped to ensure all categories have a distance of 1
## "csjas2" re-mapped to ensure all categories have a distance of 1
## "csjas4" re-mapped to ensure all categories have a distance of 1
## "csjas5" re-mapped to ensure all categories have a distance of 1
## "csjas6" re-mapped to ensure all categories have a distance of 1
## "csjas8" re-mapped to ensure all categories have a distance of 1
## "csjas9" re-mapped to ensure all categories have a distance of 1
## "csjas13" re-mapped to ensure all categories have a distance of 1
## "csjas14" re-mapped to ensure all categories have a distance of 1
## "csjas15" re-mapped to ensure all categories have a distance of 1
## "csjas16" re-mapped to ensure all categories have a distance of 1
## "csjas17" re-mapped to ensure all categories have a distance of 1
## "csjas18" re-mapped to ensure all categories have a distance of 1
## "csjas19" re-mapped to ensure all categories have a distance of 1
## "csjas20" re-mapped to ensure all categories have a distance of 1
## "csjas21" re-mapped to ensure all categories have a distance of 1
## "csjas22" re-mapped to ensure all categories have a distance of 1
## "csjas23" re-mapped to ensure all categories have a distance of 1
## "csjas24" re-mapped to ensure all categories have a distance of 1
## "csjas25" re-mapped to ensure all categories have a distance of 1
## "csjas26" re-mapped to ensure all categories have a distance of 1
## 
## Step 3: Leave one out MI testing
## 
## Step 4: Fit without DIF items, liberal threshold
## "csjas1" re-mapped to ensure all categories have a distance of 1
## "csjas2" re-mapped to ensure all categories have a distance of 1
## "csjas4" re-mapped to ensure all categories have a distance of 1
## "csjas5" re-mapped to ensure all categories have a distance of 1
## "csjas6" re-mapped to ensure all categories have a distance of 1
## "csjas8" re-mapped to ensure all categories have a distance of 1
## "csjas9" re-mapped to ensure all categories have a distance of 1
## "csjas13" re-mapped to ensure all categories have a distance of 1
## "csjas14" re-mapped to ensure all categories have a distance of 1
## "csjas15" re-mapped to ensure all categories have a distance of 1
## "csjas16" re-mapped to ensure all categories have a distance of 1
## "csjas17" re-mapped to ensure all categories have a distance of 1
## "csjas18" re-mapped to ensure all categories have a distance of 1
## "csjas19" re-mapped to ensure all categories have a distance of 1
## "csjas20" re-mapped to ensure all categories have a distance of 1
## "csjas21" re-mapped to ensure all categories have a distance of 1
## "csjas22" re-mapped to ensure all categories have a distance of 1
## "csjas23" re-mapped to ensure all categories have a distance of 1
## "csjas24" re-mapped to ensure all categories have a distance of 1
## "csjas25" re-mapped to ensure all categories have a distance of 1
## "csjas26" re-mapped to ensure all categories have a distance of 1
## 
## Step 5: Fit without DIF items, conservative threshold
## "csjas1" re-mapped to ensure all categories have a distance of 1
## "csjas2" re-mapped to ensure all categories have a distance of 1
## "csjas4" re-mapped to ensure all categories have a distance of 1
## "csjas5" re-mapped to ensure all categories have a distance of 1
## "csjas6" re-mapped to ensure all categories have a distance of 1
## "csjas8" re-mapped to ensure all categories have a distance of 1
## "csjas9" re-mapped to ensure all categories have a distance of 1
## "csjas13" re-mapped to ensure all categories have a distance of 1
## "csjas14" re-mapped to ensure all categories have a distance of 1
## "csjas15" re-mapped to ensure all categories have a distance of 1
## "csjas16" re-mapped to ensure all categories have a distance of 1
## "csjas17" re-mapped to ensure all categories have a distance of 1
## "csjas18" re-mapped to ensure all categories have a distance of 1
## "csjas19" re-mapped to ensure all categories have a distance of 1
## "csjas20" re-mapped to ensure all categories have a distance of 1
## "csjas21" re-mapped to ensure all categories have a distance of 1
## "csjas22" re-mapped to ensure all categories have a distance of 1
## "csjas23" re-mapped to ensure all categories have a distance of 1
## "csjas24" re-mapped to ensure all categories have a distance of 1
## "csjas25" re-mapped to ensure all categories have a distance of 1
## "csjas26" re-mapped to ensure all categories have a distance of 1
## 
## Step 6: Fit with anchor items, liberal threshold
## "csjas1" re-mapped to ensure all categories have a distance of 1
## "csjas2" re-mapped to ensure all categories have a distance of 1
## "csjas4" re-mapped to ensure all categories have a distance of 1
## "csjas5" re-mapped to ensure all categories have a distance of 1
## "csjas6" re-mapped to ensure all categories have a distance of 1
## "csjas8" re-mapped to ensure all categories have a distance of 1
## "csjas9" re-mapped to ensure all categories have a distance of 1
## "csjas13" re-mapped to ensure all categories have a distance of 1
## "csjas14" re-mapped to ensure all categories have a distance of 1
## "csjas15" re-mapped to ensure all categories have a distance of 1
## "csjas16" re-mapped to ensure all categories have a distance of 1
## "csjas17" re-mapped to ensure all categories have a distance of 1
## "csjas18" re-mapped to ensure all categories have a distance of 1
## "csjas19" re-mapped to ensure all categories have a distance of 1
## "csjas20" re-mapped to ensure all categories have a distance of 1
## "csjas21" re-mapped to ensure all categories have a distance of 1
## "csjas22" re-mapped to ensure all categories have a distance of 1
## "csjas23" re-mapped to ensure all categories have a distance of 1
## "csjas24" re-mapped to ensure all categories have a distance of 1
## "csjas25" re-mapped to ensure all categories have a distance of 1
## "csjas26" re-mapped to ensure all categories have a distance of 1
## 
## Step 7: Fit with anchor items, conservative threshold
## "csjas1" re-mapped to ensure all categories have a distance of 1
## "csjas2" re-mapped to ensure all categories have a distance of 1
## "csjas4" re-mapped to ensure all categories have a distance of 1
## "csjas5" re-mapped to ensure all categories have a distance of 1
## "csjas6" re-mapped to ensure all categories have a distance of 1
## "csjas8" re-mapped to ensure all categories have a distance of 1
## "csjas9" re-mapped to ensure all categories have a distance of 1
## "csjas13" re-mapped to ensure all categories have a distance of 1
## "csjas14" re-mapped to ensure all categories have a distance of 1
## "csjas15" re-mapped to ensure all categories have a distance of 1
## "csjas16" re-mapped to ensure all categories have a distance of 1
## "csjas17" re-mapped to ensure all categories have a distance of 1
## "csjas18" re-mapped to ensure all categories have a distance of 1
## "csjas19" re-mapped to ensure all categories have a distance of 1
## "csjas20" re-mapped to ensure all categories have a distance of 1
## "csjas21" re-mapped to ensure all categories have a distance of 1
## "csjas22" re-mapped to ensure all categories have a distance of 1
## "csjas23" re-mapped to ensure all categories have a distance of 1
## "csjas24" re-mapped to ensure all categories have a distance of 1
## "csjas25" re-mapped to ensure all categories have a distance of 1
## "csjas26" re-mapped to ensure all categories have a distance of 1
## 
## Step 8: Get scores
#university sample, gad scale
uni_results_gad = do_DIF_testing(d1, scales = c("gad"))
## "csjas1" re-mapped to ensure all categories have a distance of 1
## "csjas2" re-mapped to ensure all categories have a distance of 1
## "csjas4" re-mapped to ensure all categories have a distance of 1
## "csjas5" re-mapped to ensure all categories have a distance of 1
## "csjas6" re-mapped to ensure all categories have a distance of 1
## "csjas8" re-mapped to ensure all categories have a distance of 1
## "csjas9" re-mapped to ensure all categories have a distance of 1
## "csjas13" re-mapped to ensure all categories have a distance of 1
## "csjas14" re-mapped to ensure all categories have a distance of 1
## "csjas15" re-mapped to ensure all categories have a distance of 1
## "csjas16" re-mapped to ensure all categories have a distance of 1
## "csjas17" re-mapped to ensure all categories have a distance of 1
## "csjas18" re-mapped to ensure all categories have a distance of 1
## "csjas19" re-mapped to ensure all categories have a distance of 1
## "csjas20" re-mapped to ensure all categories have a distance of 1
## "csjas21" re-mapped to ensure all categories have a distance of 1
## "csjas22" re-mapped to ensure all categories have a distance of 1
## "csjas23" re-mapped to ensure all categories have a distance of 1
## "csjas24" re-mapped to ensure all categories have a distance of 1
## "csjas25" re-mapped to ensure all categories have a distance of 1
## "csjas26" re-mapped to ensure all categories have a distance of 1
## 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
## There are 8 steps
## Step 1: Initial joint fit
## "csjas1" re-mapped to ensure all categories have a distance of 1
## "csjas2" re-mapped to ensure all categories have a distance of 1
## "csjas4" re-mapped to ensure all categories have a distance of 1
## "csjas5" re-mapped to ensure all categories have a distance of 1
## "csjas6" re-mapped to ensure all categories have a distance of 1
## "csjas8" re-mapped to ensure all categories have a distance of 1
## "csjas9" re-mapped to ensure all categories have a distance of 1
## "csjas13" re-mapped to ensure all categories have a distance of 1
## "csjas14" re-mapped to ensure all categories have a distance of 1
## "csjas15" re-mapped to ensure all categories have a distance of 1
## "csjas16" re-mapped to ensure all categories have a distance of 1
## "csjas17" re-mapped to ensure all categories have a distance of 1
## "csjas18" re-mapped to ensure all categories have a distance of 1
## "csjas19" re-mapped to ensure all categories have a distance of 1
## "csjas20" re-mapped to ensure all categories have a distance of 1
## "csjas21" re-mapped to ensure all categories have a distance of 1
## "csjas22" re-mapped to ensure all categories have a distance of 1
## "csjas23" re-mapped to ensure all categories have a distance of 1
## "csjas24" re-mapped to ensure all categories have a distance of 1
## "csjas25" re-mapped to ensure all categories have a distance of 1
## "csjas26" re-mapped to ensure all categories have a distance of 1
## 
## Step 2: Initial MI fit
## "csjas1" re-mapped to ensure all categories have a distance of 1
## "csjas2" re-mapped to ensure all categories have a distance of 1
## "csjas4" re-mapped to ensure all categories have a distance of 1
## "csjas5" re-mapped to ensure all categories have a distance of 1
## "csjas6" re-mapped to ensure all categories have a distance of 1
## "csjas8" re-mapped to ensure all categories have a distance of 1
## "csjas9" re-mapped to ensure all categories have a distance of 1
## "csjas13" re-mapped to ensure all categories have a distance of 1
## "csjas14" re-mapped to ensure all categories have a distance of 1
## "csjas15" re-mapped to ensure all categories have a distance of 1
## "csjas16" re-mapped to ensure all categories have a distance of 1
## "csjas17" re-mapped to ensure all categories have a distance of 1
## "csjas18" re-mapped to ensure all categories have a distance of 1
## "csjas19" re-mapped to ensure all categories have a distance of 1
## "csjas20" re-mapped to ensure all categories have a distance of 1
## "csjas21" re-mapped to ensure all categories have a distance of 1
## "csjas22" re-mapped to ensure all categories have a distance of 1
## "csjas23" re-mapped to ensure all categories have a distance of 1
## "csjas24" re-mapped to ensure all categories have a distance of 1
## "csjas25" re-mapped to ensure all categories have a distance of 1
## "csjas26" re-mapped to ensure all categories have a distance of 1
## 
## Step 3: Leave one out MI testing
## 
## Step 4: Fit without DIF items, liberal threshold
## "csjas1" re-mapped to ensure all categories have a distance of 1
## "csjas2" re-mapped to ensure all categories have a distance of 1
## "csjas4" re-mapped to ensure all categories have a distance of 1
## "csjas5" re-mapped to ensure all categories have a distance of 1
## "csjas6" re-mapped to ensure all categories have a distance of 1
## "csjas8" re-mapped to ensure all categories have a distance of 1
## "csjas9" re-mapped to ensure all categories have a distance of 1
## "csjas13" re-mapped to ensure all categories have a distance of 1
## "csjas14" re-mapped to ensure all categories have a distance of 1
## "csjas15" re-mapped to ensure all categories have a distance of 1
## "csjas16" re-mapped to ensure all categories have a distance of 1
## "csjas17" re-mapped to ensure all categories have a distance of 1
## "csjas18" re-mapped to ensure all categories have a distance of 1
## "csjas19" re-mapped to ensure all categories have a distance of 1
## "csjas20" re-mapped to ensure all categories have a distance of 1
## "csjas21" re-mapped to ensure all categories have a distance of 1
## "csjas22" re-mapped to ensure all categories have a distance of 1
## "csjas23" re-mapped to ensure all categories have a distance of 1
## "csjas24" re-mapped to ensure all categories have a distance of 1
## "csjas25" re-mapped to ensure all categories have a distance of 1
## "csjas26" re-mapped to ensure all categories have a distance of 1
## 
## Step 5: Fit without DIF items, conservative threshold
## "csjas1" re-mapped to ensure all categories have a distance of 1
## "csjas2" re-mapped to ensure all categories have a distance of 1
## "csjas4" re-mapped to ensure all categories have a distance of 1
## "csjas5" re-mapped to ensure all categories have a distance of 1
## "csjas6" re-mapped to ensure all categories have a distance of 1
## "csjas8" re-mapped to ensure all categories have a distance of 1
## "csjas9" re-mapped to ensure all categories have a distance of 1
## "csjas13" re-mapped to ensure all categories have a distance of 1
## "csjas14" re-mapped to ensure all categories have a distance of 1
## "csjas15" re-mapped to ensure all categories have a distance of 1
## "csjas16" re-mapped to ensure all categories have a distance of 1
## "csjas17" re-mapped to ensure all categories have a distance of 1
## "csjas18" re-mapped to ensure all categories have a distance of 1
## "csjas19" re-mapped to ensure all categories have a distance of 1
## "csjas20" re-mapped to ensure all categories have a distance of 1
## "csjas21" re-mapped to ensure all categories have a distance of 1
## "csjas22" re-mapped to ensure all categories have a distance of 1
## "csjas23" re-mapped to ensure all categories have a distance of 1
## "csjas24" re-mapped to ensure all categories have a distance of 1
## "csjas25" re-mapped to ensure all categories have a distance of 1
## "csjas26" re-mapped to ensure all categories have a distance of 1
## 
## Step 6: Fit with anchor items, liberal threshold
## "csjas1" re-mapped to ensure all categories have a distance of 1
## "csjas2" re-mapped to ensure all categories have a distance of 1
## "csjas4" re-mapped to ensure all categories have a distance of 1
## "csjas5" re-mapped to ensure all categories have a distance of 1
## "csjas6" re-mapped to ensure all categories have a distance of 1
## "csjas8" re-mapped to ensure all categories have a distance of 1
## "csjas9" re-mapped to ensure all categories have a distance of 1
## "csjas13" re-mapped to ensure all categories have a distance of 1
## "csjas14" re-mapped to ensure all categories have a distance of 1
## "csjas15" re-mapped to ensure all categories have a distance of 1
## "csjas16" re-mapped to ensure all categories have a distance of 1
## "csjas17" re-mapped to ensure all categories have a distance of 1
## "csjas18" re-mapped to ensure all categories have a distance of 1
## "csjas19" re-mapped to ensure all categories have a distance of 1
## "csjas20" re-mapped to ensure all categories have a distance of 1
## "csjas21" re-mapped to ensure all categories have a distance of 1
## "csjas22" re-mapped to ensure all categories have a distance of 1
## "csjas23" re-mapped to ensure all categories have a distance of 1
## "csjas24" re-mapped to ensure all categories have a distance of 1
## "csjas25" re-mapped to ensure all categories have a distance of 1
## "csjas26" re-mapped to ensure all categories have a distance of 1
## 
## Step 7: Fit with anchor items, conservative threshold
## "csjas1" re-mapped to ensure all categories have a distance of 1
## "csjas2" re-mapped to ensure all categories have a distance of 1
## "csjas4" re-mapped to ensure all categories have a distance of 1
## "csjas5" re-mapped to ensure all categories have a distance of 1
## "csjas6" re-mapped to ensure all categories have a distance of 1
## "csjas8" re-mapped to ensure all categories have a distance of 1
## "csjas9" re-mapped to ensure all categories have a distance of 1
## "csjas13" re-mapped to ensure all categories have a distance of 1
## "csjas14" re-mapped to ensure all categories have a distance of 1
## "csjas15" re-mapped to ensure all categories have a distance of 1
## "csjas16" re-mapped to ensure all categories have a distance of 1
## "csjas17" re-mapped to ensure all categories have a distance of 1
## "csjas18" re-mapped to ensure all categories have a distance of 1
## "csjas19" re-mapped to ensure all categories have a distance of 1
## "csjas20" re-mapped to ensure all categories have a distance of 1
## "csjas21" re-mapped to ensure all categories have a distance of 1
## "csjas22" re-mapped to ensure all categories have a distance of 1
## "csjas23" re-mapped to ensure all categories have a distance of 1
## "csjas24" re-mapped to ensure all categories have a distance of 1
## "csjas25" re-mapped to ensure all categories have a distance of 1
## "csjas26" re-mapped to ensure all categories have a distance of 1
## 
## Step 8: Get scores
#university sample, dep scale
uni_results_dep = do_DIF_testing(d1, scales = c("dep"))
## "csjas1" re-mapped to ensure all categories have a distance of 1
## "csjas2" re-mapped to ensure all categories have a distance of 1
## "csjas4" re-mapped to ensure all categories have a distance of 1
## "csjas5" re-mapped to ensure all categories have a distance of 1
## "csjas6" re-mapped to ensure all categories have a distance of 1
## "csjas8" re-mapped to ensure all categories have a distance of 1
## "csjas9" re-mapped to ensure all categories have a distance of 1
## "csjas13" re-mapped to ensure all categories have a distance of 1
## "csjas14" re-mapped to ensure all categories have a distance of 1
## "csjas15" re-mapped to ensure all categories have a distance of 1
## "csjas16" re-mapped to ensure all categories have a distance of 1
## "csjas17" re-mapped to ensure all categories have a distance of 1
## "csjas18" re-mapped to ensure all categories have a distance of 1
## "csjas19" re-mapped to ensure all categories have a distance of 1
## "csjas20" re-mapped to ensure all categories have a distance of 1
## "csjas21" re-mapped to ensure all categories have a distance of 1
## "csjas22" re-mapped to ensure all categories have a distance of 1
## "csjas23" re-mapped to ensure all categories have a distance of 1
## "csjas24" re-mapped to ensure all categories have a distance of 1
## "csjas25" re-mapped to ensure all categories have a distance of 1
## "csjas26" re-mapped to ensure all categories have a distance of 1
## 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
## There are 8 steps
## Step 1: Initial joint fit
## "csjas1" re-mapped to ensure all categories have a distance of 1
## "csjas2" re-mapped to ensure all categories have a distance of 1
## "csjas4" re-mapped to ensure all categories have a distance of 1
## "csjas5" re-mapped to ensure all categories have a distance of 1
## "csjas6" re-mapped to ensure all categories have a distance of 1
## "csjas8" re-mapped to ensure all categories have a distance of 1
## "csjas9" re-mapped to ensure all categories have a distance of 1
## "csjas13" re-mapped to ensure all categories have a distance of 1
## "csjas14" re-mapped to ensure all categories have a distance of 1
## "csjas15" re-mapped to ensure all categories have a distance of 1
## "csjas16" re-mapped to ensure all categories have a distance of 1
## "csjas17" re-mapped to ensure all categories have a distance of 1
## "csjas18" re-mapped to ensure all categories have a distance of 1
## "csjas19" re-mapped to ensure all categories have a distance of 1
## "csjas20" re-mapped to ensure all categories have a distance of 1
## "csjas21" re-mapped to ensure all categories have a distance of 1
## "csjas22" re-mapped to ensure all categories have a distance of 1
## "csjas23" re-mapped to ensure all categories have a distance of 1
## "csjas24" re-mapped to ensure all categories have a distance of 1
## "csjas25" re-mapped to ensure all categories have a distance of 1
## "csjas26" re-mapped to ensure all categories have a distance of 1
## 
## Step 2: Initial MI fit
## "csjas1" re-mapped to ensure all categories have a distance of 1
## "csjas2" re-mapped to ensure all categories have a distance of 1
## "csjas4" re-mapped to ensure all categories have a distance of 1
## "csjas5" re-mapped to ensure all categories have a distance of 1
## "csjas6" re-mapped to ensure all categories have a distance of 1
## "csjas8" re-mapped to ensure all categories have a distance of 1
## "csjas9" re-mapped to ensure all categories have a distance of 1
## "csjas13" re-mapped to ensure all categories have a distance of 1
## "csjas14" re-mapped to ensure all categories have a distance of 1
## "csjas15" re-mapped to ensure all categories have a distance of 1
## "csjas16" re-mapped to ensure all categories have a distance of 1
## "csjas17" re-mapped to ensure all categories have a distance of 1
## "csjas18" re-mapped to ensure all categories have a distance of 1
## "csjas19" re-mapped to ensure all categories have a distance of 1
## "csjas20" re-mapped to ensure all categories have a distance of 1
## "csjas21" re-mapped to ensure all categories have a distance of 1
## "csjas22" re-mapped to ensure all categories have a distance of 1
## "csjas23" re-mapped to ensure all categories have a distance of 1
## "csjas24" re-mapped to ensure all categories have a distance of 1
## "csjas25" re-mapped to ensure all categories have a distance of 1
## "csjas26" re-mapped to ensure all categories have a distance of 1
## 
## Step 3: Leave one out MI testing
## 
## Step 4: Fit without DIF items, liberal threshold
## "csjas1" re-mapped to ensure all categories have a distance of 1
## "csjas2" re-mapped to ensure all categories have a distance of 1
## "csjas4" re-mapped to ensure all categories have a distance of 1
## "csjas5" re-mapped to ensure all categories have a distance of 1
## "csjas6" re-mapped to ensure all categories have a distance of 1
## "csjas8" re-mapped to ensure all categories have a distance of 1
## "csjas9" re-mapped to ensure all categories have a distance of 1
## "csjas13" re-mapped to ensure all categories have a distance of 1
## "csjas14" re-mapped to ensure all categories have a distance of 1
## "csjas15" re-mapped to ensure all categories have a distance of 1
## "csjas16" re-mapped to ensure all categories have a distance of 1
## "csjas17" re-mapped to ensure all categories have a distance of 1
## "csjas18" re-mapped to ensure all categories have a distance of 1
## "csjas19" re-mapped to ensure all categories have a distance of 1
## "csjas20" re-mapped to ensure all categories have a distance of 1
## "csjas21" re-mapped to ensure all categories have a distance of 1
## "csjas22" re-mapped to ensure all categories have a distance of 1
## "csjas23" re-mapped to ensure all categories have a distance of 1
## "csjas24" re-mapped to ensure all categories have a distance of 1
## "csjas25" re-mapped to ensure all categories have a distance of 1
## "csjas26" re-mapped to ensure all categories have a distance of 1
## 
## Step 5: Fit without DIF items, conservative threshold
## "csjas1" re-mapped to ensure all categories have a distance of 1
## "csjas2" re-mapped to ensure all categories have a distance of 1
## "csjas4" re-mapped to ensure all categories have a distance of 1
## "csjas5" re-mapped to ensure all categories have a distance of 1
## "csjas6" re-mapped to ensure all categories have a distance of 1
## "csjas8" re-mapped to ensure all categories have a distance of 1
## "csjas9" re-mapped to ensure all categories have a distance of 1
## "csjas13" re-mapped to ensure all categories have a distance of 1
## "csjas14" re-mapped to ensure all categories have a distance of 1
## "csjas15" re-mapped to ensure all categories have a distance of 1
## "csjas16" re-mapped to ensure all categories have a distance of 1
## "csjas17" re-mapped to ensure all categories have a distance of 1
## "csjas18" re-mapped to ensure all categories have a distance of 1
## "csjas19" re-mapped to ensure all categories have a distance of 1
## "csjas20" re-mapped to ensure all categories have a distance of 1
## "csjas21" re-mapped to ensure all categories have a distance of 1
## "csjas22" re-mapped to ensure all categories have a distance of 1
## "csjas23" re-mapped to ensure all categories have a distance of 1
## "csjas24" re-mapped to ensure all categories have a distance of 1
## "csjas25" re-mapped to ensure all categories have a distance of 1
## "csjas26" re-mapped to ensure all categories have a distance of 1
## 
## Step 6: Fit with anchor items, liberal threshold
## "csjas1" re-mapped to ensure all categories have a distance of 1
## "csjas2" re-mapped to ensure all categories have a distance of 1
## "csjas4" re-mapped to ensure all categories have a distance of 1
## "csjas5" re-mapped to ensure all categories have a distance of 1
## "csjas6" re-mapped to ensure all categories have a distance of 1
## "csjas8" re-mapped to ensure all categories have a distance of 1
## "csjas9" re-mapped to ensure all categories have a distance of 1
## "csjas13" re-mapped to ensure all categories have a distance of 1
## "csjas14" re-mapped to ensure all categories have a distance of 1
## "csjas15" re-mapped to ensure all categories have a distance of 1
## "csjas16" re-mapped to ensure all categories have a distance of 1
## "csjas17" re-mapped to ensure all categories have a distance of 1
## "csjas18" re-mapped to ensure all categories have a distance of 1
## "csjas19" re-mapped to ensure all categories have a distance of 1
## "csjas20" re-mapped to ensure all categories have a distance of 1
## "csjas21" re-mapped to ensure all categories have a distance of 1
## "csjas22" re-mapped to ensure all categories have a distance of 1
## "csjas23" re-mapped to ensure all categories have a distance of 1
## "csjas24" re-mapped to ensure all categories have a distance of 1
## "csjas25" re-mapped to ensure all categories have a distance of 1
## "csjas26" re-mapped to ensure all categories have a distance of 1
## 
## Step 7: Fit with anchor items, conservative threshold
## "csjas1" re-mapped to ensure all categories have a distance of 1
## "csjas2" re-mapped to ensure all categories have a distance of 1
## "csjas4" re-mapped to ensure all categories have a distance of 1
## "csjas5" re-mapped to ensure all categories have a distance of 1
## "csjas6" re-mapped to ensure all categories have a distance of 1
## "csjas8" re-mapped to ensure all categories have a distance of 1
## "csjas9" re-mapped to ensure all categories have a distance of 1
## "csjas13" re-mapped to ensure all categories have a distance of 1
## "csjas14" re-mapped to ensure all categories have a distance of 1
## "csjas15" re-mapped to ensure all categories have a distance of 1
## "csjas16" re-mapped to ensure all categories have a distance of 1
## "csjas17" re-mapped to ensure all categories have a distance of 1
## "csjas18" re-mapped to ensure all categories have a distance of 1
## "csjas19" re-mapped to ensure all categories have a distance of 1
## "csjas20" re-mapped to ensure all categories have a distance of 1
## "csjas21" re-mapped to ensure all categories have a distance of 1
## "csjas22" re-mapped to ensure all categories have a distance of 1
## "csjas23" re-mapped to ensure all categories have a distance of 1
## "csjas24" re-mapped to ensure all categories have a distance of 1
## "csjas25" re-mapped to ensure all categories have a distance of 1
## "csjas26" re-mapped to ensure all categories have a distance of 1
## 
## Step 8: Get scores
#save scores
d1$p_score = uni_results_p$p_fit %>% fscores(full.scores = T, full.scores.SE = T) %>% .[, 1] %>% standardize()
d1$gad_score = uni_results_gad$p_fit %>% fscores(full.scores = T, full.scores.SE = T) %>% .[, 1] %>% standardize()
d1$dep_score = uni_results_dep$p_fit %>% fscores(full.scores = T, full.scores.SE = T) %>% .[, 1] %>% standardize()
d1$woke_score = uni_results_p$woke_fit %>% fscores(full.scores = T, full.scores.SE = T) %>% .[, 1] %>% standardize()

#general population dataset, gad scale
gen_results_gad = do_DIF_testing(d2, scales = c("gad"))
## 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
## 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
#save scores
d2$gad_score = gen_results_gad$p_fit %>% fscores(full.scores = T, full.scores.SE = T) %>% .[, 1] %>% standardize()
d2$woke_score = gen_results_gad$woke_fit %>% fscores(full.scores = T, full.scores.SE = T) %>% .[, 1] %>% standardize()


#reliability
c(
  pooled_p = pooled_results_p$p_fit %>% get_empirical_rxx(),
  pooled_woke = pooled_results_p$woke_fit %>% get_empirical_rxx(),
  uni_p = uni_results_p$p_fit %>% get_empirical_rxx(),
  uni_gad = uni_results_gad$p_fit %>% get_empirical_rxx(),
  uni_dep = uni_results_dep$p_fit %>% get_empirical_rxx(),
  uni_woke = uni_results_p$woke_fit %>% get_empirical_rxx(),
  gen_gad = gen_results_gad$p_fit %>% get_empirical_rxx(),
  gen_woke = gen_results_gad$woke_fit %>% get_empirical_rxx()
)
##    pooled_p.F1 pooled_woke.F1       uni_p.F1     uni_gad.F1     uni_dep.F1 
##           0.86           0.93           0.92           0.87           0.89 
##    uni_woke.F1     gen_gad.F1    gen_woke.F1 
##           0.92           0.85           0.93
#median splits
#pooled
d %<>% mutate(
  p_highlow = if_else(d$p_score > 0, true = "high p", false = "low p") %>% factor(levels = c("low p", "high p")),
  woke_highlow = if_else(d$woke_score > 0, true = "high woke", false = "low woke") %>% factor(levels = c("low woke", "high woke")),
)

#uni
d1 %<>% mutate(
  p_highlow = if_else(d1$p_score > 0, true = "high p", false = "low p") %>% factor(levels = c("low p", "high p")),
  woke_highlow = if_else(d1$woke_score > 0, true = "high woke", false = "low woke") %>% factor(levels = c("low woke", "high woke")),
)

#general
d2 %<>% mutate(
  gad_highlow = if_else(d2$gad_score > 0, true = "high gad", false = "low gad") %>% factor(levels = c("low gad", "high gad")),
  woke_highlow = if_else(d2$woke_score > 0, true = "high woke", false = "low woke") %>% factor(levels = c("low woke", "high woke")),
)

Main results

#main plots
#pooled dataset
#p
d %>% 
  GG_scatter("p_score", "woke_score") +
  geom_smooth() +
  scale_x_continuous("Internalizing score") +
  scale_y_continuous("Wokeness score")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'

GG_save("figs/pooled woke p.png")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'
#nonlinearity?
lrtest(
  ols(woke_score ~ p_score, data = d),
  ols(woke_score ~ rcs(p_score), data = d)
)
## number of knots in rcs defaulting to 5
## 
## Model 1: woke_score ~ p_score
## Model 2: woke_score ~ rcs(p_score)
## 
## L.R. Chisq       d.f.          P 
##    6.9e+01    3.0e+00    6.9e-15
#anxiety plot
d %>% 
  GG_scatter("gad_score", "woke_score", ) +
  geom_smooth() +
  scale_x_continuous("General anxiety score") +
  scale_y_continuous("Wokeness score")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'

GG_save("figs/pooled woke p.png")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'
#nonlinearity?
lrtest(
  ols(woke_score ~ gad_score, data = d),
  ols(woke_score ~ rcs(gad_score), data = d)
)
## number of knots in rcs defaulting to 5
## 
## Model 1: woke_score ~ gad_score
## Model 2: woke_score ~ rcs(gad_score)
## 
## L.R. Chisq       d.f.          P 
##         81          3          0
#university sample
#p
d1 %>% 
  GG_scatter("p_score", "woke_score") +
  geom_smooth() +
  scale_x_continuous("Internalizing score") +
  scale_y_continuous("Wokeness score")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'

GG_save("figs/uni woke p.png")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
#gad
uni_gad = d1 %>% 
  GG_scatter("gad_score", "woke_score") +
  geom_smooth() +
  scale_x_continuous("General anxiety score") +
  scale_y_continuous("Wokeness score")

uni_gad
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'

GG_save("figs/uni woke gad.png")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
#dep
uni_dep = d1 %>% 
  GG_scatter("dep_score", "woke_score") +
  geom_smooth() +
  scale_x_continuous("Depression score") +
  scale_y_continuous("Wokeness score")

uni_dep
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'

GG_save("figs/uni woke dep.png")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
#combined plot
uni_gad + uni_dep
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'

GG_save("figs/uni woke both.png")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
#reliability corrections
correct.cor(
  d1 %>% select(p_score, gad_score, dep_score, woke_score) %>% cor(use = "pairwise"),
  c(
    get_empirical_rxx(uni_results_p$p_fit), 
    get_empirical_rxx(uni_results_gad$p_fit), 
    get_empirical_rxx(uni_results_dep$p_fit), 
    get_empirical_rxx(uni_results_p$woke_fit)
  )
)
##            p_score gad_score dep_score woke_score
## p_score       0.92      0.98      1.01       0.31
## gad_score     0.88      0.87      0.72       0.37
## dep_score     0.92      0.63      0.89       0.22
## woke_score    0.29      0.33      0.20       0.92
#paired correlations test
r.test(
  r12 = d1 %>% select(woke_score, gad_score) %>% wtd.cors() %>% .[1, 2],
  r13 = d1 %>% select(woke_score, dep_score) %>% wtd.cors() %>% .[1, 2],
  r23 = d1 %>% select(gad_score, dep_score) %>% wtd.cors() %>% .[1, 2],
  n = nrow(d1)
)
## Correlation tests 
## Call:[1] "r.test(n =  848 ,  r12 =  0.329731104655632 ,  r23 =  0.631990404203066 ,  r13 =  0.196313219382672 )"
## Test of difference between two correlated  correlations 
##  t value 4.8    with probability < 2.1e-06
#general population sample
#gad
d2 %>% 
  GG_scatter("gad_score", "woke_score") +
  geom_smooth() +
  scale_x_continuous("General anxiety score") +
  scale_y_continuous("Wokeness score")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'

GG_save("figs/gen woke gad.png")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'
#reliability correction
correct.cor(
  d2 %>% select(gad_score, woke_score) %>% cor(use = "pairwise"),
  c(
    get_empirical_rxx(gen_results_gad$p_fit), 
    get_empirical_rxx(gen_results_gad$woke_fit)
  )
)
##            gad_score woke_score
## gad_score       0.85       0.42
## woke_score      0.38       0.93
#compare range restriction in university and general population sample for gad and wokeness
(vars_sums = describe2(
  d %>% select(gad_score, woke_score),
  group = d$dataset
))

DIF results

#make a table with median split gaps and DIF effect sizes
bias_table = tibble(
  pooled_p_d = cohen.d(
    d %>% select(p_score),
    group = d$woke_highlow
  )$cohen.d[2],
  pooled_gad_d = cohen.d(
    d %>% select(gad_score),
    group = d$woke_highlow
  )$cohen.d[2],
  uni_p_d = cohen.d(
    d1 %>% select(p_score),
    group = d1$woke_highlow
  )$cohen.d[2],
  uni_gad_d = cohen.d(
    d1 %>% select(gad_score),
    group = d1$woke_highlow
  )$cohen.d[2],
  uni_dep_d = cohen.d(
    d1 %>% select(dep_score),
    group = d1$woke_highlow
  )$cohen.d[2],
  gen_gad_d = cohen.d(
    d2 %>% select(gad_score),
    group = d2$woke_highlow
  )$cohen.d[2],
  #bias values
  pooled_p_bias = pooled_results_p$p_DIF$effect_size_test$conservative$Value[4],
  pooled_gad_bias = pooled_results_gad$p_DIF$effect_size_test$conservative$Value[4],
  
  uni_p_bias = uni_results_p$p_DIF$effect_size_test$conservative$Value[4],
  uni_gad_bias = uni_results_gad$p_DIF$effect_size_test$conservative$Value[4],
  uni_dep_bias = uni_results_dep$p_DIF$effect_size_test$conservative$Value[4],
  
  gen_gad_bias = gen_results_gad$p_DIF$effect_size_test$conservative$Value[4]
) %>% 
  pivot_longer(cols = everything(), names_to = "variable", values_to = "value") %>% 
  separate(variable, into = c("dataset", "trait", "metric"), sep = "_", remove = F) %>% 
  select(-variable) %>% 
  pivot_wider(names_from = "metric", values_from = "value")

bias_table
#wokeness DIF tests
pooled_results_p$woke_DIF$effect_size_test$conservative$Value[4]
## [1] 0.0034
uni_results_p$woke_DIF$effect_size_test$conservative$Value[4]
## [1] -0.0033
uni_results_gad$woke_DIF$effect_size_test$conservative$Value[4]
## [1] -0.0016
uni_results_dep$woke_DIF$effect_size_test$conservative$Value[4]
## [1] 0.0078
gen_results_gad$woke_DIF$effect_size_test$conservative$Value[4]
## [1] 0.0054

Model details

#pooled samlpe
#wokeness
pooled_results_p$woke_fit %>% summary()
##             F1     h2
## csjas1   0.863 0.7440
## csjas2   0.853 0.7275
## csjas4   0.834 0.6955
## csjas5   0.682 0.4648
## csjas6   0.658 0.4330
## csjas8   0.741 0.5493
## csjas9   0.794 0.6300
## csjas13  0.735 0.5399
## csjas14  0.590 0.3477
## csjas15  0.776 0.6027
## csjas16  0.707 0.4999
## csjas17  0.785 0.6168
## csjas18  0.640 0.4097
## csjas19  0.578 0.3337
## csjas20  0.643 0.4129
## csjas21  0.590 0.3476
## csjas22  0.702 0.4923
## csjas23  0.564 0.3183
## csjas24  0.104 0.0108
## csjas25 -0.101 0.0103
## csjas26 -0.132 0.0175
## csjas3   0.852 0.7264
## csjas7   0.679 0.4612
## csjas10  0.853 0.7269
## csjas11  0.683 0.4670
## csjas12  0.694 0.4823
## 
## SS loadings:  12 
## Proportion Var:  0.46 
## 
## Factor correlations: 
## 
##    F1
## F1  1
pooled_results_p$woke_fit %>% coef(simplify = T)
## $items
##            a1     d1     d2     d3   d4
## csjas1   2.90  1.210 -1.160 -1.685 -4.7
## csjas2   2.78  0.882 -1.019 -2.178 -4.2
## csjas4   2.57  0.232 -1.286 -1.926 -3.4
## csjas5   1.59  0.998 -0.439 -0.953 -2.5
## csjas6   1.49  1.793  0.227 -0.071 -1.8
## csjas8   1.88 -0.316 -1.837 -2.435 -4.4
## csjas9   2.22  1.707  0.344 -0.129 -1.8
## csjas13  1.84 -1.902 -3.610 -4.390 -5.6
## csjas14  1.24 -0.021 -1.141 -1.445 -2.8
## csjas15  2.10 -0.039 -1.458 -1.690 -3.0
## csjas16  1.70  1.744 -0.078 -0.369 -2.3
## csjas17  2.16 -0.916 -2.620 -3.118 -4.9
## csjas18  1.42  0.392 -0.648 -1.850 -3.3
## csjas19  1.20  0.317 -1.688 -2.290 -4.3
## csjas20  1.43 -1.503 -2.878 -3.221 -4.7
## csjas21  1.24 -1.913 -3.379 -4.191   NA
## csjas22  1.68 -1.963 -4.784 -6.166   NA
## csjas23  1.16  0.397 -1.879 -3.534   NA
## csjas24  0.18 -0.567 -2.572 -3.269   NA
## csjas25 -0.17  0.240 -1.317 -2.567   NA
## csjas26 -0.23 -0.560 -2.104 -2.635   NA
## csjas3   2.77  1.678 -0.068 -0.749 -3.0
## csjas7   1.57  0.979 -0.567 -1.450 -3.0
## csjas10  2.78  1.820  0.413 -0.654 -2.4
## csjas11  1.59  0.777 -0.444 -0.888 -2.7
## csjas12  1.64 -0.608 -1.492 -2.948 -4.0
## 
## $means
## F1 
##  0 
## 
## $cov
##    F1
## F1  1
#p
pooled_results_p$p_fit %>% summary()
##          F1    h2
## gad1  0.881 0.776
## gad2  0.894 0.799
## gad3  0.894 0.798
## gad4  0.855 0.730
## gad5  0.773 0.598
## gad6  0.708 0.502
## gad7  0.745 0.556
## bdi1  0.812 0.659
## bdi2  0.685 0.469
## bdi3  0.592 0.351
## bdi4  0.768 0.590
## bdi5  0.579 0.335
## bdi6  0.487 0.237
## bdi7  0.766 0.587
## bdi8  0.727 0.529
## bdi9  0.761 0.579
## bdi10 0.588 0.346
## bdi11 0.470 0.221
## bdi12 0.630 0.397
## bdi13 0.703 0.495
## 
## SS loadings:  11 
## Proportion Var:  0.53 
## 
## Factor correlations: 
## 
##    F1
## F1  1
pooled_results_p$p_fit %>% coef(simplify = T)
## $items
##         a1     d1    d2   d3   d4
## gad1  3.17  0.619 -3.62 -5.3   NA
## gad2  3.40 -0.500 -4.50 -6.4   NA
## gad3  3.39 -0.215 -4.48 -6.4   NA
## gad4  2.80 -0.156 -3.78 -5.2   NA
## gad5  2.08 -1.775 -4.21 -5.5   NA
## gad6  1.71  0.290 -2.87 -4.1   NA
## gad7  1.90 -0.862 -3.58 -4.6   NA
## bdi1  2.37 -0.003 -3.06 -5.4 -7.8
## bdi2  1.60 -0.588 -2.58 -4.2 -4.9
## bdi3  1.25  0.154 -2.32 -4.5 -7.5
## bdi4  2.04 -0.028 -2.59 -5.2 -7.8
## bdi5  1.21  0.367 -3.67 -6.2 -7.5
## bdi6  0.95 -0.522 -2.99 -5.6 -7.2
## bdi7  2.03 -0.571 -3.06 -5.7 -8.2
## bdi8  1.80  1.137 -1.85 -4.3   NA
## bdi9  1.99  1.078 -2.21 -5.3 -6.7
## bdi10 1.24  1.333 -1.02 -2.1 -2.7
## bdi11 0.91  0.301 -1.59 -3.6 -5.1
## bdi12 1.38  0.384 -1.94 -3.6 -4.7
## bdi13 1.68  3.495 -0.83 -3.6 -6.0
## 
## $means
## F1 
##  0 
## 
## $cov
##    F1
## F1  1
#university sample
#wokeness
uni_results_p$woke_fit %>% summary()
##             F1     h2
## csjas1   0.866 0.7506
## csjas2   0.876 0.7667
## csjas4   0.849 0.7214
## csjas5   0.692 0.4785
## csjas6   0.649 0.4207
## csjas8   0.705 0.4968
## csjas9   0.844 0.7117
## csjas13  0.692 0.4785
## csjas14  0.711 0.5062
## csjas15  0.817 0.6681
## csjas16  0.743 0.5518
## csjas17  0.829 0.6864
## csjas18  0.701 0.4908
## csjas19  0.628 0.3943
## csjas20  0.633 0.4001
## csjas21  0.592 0.3500
## csjas22  0.707 0.4993
## csjas23  0.568 0.3224
## csjas24  0.105 0.0111
## csjas25 -0.106 0.0111
## csjas26 -0.132 0.0175
## 
## SS loadings:  9.7 
## Proportion Var:  0.46 
## 
## Factor correlations: 
## 
##    F1
## F1  1
uni_results_p$woke_fit %>% coef(simplify = T)
## $items
##            a1    d1     d2   d3
## csjas1   2.95  1.53 -1.312 -4.8
## csjas2   3.09  1.06 -1.825 -4.6
## csjas4   2.74  1.09 -0.869 -3.3
## csjas5   1.63  1.48 -0.555 -2.3
## csjas6   1.45  1.64 -0.007 -2.0
## csjas8   1.69 -0.28 -1.996 -4.3
## csjas9   2.67  2.44  0.944 -1.3
## csjas13  1.63 -1.70 -4.313 -5.8
## csjas14  1.72  0.19 -1.477 -3.6
## csjas15  2.42  0.25 -1.697 -3.5
## csjas16  1.89  1.86 -0.321 -2.5
## csjas17  2.52 -1.56 -3.590 -5.5
## csjas18  1.67  0.76 -1.284 -3.5
## csjas19  1.37  0.40 -1.966 -4.2
## csjas20  1.39 -1.25 -2.768 -4.6
## csjas21  1.25 -1.84 -3.310 -4.1
## csjas22  1.70 -1.87 -4.722 -6.1
## csjas23  1.17  0.47 -1.813 -3.5
## csjas24  0.18 -0.56 -2.562 -3.3
## csjas25 -0.18  0.23 -1.327 -2.6
## csjas26 -0.23 -0.57 -2.116 -2.6
## 
## $means
## F1 
##  0 
## 
## $cov
##    F1
## F1  1
#p
uni_results_p$p_fit %>% summary()
##          F1    h2
## gad1  0.844 0.712
## gad2  0.829 0.686
## gad3  0.818 0.669
## gad4  0.787 0.620
## gad5  0.716 0.513
## gad6  0.685 0.469
## gad7  0.666 0.444
## bdi1  0.809 0.655
## bdi2  0.678 0.460
## bdi3  0.597 0.357
## bdi4  0.769 0.592
## bdi5  0.570 0.325
## bdi6  0.472 0.223
## bdi7  0.767 0.588
## bdi8  0.717 0.514
## bdi9  0.764 0.583
## bdi10 0.566 0.321
## bdi11 0.468 0.219
## bdi12 0.619 0.383
## bdi13 0.689 0.475
## 
## SS loadings:  9.8 
## Proportion Var:  0.49 
## 
## Factor correlations: 
## 
##    F1
## F1  1
uni_results_p$p_fit %>% coef(simplify = T)
## $items
##         a1     d1    d2   d3   d4
## gad1  2.67  0.867 -2.85 -4.6   NA
## gad2  2.52 -0.280 -3.50 -4.9   NA
## gad3  2.42  0.033 -3.35 -4.8   NA
## gad4  2.17  0.529 -2.88 -4.5   NA
## gad5  1.75 -1.517 -3.81 -4.7   NA
## gad6  1.60  0.161 -2.86 -4.1   NA
## gad7  1.52 -0.956 -3.44 -4.4   NA
## bdi1  2.35  0.209 -2.97 -5.5 -7.9
## bdi2  1.57 -0.463 -2.52 -4.1 -4.9
## bdi3  1.27  0.267 -2.28 -4.5 -7.6
## bdi4  2.05  0.155 -2.52 -5.2 -7.9
## bdi5  1.18  0.475 -3.62 -6.1 -7.5
## bdi6  0.91 -0.446 -2.93 -5.6 -7.2
## bdi7  2.03 -0.409 -3.01 -5.8 -8.3
## bdi8  1.75  1.311 -1.73 -4.2   NA
## bdi9  2.01  1.298 -2.13 -5.4 -6.8
## bdi10 1.17  1.434 -0.92 -2.0 -2.6
## bdi11 0.90  0.380 -1.54 -3.5 -5.1
## bdi12 1.34  0.505 -1.85 -3.6 -4.6
## bdi13 1.62  3.634 -0.70 -3.5 -6.0
## 
## $means
## F1 
##  0 
## 
## $cov
##    F1
## F1  1
#gad
uni_results_gad$p_fit %>% summary()
##         F1    h2
## gad1 0.897 0.805
## gad2 0.923 0.852
## gad3 0.915 0.837
## gad4 0.854 0.730
## gad5 0.772 0.596
## gad6 0.738 0.545
## gad7 0.744 0.554
## 
## SS loadings:  4.9 
## Proportion Var:  0.7 
## 
## Factor correlations: 
## 
##    F1
## F1  1
uni_results_gad$p_fit %>% coef(simplify = T)
## $items
##       a1     d1   d2   d3
## gad1 3.5  1.039 -3.4 -5.6
## gad2 4.1 -0.373 -5.0 -7.0
## gad3 3.9  0.054 -4.7 -6.8
## gad4 2.8  0.622 -3.4 -5.3
## gad5 2.1 -1.652 -4.2 -5.1
## gad6 1.9  0.181 -3.1 -4.4
## gad7 1.9 -1.059 -3.8 -5.0
## 
## $means
## F1 
##  0 
## 
## $cov
##    F1
## F1  1
#dep
uni_results_dep$p_fit %>% summary()
##          F1    h2
## bdi1  0.837 0.700
## bdi2  0.729 0.532
## bdi3  0.733 0.537
## bdi4  0.845 0.714
## bdi5  0.598 0.357
## bdi6  0.466 0.217
## bdi7  0.843 0.711
## bdi8  0.712 0.508
## bdi9  0.856 0.733
## bdi10 0.526 0.276
## bdi11 0.532 0.283
## bdi12 0.658 0.433
## bdi13 0.661 0.436
## 
## SS loadings:  6.4 
## Proportion Var:  0.49 
## 
## Factor correlations: 
## 
##    F1
## F1  1
uni_results_dep$p_fit %>% coef(simplify = T)
## $items
##        a1    d1    d2   d3   d4
## bdi1  2.6  0.22 -3.20 -5.8 -8.5
## bdi2  1.8 -0.51 -2.77 -4.5 -5.3
## bdi3  1.8  0.32 -2.69 -5.3 -8.5
## bdi4  2.7  0.19 -3.05 -6.3 -9.3
## bdi5  1.3  0.49 -3.71 -6.3 -7.7
## bdi6  0.9 -0.45 -2.92 -5.6 -7.2
## bdi7  2.7 -0.47 -3.62 -7.0 -9.8
## bdi8  1.7  1.31 -1.71 -4.2   NA
## bdi9  2.8  1.61 -2.65 -6.9 -8.6
## bdi10 1.1  1.37 -0.91 -1.9 -2.5
## bdi11 1.1  0.39 -1.62 -3.7 -5.3
## bdi12 1.5  0.52 -1.95 -3.7 -4.8
## bdi13 1.5  3.50 -0.68 -3.4 -5.8
## 
## $means
## F1 
##  0 
## 
## $cov
##    F1
## F1  1
#general population sample
#wokeness
gen_results_gad$woke_fit %>% summary()
##            F1    h2
## csjas1  0.862 0.743
## csjas2  0.851 0.724
## csjas4  0.833 0.694
## csjas5  0.680 0.462
## csjas6  0.660 0.436
## csjas8  0.747 0.559
## csjas9  0.787 0.619
## csjas13 0.742 0.551
## csjas14 0.568 0.323
## csjas15 0.769 0.591
## csjas16 0.702 0.493
## csjas17 0.785 0.616
## csjas18 0.629 0.396
## csjas19 0.569 0.324
## csjas20 0.644 0.414
## csjas3  0.852 0.726
## csjas7  0.678 0.460
## csjas10 0.852 0.726
## csjas11 0.682 0.466
## csjas12 0.694 0.481
## 
## SS loadings:  11 
## Proportion Var:  0.54 
## 
## Factor correlations: 
## 
##    F1
## F1  1
gen_results_gad$woke_fit %>% coef(simplify = T)
## $items
##          a1     d1     d2     d3   d4
## csjas1  2.9  1.157 -1.137 -1.763 -4.7
## csjas2  2.8  0.860 -0.902 -2.272 -4.2
## csjas4  2.6  0.094 -1.370 -2.153 -3.5
## csjas5  1.6  0.921 -0.425 -1.029 -2.5
## csjas6  1.5  1.819  0.263 -0.087 -1.8
## csjas8  1.9 -0.325 -1.814 -2.528 -4.5
## csjas9  2.2  1.612  0.254 -0.291 -2.0
## csjas13 1.9 -1.943 -3.538 -4.417 -5.6
## csjas14 1.2 -0.054 -1.094 -1.444 -2.7
## csjas15 2.0 -0.087 -1.422 -1.694 -2.9
## csjas16 1.7  1.727 -0.045 -0.385 -2.3
## csjas17 2.2 -0.836 -2.527 -3.097 -4.9
## csjas18 1.4  0.327 -0.532 -1.996 -3.3
## csjas19 1.2  0.303 -1.649 -2.363 -4.3
## csjas20 1.4 -1.551 -2.900 -3.314 -4.7
## csjas3  2.8  1.645 -0.102 -0.783 -3.0
## csjas7  1.6  0.960 -0.586 -1.469 -3.0
## csjas10 2.8  1.787  0.380 -0.688 -2.4
## csjas11 1.6  0.758 -0.463 -0.907 -2.7
## csjas12 1.6 -0.628 -1.512 -2.968 -4.1
## 
## $means
## F1 
##  0 
## 
## $cov
##    F1
## F1  1
#gad
gen_results_gad$p_fit %>% summary()
##         F1    h2
## gad1 0.883 0.780
## gad2 0.903 0.815
## gad3 0.905 0.818
## gad4 0.863 0.746
## gad5 0.780 0.608
## gad6 0.710 0.504
## gad7 0.757 0.573
## 
## SS loadings:  4.8 
## Proportion Var:  0.69 
## 
## Factor correlations: 
## 
##    F1
## F1  1
gen_results_gad$p_fit %>% coef(simplify = T)
## $items
##       a1    d1   d2   d3
## gad1 3.2  0.56 -3.7 -5.4
## gad2 3.6 -0.55 -4.7 -6.7
## gad3 3.6 -0.28 -4.7 -6.8
## gad4 2.9 -0.30 -4.0 -5.4
## gad5 2.1 -1.82 -4.3 -5.6
## gad6 1.7  0.31 -2.9 -4.1
## gad7 2.0 -0.85 -3.6 -4.6
## 
## $means
## F1 
##  0 
## 
## $cov
##    F1
## F1  1

Regression results

#run models to get univariate and multiple regression estimates for predictors of interest
#only use general population sample
#only use gad scale
#define predictors to use
pred_vars = c(
  "woke_score",
  "gender",
  "academic",
  "vote",
  d2 %>% select(democracy:self_rated_conservatism) %>% names()
)

#compare models
pred_comp_res = compare_predictors(
  data = d2[c(pred_vars, "gad_score")] %>% df_standardize(),
  outcome = "gad_score",
  predictors = pred_vars
)
## Skipped gender because it is class factor
## Skipped academic because it is a character (string)
## Skipped vote because it is a character (string)
pred_comp_res
GG_plot_models(pred_comp_res)

GG_save("figs/reg results.png")

#with age
#only available for a subset
pred_comp_res_age = compare_predictors(
  data = d2[c(c(pred_vars, "age", "gad_score"))] %>% df_standardize(),
  outcome = "gad_score",
  predictors = c(pred_vars, "age")
)
## Skipped gender because it is class factor
## Skipped academic because it is a character (string)
## Skipped vote because it is a character (string)
pred_comp_res_age
GG_plot_models(pred_comp_res_age)

GG_save("figs/reg results age.png")

#sample sizes for full models
d2[c(c(pred_vars, "gad_score"))] %>% na.omit() %>% nrow()
## [1] 3353
d2[c(c(pred_vars, "age", "gad_score"))] %>% na.omit() %>% nrow()
## [1] 1884
#party plots
#gad
d2 %>% 
  #sort factor levels by gad
  mutate(
    vote = vote %>% fct_reorder(gad_score)
  ) %>%
  GG_group_means("gad_score", "vote")
## Missing values were removed.

GG_save("figs/anxiety by party.png")

#wokeness
d2 %>% 
  #sort factor levels by gad
  mutate(
    vote = vote %>% fct_reorder(woke_score)
  ) %>%
  GG_group_means("woke_score", "vote")
## Missing values were removed.

GG_save("figs/wokeness by party.png")

#scatter plot of wokeness and gad by party vote
party_data = d2 %>% 
  group_by(vote) %>%
  summarise(
    gad_score = mean(gad_score, na.rm = T),
    woke_score = mean(woke_score, na.rm = T),
    n = n(),
    party = vote[1]
  )

party_data
party_data %>% 
  GG_scatter("gad_score", "woke_score", case_names = "party", repel_names = T) +
  scale_x_continuous("General anxiety score") +
  scale_y_continuous("Wokeness score")
## `geom_smooth()` using formula = 'y ~ x'

GG_save("figs/gad and woke by party.png")
## `geom_smooth()` using formula = 'y ~ x'
#are these differences significant?
d %>% 
  #reorder by wokeness
  mutate(
    vote = vote %>% fct_reorder(woke_score)
  ) %>%
  GG_group_means("gad_score", "vote")
## Missing values were removed.

Meta

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] patchwork_1.2.0       rms_6.8-2             mirt_1.42            
##  [4] lattice_0.22-5        kirkegaard_2025-02-26 psych_2.4.6.26       
##  [7] assertthat_0.2.1      weights_1.0.4         Hmisc_5.1-3          
## [10] magrittr_2.0.3        lubridate_1.9.3       forcats_1.0.0        
## [13] stringr_1.5.1         dplyr_1.1.4           purrr_1.0.2          
## [16] readr_2.1.5           tidyr_1.3.1           tibble_3.2.1         
## [19] ggplot2_3.5.1         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        TH.data_1.1-2        jomo_2.7-6          
##   [7] farver_2.1.2         nloptr_2.1.1         rmarkdown_2.28      
##  [10] ragg_1.3.2           vctrs_0.6.5          minqa_1.2.8         
##  [13] base64enc_0.1-3      htmltools_0.5.8.1    polspline_1.1.25    
##  [16] curl_5.2.2           broom_1.0.6          Formula_1.2-5       
##  [19] mitml_0.4-5          dcurver_0.9.2        sass_0.4.9          
##  [22] parallelly_1.38.0    bslib_0.8.0          htmlwidgets_1.6.4   
##  [25] plyr_1.8.9           testthat_3.2.1.1     sandwich_3.1-0      
##  [28] zoo_1.8-12           cachem_1.1.0         lifecycle_1.0.4     
##  [31] iterators_1.0.14     pkgconfig_2.0.3      Matrix_1.7-2        
##  [34] R6_2.5.1             fastmap_1.2.0        future_1.34.0       
##  [37] digest_0.6.37        colorspace_2.1-1     textshaping_0.4.0   
##  [40] vegan_2.6-6.1        labeling_0.4.3       progressr_0.14.0    
##  [43] fansi_1.0.6          timechange_0.3.0     gdata_3.0.0         
##  [46] mgcv_1.9-1           compiler_4.4.2       bit64_4.0.5         
##  [49] withr_3.0.1          htmlTable_2.4.3      backports_1.5.0     
##  [52] highr_0.11           R.utils_2.12.3       pan_1.9             
##  [55] MASS_7.3-64          quantreg_5.98        sessioninfo_1.2.2   
##  [58] GPArotation_2024.3-1 gtools_3.9.5         permute_0.9-7       
##  [61] tools_4.4.2          foreign_0.8-88       future.apply_1.11.2 
##  [64] nnet_7.3-20          R.oo_1.26.0          glue_1.7.0          
##  [67] nlme_3.1-167         grid_4.4.2           checkmate_2.3.2     
##  [70] cluster_2.1.8        generics_0.1.3       snow_0.4-4          
##  [73] gtable_0.3.5         RPushbullet_0.3.4    tzdb_0.4.0          
##  [76] R.methodsS3_1.8.2    data.table_1.16.0    hms_1.1.3           
##  [79] Deriv_4.1.3          utf8_1.2.4           ggrepel_0.9.5       
##  [82] foreach_1.5.2        pillar_1.9.0         vroom_1.6.5         
##  [85] splines_4.4.2        bit_4.0.5            survival_3.8-3      
##  [88] SparseM_1.84-2       tidyselect_1.2.1     pbapply_1.7-2       
##  [91] knitr_1.48           gridExtra_2.3        xfun_0.47           
##  [94] brio_1.1.5           stringi_1.8.4        yaml_2.3.10         
##  [97] boot_1.3-31          evaluate_0.24.0      codetools_0.2-19    
## [100] beepr_2.0            cli_3.6.3            rpart_4.1.24        
## [103] systemfonts_1.1.0    munsell_0.5.1        jquerylib_0.1.4     
## [106] Rcpp_1.0.13          globals_0.16.3       parallel_4.4.2      
## [109] MatrixModels_0.5-3   lme4_1.1-35.5        listenv_0.9.1       
## [112] glmnet_4.1-8         mvtnorm_1.2-6        SimDesign_2.17.1    
## [115] scales_1.3.0         crayon_1.5.3         rlang_1.1.4         
## [118] multcomp_1.4-26      mnormt_2.1.1         mice_3.16.0
#save data files
d %>% write_rds("data/d.rds", compress = "xz")
d1 %>% write_rds("data/d1.rds", compress = "xz")
d2 %>% write_rds("data/d2.rds", compress = "xz")

#upload to OSF
#avoid uploading the data in case they freak out again
if (F) {
  library(osfr)
  
  #auth
  osf_auth(readr::read_lines("~/.config/osf_token"))
  
  #the project we will use
  osf_proj = osf_retrieve_node("https://osf.io/kws3v/")
  
  #upload files
  #overwrite existing (versioning)
  osf_upload(osf_proj, conflicts = "overwrite", 
             path = c(
               "figs",
               "data",
               "notebook.html",
               "notebook.Rmd",
             ))
}