---
title: "RESPONDENTS’ PREFERRED SURVEY TOPICS: MEASUREMENT AND PREVALENCE"
subtitle: "Replication Files: Study 2"
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
---
***
# Research Question 4. Analyses

## Measurement Properties

Topic Popularity

```{r topic popularity, message=FALSE, warning=FALSE}
subset_tp <- select(subset, tp_nature, tp_crisis, tp_personal, tp_economy, tp_leisure, tp_well, tp_migration, tp_work, tp_pol, tp_media )
subset_tp <- subset_tp[complete.cases(subset_tp), ]

sumtable(subset_tp, vars=c("tp_nature", "tp_crisis", "tp_personal", "tp_economy", "tp_leisure", "tp_well", "tp_migration", "tp_work", "tp_pol", "tp_media"),
  labels = c("Nature", "Crisis", "Personality", "Economy", "Leisure", "Well-Being", "Migration", "Work", "Politics", "Media"), out = "kable", add.median = TRUE, digits = 3) %>% 
  kableExtra::kable_styling(bootstrap_options = "basic")
```

Test of Comparisons 

```{r comp 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_tp[[var1]], subset_tp[[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 comp 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_tp[[var1]], subset_tp[[var2]])), tidy)
    
     tab2 <- map_df(list(chisq.test(subset_tp[[var1]], subset_tp[[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")
```

***
## Principal Component Analysis

```{r loading dataset, message=FALSE, warning=FALSE, include=FALSE, results='hide'}
# Loading Dataset
load("data/subset.RData")
```

Identifying Number of Components

```{r exploratory factor analysis topic interest, message=FALSE, warning=FALSE, fig.width=10, fig.height=4, out.width='100%', out.height='auto'}
i_topic <- select(subset, tp_nature, tp_crisis, tp_personal, tp_economy, tp_leisure, tp_well, tp_migration, tp_work, tp_pol, tp_media)
i_topic <- i_topic[complete.cases(i_topic), ]
  
scree_plot(i_topic, method="pc")
```

Table Principal Component Analysis

```{r pca fit, message=FALSE, warning=FALSE, include=FALSE}
fit_topic <- principal(i_topic, nfactors = 2, rotate = "varimax")
results_pca <- as.data.frame.matrix(fit_topic[["loadings"]])
results_pca <- cbind(results_pca, as.data.frame(fit_topic[["uniquenesses"]]))
results_pca <- cbind(results_pca, as.data.frame(fit_topic[["complexity"]]))
results_pca <- cbind(rownames(results_pca), data.frame(results_pca, row.names=NULL))
colnames(results_pca)<- c("Topic Interest", "Factor Loadings 1", "Factor Loadings 2", "Uniqueness", "Complexity")
results_pca[, 2:5] <- round(results_pca[, 2:5], 2)

n_row <- data.frame("Topic Interest" = "N", "Factor Loadings 1" = fit_topic$n.obs, "Factor Loadings 2" = NA, "Uniqueness" = NA, "Complexity" = NA)
eigenvalues <- fit_topic$values[1:2]
eigenvalues_row <- data.frame("Topic Interest" = "Eigenvalues",
  "Factor Loadings 1" = round(eigenvalues[1], 2),
  "Factor Loadings 2" = round(eigenvalues[2], 2),
  "Uniqueness" = NA, "Complexity" = NA)

colnames(eigenvalues_row) <- colnames(results_pca)
colnames(n_row) <- colnames(results_pca)
table_pca <- rbind(results_pca, eigenvalues_row, n_row)
table_pca[table_pca[["Topic Interest"]] == "N", "Factor Loadings 1"] <- as.character(as.integer(table_pca[table_pca[["Topic Interest"]] == "N", "Factor Loadings 1"]))
table_pca[is.na(table_pca)] <- ""

vars <- c("tp_well", "tp_personal", "tp_nature", "tp_crisis", "tp_work", "tp_economy", "tp_pol", "tp_media", "tp_migration", "tp_leisure")
labels <- c("Well-Being", "Values", "Nature", "Crisis", "Work", "Economy", "Politics", "Media", "Migration", "Leisure")

var_labels <- setNames(labels, vars)
table_pca <- table_pca %>%
  mutate(`Topic Interest` = ifelse(`Topic Interest` %in% names(var_labels), 
  var_labels[`Topic Interest`], `Topic Interest`))
```
```{r pca-table, echo=FALSE, message=FALSE, warning=FALSE, results='asis'}
knitr::kable(table_pca)
```

Plot Principal Component Analysis

```{r pca plot, message=FALSE, warning=FALSE, fig.width=10, fig.height=4, out.width='100%', out.height='auto'}
g_pca <- ggplot(results_pca, aes(x = `Factor Loadings 1`, y = `Factor Loadings 2`)) +
  labs(x = "Factor Loadings 1", y = "Factor Loadings 2") +
  geom_point(aes(colour = `Factor Loadings 1` < 0.5 & `Factor Loadings 2` > 0.5), show.legend = FALSE) +
  geom_text(aes(label = c("nature and environment", "current crisis", "personality and values", "economy and society", "leisure and rest", "satisfaction and well-being", "flight and migration", "work and occupation", "political attiudes and behavior", "media and social networks")), 
       hjust = 0, nudge_x = 0.02, size = 3, family = "Times New Roman", colour = "gray45") + 
  theme_light() + custom_theme + scale_color_grey() +
  scale_y_continuous(limits = c(0, 1.)) +
  scale_x_continuous(limits = c(0, 1.)) + 
  geom_hline(yintercept = 0.5) + 
  geom_vline(xintercept = 0.5) + 
  guides(colour = guide_legend(title.position = "top", title.hjust = 0.5))

g_pca
```

```{r save plot, message=FALSE, warning=FALSE, include=FALSE}
 ggsave(plot = g_pca, filename = "graphs/g_pca.pdf", device = cairo_pdf,
  width = 18, height = 10, units = "cm")
```

***
# Research Question 5. Analyses

```{r loading dataset, message=FALSE, warning=FALSE, include=FALSE}
# loading dataset
load("data/subset.RData")
```
```{r subset, warning=FALSE, message=FALSE}
# Creating Subset
subset_tp <- select(subset, tp_nature, tp_crisis, tp_personal, tp_economy, tp_leisure, tp_well, tp_migration, tp_work, tp_pol, tp_media, i_gender, i_education, age_group, i_east, i_trust, i_polinterest)
subset_tp <- subset_tp[complete.cases(subset_tp), ]
```
```{r rescale, warning=FALSE, message=FALSE}
# Rescaling Variables
subset_tp$st_trust <- scale(subset_tp$i_trust)
subset_tp$st_polinterest <- scale(subset_tp$i_polinterest)
```

***
## Regression Political Topics

```{r reg pol, message=FALSE, warning=FALSE}
response_vars <- c("tp_pol", "tp_crisis", "tp_economy", "tp_migration")
refitted_models <- list()
coefficients_list <- list()

for (response_var in response_vars) {
  
  formula <- as.formula(paste(response_var, "~ age_group + i_gender + i_east + i_education + st_polinterest + st_trust"))
  model <- lm(formula, data=subset_tp)
  
  # Breusch-Pagan test
  bp_test <- lmtest::bptest(model)
  print(paste("Breusch-Pagan test for", response_var))
  print(bp_test)
  
  # Identify influential cases
  cooksd <- cooks.distance(model)
  influential_cases <- as.numeric(names(cooksd)[(cooksd > 4*mean(cooksd, na.rm=TRUE))])
  
  # Subset the data excluding influential cases
  subset_no_influential <- subset_tp[-influential_cases, ]
  
  # Refit the model without influential cases
  if (bp_test$p.value < 0.05) {
    refit_model <- lm_robust(formula, data=subset_no_influential)
    print(paste("Summary of refitted robust model for", response_var))
  } else {
    refit_model <- lm(formula, data=subset_no_influential)
    print(paste("Summary of refitted standard model for", response_var))
  }
   
  refitted_models[[response_var]] <- refit_model
  print(summary(refit_model))
  
  coefficients <- tidy(refit_model) %>%
    filter(term %in% c("st_trust", "st_polinterest", "i_gender2", "i_education2", "i_education3", "age_group2", "age_group3", "i_east2"))
  coefficients$response_var <- response_var  # Add response variable name to the coefficients data frame
  coefficients_list[[response_var]] <- coefficients
}

# Combine all coefficients into a single data frame
all_coefficients <- bind_rows(coefficients_list)
significant_coefficients <- all_coefficients %>%
  filter(p.value <= 0.05)

tp_trust <- filter(significant_coefficients, term == "st_trust")
tp_polint <- filter(significant_coefficients, term == "st_polinterest")
tp_gender <- filter(significant_coefficients, term == "i_gender2")
tp_edu2 <- filter(significant_coefficients, term == "i_education2")
tp_edu3 <- filter(significant_coefficients, term == "i_education3")
tp_age2 <- filter(significant_coefficients, term == "age_group2")
tp_age3 <- filter(significant_coefficients, term == "age_group3")
tp_east <- filter(significant_coefficients, term == "i_east2")

pol <- bind_rows(tp_trust, tp_polint, tp_gender, tp_edu2, tp_edu3, tp_age2, tp_age3, tp_east)
```

Regression Table 

```{r pol tab, message=FALSE, warning=FALSE}
r_pol <- refitted_models$tp_pol
r_migration <- refitted_models$tp_migration
r_economy <- refitted_models$tp_economy
r_crisis <- refitted_models$tp_crisis

tab_model(r_pol, r_migration, r_economy, r_crisis,
  show.est = TRUE, show.se = TRUE, show.ci = FALSE, show.aic = TRUE, collapse.se = TRUE, linebreak = TRUE,  p.style = "numeric", show.reflvl = TRUE,
  pred.labels = c("Intercept", "Age Group 49-63", "Age Group >63", "Gender: Female", "Germany: East", "Education: Intermediate", "Education: High",       
    "Political Interest", "Social Trust" ),
  dv.labels = c("Politics", "Migration", "Economy", "Crises"), 
  title = "Regression Models: Differences in Topic Interests",
  CSS = list(css.thead = 'border-top: 1px solid;', css.summary= 'border-bottom: 1px solid;', css.table = 'width: 100%;'))
```

Regression Graph

```{r pol plot, warning=FALSE, message=FALSE, fig.width=10, out.width='100%', out.height='auto'}
pol$group <- ifelse(pol$outcome %in% c("tp_crisis", "tp_migration"), "Panel 1: Current Crises, Flight and Migration", "Panel 2: Economy and Society, Political Attitudes and Participation")
gpol <- ggplot(pol, aes(x = term, y = estimate, colour = outcome, shape = outcome)) + 
   labs(x = NULL, y = "Estimated Effects\nwith 95% Confidence Intervals", title = NULL) +
  geom_pointrange(aes(ymin = conf.low, ymax = conf.high)) +
  geom_point() +
  geom_hline(yintercept = 0.0) + 
  coord_flip() + theme_light() + custom_theme +
  scale_color_manual(limits = c("tp_crisis", "tp_economy", "tp_migration", "tp_pol"),
    labels = c("Current Crises", "Economy and Society", "Flight and Migration", "Political Attitudes and Participation"),
    values = c("#008080", "#7EAB96", "#CA562C", "#E19464"), drop = TRUE) +
  scale_shape_manual(limits = c("tp_crisis", "tp_economy", "tp_migration", "tp_pol"),
    labels = c("Current Crises", "Economy and Society", "Flight and Migration", "Political Attitudes and Participation"),
    values = c(19, 21, 19, 21),  drop = FALSE) +
  guides(colour = guide_legend(nrow = 2)) +
  scale_y_continuous(limits = c(-1.2, +1.0)) +
  scale_x_discrete(limits = c("i_gender2", "i_gender1", "i_east2", "i_east1", "age_group3", "age_group2", "age_group1", "i_education3", "i_education1", "st_trust", "st_polinterest"),
    labels = c("Female Gender", "Ref. Male Gender", "East Germany", "Ref. West Germany", "Age Group >63",  "Age Group 49-63", "Ref. Age Group <49", "High Education", "Ref. Low Education",
     "Std. Social Trust", "Std. Political Interest"))  +
  facet_wrap(~ group, nrow = 2) + theme(strip.text = element_blank(), plot.margin = margin(t = 5, r = 30, b = 5, l = 5))

gpol
```

## Regression Private Topics

```{r reg priv, message=FALSE, warning=FALSE}
response_vars <- c("tp_nature", "tp_well", "tp_personal", "tp_media", "tp_work", "tp_leisure")
refitted_models <- list()
coefficients_list <- list()

# Run diagnostics for each model
for (response_var in response_vars) {
  
  formula <- as.formula(paste(response_var, "~ age_group + i_gender + i_east + i_education + st_polinterest + st_trust"))
  model <- lm(formula, data=subset_tp)
  
  # Breusch-Pagan test
  bp_test <- lmtest::bptest(model)
  print(paste("Breusch-Pagan test for", response_var))
  print(bp_test)
  
  # Identify influential cases
  cooksd <- cooks.distance(model)
  influential_cases <- as.numeric(names(cooksd)[(cooksd > 4*mean(cooksd, na.rm=TRUE))])
  
  # Subset the data excluding influential cases
  subset_no_influential <- subset_tp[-influential_cases, ]
  
  # Refit the model without influential cases
  if (bp_test$p.value < 0.05) {
    refit_model <- lm_robust(formula, data=subset_no_influential)
    print(paste("Summary of refitted robust model for", response_var))
  } else {
    refit_model <- lm(formula, data=subset_no_influential)
    print(paste("Summary of refitted standard model for", response_var))
  }
   
  refitted_models[[response_var]] <- refit_model
  print(summary(refit_model))
  
  coefficients <- tidy(refit_model) %>%
    filter(term %in% c("st_trust", "st_polinterest", "i_gender2", "i_education2", "i_education3", "age_group2", "age_group3", "i_east2"))
  coefficients$response_var <- response_var  # Add response variable name to the coefficients data frame
  coefficients_list[[response_var]] <- coefficients
  }

# Combine all coefficients into a single data frame
all_coefficients <- bind_rows(coefficients_list)
significant_coefficients <- all_coefficients %>%
  filter(p.value <= 0.05)

tp_trust <- filter(significant_coefficients, term == "st_trust")
tp_polint <- filter(significant_coefficients, term == "st_polinterest")
tp_gender <- filter(significant_coefficients, term == "i_gender2")
tp_edu2 <- filter(significant_coefficients, term == "i_education2")
tp_edu3 <- filter(significant_coefficients, term == "i_education3")
tp_age2 <- filter(significant_coefficients, term == "age_group2")
tp_age3 <- filter(significant_coefficients, term == "age_group3")
tp_east <- filter(significant_coefficients, term == "i_east2")

priv <- bind_rows(tp_trust, tp_polint, tp_gender, tp_edu2, tp_edu3, tp_age2, tp_age3, tp_east)
```

Regression Table 

```{r priv table, message=FALSE, warning=FALSE}
r_nature <- refitted_models$tp_nature
r_well <- refitted_models$tp_well
r_personal <- refitted_models$tp_personal
r_work <- refitted_models$tp_work
r_leisure <- refitted_models$tp_leisure
r_media <- refitted_models$tp_media

tab_model(r_nature, r_well, r_personal,
  show.est = TRUE, show.se = TRUE, show.ci = FALSE, show.aic = TRUE, collapse.se = TRUE, linebreak = TRUE,  p.style = "numeric", show.reflvl = TRUE,
  pred.labels = c("Intercept", "Age Group 49-63", "Age Group >63", "Gender: Female", "Germany: East", "Education: Intermediate", "Education: High", "Political Interest", "Social Trust" ),
  dv.labels = c("Nature", "Well-Being", "Personality"), 
  title = "Regression Models: Differences in Topic Interests",
  CSS = list(css.thead = 'border-top: 1px solid;', css.summary= 'border-bottom: 1px solid;', css.table = 'width: 100%;'))

tab_model(r_work, r_leisure, r_media,
  show.est = TRUE, show.se = TRUE, show.ci = FALSE, show.aic = TRUE, collapse.se = TRUE, linebreak = TRUE,  p.style = "numeric", show.reflvl = TRUE,
  pred.labels = c("Intercept", "Age Group 49-63", "Age Group >63", "Gender: Female", "Germany: East", "Education: Intermediate", "Education: High", "Political Interest", "Social Trust" ),
  dv.labels = c("Work", "Leisure", "Media"), 
  title = "Regression Models: Differences in Topic Interests",
  CSS = list(css.thead = 'border-top: 1px solid;', css.summary= 'border-bottom: 1px solid;', css.table = 'width: 100%;'))
```

Regression Graph 

```{r priv plot, warning=FALSE, message=FALSE, fig.width=10, out.width='100%', out.height='auto'}
priv$group <- ifelse(priv$outcome %in% c("tp_leisure", "tp_nature", "tp_well"), "Panel 1: Leisure, Nature, Well-being", "Panel 2: Media, Personality, Work")

gpriv <- ggplot(priv, aes(x = term, y = estimate, colour = outcome, shape = outcome)) + 
   labs(x = NULL, y = "Estimated Effects\nwith 95% Confidence Intervals", title = NULL) +
  geom_point() +  geom_pointrange(aes(ymin=conf.low, ymax=conf.high)) +
  geom_hline(yintercept = 0.) + 
  theme_light() + coord_flip() + custom_theme +
  scale_color_manual(limits = c("tp_leisure", "tp_media", "tp_nature", "tp_personal", "tp_well", "tp_work"),
    labels = c("Leisure and Rest", "Media and Social Networks", "Nature and Environment", "Personality and Values", "Satisfaction and Well-Being", "Work and Occupation"),
    values = c("#008080","#7EAB96", "#CA562C",  "#E19464", "#F6EDBD", "#F6EDBD"), drop = TRUE) +
  scale_shape_manual(limits = c("tp_leisure", "tp_media", "tp_nature", "tp_personal", "tp_well", "tp_work"),
    labels = c("Leisure and Rest", "Media and Social Networks", "Nature and Environment", "Personality and Values", "Satisfaction and Well-Being", "Work and Occupation"),
    values = c(19, 21, 19, 21, 19, 21), drop = FALSE) +
  guides(colour = guide_legend(nrow = 2)) +
  scale_y_continuous(limits = c(-1.2, +1.0)) +
  scale_x_discrete(limits = c("i_gender2", "i_gender1","i_east2", "i_east1", "age_group3", "age_group2", "age_group1",
    "i_education3", "i_education2", "i_education1","st_trust", "st_polinterest"), 
    labels = c("Female Gender", "Ref. Male Gender", "East Germany", "Ref. West Germany", "Age Group >63", "Age Group 49-63", "Ref. Age Group <49", "High Education", "Intermediate Education", "Ref. Low Education","Std. Social Trust", "Std. Political Interest")) +
  facet_wrap(~ group, nrow = 2) + theme(strip.text = element_blank(), plot.margin = margin(t = 5, r = 30, b = 5, l = 5))

gpriv
```

```{r save graph, message=FALSE, warning=FALSE, include=FALSE}
# ggsave(plot= gpriv, file = "graphs/g_pri_col.pdf", device = cairo_pdf,
#   dpi = 1200, width = 18, height = 15, units = "cm")
# 
# ggsave(plot= gpol, file = "graphs/g_pol_col.pdf", device = cairo_pdf,
#  width = 18, height = 15, units = "cm")
```

```{r pol plot, eval=FALSE, fig.width=10, message=FALSE, warning=FALSE, include=FALSE, out.height='auto', out.width='100%'}
pol$group <- ifelse(pol$outcome %in% c("tp_crisis", "tp_migration"), "Panel 1: Current Crises, Flight and Migration", "Panel 2: Economy and Society, Political Attitudes and Participation")
gpol <- ggplot(pol, aes(x = term, y = estimate, colour = outcome, shape = outcome)) + 
   labs(x = NULL, y = "Estimated Effects\nwith 95% Confidence Intervals", title = NULL) +
  geom_pointrange(aes(ymin = conf.low, ymax = conf.high)) +
  geom_point() +
  geom_hline(yintercept = 0.0) + 
  coord_flip() + theme_light() + custom_theme +
  scale_color_manual(limits = c("tp_crisis", "tp_economy", "tp_migration", "tp_pol"),
    labels = c("Current Crises", "Economy and Society", "Flight and Migration", "Political Attitudes and Participation"),
    values = c("gray40", "gray40", "gray70", "gray70"), drop = TRUE) +
  scale_shape_manual(limits = c("tp_crisis", "tp_economy", "tp_migration", "tp_pol"),
    labels = c("Current Crises", "Economy and Society", "Flight and Migration", "Political Attitudes and Participation"),
    values = c(19, 21, 19, 21),  drop = FALSE) +
  guides(colour = guide_legend(nrow = 2)) +
  scale_y_continuous(limits = c(-1.2, +1.0)) +
  scale_x_discrete(limits = c("i_gender2", "i_gender1", "i_east2", "i_east1", "age_group3", "age_group2", "age_group1", "i_education3", "i_education1", "st_trust", "st_polinterest"),
    labels = c("Female Gender", "Ref. Male Gender", "East Germany", "Ref. West Germany", "Age Group >63",  "Age Group 49-63", "Ref. Age Group <49", "High Education", "Ref. Low Education",
     "Std. Social Trust", "Std. Political Interest"))  +
  facet_wrap(~ group, nrow = 2) + theme(strip.text = element_blank(), plot.margin = margin(t = 5, r = 30, b = 5, l = 5))
```

```{r priv plot, fig.height=4, fig.width=10, message=FALSE, warning=FALSE, include=FALSE, out.height='auto', out.width='100%'}
priv$group <- ifelse(priv$outcome %in% c("tp_leisure", "tp_nature", "tp_well"), "Panel 1: Leisure, Nature, Well-being", "Panel 2: Media, Personality, Work")

gpriv <- ggplot(priv, aes(x = term, y = estimate, colour = outcome, shape = outcome)) + 
   labs(x = NULL, y = "Estimated Effects\nwith 95% Confidence Intervals", title = NULL) +
  geom_point() +  geom_pointrange(aes(ymin=conf.low, ymax=conf.high)) +
  geom_hline(yintercept = 0.) + 
  theme_light() + coord_flip() + custom_theme +
  scale_color_manual(limits = c("tp_leisure", "tp_media", "tp_nature", "tp_personal", "tp_well", "tp_work"),
    labels = c("Leisure and Rest", "Media and Social Networks", "Nature and Environment", "Personality and Values", "Satisfaction and Well-Being", "Work and Occupation"),
    values = c("gray30", "gray30", "gray60", "gray60", "gray80", "gray80"), drop = TRUE) +
  scale_shape_manual(limits = c("tp_leisure", "tp_media", "tp_nature", "tp_personal", "tp_well", "tp_work"),
    labels = c("Leisure and Rest", "Media and Social Networks", "Nature and Environment", "Personality and Values", "Satisfaction and Well-Being", "Work and Occupation"),
    values = c(19, 21, 19, 21, 19, 21), drop = FALSE) +
  guides(colour = guide_legend(nrow = 2)) +
  scale_y_continuous(limits = c(-1.2, +1.0)) +
  scale_x_discrete(limits = c("i_gender2", "i_gender1","i_east2", "i_east1", "age_group3", "age_group2", "age_group1",
    "i_education3", "i_education2", "i_education1","st_trust", "st_polinterest"), 
    labels = c("Female Gender", "Ref. Male Gender", "East Germany", "Ref. West Germany", "Age Group >63", "Age Group 49-63", "Ref. Age Group <49", "High Education", "Intermediate Education", "Ref. Low Education","Std. Social Trust", "Std. Political Interest")) +
  facet_wrap(~ group, nrow = 2) + theme(strip.text = element_blank(), plot.margin = margin(t = 5, r = 30, b = 5, l = 5))
```

```{r save graph, message=FALSE, warning=FALSE, include=FALSE}
ggsave(plot= gpol, file = "graphs/g_pol.pdf", device = cairo_pdf,
 width = 18, height = 15, units = "cm")

ggsave(plot= gpriv, file = "graphs/g_priv.pdf", device = cairo_pdf,
 width = 18, height = 15, units = "cm")
```
