Source: https://data.worldbank.org/indicator/PA.NUS.PPPC.RF
Price level ratio is the ratio of a purchasing power parity (PPP) conversion factor to an exchange rate. It provides a measure of the differences in price levels between countries by indicating the number of units of the common currency needed to buy the same volume of the aggregation level in each country.
Indicator source: International Comparison Program, World Bank
# library(priceR)
# country <- "United States"
# countries_dataframe <- show_countries()
# inflation_dataframe <- retrieve_inflation_data(country, countries_dataframe)
#
# # Provide a World Bank API URL and `url_all_results` will convert it into one with all results for that indicator
# original_url <- "http://api.worldbank.org/v2/country"
#
# url_all_results(original_url)
#
# my_df$budget_const <- adjust_for_inflation(my_df$budget,
# my_df$year,
# country,
# to_date = 2014,
# inflation_dataframe = inflation_dataframe,
# countries_dataframe = countries_dataframe)
iv <- c("log(pop)",
"log(gdp_pc)",
"polity2",
"log(us_trade + 1)",
"log(russia_trade + 1)",
# "as.factor(post_soviet)",
"us_same_vote_percent",
"china_same_vote_percent",
"log(us_troops + 1)*log(suicide_attacks + 1)")
dv <- "lead(log(budget_2010_adj))"
lm_formula <- as.formula(paste(dv, paste(iv, collapse = " + "), sep = " ~ "))
within_model <- plm(lm_formula, data = pdf,model = "within")
within_time_model <- plm(lm_formula, data = pdf, model = "within", effect = "time")
random_model <- plm(lm_formula, data = pdf, model = "random")
pooled_model <- plm(lm_formula, data = pdf, model = "pooling")
stargazer(within_model,
within_time_model,
random_model,
column.labels = c("IND FIXED", "TIME FIXED", "RANDOM"),
covariate.labels = c(
"population",
"GDP per capita",
"Polity",
"US trade (logged)",
"Russia trade (logged)",
"US UNGA votes",
"China UNGA votes",
"Troops",
"Suicide attacks",
"Troops x suicide attacks"),
type= "html", header = FALSE)
| Dependent variable: | |||
| lead(log(budget_2010_adj)) | |||
| IND FIXED | TIME FIXED | RANDOM | |
| (1) | (2) | (3) | |
| population | -7.437*** | 0.393*** | 0.307*** |
| (0.494) | (0.028) | (0.056) | |
| GDP per capita | -0.999*** | 0.014 | -0.127** |
| (0.234) | (0.033) | (0.063) | |
| Polity | 0.008 | 0.011*** | 0.007 |
| (0.013) | (0.004) | (0.008) | |
| US trade (logged) | 0.018 | 0.030 | 0.139*** |
| (0.052) | (0.019) | (0.036) | |
| Russia trade (logged) | 0.026 | 0.066*** | 0.027 |
| (0.020) | (0.010) | (0.017) | |
| US UNGA votes | 0.135 | 0.013 | 0.141 |
| (0.096) | (0.114) | (0.111) | |
| China UNGA votes | 0.104 | 0.021 | 0.124 |
| (0.084) | (0.094) | (0.096) | |
| Troops | -0.066** | 0.011 | 0.011 |
| (0.027) | (0.012) | (0.022) | |
| Suicide attacks | -0.284*** | -0.241*** | -0.271*** |
| (0.066) | (0.041) | (0.063) | |
| Troops x suicide attacks | 0.045*** | 0.072*** | 0.048*** |
| (0.012) | (0.007) | (0.011) | |
| Constant | 7.928*** | ||
| (0.945) | |||
| Observations | 906 | 906 | 906 |
| R2 | 0.319 | 0.631 | 0.262 |
| Adjusted R2 | 0.171 | 0.625 | 0.254 |
| F Statistic | 34.846*** (df = 10; 743) | 152.046*** (df = 10; 890) | 236.553*** |
| Note: | p<0.1; p<0.05; p<0.01 | ||
If the p-value is significantly small, use fixed model rather than pooled OLS
pFtest(within_model, pooled_model)
F test for individual effects
data: lm_formula F = 10.525, df1 = 152, df2 = 743, p-value < 2.2e-16 alternative hypothesis: significant effects
If the p-value is significantly small, use fixed model rather than random.
phtest(within_model, random_model)
Hausman Test
data: lm_formula chisq = 2592.2, df = 10, p-value < 2.2e-16 alternative hypothesis: one model is inconsistent
If the p-value is significantly small, use time-fixed effects rather than individual.
plmtest(within_time_model, c("time"), type=("bp"))
Lagrange Multiplier Test - time effects (Breusch-Pagan) for unbalanced
panels
data: lm_formula chisq = 4322.2, df = 1, p-value < 2.2e-16 alternative hypothesis: significant effects
stargazer(within_model,
coeftest(within_model,vcov = vcovHC(within_time_model,
type = "HC1",
cluster = "group")),
type = "html")
| Dependent variable: | ||
| lead(log(budget_2010_adj)) | ||
| panel | coefficient | |
| linear | test | |
| (1) | (2) | |
| log(pop) | -7.437*** | -7.437*** |
| (0.494) | (0.053) | |
| log(gdp_pc) | -0.999*** | -0.999*** |
| (0.234) | (0.062) | |
| polity2 | 0.008 | 0.008 |
| (0.013) | (0.007) | |
| log(us_trade + 1) | 0.018 | 0.018 |
| (0.052) | (0.036) | |
| log(russia_trade + 1) | 0.026 | 0.026 |
| (0.020) | (0.019) | |
| us_same_vote_percent | 0.135 | 0.135 |
| (0.096) | (0.161) | |
| china_same_vote_percent | 0.104 | 0.104 |
| (0.084) | (0.126) | |
| log(us_troops + 1) | -0.066** | -0.066*** |
| (0.027) | (0.021) | |
| log(suicide_attacks + 1) | -0.284*** | -0.284*** |
| (0.066) | (0.087) | |
| log(us_troops + 1):log(suicide_attacks + 1) | 0.045*** | 0.045*** |
| (0.012) | (0.011) | |
| Observations | 906 | |
| R2 | 0.319 | |
| Adjusted R2 | 0.171 | |
| F Statistic | 34.846*** (df = 10; 743) | |
| Note: | p<0.1; p<0.05; p<0.01 | |
fh_free <- pdf %>%
dplyr::filter(freedom_house == 1)
fh_partly_free <- pdf %>%
dplyr::filter(freedom_house == 2)
fh_not_free <- pdf %>%
dplyr::filter(freedom_house == 3)
free_within_time_model <- plm(lm_formula, data = fh_free, model = "within", effect = "time")
partly_free_within_time_model <- plm(lm_formula, data = fh_partly_free, model = "within", effect = "time")
not_free_within_time_model <- plm(lm_formula, data = fh_not_free, model = "within", effect = "time")
stargazer(free_within_time_model,
partly_free_within_time_model,
not_free_within_time_model,
column.labels = c("FREE", "PARTLY", "NOT FREE"),
covariate.labels = c(
"population",
"GDP per capita",
"Polity",
"US trade (logged)",
"Russia trade (logged)",
"US UNGA votes",
"China UNGA votes",
"Troops",
"Suicide attacks",
"Troops x suicide attacks"),
header = FALSE,
type= "html")
| Dependent variable: | |||
| lead(log(budget_2010_adj)) | |||
| FREE | PARTLY | NOT FREE | |
| (1) | (2) | (3) | |
| population | 0.479*** | 0.319*** | 0.299*** |
| (0.053) | (0.065) | (0.073) | |
| GDP per capita | 0.085 | 0.078 | -0.070 |
| (0.064) | (0.078) | (0.086) | |
| Polity | -0.009 | 0.015 | 0.009 |
| (0.032) | (0.013) | (0.014) | |
| US trade (logged) | 0.009 | -0.007 | 0.121** |
| (0.035) | (0.040) | (0.050) | |
| Russia trade (logged) | -0.014 | 0.121*** | 0.084*** |
| (0.017) | (0.022) | (0.022) | |
| US UNGA votes | 0.202 | -0.086 | 0.347 |
| (0.166) | (0.258) | (0.312) | |
| China UNGA votes | -0.068 | -0.245 | -0.056 |
| (0.173) | (0.219) | (0.194) | |
| Troops | 0.029 | -0.028 | 0.011 |
| (0.020) | (0.033) | (0.024) | |
| Suicide attacks | 0.064 | -0.330* | -0.304*** |
| (0.331) | (0.180) | (0.058) | |
| Troops x suicide attacks | -0.041 | 0.144*** | 0.074*** |
| (0.072) | (0.046) | (0.009) | |
| Observations | 347 | 300 | 247 |
| R2 | 0.654 | 0.482 | 0.645 |
| Adjusted R2 | 0.634 | 0.447 | 0.615 |
| F Statistic | 61.767*** (df = 10; 327) | 26.095*** (df = 10; 280) | 41.195*** (df = 10; 227) |
| Note: | p<0.1; p<0.05; p<0.01 | ||
similar_liberal_unga_voting <- pdf %>%
dplyr::filter(ideal_point_distance < 2)
dissimilar_liberal_unga_voting <- pdf %>%
dplyr::filter(ideal_point_distance > 2)
# pdf %>%
# filter(year == 2018) %>%
# select(country_name, ideal_point_distance) %>%
# arrange(desc(ideal_point_distance)) %>%
# print(n = 50)
similar_liberal_unga_voting <- plm(lm_formula, data = similar_liberal_unga_voting, model = "within", effect = "time")
dissimilar_liberal_unga_voting <- plm(lm_formula, data = dissimilar_liberal_unga_voting, model = "within", effect = "time")
stargazer(similar_liberal_unga_voting,
dissimilar_liberal_unga_voting,
column.labels = c("Similar", "Dissimilar"),
covariate.labels = c(
"population",
"GDP per capita",
"Polity",
"US trade (logged)",
"Russia trade (logged)",
"US UNGA votes",
"China UNGA votes",
"Troops",
"Suicide attacks",
"Troops x suicide attacks"),
style = "qje",
type = "text")
=========================================================================== lead(log(budget_2010_adj))
Similar Dissimilar
(1) (2)
————————————————————————— population 0.395*** 0.486***
(0.065) (0.035)
GDP per capita -0.086 0.150***
(0.082) (0.044)
Polity -0.177*** 0.033***
(0.033) (0.005)
US trade (logged) -0.022 -0.007
(0.045) (0.025)
Russia trade (logged) -0.036* 0.052***
(0.021) (0.013)
US UNGA votes 0.356** 0.002
(0.144) (0.161)
China UNGA votes -0.118 0.028
(0.173) (0.117)
Troops 0.058*** 0.007
(0.020) (0.016)
Suicide attacks 0.513 -0.314***
(0.368) (0.044)
Troops x suicide attacks -0.159*** 0.077***
(0.053) (0.008)
N 246 660
R2 0.664 0.640
Adjusted R2 0.636 0.629
F Statistic 44.729*** (df = 10; 226) 113.795*** (df = 10; 640) =========================================================================== Notes: Significant at the 1 percent level. Significant at the 5 percent level. Significant at the 10 percent level.
?stargazer
## starting httpd help server ... done
Compare Public Diplomacy budget to USAID spending
mil_aid_dv <- "lead(log(military_aid + 1))"
human_aid_dv <- "lead(log(humanitarian_aid + 1))"
mil_lm_formula <- as.formula(paste(mil_aid_dv, paste(iv, collapse = " + "), sep = " ~ "))
human_lm_formula <- as.formula(paste(human_aid_dv, paste(iv, collapse = " + "), sep = " ~ "))
mil_within_time_model <- plm(mil_lm_formula, data = pdf, model = "within", effect = "time")
human_within_time_model <- plm(human_lm_formula, data = pdf, model = "within", effect = "time")
stargazer(within_time_model,
mil_within_time_model,
human_within_time_model,
column.labels = c("PD SPENDING", "MILITARY AID", "HUMANITARIAN AID"),
covariate.labels = c(
"population",
"GDP per capita",
"Polity",
"US trade (logged)",
"Russia trade (logged)",
"US UNGA votes",
"China UNGA votes",
"Troops",
"Suicide attacks",
"Troops x suicide attacks"),
header = FALSE,
type= "html")
| Dependent variable: | |||
| lead(log(budget_2010_adj)) | lead(log(military_aid + 1)) | lead(log(humanitarian_aid + 1)) | |
| PD SPENDING | MILITARY AID | HUMANITARIAN AID | |
| (1) | (2) | (3) | |
| population | 0.393*** | -1.121*** | 0.240 |
| (0.028) | (0.152) | (0.197) | |
| GDP per capita | 0.014 | -2.995*** | -4.160*** |
| (0.033) | (0.174) | (0.226) | |
| Polity | 0.011*** | 0.091*** | 0.048 |
| (0.004) | (0.023) | (0.030) | |
| US trade (logged) | 0.030 | 0.801*** | 0.880*** |
| (0.019) | (0.104) | (0.135) | |
| Russia trade (logged) | 0.066*** | 0.516*** | -0.049 |
| (0.010) | (0.051) | (0.066) | |
| US UNGA votes | 0.013 | -0.234 | -0.462 |
| (0.114) | (0.626) | (0.813) | |
| China UNGA votes | 0.021 | -0.261 | 1.225* |
| (0.094) | (0.525) | (0.683) | |
| Troops | 0.011 | 0.096 | 0.159* |
| (0.012) | (0.063) | (0.082) | |
| Suicide attacks | -0.241*** | 0.829*** | 1.990*** |
| (0.041) | (0.251) | (0.327) | |
| Troops x suicide attacks | 0.072*** | -0.001 | -0.153*** |
| (0.007) | (0.040) | (0.052) | |
| Observations | 906 | 1,225 | 1,225 |
| R2 | 0.631 | 0.308 | 0.529 |
| Adjusted R2 | 0.625 | 0.299 | 0.522 |
| F Statistic | 152.046*** (df = 10; 890) | 53.824*** (df = 10; 1207) | 135.336*** (df = 10; 1207) |
| Note: | p<0.1; p<0.05; p<0.01 | ||