Commit ae7a2dc2 authored by Reinhold Kainhofer's avatar Reinhold Kainhofer

MCMC-Zerlegung (von Jonas Hirz) eingebaut

parent 3c64a96b
This diff is collapsed.
This diff is collapsed.
stopifnot(require(methods), require(utils), require(MortalityTables), require(tidyverse), require(reshape2)) # MortalityTable classes; new; Excel reader
###############################################################################
### Gesamtbevölkerung Österreich: Bevölkerungsprognose bis 2080 (mittleres Szenario)
### Datenquelle: Statistik Austria
###############################################################################
mort.AT.MCMC.load = function() {
data = utils::read.csv(system.file("extdata", "Austria_Population_MCMC2018.csv", package = "MortalityTables"), skip = 5, encoding = "UTF-8", check.names = FALSE);
data.array = data %>% as_tibble %>%
gather(Variable, Value, -Parameter, -Alter) %>%
separate(Variable, into = c("Geschlecht", "Jahr"), sep = ", ") %>%
filter(Jahr == "1980") %>%
mutate(Jahr = NULL) %>%
acast(Alter ~ Geschlecht ~ Parameter, value.var = "Value")
exp(data.array[,,"alpha"])
mort.AT.MCMC = array(
data = c(mortalityTable.NA),
dim = c(3),
dimnames = list(Geschlecht = c("m", "w", "u"))
)
# TODO: Eta einbauen
mort.AT.MCMC[["m"]] = mortalityTable.trendProjection(
name = "Österreich MCMC Männer",
baseYear = 2008,
deathProbs = exp(data.array[,"Mann","alpha"]),
trend = data.array[,"Mann","beta"],
ages = as.integer(dimnames(data.array)[[1]]),
data = list(
dim = list(sex = "m", collar = "Gesamtbevölkerung", type = "MCMC-Fit 1980-2017", data = "MCMC", year = "1980-2017", Tafel = "MCMC-Zerlegung Bevölkerungssterblichkeit")
)
)
mort.AT.MCMC[["w"]] = mortalityTable.trendProjection(
name = "Österreich MCMC Frauen",
baseYear = 2008,
deathProbs = exp(data.array[,"Frau","alpha"]),
trend = data.array[,"Frau","beta"],
ages = as.integer(dimnames(data.array)[[1]]),
data = list(
dim = list(sex = "m", collar = "Gesamtbevölkerung", type = "MCMC-Fit 1980-2017", data = "MCMC", year = "1980-2017", Tafel = "MCMC-Zerlegung Bevölkerungssterblichkeit")
)
)
mort.AT.MCMC[["w"]] = mort.AT.forecast.male
mort.AT.MCMC[["u"]] = mort.AT.forecast.female
# mort.AT.forecast.male = mortalityTable.trendProjection(
# name = "Österreich Männer (mittl. Sz.)",
# baseYear = 2014,
# deathProbs = AT.pop.fc$q.M.2014,
# trend = -AT.pop.fc$M,
# ages = AT.pop.fc$X,
# data = list(
# dim = list(sex = "m", collar = "Gesamtbevölkerung", type = "Bevölkerungsprognose", data = "official", year = "2014-2080")
# )
# )
# mort.AT.forecast.female = mortalityTable.trendProjection(
# name = "Österreich Frauen (mittl. Sz.)",
# baseYear = 2014,
# deathProbs = AT.pop.fc$q.F.2014,
# trend = -AT.pop.fc$F,
# ages = AT.pop.fc$X,
# data = list(
# dim = list(sex = "w", collar = "Gesamtbevölkerung", type = "Bevölkerungsprognose", data = "official", year = "2014-2080")
# )
# )
#
mort.AT.forecast = array(
data = c(mortalityTable.NA),
dim = c(3),
dimnames = list(Geschlecht = c("m", "w", "u"))
)
mort.AT.forecast[["m"]] = mort.AT.forecast.male
mort.AT.forecast[["w"]] = mort.AT.forecast.male
mort.AT.forecast[["u"]] = mort.AT.forecast.female
mort.AT.forecast
}
mort.AT.MCMC = mort.AT.MCMC.load()
rm(mort.AT.MCMC.load)
###############################################################################
# mortalityTables.load("Austria*")
# plot(mort.AT.forecast.male, mort.AT.forecast.female, AVOe1996R.male, AVOe2005R.male, AVOe1996R.female, AVOe2005R.female, YOB = 2000)
# plotMortalityTrend(mort.AT.forecast.male, mort.AT.forecast.female, AVOe1996R.male, AVOe2005R.male, AVOe1996R.female, AVOe2005R.female, Period = 2002)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment