-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.Rhistory
138 lines (138 loc) · 4.96 KB
/
.Rhistory
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
library(tidyverse)
library(wbstats)
?WDI
library(WDI)
df_edu <- WDI(indicator = "EG.USE.ELEC.KH.PC", country = c('HN','GT','SV','NI','CR'), start = 1971, end=2012)
View(df_edu)
df_elec <- WDI(indicator = "EG.USE.ELEC.KH.PC", country = c('HN','GT','SV','NI','CR'), start = 1980, end=2014)
# Primary School Completion Rate
df_edu <- WDI(indicator = "SE.PRM.CMPT.ZS", country = c('HN','GT','SV','NI','CR'), start = 1980, end=2014)
library(plm)
df_all <- full_join(df_elec, df_edu, by = "iso2c")
# Primary School Completion Rate
df_edu <- WDI(indicator = "SE.PRM.CMPT.ZS", country = c('HN','GT','SV','NI','CR'), start = 1980, end=2014) %>% select(-iso2c)
# Electric Power Consumption (kWh per capita)
df_elec <- WDI(indicator = "EG.USE.ELEC.KH.PC", country = c('HN','GT','SV','NI','CR'), start = 1980, end=2014) %>% select(-iso2c)
df_all <- full_join(df_elec, df_edu, by = "country)
# Electric Power Consumption (kWh per capita)
df_elec <- WDI(indicator = "EG.USE.ELEC.KH.PC", country = c('HN','GT','SV','NI','CR'), start = 1980, end=2014) %>% select(-iso2c)
# Primary School Completion Rate
df_edu <- WDI(indicator = "SE.PRM.CMPT.ZS", country = c('HN','GT','SV','NI','CR'), start = 1980, end=2014) %>% select(-iso2c)
df_all <- full_join(df_elec, df_edu, by = "country")
df_elec <- WDI(indicator = "EG.USE.ELEC.KH.PC", country = c('HN','GT','SV','NI','CR'), start = 1980, end=2014) %>% select(-iso2c)
# Primary School Completion Rate
df_edu <- WDI(indicator = "SE.PRM.CMPT.ZS", country = c('HN','GT','SV','NI','CR'), start = 1980, end=2014) %>% select(-iso2c)
df_all <- full_join(df_elec, df_edu, by = c("country", "year"))
names(df_elec)
# Electric Power Consumption (kWh per capita)
df_elec <- WDI(
indicator = "EG.USE.ELEC.KH.PC",
country = c('HN','GT','SV','NI','CR'),
start = 1980, end=2014) %>%
select(-iso2c) %>%
rename(kwh_per_cap = EG.USE.ELEC.KH.PC)
names(df_edu)
df_elec <- WDI(
indicator = "EG.USE.ELEC.KH.PC",
country = c('HN','GT','SV','NI','CR'),
start = 1980, end=2014) %>%
select(-iso2c) %>%
rename(kwh_per_cap = EG.USE.ELEC.KH.PC)
# Primary School Completion Rate
df_edu <- WDI(
indicator = "SE.PRM.CMPT.ZS",
country = c('HN','GT','SV','NI','CR'),
start = 1980, end=2014) %>%
select(-iso2c) %>%
rename(edu_comp = SE.PRM.CMPT.ZS)
df_all <- full_join(df_elec, df_edu, by = c("country", "year"))
df_all %>%
ggplot(aes(x = kwh_per_cap, y = edu_comp)) +
geom_point()
df_all %>%
ggplot(aes(x = kwh_per_cap, y = edu_comp)) +
geom_point() +
stat_smooth(method = "lm", se = FALSE) +
labs(
x = "Electric Power Consumption (kWh per capita)",
y = "Primary School Completion Rate",
)
df_all %>%
ggplot(aes(x = kwh_per_cap, y = edu_comp)) +
geom_point() +
stat_smooth(method = "lm", se = FALSE) +
labs(
x = "Electric Power Consumption (kWh per capita)",
y = "Primary School Completion Rate"
)
df_all %>%
ggplot(aes(x = kwh_per_cap, y = edu_comp, fill = country)) +
geom_point() +
facit_wrap(country) +
stat_smooth(method = "lm", se = FALSE) +
labs(
x = "Electric Power Consumption (kWh per capita)",
y = "Primary School Completion Rate"
)
df_all %>%
ggplot(aes(x = kwh_per_cap, y = edu_comp, fill = country)) +
geom_point() +
facet_wrap(country) +
stat_smooth(method = "lm", se = FALSE) +
labs(
x = "Electric Power Consumption (kWh per capita)",
y = "Primary School Completion Rate"
)
df_all %>%
ggplot(aes(x = kwh_per_cap, y = edu_comp, fill = country)) +
geom_point() +
facet_wrap(vars(country)) +
stat_smooth(method = "lm", se = FALSE) +
labs(
x = "Electric Power Consumption (kWh per capita)",
y = "Primary School Completion Rate"
)
df_all %>%
ggplot(aes(x = kwh_per_cap, y = edu_comp, col = country)) +
geom_point() +
facet_wrap(vars(country)) +
stat_smooth(method = "lm", se = FALSE) +
labs(
x = "Electric Power Consumption (kWh per capita)",
y = "Primary School Completion Rate",
col = ""
)
df_all %>%
ggplot(aes(x = kwh_per_cap, y = edu_comp, col = country)) +
geom_point() +
facet_wrap(vars(country)) +
stat_smooth(method = "lm", se = FALSE) +
labs(
x = "Electric Power Consumption (kWh per capita)",
y = "Primary School Completion Rate",
col = ""
) +
theme(legend.position = "none")
?pdata.frame()
p_all <- pdata.frame(df_all, index = c("country", "year"))
View(p_all)
model_all <- plm(edu_comp ~ kwh_per_cap, data = p_all, model = "within")
summary(model_all)
stargazer(model_all, title = "Results of 150-Country Sample", type = "latex")
library(stargazer)
stargazer(model_all, title = "Results of 150-Country Sample", type = "latex")
stargazer(model_all, title = "Results of 150-Country Sample", type = "text")
stargazer(attitude)
stargazer(model_all, title = "Results of 150-Country Sample", type = "text")
stargazer(model_all,
title = "Electricity and Education in Central America",
type = "html",
covariate.labels = "Electric Power Consumption (kWh per capita)",
dep.var.labels = "Primary School Completion Rate"
out="edu_elec.html")
stargazer(model_all,
title = "Electricity and Education in Central America",
type = "html",
covariate.labels = "Electric Power Consumption (kWh per capita)",
dep.var.labels = "Primary School Completion Rate",
out="edu_elec.html")