---
title: "RESPONDENTS’ PREFERRED SURVEY TOPICS: MEASUREMENT AND PREVALENCE"
subtitle: "Replication Files: Study 3"
author: "Tobias Gummer, Saskia Bartholomäus, and Bernd Weiss"
date: "19.01.2026"
output:
  html_document:
    theme: united
    toc: true
    toc_depth: 4
    toc_float:
      collapsed: true
      smooth_scroll: true
---
***
# Measurement Properties
 
```{r loading dataset, message=FALSE, warning=FALSE, include=FALSE}
# Loading Dataset
load("data/subset.RData")
```
 
Topic Popularity
 
```{r topic popularity, message=FALSE, warning=FALSE}
sumtable(subset, vars=c("tp_personal", "tp_pol", "tp_nature", "tp_crisis", "tp_well", "tp_economy", "tp_migration", "tp_leisure", "tp_media", "tp_work"),
  labels = c("Personality", "Politics", "Nature", "Crisis", "Well-Being", "Economy", "Migration", "Leisure", "Media", "Work"), 
  out = "kable", add.median = TRUE, digits = 3) %>% 
  kableExtra::kable_styling(bootstrap_options = "basic")
```
 
Test of Comparisons 
 
```{r comparison ttest, message=TRUE, warning=TRUE}
topics <- c("tp_nature", "tp_crisis", "tp_personal", "tp_economy", "tp_leisure", "tp_well", "tp_migration", "tp_work", "tp_pol", "tp_media")
tt_results <- list()

for (i in 1:(length(topics) - 1)) {
    for (j in (i + 1):length(topics)) {
      var1 <- topics[i]
      var2 <- topics[j]

     tab <- map_df(list(t.test(subset[[var1]], subset[[var2]], paired = TRUE, alternative = "two.sided")), tidy)
   
     tt_results[[paste(var1, "_vs_", var2, sep = "")]] <- tab 
    }
}

ttresults_df <- do.call(rbind, tt_results)
  ttresults_df$Comparison <- gsub("_vs_", " vs. ", rownames(ttresults_df))
  ttresults_df <- ttresults_df[c("Comparison", "estimate", "statistic", "p.value", 
  "conf.low", "conf.high", "method")]

ttresults_df[c("Comparison", "estimate", "statistic", "p.value", "conf.low", "conf.high", "method")] %>%
  kbl(align = "llllll", col.names = c("Comparison", "Difference in Means", "t", "p.value", "conf.low", "conf.high", "Method"),
  digits = 3, caption = "Difference of Topic Popularity") %>%
  kable_styling() %>% kableExtra::scroll_box(width = "100%", height = "300px")
```

```{r comparison chi2, message=TRUE, warning=TRUE}
chi_results <- list()
sim_results <- list()

for (i in 1:(length(topics) - 1)) {
    for (j in (i + 1):length(topics)) {
      var1 <- topics[i]
      var2 <- topics[j]

     tab <- map_df(list(chisq.test(subset[[var1]], subset[[var2]])), tidy)
    
     tab2 <- map_df(list(chisq.test(subset[[var1]], subset[[var2]], simulate.p.value = TRUE)), tidy)
   
     chi_results[[paste(var1, "_vs_", var2, sep = "")]] <- tab 
     sim_results[[paste(var1, "_vs_", var2, sep = "")]] <- tab2
    }
}

chiresults_df <- do.call(rbind, chi_results)
  chiresults_df$Comparison <- gsub("_vs_", " vs. ", rownames(chiresults_df))
  chiresults_df <- chiresults_df[c("statistic", "p.value", "parameter", "method")]

chiresults_df[c("statistic", "p.value", "parameter", "method")] %>%
  kbl(align = "llllll", col.names = c("Chisq", "p.value", "df", "Method"),
      digits = 3, caption = "Difference of Topic Popularity") %>%
  kable_styling()  %>% 
  kableExtra::scroll_box(width = "100%", height = "300px")

simresults_df <- do.call(rbind, sim_results)
  simresults_df$Comparison <- gsub("_vs_", " vs. ", rownames(simresults_df))
  simresults_df <- simresults_df[c("statistic", "p.value", "parameter", "method")]

simresults_df[c("statistic", "p.value", "parameter", "method")] %>%
  kbl(align = "llllll", col.names = c("Chisq", "p.value", "df", "Method"),
      digits = 3, caption = "Difference of Topic Popularity") %>%
  kable_styling() %>% 
  kableExtra::scroll_box(width = "100%", height = "300px")
```