You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#renaming columns for wbi
non_oil_wbi = non_oil_wbi %>% rename(country = Country Name,countrycode = Country Code)
#filtering the countries
non_oil_wbi = non_oil_wbi %>% filter(country %in% non_oil_countries)
#getting unique countries names
unique(non_oil_wbi$country) %>% length()
#rearaanging the working age pop data from wbi
non_oil_wbi = gather(non_oil_wbi,-country, -countrycode,key = 'year',value = 'working_age_pop')
#changing the year data type to be numberic in non_oil_wbi
non_oil_wbi$year = as.numeric(non_oil_wbi$year)
#sort in ascending order
non_oil_wbi = non_oil_wbi %>% arrange(country)
#Working on PWT
non_oil_pwt <- read_excel("raw data for solow model for non.xlsx",sheet = 1)
#selecting non_oil countries from the pwt
non_oil_pwt = non_oil_pwt %>% filter(country %in% non_oil_countries)
#checking if the unique countries are 128
unique(non_oil_pwt$country) %>% length()
#selecting import variables in pwt
non_oil_pwt = non_oil_pwt %>% select(country,countrycode,year,hc,rgdpna,rnna,delta)
#selecting data from 1970 up for pwt and wbi
non_oil_pwt = non_oil_pwt %>% filter(between(year,1970,2015))
non_oil_wbi = non_oil_wbi %>% filter(between(year,1970,2015))
#joining the two dataset non_oil_pwt and non_oil_wbi
non_oil = left_join(non_oil_pwt,non_oil_wbi,by = c("country","countrycode","year"))
I am running solow model for 1960-2019, but i decide to do 1970-2015 if i can get thesame results with the existing one
below is my codes
library(tidyverse)
library(readxl)
non_oil_wbi <- read_excel("raw data for solow model for non.xlsx",sheet = 2)
View(non_oil_wbi)
#Total no of non oil countries = 128
#non_oil_countries
non_oil_countries <- c(
"Albania", "Argentina", "Armenia", "Australia", "Austria", "Bahrain", "Bangladesh", "Barbados", "Belgium", "Belize",
"Benin", "Bolivia", "Botswana", "Brazil", "Brunei Darussalam", "Bulgaria", "Burma", "Burundi", "Cambodia", "Cameroon",
"Canada", "Central African Republic", "Chile", "China", "China, Macao SAR", "Colombia", "Costa Rica", "Croatia", "Cyprus",
"Czech Republic", "Denmark", "Dominican Republic", "Ecuador", "Egypt", "El Salvador", "Estonia", "Fiji", "Finland",
"France", "Gambia", "Germany", "Ghana", "Greece", "Guatemala", "Haiti", "Honduras", "Hong Kong", "Hungary", "Iceland",
"India", "Indonesia", "Ireland", "Israel", "Italy", "Côte d'Ivoire", "Jamaica", "Japan", "Jordan", "Kazakhstan", "Kenya",
"Kyrgyzstan", "Lao", "Latvia", "Lesotho", "Liberia", "Lithuania", "Luxembourg", "Malawi", "Malaysia", "Maldives", "Mali",
"Malta", "Mauritania", "Mauritius", "Mexico", "Mongolia", "Morocco", "Mozambique", "Namibia", "Nepal", "Netherlands",
"New Zealand", "Nicaragua", "Niger", "Norway", "Pakistan", "Panama", "Paraguay", "Peru", "Philippines", "Poland",
"Portugal", "Qatar", "Republic of Korea", "Republic of Moldova", "Romania", "Russian Federation", "Rwanda", "Senegal",
"Serbia", "Sierra Leone", "Singapore", "Slovakia", "Slovenia", "South Africa", "Spain", "Sri Lanka", "Sudan", "Sweden",
"Switzerland", "Syrian Arab Republic", "Tajikistan", "Tanzania", "Thailand", "Togo", "Trinidad and Tobago", "Tunisia",
"Turkey", "Uganda", "Ukraine", "United Kingdom", "United States", "Uruguay", "Viet Nam", "Yemen", "Zaire", "Zambia",
"Zimbabwe"
)
#renaming columns for wbi
non_oil_wbi = non_oil_wbi %>% rename(country =
Country Name
,countrycode =Country Code
)#filtering the countries
non_oil_wbi = non_oil_wbi %>% filter(country %in% non_oil_countries)
#getting unique countries names
unique(non_oil_wbi$country) %>% length()
#rearaanging the working age pop data from wbi
non_oil_wbi = gather(non_oil_wbi,-country, -countrycode,key = 'year',value = 'working_age_pop')
#changing the year data type to be numberic in non_oil_wbi
non_oil_wbi$year = as.numeric(non_oil_wbi$year)
#sort in ascending order
non_oil_wbi = non_oil_wbi %>% arrange(country)
#Working on PWT
non_oil_pwt <- read_excel("raw data for solow model for non.xlsx",sheet = 1)
#selecting non_oil countries from the pwt
non_oil_pwt = non_oil_pwt %>% filter(country %in% non_oil_countries)
#checking if the unique countries are 128
unique(non_oil_pwt$country) %>% length()
#selecting import variables in pwt
non_oil_pwt = non_oil_pwt %>% select(country,countrycode,year,hc,rgdpna,rnna,delta)
#selecting data from 1970 up for pwt and wbi
non_oil_pwt = non_oil_pwt %>% filter(between(year,1970,2015))
non_oil_wbi = non_oil_wbi %>% filter(between(year,1970,2015))
#joining the two dataset non_oil_pwt and non_oil_wbi
non_oil = left_join(non_oil_pwt,non_oil_wbi,by = c("country","countrycode","year"))
view(non_oil)
write.csv(non_oil,"non_oil.csv")
non_oils = non_oil %>% arrange(country, year) %>%
group_by(country) %>% mutate(gdp_per_worker = (rgdpna/working_age_pop)*1000000,
saving_rate = (lead(rnna) - rnna * (1 - delta))/ rgdpna,
growth_rate = ((working_age_pop - lag(working_age_pop)) / lag(working_age_pop)) ,
#setting the first growth 0
growth_rate = ifelse(row_number()==1,0,growth_rate))
#calculating the average growth rate
n_g_d = non_oils %>% group_by(country) %>% summarize(n_g_d = mean(growth_rate)+0.05)
non_oils = left_join(non_oils,n_g_d,by = c("country"))
write.csv(non_oils,"non_oil.csv")
view(non_oils)
Calculate initial period GDP per worker (for conditional convergence)
non_oils = non_oils %>% group_by(country) %>% mutate(gdp_per_worker_0 = first(gdp_per_worker))
data_mrw = non_oils %>% mutate(log_gdp_per_worker = log(gdp_per_worker),
log_saving_rate = log(saving_rate),
log_n_g_d = log(n_g_d),
log_hc = log(hc),
log_gdp_per_worker_0 = log(gdp_per_worker_0))
View(data_mrw)
mrw_noil_countries = data_mrw %>% select(country,countrycode,year,log_gdp_per_worker,log_saving_rate,log_n_g_d,log_hc,log_gdp_per_worker_0)
view(mrw_noil_countries)
write_excel_csv(mrw_noil_countries,"mrw_non_oil_countries.csv")
Remove rows with NA, NaN, or Inf values in relevant columns
mrw_noil_countries_clean <- mrw_noil_countries %>%
filter(
!is.na(log_gdp_per_worker) & !is.nan(log_gdp_per_worker) & is.finite(log_gdp_per_worker),
!is.na(log_saving_rate) & !is.nan(log_saving_rate) & is.finite(log_saving_rate),
!is.na(log_n_g_d) & !is.nan(log_n_g_d) & is.finite(log_n_g_d)
)
#Solow model
mrw_model = lm(data = mrw_noil_countries_clean,formula = log_gdp_per_worker ~ log_saving_rate+ log_n_g_d)
summary(mrw_model)
#Restricted Regression
library(car)
mrw_model_restricted = lm(data = mrw_noil_countries_clean,formula = log_gdp_per_worker ~ I(log_saving_rate - log_n_g_d))
summary(mrw_model_restricted)
alpha_restricted = (coef(mrw_model_restricted)[2])/(1+coef(mrw_model_restricted)[2])
alpha_restricted
The text was updated successfully, but these errors were encountered: