timriffe / DemoTools

Tools for the evaluation, adjustment, and standardization of demographic data
https://timriffe.github.io/DemoTools
Other
59 stars 31 forks source link

`extrapFit` arg not passing correctly #256

Closed timriffe closed 2 years ago

timriffe commented 3 years ago

Here we have a lifetable starting from lx, where the closeout age is very low, 60. I've followed values back to where they get passed to MortalityLaws::MortalityLaw() and the vector extrapFit (which becomes x_fit before passing to MortalityLaw() arg fit.this.x and it maintains length 9. However, its length is detected as < 2 in MortalityLaws::check.MortalityLaw(). Possible that this vector is being held in a single element list such that length(fit.this.x) evaluates to 1? I saw nowhere else along the passing of extrapFit where the length would get cut down.

lx <-c(1.0000000 ,0.8352893 ,0.6128018 ,0.5733119 ,0.5723181 ,0.5568574 ,0.5477342 ,0.5244361 ,0.5120798, 0.4926618 ,0.4628227 ,0.4390118, 0.4100229, 0.3840418)

Age <- c(0,  1 , 5 ,10,15, 20 ,25 ,30, 35 ,40 ,45, 50 ,55, 60)

Sex <- "m"

devtools::load_all()

lt_abridged(lx = lx, 
            Age = Age, 
            radix = 1e+05, 
            axmethod = "un", 
            a0rule = "cd", 
            Sex = Sex, 
            region = "w", 
            mod = TRUE, 
            OAG = TRUE,
            extrapFit = seq(20,60,by=5))