
---
title: "[WEEK 14 TITLE]"
subtitle: "[WEEK 14 SUBTITLE]"
date: last-modified
date-format: "[Updated ]MMM D, YYYY"
format: 
  revealjs:
    theme: brownslides.scss
    logo: images/pols1140_hex.png
    footer: "[COURSE CODE]"
    multiplex: false
    transition: fade
    slide-number: c
    incremental: true
    center: false
    menu: true
    scrollable: true
    highlight-style: github
    progress: true
    code-overflow: wrap
    chalkboard: false
    # include-after-body: title-slide.html
    title-slide-attributes:
      align: left
      data-background-image: images/pols1140_hex.png
      data-background-position: 90% 50%
      data-background-size: 40%
filters:
  - openlinksinnewpage
execute: 
  eval: true
  echo: false
  warning: false
  message: false
  cache: true
---


```{r}
#| label: init
#| echo: false
#| results: hide
#| warning: false 
#| message: false

library(tidyverse)
library(labelled)
library(haven)
library(DeclareDesign)
library(easystats)
library(texreg)

```


```{r}
df <- haven::read_spss("../files/data/class_surveys/pols_1140_2024_survey.sav")

# Data cleaning

df %>% 
  mutate(
    ck_snap = case_when(
      !is.na(ck_1_snap) ~ ck_1_snap,
      !is.na(ck_2_snap) ~ ck_2_snap,
      !is.na(ck_3_snap) ~ ck_3_snap,
      !is.na(ck_4_snap) ~ ck_4_snap,
      T ~ NA

    ),
    ck_snap_support01 = ifelse(ck_snap < 3, 1, 0),
    ck_general = case_when(
      !is.na(ck_1_general) ~ ck_1_general,
      !is.na(ck_2_general) ~ ck_2_general,
      !is.na(ck_3_general) ~ ck_3_general,
      !is.na(ck_4_general) ~ ck_4_general,
      T ~ NA

    ),
    ck_general_support01 = ifelse(ck_general < 3, 1, 0),
    ck_diff = ck_snap - ck_general,
    ck_consistent_support = case_when(
      ck_snap < 3 & ck_general < 3 ~ 1,
      T ~ 0
    ),
    ck_consistent_opposition = case_when(
      ck_snap > 2 & ck_general > 2 ~ 1,
      T ~ 0
    ),
    ck_let_me_eat_cake = case_when(
      ck_snap < 3 & ck_general > 2 ~ 1,
      T ~ 0
    ),
    ck_let_them_eat_cake = case_when(
      ck_snap > 2 & ck_general < 3 ~ 1,
      T ~ 0
    ),
    ck_treat_order = case_when(
      !is.na(ck_1_general) ~ "General first",
      !is.na(ck_2_general) ~ "General first",
      !is.na(ck_3_general) ~ "SNAP first",
      !is.na(ck_4_general) ~ "SNAP first",
      T ~ NA

    ),
    ck_treat_page = case_when(
      !is.na(ck_1_general) ~ "Page break",
      !is.na(ck_2_general) ~ "Same page",
      !is.na(ck_3_general) ~ "Page break",
      !is.na(ck_4_general) ~ "Same page",
      T ~ NA

    ),
    ck_treatment = case_when(
      !is.na(ck_1_general) ~ "General first, page break",
      !is.na(ck_2_general) ~ "General first, same page",
      !is.na(ck_3_general) ~ "SNAP first, page break",
      !is.na(ck_4_general) ~ "SNAP first, same page",
      T ~ NA

    ),
  ) -> df


df %>% 
  mutate(
    pid7pt = case_when(
      pid_init == 1 & pid_str_dem == 3 ~ 1,
      pid_init == 1 & pid_str_dem == 2 ~ 2,
      pid_init == 2 & pid_str_rep == 3 ~ 7,
      pid_init == 2 & pid_str_rep == 2 ~ 6,
      pid_init == 3 & pid_str_rep == 3 ~ 4,
      pid_init == 3 & pid_str_ind == 1 ~ 5,
      pid_init == 3 & pid_str_ind == 2 ~ 3,
      pid_init == 4 & pid_str_ind == 3 ~ 4,
      pid_init == 4 & pid_str_ind == 1 ~ 5,
      pid_init == 4 & pid_str_ind == 2 ~ 3,
      T ~ NA
    ),
    is_dem = ifelse(pid7pt < 4, 1, 0),
    is_rep = ifelse(pid7pt > 4, 1, 0),
    is_ind = ifelse(pid7pt == 4, 1, 0),
    pid_3cat = case_when(
      is_dem == 1 ~ "Democrat",
      is_rep == 1 ~ "Republican",
      is_ind == 1 ~ "Independent",
      T ~ NA
    ) %>% factor(., levels = c("Democrat","Independent","Republican")),
    # Ideology
    is_lib = ifelse(ideology < 4, 1, 0),
    is_con = ifelse(ideology > 4, 1, 0),
    is_mod = ifelse(ideology == 4, 1, 0),
    ideology_3cat = case_when(
      is_lib == 1 ~ "Liberal",
      is_con == 1 ~ "Conservative",
      is_mod == 1 ~ "Moderate",
      T ~ NA
    ) %>% factor(., levels = c("Liberal","Moderate","Conservative")),
    # Gender
    is_man = ifelse(demo_gender == 3, 1, 0),
    is_woman = ifelse(demo_gender == 7, 1, 0),
    # Race
    is_white = ifelse(!is.na(demo_race_1) == 1, 1, 0),
    is_nonwhite = ifelse(!is.na(demo_race_1) != 1, 1, 0),
    is_black = ifelse(!is.na(demo_race_2) == 1, 1, 0),
    is_asian = ifelse(!is.na(demo_race_4 )== 1 | !is.na(demo_race_5) == 1 , 1, 0),
    is_latino = ifelse(!is.na(demo_race_6) == 1, 1, 0)


    

  ) -> df


```

# {{<fa magnifiying-glass>}} Monday {.inverse}

## Plan

**Monday:**

- Explore initial results from survey

- Develop additional questions of the data

**Wednesday:**

- Finalized results from the data

**Friday:**

- Last class (Pizza or donuts?)


## Attendance Survey!

Click [here](https://brown.co1.qualtrics.com/jfe/form/SV_8oILSRPjrYIvLpA) to take one last attendance survey.

## Course Evaluations

Students can access the Course Feedback System through: 

1) Canvas

2) https://brown.evaluationkit.com  

3) Personalized login link in the reminder emails sent from <course_feedback@brown.edu>.


# Group 1 {.inverse}

Scott Hilgartner, Harris Laferriere, Tess Naquet-Radiguet, Lily Robinson

## Project {.smaller}



## Expectations {.smaller}

- H1: We expect that as people interact more on social media/ are more active on it, they will have higher degrees of politicization.

- H2: We expect that as people engage more with video sharing social media such as Instagram or Tiktok, they will tend to lean more ideologically liberal.

- H3: We expect that as people engage more with text sharing social media such as X or Facebook, they will tend to lean more ideologically conservative.

- H4: We expect that as people increasingly trust the information they receive on social media, they wil tend to lean more ideologically conservative

```{r}
df %>% 
  mutate(
    ft_in_party = case_when(
      is_dem == 1 ~ ft_3,
      is_rep == 1 ~ ft_4,
      T ~ NA
    ),
    ft_out_party = case_when(
      is_dem == 1 ~ ft_4,
      is_rep == 1 ~ ft_3,
      T ~ NA
    ),
      
    affective_polarization = ft_in_party - ft_out_party,
    # Media Use
    used_social_media = ifelse(!is.na(media_use_1), 1, 0),
    sm_political_instagram = g1_social_political_1,
    sm_political_tiktok = g1_social_political_2,
    sm_political_twitter = g1_social_political_3,
    sm_political_threads = g1_social_political_4,
    sm_political_facebok = g1_social_political_5,
    # Ideolgoy
    sm_ideology_instagram = case_when(
    	g1_social_ideo_1 == 1 ~ -2,
    	g1_social_ideo_1 == 2 ~ -1,
    	g1_social_ideo_1 == 5 ~ 0,
    	g1_social_ideo_1 == 3 ~ 1,
    	g1_social_ideo_1 == 4 ~ 2,
    	g1_social_ideo_1 == 6 ~ NA,
    	T ~ NA
    	),
    sm_ideology_tiktok = case_when(
    	g1_social_ideo_2 == 1 ~ -2,
    	g1_social_ideo_2 == 2 ~ -1,
    	g1_social_ideo_2 == 5 ~ 0,
    	g1_social_ideo_2 == 3 ~ 1,
    	g1_social_ideo_2 == 4 ~ 2,
    	g1_social_ideo_2 == 6 ~ NA,
    	T ~ NA
    	),
    sm_ideology_twitter = case_when(
    	g1_social_ideo_3 == 1 ~ -2,
    	g1_social_ideo_3 == 2 ~ -1,
    	g1_social_ideo_3 == 5 ~ 0,
    	g1_social_ideo_3 == 3 ~ 1,
    	g1_social_ideo_3 == 4 ~ 2,
    	g1_social_ideo_3 == 6 ~ NA,
    	T ~ NA
    	),
    sm_ideology_threads = case_when(
    	g1_social_ideo_4 == 1 ~ -2,
    	g1_social_ideo_4 == 2 ~ -1,
    	g1_social_ideo_4 == 5 ~ 0,
    	g1_social_ideo_4 == 3 ~ 1,
    	g1_social_ideo_4 == 4 ~ 2,
    	g1_social_ideo_4 == 6 ~ NA,
    	T ~ NA
    	),
    sm_ideology_facebok = case_when(
    	g1_social_ideo_5 == 1 ~ -2,
    	g1_social_ideo_5 == 2 ~ -1,
    	g1_social_ideo_5 == 5 ~ 0,
    	g1_social_ideo_5 == 3 ~ 1,
    	g1_social_ideo_5 == 4 ~ 2,
    	g1_social_ideo_5 == 6 ~ NA,
    	T ~ NA
    	),
    # Trust
    sm_trust_instagram = case_when(
    	g1_social_trust_1 == 11 ~ 0,
    	g1_social_trust_1 == 12 ~ 1,
    	g1_social_trust_1 == 13 ~ 2,
    	g1_social_trust_1 == 14 ~ 3,
    	g1_social_trust_1 == 15 ~ 4,
    	g1_social_trust_1 == 16 ~ NA,
    	T ~ NA
    	),
    sm_trust_tiktok = case_when(
    	g1_social_trust_2 == 11 ~ 0,
    	g1_social_trust_2 == 12 ~ 1,
    	g1_social_trust_2 == 13 ~ 2,
    	g1_social_trust_2 == 14 ~ 3,
    	g1_social_trust_2 == 15 ~ 4,
    	g1_social_trust_2 == 16 ~ NA,
    	T ~ NA
    	),
    sm_trust_twitter = case_when(
    	g1_social_trust_3 == 11 ~ 0,
    	g1_social_trust_3 == 12 ~ 1,
    	g1_social_trust_3 == 13 ~ 2,
    	g1_social_trust_3 == 14 ~ 3,
    	g1_social_trust_3 == 15 ~ 4,
    	g1_social_trust_3 == 16 ~ NA,
    	T ~ NA
    	),
    sm_trust_threads = case_when(
    	g1_social_trust_4 == 11 ~ 0,
    	g1_social_trust_4 == 12 ~ 1,
    	g1_social_trust_4 == 13 ~ 2,
    	g1_social_trust_4 == 14 ~ 3,
    	g1_social_trust_4 == 15 ~ 4,
    	g1_social_trust_4 == 16 ~ NA,
    	T ~ NA
    	),
    sm_trust_facebok = case_when(
    	g1_social_trust_5 == 11 ~ 0,
    	g1_social_trust_5 == 12 ~ 1,
    	g1_social_trust_5 == 13 ~ 2,
    	g1_social_trust_5 == 14 ~ 3,
    	g1_social_trust_5 == 15 ~ 4,
    	g1_social_trust_5 == 16 ~ NA,
    	T ~ NA
    	)


    
    
  ) -> df



```


## Affective Polarization

```{r}
g1_1 <- df %>% 
  ggplot(aes(ft_in_party))+
  geom_density()+
  geom_rug()+
  labs(x="In Party")

g1_2 <- df %>% 
  ggplot(aes(ft_out_party))+
  geom_density()+
  geom_rug()+
  labs(x="Out Party")

g1_3 <- df %>% 
  ggplot(aes(affective_polarization))+
  geom_density()+
  geom_rug()+
  labs(x="Affective Polarization")

g1_3

g1_4 <- df %>% 
  filter(pid_3cat %in% c("Democrat","Republican")) %>% 
  ggplot(aes(affective_polarization))+
  geom_density()+
  geom_rug()+
  labs(x="Affective Polarization")+
  facet_wrap(~ pid_3cat)

```

## Affective Polarization by Partisanship

```{r}
g1_4
```


## Engage with poltical content

```{r}

df %>% 
  select(starts_with("sm_political")) %>% 
  pivot_longer(cols = 1:5,
               names_to = "variable",
               ) %>% 
  mutate(
    Politics = as_factor(value),
    Platform = gsub("sm_political_", replacement ="", variable) %>% 
      str_to_title()
  ) %>% 
  group_by(Platform, Politics) %>% 
  summarise(
    percent = n()/403
  ) %>% 
  ggplot(aes(Politics, percent))+
  geom_bar(stat = "identity")+
  scale_y_continuous(labels = scales::percent) +
  facet_wrap(~ Platform)+
  coord_flip()

```


## Perceived Ideology

```{r}

df %>% 
  select(starts_with("sm_ideology")) %>% 
  pivot_longer(cols = 1:5,
               names_to = "variable",
               ) %>% 
  mutate(
    Ideology = as_factor(value),
    Platform = gsub("sm_ideology_", replacement ="", variable) %>% 
      str_to_title()
  ) %>% 
  # group_by(Platform, Politics) %>% 
  # summarise(
  #   percent = n()/403
  # ) %>% 
  ggplot(aes(Platform, value))+
  stat_summary()+
  coord_flip()+
  labs(
    y= "Ideology\n(-2=Very conservative | 2 = Very Liberal)"
  )


```


```{r}


```


## Trust in content by platform

```{r}
df %>% 
  select(starts_with("sm_trust")) %>% 
  pivot_longer(cols = 1:5,
               names_to = "variable",
               ) %>% 
  mutate(
    Trust = as_factor(value),
    Platform = gsub("sm_trust_", replacement ="", variable) %>% 
      str_to_title()
  ) %>% 
  # group_by(Platform, Politics) %>% 
  # summarise(
  #   percent = n()/403
  # ) %>% 
  ggplot(aes(Platform, value))+
  stat_summary()+
  coord_flip()+
  labs(
    y= "Trust\n(0=Never | 4 = Always)"
  )+
  ylim(0,4)
```

## Trust in content by platform and ideolgoy

```{r}
df %>% 
  select(starts_with("sm_trust"), ideology_3cat) %>% 
  pivot_longer(cols = 1:5,
               names_to = "variable",
               ) %>% 
  mutate(
    Trust = as_factor(value),
    Platform = gsub("sm_trust_", replacement ="", variable) %>% 
      str_to_title()
  ) %>% 
  # group_by(Platform, Politics) %>% 
  # summarise(
  #   percent = n()/403
  # ) %>% 
  ggplot(aes(Platform, value))+
  stat_summary()+
  coord_flip()+
  labs(
    y= "Trust\n(0=Never | 4 = Always)"
  ) +
  facet_wrap( ~ ideology_3cat, ncol=1)
```

## Media Use and Affective polarization

```{r}

g1_m1 <- lm(affective_polarization ~ sm_political_twitter, df)
g1_m2 <- lm(affective_polarization ~ sm_political_twitter*is_rep, df)

summary(g1_m1)


df %>% ggplot(
  aes( y= affective_polarization,
       x= sm_political_twitter)
)+
  geom_point()+
  stat_smooth(method = "lm")


```




# Group 2 {.inverse}

 Caleb, Michael, Ruairi, Kate, Cassandra


## Project {.smaller}

Survey takers  will be randomly presented with an article from Fox News, the AP, or MSNBC, all identical in text, and will then be asked a series of questions regarding their opinion on deportations

## Expectations {.smaller}

- H1: Liberals who read the MSNBC article will be more likely to oppose Trump’s policies than liberals who read neutral articles, and conservatives who read the Fox News article will be more likely to support Trump’s policies.

- H2: Liberals who read the Fox News article will also be more likely to oppose Trump’s policies than liberals who read neutral articles, and conservatives who read the MSNBC article will also be more likely to support Trump’s policies.

## Results

```{r}
df %>% 
  mutate(
    g2_treatment = case_when(
      !is.na(g2_t0) ~ "Control",
      !is.na(g2_t1_support) ~ "MSNBC",
      !is.na(g2_t2_support) ~ "FOX",
      !is.na(g2_t3_support) ~ "Neutral",
      T ~ NA
    ),
    g2_support = case_when(
      !is.na(g2_t0) ~ (g2_t0-6)*-1,
      !is.na(g2_t1_support) ~ (g2_t1_support-6)*-1,
      !is.na(g2_t2_support) ~ (g2_t2_support-6)*-1,
      !is.na(g2_t3_support) ~ (g2_t3_support-6)*-1,
      T ~ NA
    ),
  ) -> df

```


::::{.panel-tabset}

## Overall Support

```{r}

df %>% 
  ggplot(aes(g2_treatment, g2_support))+
  stat_summary()+
  coord_flip()
```


## Ideology

```{r}

df %>% 
  ggplot(aes(g2_treatment, g2_support))+
  stat_summary() +
  coord_flip()+
  facet_wrap(~ideology_3cat, ncol = 1)
```


::::

# Group 3 {.inverse}

Finn Brown, Lorena Calderon, Mia Hamilton, Ty Pham-Swann

## Project {.smaller}

We are interested in evaluating 

-  perceptions of partisan music preferences, including how political endorsements by musical artists might influence individuals’ listening habits, and 

- the potential ordering effect of asking respondents to evaluate their own music preferences before considering broader partisan music preferences, or vice versa.

## Expectations {.smaller}

- H1: We expect respondents who begin with the partisan music preference questions may report greater sensitivity to political endorsements, such as being less likely to listen to music associated with opposite-party endorsements, as the partisan framing could heighten their political identity. 

- H2: We expect respondents will rate genres like rap/hip-hop, jazz/classical, international (foreign), and pop as more Democratic. Conversely, we expect respondents will rate country and classic rock as more Republican. 


```{r}

df %>% 
  mutate(
    g3_order = case_when(
      !is.na(g3_t1_self_1) ~ "Self First",
      !is.na(g3_t2_self_1) ~ "Party First",
    ),
    g3_self_rock = ifelse(!is.na(g3_t1_self_1),
                          g3_t1_self_1,
                          g3_t2_self_1),
    g3_self_country = ifelse(!is.na(g3_t1_self_2),
                          g3_t1_self_2,
                          g3_t2_self_2),
    g3_self_rap = ifelse(!is.na(g3_t1_self_3),
                          g3_t1_self_3,
                          g3_t2_self_3),
    g3_self_jazz = ifelse(!is.na(g3_t1_self_4),
                          g3_t1_self_4,
                          g3_t2_self_4),
    g3_self_pop = ifelse(!is.na(g3_t1_self_5),
                          g3_t1_self_5,
                          g3_t2_self_5),
    g3_self_international = ifelse(!is.na(g3_t1_self_6),
                          g3_t1_self_6,
                          g3_t2_self_6),
    g3_party_rock = ifelse(!is.na(g3_t1_party_1),
                          g3_t1_party_1,
                          g3_t2_party_1),
    g3_party_country = ifelse(!is.na(g3_t1_party_2),
                          g3_t1_party_2,
                          g3_t2_party_2),
    g3_party_rap = ifelse(!is.na(g3_t1_party_3),
                          g3_t1_party_3,
                          g3_t2_party_3),
    g3_party_jazz = ifelse(!is.na(g3_t1_party_4),
                          g3_t1_party_4,
                          g3_t2_party_4),
    g3_party_pop = ifelse(!is.na(g3_t1_party_5),
                          g3_t1_party_5,
                          g3_t2_party_5),
    g3_party_international = ifelse(!is.na(g3_t1_party_6),
                          g3_t1_party_6,
                          g3_t2_party_6),
    g3_party_rock = case_when(
g3_party_rock == 1 ~ -1,
g3_party_rock == 2 ~ 1,
g3_party_rock == 6 ~ 0,

),
    g3_party_country = case_when(
g3_party_country == 1 ~ -1,
g3_party_country == 2 ~ 1,
g3_party_country == 6 ~ 0,
    
    ),
    g3_party_rap = case_when(
g3_party_rap == 1 ~ -1,
g3_party_rap == 2 ~ 1,
g3_party_rap == 6 ~ 0,
    
    ),
    g3_party_jazz = case_when(
g3_party_jazz == 1 ~ -1,
g3_party_jazz == 2 ~ 1,
g3_party_jazz == 6 ~ 0,
    
    ),
    g3_party_pop = case_when(
g3_party_pop == 1 ~ -1,
g3_party_pop == 2 ~ 1,
g3_party_pop == 6 ~ 0,
    
    ),
    g3_party_international = case_when(
g3_party_international == 1 ~ -1,
g3_party_international == 2 ~ 1,
g3_party_international == 6 ~ 0,
    
    )
    
  ) -> df


```

## Listening Preferences

```{r}
df %>% 
  select(starts_with("g3_self"), g3_order) %>% 
  filter(!is.na(g3_order)) %>% 
  pivot_longer(cols = 1:6,
               names_to = "variable",
               ) %>% 
  mutate(
    Genre = gsub("g3_self_", replacement ="", variable) %>% 
      str_to_title()
  ) %>% 
  # group_by(Platform, Politics) %>% 
  # summarise(
  #   percent = n()/403
  # ) %>% 
  ggplot(aes(Genre, value))+
  stat_summary()+
  coord_flip()+
  labs(
    y= "Frequency of Listenting \n(1 = Never, 4 = All the time)"
  )
```


## Listening Preferences by Partisanship

```{r}
df %>% 
  select(starts_with("g3_self"), pid_3cat,g3_order) %>% 
  filter(!is.na(g3_order)) %>% 
  filter(!is.na(pid_3cat)) %>% 
  pivot_longer(cols = 1:6,
               names_to = "variable",
               ) %>% 
  mutate(
    Genre = gsub("g3_self_", replacement ="", variable) %>% 
      str_to_title()
  ) %>% 
  # group_by(Platform, Politics) %>% 
  # summarise(
  #   percent = n()/403
  # ) %>% 
  ggplot(aes(Genre, value))+
  stat_summary()+
  facet_wrap(~pid_3cat, ncol=1)+
  coord_flip()+
  labs(
    y= "Frequency of Listenting \n(1 = Never, 4 = All the time)"
  )
```

## Listening Preferences by Partisanship and Order

```{r}
df %>% 
  select(starts_with("g3_self"), pid_3cat,g3_order) %>% 
  filter(!is.na(g3_order)) %>% 
  filter(!is.na(pid_3cat)) %>% 
  pivot_longer(cols = 1:6,
               names_to = "variable",
               ) %>% 
  mutate(
    Genre = gsub("g3_self_", replacement ="", variable) %>% 
      str_to_title()
  ) %>% 
  # group_by(Platform, Politics) %>% 
  # summarise(
  #   percent = n()/403
  # ) %>% 
  ggplot(aes(Genre, value, col = g3_order))+
  stat_summary(position = position_dodge(width=.5))+
  facet_wrap(~pid_3cat, ncol=1)+
  coord_flip()+
  labs(
    y= "Frequency of Listenting \n(1 = Never, 4 = All the time)"
  )
```


## Perceived Partisanship of Genre's Listeners

```{r}
df %>% 
  select(starts_with("g3_party")) %>% 
  pivot_longer(cols = 1:6,
               names_to = "variable",
               ) %>% 
  mutate(
    Genre = gsub("g3_party_", replacement ="", variable) %>% 
      str_to_title()
  ) %>% 
  # group_by(Platform, Politics) %>% 
  # summarise(
  #   percent = n()/403
  # ) %>% 
  ggplot(aes(Genre, value))+
  stat_summary()+
  coord_flip()+
  labs(
    y= "Who Listens More \n(-1=Democrats | 1 = Republicans)"
  )
```


## What if favorite musician endorsed: Democrat/Republican

```{r}
df %>% 
  mutate(
    g3_endorse = case_when(
      !is.na(g3_dem_endorse) ~ "Endorsed Democrat",
      !is.na(g3_rep_endorse) ~ "Endorsed Republican",
    ),
    listen_more_or_less =
      case_when(
      !is.na(g3_dem_endorse) ~ g3_dem_endorse-3,
      !is.na(g3_rep_endorse) ~ g3_rep_endorse-3,
    ),
  ) -> df
  

```

```{r}
df %>% 
  ggplot(aes(g3_endorse,listen_more_or_less ))+
  stat_summary()+
  geom_hline(yintercept = 0, linetype="dashed")+
  coord_flip()+
  theme_minimal()

```


# By ideolgoy

```{r}
df %>% 
  ggplot(aes(g3_endorse,listen_more_or_less ))+
  stat_summary()+
  geom_hline(yintercept = 0, linetype="dashed")+
  coord_flip()+
  facet_wrap(~ideology_3cat, ncol=1)+
  theme_minimal()
```



# Group 4 {.inverse}

Anastasios Demopoulos, Mikael Oberlin, Joshua Silverman


## Project {.smaller}

We are interested in understanding 

- how different demographic groups respond to media coverage of voter suppression policies, and 

- how does being a member of an underrepresented minority group (URM) correlate with trust or distrust in mainstream media? 


## Expectations {.smaller}



## Confidence in Elections by Race {.smaller}

```{r}

df %>% 
  mutate(
    election_confidence = case_when(
      g4_confidence == 11 ~ 4,
      g4_confidence == 12 ~ 3,
      g4_confidence == 13 ~ 2,
      g4_confidence == 15 ~ 1,

    ),
    income = ifelse(demo_income == 7, NA, demo_income),
    has_ba = ifelse(demo_educ >4,1,0),
    age = demo_age
  ) -> df


m1 <- lm_robust(election_confidence ~
                  is_black +
                  is_asian +
                  is_latino,
                df)

m2 <- lm_robust(election_confidence ~
                  is_black +
                  is_asian +
                  is_latino +
                  is_rep+
                  is_ind+
                  age +
                  is_woman +
                  has_ba +
                  income,
                df)


```



```{r}
#| results: asis

texreg::htmlreg(list(m1,m2),include.ci = F)
```

## Coefficient plots

```{r}
g4_coefs <- tidy(m1) %>% mutate(Model ="Baseline") %>% bind_rows(
  tidy(m2) %>% mutate(Model = "Controls")
)
g4_coefs %>% 
  filter(term %in% c("is_black","is_latino","is_asian")) %>% 
  ggplot(aes(term, estimate, col = Model))+
  geom_pointrange(aes(ymin = conf.low, ymax = conf.high),
                  position = position_dodge(width=.5))+
  geom_hline(yintercept = 0, linetype="dashed")+
  coord_flip()+
  theme_minimal()+
  labs(
    title= "Racial Differences in Confidence in Elections"
  )

```




# Group 5 {.inverse}

Bridget Hickton, Sailihe Men, Riya Srinivasan, Jack Zarate

## Project {.smaller}

We are interested in how public opinion of celebrities changes when they endorse politicians and how public opinion of these endorsements varies across different levels of age, education, and political ideology.

## Expectations {.smaller}

- H1: We expect that public opinion of celebrities will be more extreme when the politician they endorsed is given

- H2: Favorability toward a celebrity is positively associated with the likelihood of voting for the politician they endorsed.

## Knowledge of Celebrity Endorsements

```{r}
df %>% 
  mutate(
    vote_choice = case_when(
      common_votechoice == 1 ~ "Harris",
      common_votechoice == 2 ~ "Trump",
      T ~ NA
    ),
    know_taylor = case_when(
      g5_endorse_t0_1 == 1 ~ 1,
      g5_endorse_t1_1 == 1 ~ 1,
      T ~ 0
    ),
    know_kid_rock = case_when(
      g5_endorse_t0_2 == 2 ~ 1,
      g5_endorse_t1_2 == 2 ~ 1,
      T ~ 0
    ),
    know_oprah = case_when(
      g5_endorse_t0_3 == 1 ~ 1,
      g5_endorse_t1_3 == 1 ~ 1,
      T ~ 0
    ),
    know_dr_phil = case_when(
      g5_endorse_t0_4 == 2 ~ 1,
      g5_endorse_t1_4 == 2 ~ 1,
      T ~ 0
    ),
    know_chappell_roan = case_when(
      g5_endorse_t0_5 == 4 ~ 1,
      g5_endorse_t1_5 == 4 ~ 1,
      T ~ 0
      ),
    know_the_rock = case_when(
      g5_endorse_t0_6 == 4 ~ 1,
      g5_endorse_t1_6 == 4 ~ 1,
      T ~ 0
      ),
    eval_taylor_swift = case_when(
      !is.na(g5_eval_t0_1) ~ g5_eval_t0_1,
      !is.na(g5_eval_t1_1) ~ g5_eval_t1_1,
      T ~ 0
    ),
    eval_kid_rock = case_when(
      !is.na(g5_eval_t0_2) ~ g5_eval_t0_2,
      !is.na(g5_eval_t1_2) ~ g5_eval_t1_2,
      T ~ 0
    ),
    eval_oprah = case_when(
      !is.na(g5_eval_t0_4) ~ g5_eval_t0_4,
      !is.na(g5_eval_t1_4) ~ g5_eval_t1_4,
      T ~ 0
    ),
    eval_dr_phil = case_when(
      !is.na(g5_eval_t0_7) ~ g5_eval_t0_7,
      !is.na(g5_eval_t1_7) ~ g5_eval_t1_7,
      T ~ 0
    ),
    eval_chappell_roan = case_when(
      !is.na(g5_eval_t0_8) ~ g5_eval_t0_8,
      !is.na(g5_eval_t1_8) ~ g5_eval_t1_8,
      T ~ 0
      ),
    eval_the_rock = case_when(
      !is.na(g5_eval_t0_9) ~ g5_eval_t0_9,
      !is.na(g5_eval_t1_9) ~ g5_eval_t1_9,
      T ~ 0
      ),
    eval_kamala_harris = case_when(
      !is.na(g5_eval_t0_10) ~ g5_eval_t0_10,
      !is.na(g5_eval_t1_10) ~ g5_eval_t1_10,
      T ~ 0
      ),
    eval_donal_trump = case_when(
      !is.na(g5_eval_t0_11) ~ g5_eval_t0_11,
      !is.na(g5_eval_t1_11) ~ g5_eval_t1_11,
      T ~ 0
      ),
    g5_treatment = ifelse(!is.na(g5_eval_t1_1), "Told Endorsment", "No Info")
  ) -> df




```


```{r}
df %>% 
  select(starts_with("know_")) %>% 
  pivot_longer(cols = 1:6) %>% 
  group_by(name) %>% 
  summarise(
    `Percent Correct` = round(mean(value)*100)
  ) %>% 
  mutate(
    name = fct_reorder(name, `Percent Correct`)
  ) -> know_df
know_df %>% 
  ggplot(aes(name, `Percent Correct`))+
  geom_bar(stat = "identity")+
  geom_text(aes(label = `Percent Correct`), hjust = -.5)+
  coord_flip()+
  ylim(0,100)
```


## Impact of Knowing Celebrity Endorsments

```{r}
df %>% 
  select(starts_with("eval_"), g5_treatment) %>% 
  pivot_longer(cols = 1:8) %>% 
  mutate(
    name = factor(name,levels =  c("eval_taylor_swift","eval_kid_rock", "eval_oprah", "eval_dr_phil", "eval_chappell_roan", "eval_the_rock", "eval_kamala_harris", "eval_donal_trump"))
  ) %>%
  ggplot(aes(name, value, col = g5_treatment))+
  stat_summary(position = position_dodge(width = .5))+
  coord_flip()


```


## Impact of Knowing Celebrity Endorsments by Vote Choice

```{r}
df %>% 
  select(starts_with("eval_"), g5_treatment, vote_choice) %>% 
  filter(!is.na(vote_choice)) %>% 
  pivot_longer(cols = 1:8) %>% 
  mutate(
    name = factor(name,levels =  c("eval_taylor_swift","eval_kid_rock", "eval_oprah", "eval_dr_phil", "eval_chappell_roan", "eval_the_rock", "eval_kamala_harris", "eval_donal_trump"))
  ) %>%
  ggplot(aes(name, value, col = g5_treatment))+
  stat_summary(position = position_dodge(width = .5))+
  facet_wrap(~ vote_choice, ncol=1)+
  coord_flip()


```





# Group 6 {.inverse}

Patrick Behan, Brandon Bergner, Ellie Brault, Connor Swenson

## Project {.smaller}

- We are interested in whether citizens from smaller states favor the Electoral College more than citizens from larger states.

## Expectations {.smaller}

-  We expect that citizens from smaller states favor the Electoral College more than citizens from larger states.


## Data

```{r}
#| echo: true

library(zipcodeR)
library(tidycensus)

# Get State and County from Zipcode
df$state <- NA
df$county <- NA

for(i in 1:403){
df$state[i] <- try(reverse_zipcode(df$zipcode[i])$state)
df$county[i] <- try(reverse_zipcode(df$zipcode[i])$county)

}

df %>% 
  mutate(
    state = ifelse(nchar(state)>2, NA, state),
    county = ifelse(grepl("(zip_char != 5)", county), NA, county)
  ) -> df

# Load county fips data, merge in df

data("fips_codes")

df <- df %>% left_join(fips_codes, by=c("county"="county", "state" = "state" ))

df %>% 
  mutate(
    fips = paste(state_code, county_code, sep="")
  ) -> df


# Load ACS Data



state_pop <- get_acs(
  geography = "state",
  variables = "B01003_001",
  year = 2020
)

state_pop %>% 
  mutate(
    state_code = GEOID,
    state_population = estimate
  ) -> state_pop

# Merge state population

df <- df %>%  left_join(state_pop)  


# County Data
county_pop <- get_acs(
  geography = "county",
  variables = c("B01003_001", "B01001B_001"),
  output = "wide",
  year = 2020
) 
county_pop %>% 
  mutate(
    county = NAME,
    fips = GEOID,
    county_population = B01003_001E,
    county_black = B01001B_001E,
    per_black_county = county_black/county_population
  ) -> county_pop

df <- df %>% left_join(county_pop %>% 
                          select(fips, per_black_county, county_population,county_black ))

# Recode Group 6 Variables

df %>% 
  mutate(
    support_ec_reform = g6_ec_reform - 4,
    state_pop_quartile = case_when(
      state_population <= quantile(state_pop$state_population)[2] ~ "Q1",
      state_population > quantile(state_pop$state_population)[2] &
        state_population < quantile(state_pop$state_population)[3] ~ "Q2",
      state_population >
      quantile(state_pop$state_population)[3] &
        state_population < quantile(state_pop$state_population)[4] ~ "Q3",
      state_population >
      quantile(state_pop$state_population)[4] ~ "Q4" 
    ),
    from_big_state = ifelse(state_population > quantile(state_pop$state_population)[4],1,0)
    ) -> df


df %>% 
  ggplot(aes(state_pop_quartile, support_ec_reform)) +
  stat_summary() +
  coord_flip()

## TODO


# Scale perceptions of EC



```

## Respondents by Size

```{r}
df %>% 
  mutate(
    state_size_f = fct_reorder(state, state_population)
  ) -> df

table(df$state_size_f, df$state_pop_quartile)
```


## State Size and Support for EC Reform

```{r}
df %>% 
  filter(!is.na(state_pop_quartile)) %>% 
  ggplot(aes(state_pop_quartile, support_ec_reform)) +
  stat_summary() +
  coord_flip()
```


# Group 8 {.inverse}

Tanner Burns, Serenity Hamilton, Charlie Jeffers, Christian Rasmussen

## Project {.smaller}

- We are interested in studying how certain beliefs about election denial are affected by voting decisions in the 2024 U.S. Presidential Election, and how political affiliation relates to the strength of the belief in election fraud


## Expectations {.smaller}

- H1: We expect that more moderate and liberal identifying people will display more confidence in the election process, while conservatives will have an increased belief in fraud. Non-voters may have higher belief in fraud as well. 

- H2: We expect that higher amounts of exposure to conservative media will be correlated with higher amounts of belief in fraudulent activity. 

- H3: We expect that respondents in younger age ranges will have a stronger relationship between media bias leaning and its influence on belief in the security and accuracy of elections. 

## Results

```{r}

df %>% 
  mutate(
    fraud_mailin = g8_fraud_1-6,
    fraud_illegal_immigrants = g8_fraud_2-6,
    fraud_trump_won20 = g8_fraud_3-6,
    fraud_trump_won24 = (g8_fraud_4-10)*-1,# Reverse Code

  ) -> df




```

## Fraud in Elections

```{r}
df %>% 
  select(starts_with("fraud")) %>% 
  pivot_longer(cols=1:4) %>% 
  ggplot(aes(name, value))+
  stat_summary()+
  coord_flip()
```

## Fraud in Elections by Partisanship


```{r}
df %>% 
  select(starts_with("fraud"),"pid_3cat") %>% 
  pivot_longer(cols=1:4) %>% 
  filter(!is.na(pid_3cat)) %>% 
  ggplot(aes(name, value,col=pid_3cat))+
  stat_summary()+
  coord_flip()+
  facet_wrap(~pid_3cat,ncol=1)
```


# Group 9 {.inverse}

Benjamin Buka, Maya Choksi, Kaicee Klus, Claire Mahoney

## Project {.smaller}

We are interested in whether people actually align with the ideals of media sources affiliated with the party they identify with. To study this question, we want to present people with a short article containing the same information, but appearing to be from a left-leaning, neutral, or right-leaning source. 

## Expectations {.smaller}

- H1: We expect that a person who identifies with a certain party is less likely to trust the information presented from a source that leans opposite from their own party.

- H2: We expect that people may not full-heartedly agree with the information presented by a media source that skew towards their own political bias.

- H3: We expect that independents will be less likely to trust any polarized media source, and will be more likely to align with the source with no lean.

## Results

```{r}


df %>% 
  mutate(
    article_unbiased = case_when(
      !is.na(gt_t1_article_1) ~ gt_t1_article_1 -6,
      !is.na(g2_t2_article_1) ~ g2_t2_article_1 -6,
      !is.na(g2_t3_article_1) ~ g2_t3_article_1 -6,
    ),
    article_useful_info = case_when(
      !is.na(gt_t1_article_2) ~ gt_t1_article_2 -6,
      !is.na(g2_t2_article_2) ~ g2_t2_article_2 -6,
      !is.na(g2_t3_article_2) ~ g2_t3_article_2 -6,
    ),
    article_increased_support = case_when(
      !is.na(gt_t1_article_3) ~ gt_t1_article_3 -6,
      !is.na(g2_t2_article_3) ~ g2_t2_article_3 -6,
      !is.na(g2_t3_article_3) ~ g2_t3_article_3 -6,
    )
    ) -> df

```

## Biased of Article

```{r}
df %>% 
  filter(g2_treatment != "Control") %>% 
  ggplot(aes(g2_treatment, article_unbiased))+
  stat_summary()+
  coord_flip()
```

## Biased of Article by Ideology

```{r}
df %>% 
  filter(g2_treatment != "Control") %>% 
  ggplot(aes(g2_treatment, article_unbiased))+
  stat_summary()+
  coord_flip()+
  facet_wrap(~ideology_3cat, ncol=1)
```

## Useful Info

```{r}
df %>% 
  filter(g2_treatment != "Control") %>% 
  ggplot(aes(g2_treatment, article_useful_info))+
  stat_summary()+
  coord_flip()
```

## Useful Info by Ideology

```{r}
df %>% 
  filter(g2_treatment != "Control") %>% 
  ggplot(aes(g2_treatment, article_useful_info))+
  stat_summary()+
  coord_flip()+
  facet_wrap(~ideology_3cat, ncol=1)
```

## Increased Support 


```{r}
df %>% 
  filter(g2_treatment != "Control") %>% 
  ggplot(aes(g2_treatment, article_increased_support))+
  stat_summary()+
  coord_flip()
```


## Increased Support by Ideology


```{r}
df %>% 
  filter(g2_treatment != "Control") %>% 
  ggplot(aes(g2_treatment, article_increased_support))+
  stat_summary()+
  coord_flip()+
  facet_wrap(~ideology_3cat, ncol=1)
```


