robjhyndman / demography

demography package for R
https://pkg.robjhyndman.com/demography
73 stars 25 forks source link

Can I apply lca to abridged mortality rate? #12

Closed kcsamir closed 9 years ago

kcsamir commented 9 years ago

Can I apply lca to abridged mortality rate? Age: 0, 1, 5, ...100 Years: 5 year steps. I tried it with 10 period data and following is what I get when I run the following codes

data <- read.demogdata(file="rate.txt", popfile="popfile.txt", type="mortality", label="NepalMale" , max.mx = 10, skip = 0, popskip = 0, lambda=0, scale=1000)

nepalmale <- lca(data=data, series=names(data$rate)[1], years=data$year, ages=data$age, max.age=100, adjust = c("dt", "dxt", "e0", "none")[1], chooseperiod=FALSE, minperiod=9, breakmethod=c("bai","bms"), scale = FALSE, restype = c("logrates", "rates", "deaths")[2], interpolate = FALSE)

Error in matrix(mx, nrow = n, ncol = m) : invalid 'ncol' value (too large or NA)

robjhyndman commented 9 years ago

Can you please provide a reproducible example of the error.

kcsamir commented 9 years ago

Please find two files that I prepared using projections from UN Medium Variant life table and the corresponding population for 10 five yearly period. I am trying to extend the life table upto 2150. Also please find the R file.

On Wed, Sep 10, 2014 at 6:58 AM, Rob J Hyndman notifications@github.com wrote:

Can you please provide a reproducible example of the error.

— Reply to this email directly or view it on GitHub https://github.com/robjhyndman/demography/issues/12#issuecomment-55049334 .

Samir K.C., Ph.D. Project Leader, Modelling Human Capital World Population Program International Institute for Applied Systems Analysis

robjhyndman commented 9 years ago

I don't think the files were attached. Perhaps forward them by email to Rob.Hyndman@monash.edu.

robjhyndman commented 9 years ago

Now fixed in https://github.com/robjhyndman/demography/commit/9f149224e083e217201a272f561d1dd2d67dc11d

kcsamir commented 9 years ago

Hi, I am not used to following github, does this mean I have to re-install the package again from CRAN, can you please advise?

robjhyndman commented 9 years ago

I will update the CRAN version sometime in the next couple of weeks. In the meantime, you can install the github version as follows:

install.packages("devtools")
library(devtools)
install_github("demography", "robjhyndman") 
kcsamir commented 9 years ago

Thanks a lot, really helpful. Cheers, Samir

On Fri, Sep 12, 2014 at 6:28 AM, Rob J Hyndman notifications@github.com wrote:

I will update the CRAN version sometime in the next couple of weeks. In the meantime, you can install the github version as follows:

install.packages("devtools") library(devtools) install_github("demography", "robjhyndman")

— Reply to this email directly or view it on GitHub https://github.com/robjhyndman/demography/issues/12#issuecomment-55338268 .

Samir K.C., Ph.D. Project Leader, Modelling Human Capital World Population Program International Institute for Applied Systems Analysis

kcsamir commented 9 years ago

HI, thanks for the update. I applied it and it ran smoothly. I applied lca.forecast and found that there is some inconsistency in Time. My example has the data for five yearly period 2053,...,2098, however, 2053, 2054,....2062 is taken as input. The results, however, are for the time starting 2098, 2099,..... Please help. Samir

On Fri, Sep 12, 2014 at 6:28 AM, Rob J Hyndman notifications@github.com wrote:

I will update the CRAN version sometime in the next couple of weeks. In the meantime, you can install the github version as follows:

install.packages("devtools") library(devtools) install_github("demography", "robjhyndman")

— Reply to this email directly or view it on GitHub https://github.com/robjhyndman/demography/issues/12#issuecomment-55338268 .

Samir K.C., Ph.D. Project Leader, Modelling Human Capital World Population Program International Institute for Applied Systems Analysis

robjhyndman commented 9 years ago

Try again now. I made some more changes in https://github.com/robjhyndman/demography/commit/4ed8c2c2ca6489b1c4f8a44a3b8ec133c2e53b05.