Skip to content

Commit

Permalink
allow to start predictions from a future year
Browse files Browse the repository at this point in the history
  • Loading branch information
hanase committed Nov 3, 2023
1 parent 24a1127 commit ddace4c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: bayesPop
Type: Package
Title: Probabilistic Population Projection
Version: 10.0-1.9005
Date: 2023-11-01
Version: 10.0-1.9006
Date: 2023-11-03
Author: Hana Sevcikova, Adrian Raftery, Thomas Buettner
Maintainer: Hana Sevcikova <[email protected]>
Depends: R (>= 3.5.0), bayesTFR (>= 7.1-0), bayesLife (>= 5.0-0), MortCast (>= 2.6-1)
Expand Down
11 changes: 8 additions & 3 deletions R/predict.pop.R
Original file line number Diff line number Diff line change
Expand Up @@ -506,9 +506,14 @@ load.inputs <- function(inputs, start.year, present.year, end.year, wpp.year, fi
# Get initial population counts
for(sex in c('M', 'F')) {
dataset.name <- paste0('pop', sex)
if(is.null(inputs[[dataset.name]]))
POP0 <- bayesTFR:::load.from.wpp(dataset.name, wpp.year = wpp.year, annual = annual)
else POP0 <- read.pop.file(inputs[[dataset.name]])
if(is.null(inputs[[dataset.name]])) {
POP0 <- bayesTFR:::load.from.wpp(dataset.name, wpp.year = wpp.year, annual = annual)
if(! present.year %in% colnames(POP0)) {
# if present year is not found in observed years, load WPP projections
POP0proj <- bayesTFR:::load.from.wpp(paste0(dataset.name, "projMed"), wpp.year = wpp.year, annual = annual)
POP0 <- merge(POP0, POP0proj, by = c("country_code", "name", "age"), sort = FALSE)
}
} else POP0 <- read.pop.file(inputs[[dataset.name]])
num.columns <- grep('^[0-9]{4}$', colnames(POP0), value=TRUE) # values of year-columns
if(!is.element(as.character(present.year), colnames(POP0))) {
stop('Wrong present.year. ', present.year, ' not available in the ', dataset.name, ' file.\nAvailable years: ',
Expand Down

0 comments on commit ddace4c

Please sign in to comment.