n-parameters

Author

Judy Zhu

library(brms)
Warning: package 'brms' was built under R version 4.4.1
Loading required package: Rcpp
Warning: package 'Rcpp' was built under R version 4.4.1
Loading 'brms' package (version 2.21.0). Useful instructions
can be found by typing help('brms'). A more detailed introduction
to the package is available through vignette('brms_overview').

Attaching package: 'brms'
The following object is masked from 'package:stats':

    ar
library(tidybayes)
Warning: package 'tidybayes' was built under R version 4.4.1

Attaching package: 'tidybayes'
The following objects are masked from 'package:brms':

    dstudent_t, pstudent_t, qstudent_t, rstudent_t
library(gtsummary)
Warning: package 'gtsummary' was built under R version 4.4.1
#Uighur
library(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
library(primer.data)

\[voted ~ treatment + sex\]

data <- shaming |> 
mutate(p_00 = (primary_00 == "Yes"), p_02 = (primary_02 == "Yes"),
       p_04 = (primary_04 == "Yes"), g_00 = (general_00 == "Yes"),
       g_02 = (general_02 == "Yes"), g_04 = (general_04 == "Yes"),
civ_engage = p_00 + p_02 + p_04 + g_00 + g_02 + g_04,
voter_class = case_when(civ_engage %in% c(5, 6) ~ "Always Vote",
                        civ_engage %in% c(3, 4) ~ "Sometimes Vote",
                        civ_engage %in% c(1, 2) ~ "Rarely Vote"),
voter_class = factor(voter_class, levels = c("Rarely Vote", "Sometimes Vote", "Always Vote")), age_z = as.numeric(scale(age))) |>
rename(voted = primary_06) |>
select(voted, treatment, sex, age_z, civ_engage, voter_class) 


data |> sample_frac(0.5) |>
ggplot(aes(x = civ_engage, y = voted)) +
geom_jitter(alpha = 0.03, height = 0.1)+
scale_x_continuous(breaks = 1:6)+
scale_y_continuous(breaks = c(0,1), labels = c("No", "Yes")) +
labs(title = "Civic Engagement and Voting Behavior in Michigan",
subtitle = "Past voting preficts future voting",
x = "Civic Engagement", y = "Voted in 2006 Primary Election")

Made github repo n parameters, connected to R. Made graph explaning that past voting predicts future voting habits. Found out that stability may not hold due to the fact that Michigan and Texas have very different voting patterns. Piped fit_postcard_vote to tbl_regression to find the data of fit_postcard_vote. The quality of interest is how the texas votes are going to go, but comparing it from michigan data with different voters and time may not work out.