library(RCPA3)POL 300: Lab 8
This page contains R code for Lab 8.
Instructions
To complete this lab:
- create a new R script on your computer
- save it under the name
POL 300 Lab 8.R - copy and paste the code from this page (in the gray boxes) into the script
- comment the code as instructed during the lab
Code
setwd(dirname(rstudioapi::getSourceEditorContext()$path))
getwd()levels(nes$race.ethnicity)
regC(formula = ft.police ~ race.ethnicity,
data = nes)regC(formula = ft.police ~ relevel(x = race.ethnicity, ref = "3. Hispanic"),
data = nes)regC(formula = poverty ~ corrupt.perception + conflict.index + coup.attempts,
data = world)# install.packages("modelsummary")
library(modelsummary)m.poverty <- regC(formula = poverty ~ corrupt.perception + conflict.index + coup.attempts,
data = world)
modelsummary(models = list(m.poverty))
modelsummary(models = list(m.poverty),
stars = TRUE)# install.packages(c("marginaleffects", "ggplot2"))
library(marginaleffects)levels(states$term.limits)
regC(abortlaws ~ prochoice.percent + term.limits + prochoice.percent * term.limits,
data = states)
m.abortlaws <- regC(abortlaws ~ prochoice.percent + term.limits + prochoice.percent * term.limits,
data = states)
plot_predictions(model = m.abortlaws,
condition = c("prochoice.percent", "term.limits"))levels(states$south)
regC(trump2020 ~ unemployment + south + unemployment * south,
data = states)
m.trump <- regC(trump2020 ~ unemployment + south + unemployment*south,
data = states)
plot_predictions(model = m.trump,
condition = c("unemployment", "south"))