library("demography")
#> Loading required package: forecast
#> This is demography 1.20
library("StMoMo")
#> Loading required package: gnm
canada <- hmd.mx("CAN", "username", "password", "Canada")
#> Error in hmd.mx("CAN", "username", "password", "Canada"): Connection error at www.mortality.org. Please check username, password and country label.
constLC <- function(ax, bx, kt, b0x, gc, wxt, ages){
+ + c1 <- mean(kt[1, ], na.rm = TRUE)
+ + c2 <- sum(bx[, 1], na.rm = TRUE)
+ + list(ax = ax + c1 * bx, bx = bx / c2, kt = c2 * (kt - c1))
}
LC <- StMoMo(link = "logit", staticAgeFun = TRUE, periodAgeFun = "NP",
constFun = constLC)
CANStMoMo <- StMoMoData(canada, series = "total")
#> Error in StMoMoData(canada, series = "total"): object 'canada' not found
summary(CANStMoMo)
#> Error in summary(CANStMoMo): object 'CANStMoMo' not found
CANStMoMoinitial <- central2initial(CANStMoMo)
#> Error in central2initial(CANStMoMo): object 'CANStMoMo' not found
wxt <- genWeightMat(ages = ages.fit, years = CANStMoMoinitial$years,
clip = 3)
#> Error in genWeightMat(ages = ages.fit, years = CANStMoMoinitial$years, : object 'ages.fit' not found
LCfit <- fit(LC, data = CANStMoMoinitial, ages.fit = ages.fit, wxt = wxt)
#> Error in fit.StMoMo(LC, data = CANStMoMoinitial, ages.fit = ages.fit, : object 'CANStMoMoinitial' not found
Created on 2018-11-14 by the reprex package (v0.2.1)