У меня проблемы с подгонкой модели Реншоу и Хабермана к женским канадским данным.Когда я пытаюсь соответствовать модели, эта ошибка появляется.
Warning in fit.StMoMo(RH, data = CANfemaleinidata, ages.fit = ages.fit, : StMoMo: The model fitting didn't converge.
Полный контекст для этого показан в представ.
Представляет
RH <- rh(link = "logit", cohortAgeFun = "1")
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)
canada <- hmd.mx("CAN", "username", "password", "Canada")
#> Warning in hmd.mx("CAN", "username", "password", "Canada"):
#> NAs introduced by coercion
CANfemale <- StMoMoData(canada, series = "female")
CANfemaleinidata <- central2initial(CANfemale)
ages.fit <- 55:89
wxt <- genWeightMat(ages = ages.fit, years = CANfemaleinidata$years,
clip = 3)
LCfitfemale <- fit(LC, data = CANfemaleinidata, ages.fit = ages.fit, wxt = wxt)
#> StMoMo: The following cohorts have been zero weigthed: 1832 1833 1834 1954 1955 1956
#> StMoMo: Start fitting with gnm
#> Initialising
#> Running start-up iterations..
#> Running main iterations.....
#> Done
#> StMoMo: Finish fitting with gnm
RHfitfemale <- fit(RH, data = CANfemaleinidata, ages.fit = ages.fit, wxt = wxt,
start.ax = LCfitfemale$ax, start.bx = LCfitfemale$bx, start.kt = LCfitfemale$kt)
#> StMoMo: The following cohorts have been zero weigthed: 1832 1833 1834 1954 1955 1956
#> StMoMo: Start fitting with gnm
#> Initialising
#> Running main iterations....................................................
#> ...........................................................................
#> ...........................................................................
#> ...........................................................................
#> ...........................................................................
#> ...........................................................................
#> .........................................................................
#> Done
#> Warning in gnmFit(modelTools = modelTools, y = y, constrain = constrain, : Fitting algorithm has either not converged or converged
#> to a non-solution of the likelihood equations.
#> Use exitInfo() for numerical details of last iteration.
#> StMoMo: Finish fitting with gnm
#> Warning in fit.StMoMo(RH, data = CANfemaleinidata, ages.fit = ages.fit, : StMoMo: The model fitting didn't converge.
Что особенно странно в этой ошибке, так это то, что она не возникает, когда я использую данные канадских мужчин (см. Рисунок ниже)
CANmale <- StMoMoData(canada, series = "male")
CANmaleinidata <- central2initial(CANmale)
ages.fit <- 55:89
wxt <- genWeightMat(ages = ages.fit, years = CANmaleinidata$years,
clip = 3)
LCfitmale <- fit(LC, data = CANmaleinidata, ages.fit = ages.fit, wxt = wxt)
#> StMoMo: The following cohorts have been zero weigthed: 1832 1833 1834 1954 1955 1956
#> StMoMo: Start fitting with gnm
#> Initialising
#> Running start-up iterations..
#> Running main iterations......
#> Done
#> StMoMo: Finish fitting with gnm
RHfitmale <- fit(RH, data = CANmaleinidata, ages.fit = ages.fit, wxt = wxt,
start.ax = LCfitmale$ax, start.bx = LCfitmale$bx, start.kt = LCfitmale$kt)
#> StMoMo: The following cohorts have been zero weigthed: 1832 1833 1834 1954 1955 1956
#> StMoMo: Start fitting with gnm
#> Initialising
#> Running main iterations.........................
#> Done
#> StMoMo: Finish fitting with gnm
Как мне обойти эту проблему?