| | library("lmtest") |
| | library("sandwich") |
| | set.seed(2020) |
| |
|
| | |
| |
|
| | main <- function(mode = "test", drop_wave_7 = T){ |
| | data <- read.csv("output/data.csv") |
| | |
| | if (drop_wave_7) data <- data[!(data$wave == 7), ] |
| | drop <- ifelse(drop_wave_7, "drop_7", "keep_7") |
| | |
| | if (mode == "test"){ |
| | |
| | for (i in 3:ncol(data)){ |
| | data[, i] <- sample(data[, i]) |
| | } |
| | } |
| | |
| | |
| | |
| | |
| | model <- lm(gov_consumption ~ sd_gov + mean_gov + |
| | africa + laam + asiae + |
| | col_uka + col_espa + col_otha + |
| | federal + oecd + |
| | log_gdp_per_capita + trade_share + age_15_64 + age_65_plus, |
| | data = data) |
| | out <- coeftest(model, vcov = vcovHC(model, type = "HC1")) |
| | |
| | |
| | |
| | out <- rbind(out, c(length(model$residuals), "", "", "")) |
| | out <- rbind(out, c(summary(model)$r.squared, "", "", "")) |
| | rownames(out) <- c(rownames(out)[-c((nrow(out)-1):nrow(out))], "Obs.", "R-squared") |
| | write.table(out, file = sprintf("output/%s_%s.txt", mode, drop)) |
| | } |
| |
|
| | |
| | main(mode = "test", drop_wave_7 = T) |
| | main(mode = "test", drop_wave_7 = F) |
| |
|
| | |
| | main(mode = "real", drop_wave_7 = T) |
| |
|
| | |
| | main(mode = "real", drop_wave_7 = F) |