# Script 1: Country/Version-Specific Setup File ## Version: "Imaginary Country" Start Year 2000 > This setup file generates all country-specific objects used by the set of R data analysis scripts estimating and generating model parameters and writing all parameter files of DYNAMIS-POP. The output of this script is an image file "globals_for_analysis.RData" which is read by each of the module-specific analysis scripts. This is the only R script which has to be adapted when porting the model to another country context. The script produces a set of global objects including: - Four data frame objects corresponding with the four micro-data files required. - File names and locations for all parameter files and the starting population - Some global variables like the year of the starting population and time-sensitive cut-off points for data analysis - Information on a shape file for geographical map output - Some target values for default scenarios - Some country-specific labels (like names of regions) for analysis graphs - The file location of demographic macro-scenario csv files (e.g. DemProj projections) ## Code: ```{r, message=TRUE, warning=FALSE} #################################################################################################### # # DYNAMIS-POP Parameter Generation File 1 - Generate all country-specific R objects # This file has to be run before performing all other parameter generation steps # Last Update: Martin Spielauer 2019-11-28 # #################################################################################################### #################################################################################################### # Clear work space and load required packages #################################################################################################### rm(list=ls()) library(haven) library(data.table) g_reweight <- 100 #################################################################################################### # NEW #################################################################################################### g_newstartpop_file <- "../Data/ABC_2000/Parameters/NewStartingPopulation_ABC_2000.csv" #################################################################################################### # Data Table of Residents: g_residents_dat #################################################################################################### g_residents_dat <- read.csv("../Data/ABC_2000/AnalysisData/Residents_ABC_2000.csv") g_residents_dat$M_AGEMAR[g_residents_dat$M_AGEMAR==999] <- NA g_residents_dat$M_AGEBIR[g_residents_dat$M_AGEBIR==999] <- NA #################################################################################################### # Data Table of Emigrants: g_emigrants_dat #################################################################################################### g_emigrants_dat <- read.csv("../Data/ABC_2000/AnalysisData/Emigrants_ABC_2000.csv") #################################################################################################### # Data Table of Births: g_births_dat #################################################################################################### g_births_dat <- read.csv("../Data/ABC_2000/AnalysisData/Births_ABC_2000.csv") g_births_dat$M_B01[g_births_dat$M_B01==9999] <- NA g_births_dat$M_B02[g_births_dat$M_B02==9999] <- NA g_births_dat$M_B03[g_births_dat$M_B03==9999] <- NA g_births_dat$M_B04[g_births_dat$M_B04==9999] <- NA g_births_dat$M_B05[g_births_dat$M_B05==9999] <- NA g_births_dat$M_B06[g_births_dat$M_B06==9999] <- NA g_births_dat$M_B07[g_births_dat$M_B07==9999] <- NA g_births_dat$M_B08[g_births_dat$M_B08==9999] <- NA g_births_dat$M_B09[g_births_dat$M_B09==9999] <- NA g_births_dat$M_B10[g_births_dat$M_B10==9999] <- NA g_births_dat$M_B11[g_births_dat$M_B11==9999] <- NA g_births_dat$M_B12[g_births_dat$M_B12==9999] <- NA g_births_dat$M_B13[g_births_dat$M_B13==9999] <- NA g_births_dat$M_B14[g_births_dat$M_B14==9999] <- NA g_births_dat$M_MAR[g_births_dat$M_MAR==9999] <- NA #################################################################################################### # Data Table of Children: g_children_dat #################################################################################################### g_children_dat <-read.csv("../Data/ABC_2000/AnalysisData/Children_ABC_2000.csv") g_children_dat$M_DEATH[g_children_dat$M_DEATH==9999] <- NA #################################################################################################### # Country Shape file for geographical maps on district level # Available country shape files frequently put districts in aphabetical order which typically does # not coincide with coding in the micro data: g_shape_display_order can be used to define the order #################################################################################################### g_shapes <- "../Data/ABC_2000/Shapes/shape_abc.shp" g_shape_display_order <- c(0,1,2,3,4,5,6,7,8,9,10,11) #################################################################################################### # Census Year: g_census_year. This is the year of the starting population #################################################################################################### g_census_year <- 2000 #################################################################################################### # Settings for starting population analysis an parameters #################################################################################################### g_startpop_file <- "../Data/ABC_2000/Parameters/StartingPopulation_ABC_2000.csv" g_startpop_name <- "StartingPopulation_ABC_2000.csv" g_para_startpop <- "../Data/ABC_2000/Parameters/StartingPopulation_ABC_2000.dat" #################################################################################################### # Settings for primary education analysis and parameters #################################################################################################### g_para_primaryeduc <- "../Data/ABC_2000/Parameters/PrimaryEducation_ABC_2000.dat" g_para_primaryeducrefined <- "../Data/ABC_2000/Parameters/PrimaryEducationRefined_ABC_2000.dat" g_para_primaryeductrack <- "../Data/ABC_2000/Parameters/PrimaryEducationGrades_ABC_2000.dat" g_school_season_end <- 0.5 g_school_season_start <- 0.66666 g_school_entry <- 6 #################################################################################################### # Settings for analysis microdata output #################################################################################################### g_para_analysisoutput <- "../Data/ABC_2000/Parameters/AnalysisDataOutput_ABC_2000.dat" #################################################################################################### # Settings for migration analysis and parameters #################################################################################################### g_para_migration <- "../Data/ABC_2000/Parameters/Migration_ABC_2000.dat" #################################################################################################### # Settings for child vaccinatin parameters #################################################################################################### g_children_dat$m_ethnov <- 0 g_children_dat$m_ethnov[g_children_dat$M_ETHNO == 0] <- 0 g_children_dat$m_ethnov[g_children_dat$M_ETHNO == 1] <- 4 g_children_dat$m_ethnov[g_children_dat$M_ETHNO == 2] <- 2 g_children_dat$m_ethnov[g_children_dat$M_ETHNO == 3] <- 0 g_children_dat$m_ethnov[g_children_dat$M_ETHNO == 4] <- 1 g_children_dat$m_ethnov[g_children_dat$M_ETHNO == 5] <- 3 g_children_dat$m_ethnov[g_children_dat$M_ETHNO == 6] <- 4 g_children_dat$m_ethnov[g_children_dat$M_ETHNO == 7] <- 5 g_children_dat$m_ethnov[g_children_dat$M_ETHNO == 8] <- 6 g_children_dat$m_ethnov[g_children_dat$M_ETHNO == 9] <- 6 g_para_childvacc <- "../Data/ABC_2000/Parameters/ChildVaccination_ABC_2000.dat" #################################################################################################### # Settings for immigration analysis and parameters #################################################################################################### g_para_immigration <- "../Data/ABC_2000/Parameters/Immigration_ABC_2000.dat" g_immigration_number_growth <- 1.01 #################################################################################################### # Settings for emigration analysis and parameters #################################################################################################### g_para_emigration <- "../Data/ABC_2000/Parameters/Emigration_ABC_2000.dat" #################################################################################################### # Settings for first marriage analysis and parameters #################################################################################################### g_para_marriage <- "../Data/ABC_2000/Parameters/Marriage_ABC_2000.dat" # First Marriage Scenario future target values Coal McNeil model target_c_low <- .95 target_c_med <- .90 target_c_hig <- .83 target_a0_low <- 15 target_a0_med <- 16.5 target_a0_hig <- 18 target_av_low <- 19 target_av_med <- 21 target_av_hig <- 25 #################################################################################################### # Settings for first birth analysis and parameters #################################################################################################### g_para_firstbirths <- "../Data/ABC_2000/Parameters/FirstBirths_ABC_2000.dat" #################################################################################################### # Settings for higher order births analysis and parameters #################################################################################################### g_para_higherbirths <- "../Data/ABC_2000/Parameters/HigherBirths_ABC_2000.dat" g_birth_timecuts <- c(1980,1990) #################################################################################################### # Settings for child mortality analysis and parameters #################################################################################################### g_para_childmort <- "../Data/ABC_2000/Parameters/ChildMortality_ABC_2000.dat" g_childmort_timecuts <- c(1970,1980,1990) #################################################################################################### # Settings for ethnicity analysis and parameters #################################################################################################### g_para_ethnicity <- "../Data/ABC_2000/Parameters/Ethnicity_ABC_2000.dat" #################################################################################################### # Settings for secondary education analysis and parameters #################################################################################################### g_para_secondary <- "../Data/ABC_2000/Parameters/Secondary_ABC_2000.dat" #################################################################################################### # Settings for school planning analysis and parameters #################################################################################################### g_para_schoolplanning <- "../Data/ABC_2000/Parameters/SchoolPlanning_ABC_2000.dat" #################################################################################################### # Settings for general settings parameters #################################################################################################### g_para_settings <- "../Data/ABC_2000/Parameters/GeneralSettings_ABC_2000.dat" #################################################################################################### # Settings for macro parameters of demographic modules # This includes file locations of 4 required csv files containing demographic projections #################################################################################################### g_para_basemortality <- "../Data/ABC_2000/Parameters/DemProj_ABC_2000.dat" <- "../Data/ABC_2000/Parameters/BaseMortality_ABC_2000.dat" g_para_basefertility <- "../Data/ABC_2000/Parameters/BaseFertility_ABC_2000.dat" # removed g_para_demproj <- "../Data/ABC_2000/Parameters/DemProj_ABC_2000.dat" g_sexratio <- 104 dp_expectancy_dat <- as.matrix(as.vector(t(read.csv("../Data/ABC_2000/DemographicProjections/lifeexpectancy_abc_2000.csv", header=FALSE)))) dp_mortality_dat <- as.matrix(as.vector(t(read.csv("../Data/ABC_2000/DemographicProjections/mortality_abc_2000.csv", header=FALSE)))) dp_tfr_dat <- as.matrix(read.csv("../Data/ABC_2000/DemographicProjections/tfr_abc_2000.csv", header=FALSE)) dp_fertility_dat <- as.matrix(as.vector(t(read.csv("../Data/ABC_2000/DemographicProjections/fertility_abc_2000.csv", header=FALSE)))) #################################################################################################### # 5 Selected regions and districts incl labels for analysis graphs # This are typically the 5 largest regions and districts including the Capital #################################################################################################### g_selreg1_label <- "Far-West" g_selreg2_label <- "West" g_selreg3_label <- "Central" g_selreg4_label <- "Capital" g_selreg5_label <- "East" g_selreg1_val <- 0 g_selreg2_val <- 1 g_selreg3_val <- 2 g_selreg4_val <- 3 g_selreg5_val <- 4 g_seldist1_label <- "Far-West-Highland" g_seldist2_label <- "West-Highland" g_seldist3_label <- "Central-Flatland" g_seldist4_label <- "Capital" g_seldist5_label <- "East-Lowland" g_seldist1_val <- 0 g_seldist2_val <- 3 g_seldist3_val <- 7 g_seldist4_val <- 10 g_seldist5_val <- 11 #################################################################################################### # Settings for HCI related parameters #################################################################################################### g_para_hci <- "../Data/ABC_2000/Parameters/HCI_ABC_2000.dat" g_para_stunting <- "../Data/ABC_2000/Parameters/Stunting_ABC_2000.dat" g_para_preschool <- "../Data/ABC_2000/Parameters/PreSchool_ABC_2000.dat" #################################################################################################### # Save global objects #################################################################################################### save.image(file="globals_for_analysis.RData") ```