Skip to content

Commit

Permalink
handle default migration
Browse files Browse the repository at this point in the history
  • Loading branch information
hanase committed Nov 16, 2024
1 parent 6850837 commit 3c26ce7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 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.9018
Date: 2024-10-18
Version: 10.0-1.9019
Date: 2024-11-16
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
14 changes: 12 additions & 2 deletions R/predict.pop.R
Original file line number Diff line number Diff line change
Expand Up @@ -1064,9 +1064,19 @@ migration.totals2age <- function(df, ages = NULL, annual = FALSE, time.periods =
if(migdsname %in% wppds$results[,'Item']) { # if available in the WPP package (only in wpp2012 and for projections in wpp2024)
miginp[[inpname]] <- bayesTFR:::load.from.wpp(migdsname, wpp.year, annual = annual)
if(length((missing.years <- setdiff(periods, colnames(miginp[[inpname]])))) > 0){ #for wpp2024 only projected years available, so attach the remaining years
miginp[[inpname]] <- data.frame(merge(migtempl[, c("country_code", "age", missing.years), with = FALSE],
missing.mig.data <- bayesTFR:::load.from.wpp("migration", wpp.year, annual = annual)[, c("country_code", as.character(missing.years))]
missing.migage.data <- data.frame(migration.totals2age(missing.mig.data,
ages = migtempl$age[age.index.all(annual, observed = TRUE)],
annual = annual, time.periods = missing.years,
scale = if(is.null(inputs[[fname]])) 0.5 else 1,
method = mig.age.method,
sex = sex, template = migtempl,
alt.schedule.file = inputs$mig.alt.age.schedule,
wpp.year = wpp.year),
check.names = FALSE)
miginp[[inpname]] <- data.frame(merge(missing.migage.data,
miginp[[inpname]][, setdiff(colnames(miginp[[inpname]]), "name")],
by = c("country_code", "age")), check.names = FALSE)
by = c("country_code", "age"), sort = FALSE), check.names = FALSE)
}
next
}
Expand Down

0 comments on commit 3c26ce7

Please sign in to comment.