Note that throughout section we will be using the data from problem set 6.



# Libraries
library(tidyverse)
library(knitr)
library(stargazer)
library(sandwich)
library(foreign)
library(plotly)
library(reshape2)
library(glmnet)
library(caTools)

# Import data
ps6 = read.dta('/Users/trevorincerti/Box Sync/Graduate/Teaching/500/section_notes/data/qog_std_cs_15may13.dta')

# Drop all observations such that wdi_gnipc has missing values.
ps6_clean = ps6 %>% 
  filter(!is.na(wdi_gnipc))

# Create logged wdi_gnipc variable
ps6_clean$ln_wdi_gnipc = log(ps6_clean$wdi_gnipc)

# Keep variables needed for analysis only
ps6_clean = ps6_clean %>% 
  select(ccode, cname, fh_ipolity2, ln_wdi_gnipc, ciri_empinx_new)

Bivariate regression vs. Multivariate regression

Interpreting a coefficient in a bivariate linear regression (e.g. \(\beta_1\) in \(Y = \alpha + \beta_1 x_1\)).

ps6_lm = lm(fh_ipolity2 ~ ln_wdi_gnipc, data = ps6_clean)


Dependent variable:
Polity score
Logged GNI per capita 0.846***
(0.129)
Constant -0.390
(1.101)
Observations 187
Adjusted R2 0.185
Note: p<0.1; p<0.05; p<0.01



## `geom_smooth()` using formula 'y ~ x'


Interpreting a coefficient in a multivariate linear regression (\(Y = \alpha + \beta_1x_1 + \beta_2x_2\)).

\[\beta_1 = \frac{\partial Y}{\partial x_1} \]


ps6_lm2 = lm(fh_ipolity2 ~ ln_wdi_gnipc + ciri_empinx_new, data = ps6_clean)


Dependent variable:
Polity score
Logged GNI per capita 0.142*
(0.072)
CIRI Empowerment score 0.631***
(0.027)
Constant 0.475
(0.558)
Observations 187
Adjusted R2 0.792
Note: p<0.1; p<0.05; p<0.01