From 10afd15fd2335ba22a0f2919b3e7fcdb01d8f6e3 Mon Sep 17 00:00:00 2001 From: Hana Sevcikova Date: Fri, 2 Feb 2024 12:12:01 -0800 Subject: [PATCH] fix in time index for imputation --- ChangeLog | 2 ++ DESCRIPTION | 4 ++-- R/project_subnat.R | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index fad5d79..1a4a291 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,8 @@ Default for par.names and par.names.cs in e0.raftery.diag changed to all paramet Fixed bug in e0.joint.plot for annual prediction object. +Fixed bug in setting time index when imputation is present in e0.predict.subnat(). + 5.2-0 (09/15/2023) ----- Annual subnational projections are now possible, via the argument "annual" diff --git a/DESCRIPTION b/DESCRIPTION index c8db227..56e87fb 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: bayesLife Type: Package Title: Bayesian Projection of Life Expectancy -Version: 5.2-0.9002 -Date: 2023-12-22 +Version: 5.2-0.9003 +Date: 2024-02-02 Author: Hana Sevcikova, Adrian Raftery, Jennifer Chunn Maintainer: Hana Sevcikova Description: Making probabilistic projections of life expectancy for all countries of the world, using a Bayesian hierarchical model . Subnational projections are also supported. diff --git a/R/project_subnat.R b/R/project_subnat.R index b7f310b..a6091c6 100644 --- a/R/project_subnat.R +++ b/R/project_subnat.R @@ -153,7 +153,7 @@ e0.predict.subnat <- function(countries, my.e0.file, sim.dir=file.path(getwd(), PIs_cqp <- array(NA, c(nr.reg, length(quantiles.to.keep), nrow(wtrajs)), dimnames=list(meta$regions$country_code, dimnames(wpred$quantiles)[[2]], dimnames(wtrajs)[[1]])) mean_sd <- array(NA, c(nr.reg, 2, nrow(wtrajs))) - #meta$Tc.index <- .get.Tcindex(meta$e0.matrix, cnames = meta$regions$country_name) + meta$Tc.index <- .get.Tcindex(meta$e0.matrix, cnames = meta$regions$country_name) country.char <- as.character(country.obj$code) e0reconstructed <- meta$e0.matrix @@ -171,7 +171,7 @@ e0.predict.subnat <- function(countries, my.e0.file, sim.dir=file.path(getwd(), widx <- which(rownames(wtrajs.all) %in% names(rege0[i])) c.first <- rep(do.call(paste0("compute.alpha.", method), list(rege0[i], wtrajs.all[widx,])), nr.traj) # set of initial scales - meta$Tc.index[region] <- i + meta$Tc.index[[region]] <- meta$Tc.index[[region]][meta$Tc.index[[region]] <= i] imptraj <- matrix(NA, nrow = length(rege0) - i, ncol = nr.traj) # trajectory matrix for imputation for(tr in 1:nr.traj) { # iterate over trajectories imp.time <- i:(length(rege0)-1)