Deportations by political party of the President

Create a factor-level variable and regress deportations as a function of it: \(\hat{D}=\beta_0 + \beta_1Party\)

1=Democrat; 0=Republican

#Create factor-level variable

remove.1$PartyofPres<-factor(remove.1$Party, 
                levels=c(0,1),
                labels=c("Republican", "Democrat"))
summary(remove.1$PartyofPres)
## Republican   Democrat 
##         40         35

Regression model

#"Regress" deportations "on" decade

reg1<-lm(Deportations~PartyofPres, data=remove.1)

summary(reg1)
## 
## Call:
## lm(formula = Deportations ~ PartyofPres, data = remove.1)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -118080  -87243  -71318   82297  306491 
## 
## Coefficients:
##                     Estimate Std. Error t value  Pr(>|t|)    
## (Intercept)            94800      21372   4.436 0.0000319 ***
## PartyofPresDemocrat    31043      31286   0.992     0.324    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 135200 on 73 degrees of freedom
## Multiple R-squared:  0.01331,    Adjusted R-squared:  -0.0002093 
## F-statistic: 0.9845 on 1 and 73 DF,  p-value: 0.3244

plot_model

plot_model(reg1, type = "pred", terms = c("PartyofPres"), ci.lvl = .95, 
    title="Use of deportations by Republican and Democratic Presidents \nshows no differences, 1948-1922", axis.title=c("Party", "Number of removals"),           colors=c("coral2")) +  
  geom_line(color=c("coral2"), size=1) +
  theme_classic()

All the things

plot_model : invokes sjPlot and tells R to plot a regression object.

reg1 : It is the name of the regression object you want to plot.

type=“pred” : Informs plot_model to plot predicted values from regression function

terms=c(“PartyofPres) : Corresponds to the name of the independent variable(s) used in the regression model. It is case-sensitive and must be identical to what you specified in lm .

ci.lvl: .95 : Specifies confidence level (here we specify the 95% level)

title=“Use of deportations by Republican and Democratic Presidents no differences, 1948-1922”, axis.title=c(“Party”, “Number of removals”) : Gives main title, and axis titles (x-axis first, y-axis second).

colors=c(“coral2”)) : Specifies color of objects in plot_model .

geom_line(color=c(“coral2”), size=1) : Adding a line to connect the plot points (used here to show differences)

theme_classic() : This controls the appearance of the overall plot. There are many themes. Google ggplot2 themes to see them.