Retrieve subnational (regional) prediction results produced by tfr.predict.subnat, either for one country or for all available countries.
get.regtfr.prediction(sim.dir, country =NULL)
Arguments
sim.dir: Simulation directory of the subnational predictions. It corresponds to the argument output.dir in tfr.predict.subnat.
country: Numerical country code. If it is not given, all available subnational predictions are retrieved.
Details
Predictions for country x are assumed to be stored in ‘sim.dir’/subnat/cx .
Returns
If argument country is given, the function returns an object of class bayesTFR.prediction. If it is NULL, it returns a list of such objects. Names of the list items are the country codes.
See Also
tfr.predict.subnat
Examples
# Subnational example datamy.subtfr.file <- file.path(find.package("bayesTFR"),'extdata','subnational_tfr_template.txt')subtfr <- read.delim(my.subtfr.file, check.names=FALSE, stringsAsFactor=FALSE)countries <- unique(subtfr[, c("country_code","country")])# Directory with national projections (contains 30 trajectories for each country)nat.dir <- file.path(find.package("bayesTFR"),"ex-data","bayesTFR.output")# Subnational projections for all three countries ()subnat.dir <- tempfile()tfr.predict.subnat(countries$country_code, my.tfr.file=my.subtfr.file, sim.dir=nat.dir, output.dir=subnat.dir, start.year=2013)# Retrieve results for all countriespreds <- get.regtfr.prediction(subnat.dir)names(preds)# View tables of subregions for each countryfor(i in1:nrow(countries)){ cat("\n\n", countries$country[i],"\n") print(get.countries.table(preds[[as.character(countries$country_code[i])]]))}# Quantiles for individual subregionstfr.trajectories.table(preds[["218"]],"Bolivar")# Retrieve results for one countrypred <- get.regtfr.prediction(subnat.dir,218)tfr.trajectories.plot(pred,"Loja")# cleanupunlink(subnat.dir)# See more examples in ?tfr.predict.subnat