14 Ballot order effect
library(tidyverse)
library(readxl)
library(moderndive)
library(plm)
library(sandwich)
library(lmtest)
library(stargazer)
library(zoo)
.2020 <- read_excel("ballot/candidates-2020.xls")
candidates.2016 <- read_excel("ballot/candidates-2016.xls")
candidates.2012 <- read_excel("ballot/candidates-2012.xls")
candidates.2008 <- read_excel("ballot/candidates-2008.xls") candidates
<- bind_rows(candidates.2020 %>% mutate(year = 2020),
candidates .2016 %>% mutate(year = 2016),
candidates.2012 %>% mutate(year = 2012),
candidates.2008 %>% mutate(year = 2008)) candidates
.2020 <- candidates.2020 %>%
candidatesmutate(top = ifelse(號次 == 1, 1, 0),
sex = ifelse(性別 == "男", 1, 0),
incumbent = ifelse(是否現任 == "是", 1, 0),
birth = as.integer(出生年次),
share = 得票率)
.2016 <- candidates.2016 %>%
candidatesmutate(top = ifelse(號次 == 1, 1, 0),
sex = ifelse(性別 == "男", 1, 0),
incumbent = ifelse(是否現任 == "是", 1, 0),
birth = as.integer(出生年次),
share = 得票率)
.2012 <- candidates.2012 %>%
candidatesmutate(top = ifelse(號次 == 1, 1, 0),
sex = ifelse(性別 == "男", 1, 0),
incumbent = ifelse(是否現任 == "是", 1, 0),
birth = as.integer(出生年次),
share = 得票率)
.2008 <- candidates.2008 %>%
candidatesmutate(top = ifelse(號次 == 1, 1, 0),
sex = ifelse(性別 == "男", 1, 0),
incumbent = ifelse(是否現任 == "是", 1, 0),
birth = as.integer(出生年次),
share = 得票率)
<- candidates %>%
candidates mutate(top = ifelse(號次 == 1, 1, 0),
sex = ifelse(性別 == "男", 1, 0),
incumbent = ifelse(是否現任 == "是", 1, 0),
birth = as.integer(出生年次),
share = 得票率,
year = as.character(year))
<- lm(share ~ top + sex + incumbent + birth + year, candidates)
ols .2020 <- lm(share ~ top + sex + incumbent + birth, candidates.2020)
ols.2016 <- lm(share ~ top + sex + incumbent + birth, candidates.2016)
ols.2012 <- lm(share ~ top + sex + incumbent + birth, candidates.2012)
ols.2008 <- lm(share ~ top + sex + incumbent + birth, candidates.2008)
ols
<- plm(share ~ top + sex + incumbent + birth + year,
plm data = candidates,
index = c("year"),
model = "within")
::kable(get_regression_table(ols)) knitr
term | estimate | std_error | statistic | p_value | lower_ci | upper_ci |
---|---|---|---|---|---|---|
intercept | -1.090 | 0.818 | -1.333 | 0.183 | -2.695 | 0.514 |
top | 0.041 | 0.011 | 3.727 | 0.000 | 0.019 | 0.062 |
sex | -0.006 | 0.011 | -0.525 | 0.600 | -0.026 | 0.015 |
incumbent | 0.375 | 0.011 | 34.456 | 0.000 | 0.354 | 0.397 |
birth | 0.001 | 0.000 | 1.460 | 0.145 | 0.000 | 0.001 |
year: 2012 | 0.068 | 0.014 | 4.827 | 0.000 | 0.040 | 0.096 |
year: 2016 | 0.026 | 0.013 | 1.957 | 0.051 | 0.000 | 0.053 |
year: 2020 | 0.004 | 0.013 | 0.267 | 0.789 | -0.023 | 0.030 |
::kable(get_regression_table(ols.2020)) knitr
term | estimate | std_error | statistic | p_value | lower_ci | upper_ci |
---|---|---|---|---|---|---|
intercept | -1.359 | 1.285 | -1.057 | 0.291 | -3.885 | 1.168 |
top | 0.018 | 0.019 | 0.917 | 0.360 | -0.020 | 0.056 |
sex | -0.037 | 0.016 | -2.314 | 0.021 | -0.069 | -0.006 |
incumbent | 0.405 | 0.020 | 20.565 | 0.000 | 0.366 | 0.443 |
birth | 0.001 | 0.001 | 1.160 | 0.247 | -0.001 | 0.002 |
::kable(get_regression_table(ols.2016)) knitr
term | estimate | std_error | statistic | p_value | lower_ci | upper_ci |
---|---|---|---|---|---|---|
intercept | -2.035 | 1.595 | -1.276 | 0.203 | -5.171 | 1.102 |
top | 0.049 | 0.023 | 2.159 | 0.032 | 0.004 | 0.094 |
sex | -0.002 | 0.021 | -0.094 | 0.925 | -0.044 | 0.040 |
incumbent | 0.385 | 0.024 | 16.178 | 0.000 | 0.338 | 0.432 |
birth | 0.001 | 0.001 | 1.357 | 0.176 | 0.000 | 0.003 |
::kable(get_regression_table(ols.2012)) knitr
term | estimate | std_error | statistic | p_value | lower_ci | upper_ci |
---|---|---|---|---|---|---|
intercept | -2.014 | 2.054 | -0.981 | 0.328 | -6.059 | 2.030 |
top | 0.068 | 0.024 | 2.777 | 0.006 | 0.020 | 0.116 |
sex | 0.020 | 0.026 | 0.780 | 0.436 | -0.031 | 0.072 |
incumbent | 0.336 | 0.025 | 13.459 | 0.000 | 0.287 | 0.385 |
birth | 0.001 | 0.001 | 1.058 | 0.291 | -0.001 | 0.003 |
::kable(get_regression_table(ols.2008)) knitr
term | estimate | std_error | statistic | p_value | lower_ci | upper_ci |
---|---|---|---|---|---|---|
intercept | 1.597 | 1.890 | 0.845 | 0.399 | -2.122 | 5.317 |
top | 0.026 | 0.022 | 1.197 | 0.232 | -0.017 | 0.069 |
sex | 0.021 | 0.024 | 0.846 | 0.398 | -0.027 | 0.069 |
incumbent | 0.366 | 0.020 | 18.366 | 0.000 | 0.327 | 0.406 |
birth | -0.001 | 0.001 | -0.802 | 0.423 | -0.003 | 0.001 |
coeftest(plm, vcov. = vcovHC, type = "HC1")
##
## t test of coefficients:
##
## Estimate Std. Error t value Pr(>|t|)
## top 0.04080519 0.01040288 3.9225 9.22e-05 ***
## sex -0.00553474 0.01343974 -0.4118 0.68054
## incumbent 0.37545948 0.01238707 30.3106 < 2.2e-16 ***
## birth 0.00060766 0.00030180 2.0135 0.04427 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1