Closed reshaa closed 10 years ago
This works: aus.sim <- pop.sim(mort.fcast, fert.fcast, firstyearpop=australia)
Make sure you are using the latest version of the package.
Rob J Hyndman Professor of Statistics, Monash University
On Thu, Dec 12, 2013 at 8:25 PM, reshaa notifications@github.com wrote:
I wish to use the code pop.sim without migration. When trying this with the australian data provided by the addb package, I am getting the following error:
mort.sm <- smooth.demogdata(set.upperage(extract.years(australia,1950:2002),100)) fert.sm <- smooth.demogdata(extract.years(aus.fertility,1950:2002)) mort.fit <- coherentfdm(mort.sm) fert.fit <- fdm(fert.sm) mort.fcast <- forecast(mort.fit) fert.fcast <- forecast(fert.fit)
aus.sim <- pop.sim(mort.fcast,fert.fcast,australia) Error in pop.sim(mort.fcast, fert.fcast, australia) : Inputs not fmforecast2 objects
I tried solving it by setting mig=NULL but then I am getting another error: aus.sim <- pop.sim(mort.fcast,fert.fcast,mig=NULL,australia) Error in pop.sim(mort.fcast, fert.fcast, mig = NULL, australia) : Please ensure that mortality, migration and population data have the same age dimension
Is there any other way to solve this? Thanks
— Reply to this email directly or view it on GitHubhttps://github.com/robjhyndman/demography/issues/8 .
Hello Sir, I have tried the code and it still doesn't work and says: Error in pop.sim(mort.fcast, fert.fcast, firstyearpop = australia) : Please ensure that mortality, migration and population data have the same age dimension
I have the latest R (V 3.0.2) and latest Demography package ( V1.15)
This problem was fixed in the commit three months ago. The new version is not on CRAN but you can install from here.
Rob J Hyndman
On Tue, Dec 17, 2013 at 1:31 AM, reshaa notifications@github.com wrote:
Hello Sir, I have tried the code and it still doesn't work and says: Error in pop.sim(mort.fcast, fert.fcast, firstyearpop = australia) : Please ensure that mortality, migration and population data have the same age dimension
I have the latest R (V 3.0.2) and latest Demography package ( V1.15)
— Reply to this email directly or view it on GitHubhttps://github.com/robjhyndman/demography/issues/8#issuecomment-30664305 .
Hello Sir Please can you give me the link for the new version of the package? I downloaded it here, but it's not installing on R.
Hi
If you'd like to install the development version on Github, you may need to install devtools
first.
Here's the link to show how to install R packages.
Dear Mr EaroWang, Thank you very much for your help . I have managed to install the package.
Dear Mr Hyndman, The package v1.6 has worked for the australian data. However it is not working for Mauritian data. I am getting 2 errors:
fert.sm <- smooth.demogdata(extract.years(fert,1975:2011),method="cspline", age.grid=17.5:47.5,weight=TRUE) Warning messages: 1: In simpleLoess(y, x, w, span, degree, parametric, drop.square, normalize, : span too small. fewer data values than degrees of freedom. 2: In simpleLoess(y, x, w, span, degree, parametric, drop.square, normalize, : pseudoinverse used at 22.5 3: In simpleLoess(y, x, w, span, degree, parametric, drop.square, normalize, : neighborhood radius 10 4: In simpleLoess(y, x, w, span, degree, parametric, drop.square, normalize, : reciprocal condition number 0 5: In simpleLoess(y, x, w, span, degree, parametric, drop.square, normalize, : There are other near singularities as well. 25 6: In predLoess(y, x, newx, s, weights, pars$robust, pars$span, pars$degree, : span too small. fewer data values than degrees of freedom. 7: In predLoess(y, x, newx, s, weights, pars$robust, pars$span, pars$degree, : pseudoinverse used at 17 8: In predLoess(y, x, newx, s, weights, pars$robust, pars$span, pars$degree, : neighborhood radius 15.5 9: In predLoess(y, x, newx, s, weights, pars$robust, pars$span, pars$degree, : reciprocal condition number 0 10: In predLoess(y, x, newx, s, weights, pars$robust, pars$span, pars$degree, : There are other near singularities as well. 210.25
mur.sim <- pop.sim(mort.fcast,fert.fcast, firstyearpop=mort) Error in pop.sim(mort.fcast, fert.fcast, firstyearpop = mort) : Please ensure that mortality and population data have the same age dimension
I am sending you my data by email. Please can you help me sort out these 2 issues? Thank you
This is not a help service and I am unable to provide help for users of the package.
I understand that it is not a help service, but i am trying hard and yet i cant figure out why the code is working for australian data and not for mauritian data, despite doing evrything the same way as i did for australia.
Dear Resha, the Australian data is for single ages whereas in the Mauritian data, the ages are grouped. When smoothing is done, the rates are 'transformed' into the same format as the single ages and when applying the Rcode 'pop.sim' and using 'firstyearpop=mort', you are using a population where the age dimension (age groups) does not match your mortality forecast (single ages). What you can do is to smooth your demogdata (named 'mort' in your case) and give it another name (say 'mort_smoothed').
I have actually tried this but an error crops up: Error in sample.int(length(x), size, replace, prob) : invalid first argument
I have tried to compare the Australian data (called australia) with the Mauritian data (called mort) and I found something very curious when I compared their 'order':
names(mort) [1] "type" "label" "lambda" "year" "age" "rate" "pop"
names(australia) [1] "year" "age" "rate" "pop" "type" "label" "lambda"
I don't know how to make the order the same.
I wish to use the code pop.sim without migration. When trying this with the australian data provided by the addb package, I am getting the following error:
mort.sm <- smooth.demogdata(set.upperage(extract.years(australia,1950:2002),100)) fert.sm <- smooth.demogdata(extract.years(aus.fertility,1950:2002)) mort.fit <- coherentfdm(mort.sm) fert.fit <- fdm(fert.sm) mort.fcast <- forecast(mort.fit) fert.fcast <- forecast(fert.fit)
aus.sim <- pop.sim(mort.fcast,fert.fcast,australia) Error in pop.sim(mort.fcast, fert.fcast, australia) : Inputs not fmforecast2 objects
I tried solving it by setting mig=NULL but then I am getting another error: aus.sim <- pop.sim(mort.fcast,fert.fcast,mig=NULL,australia) Error in pop.sim(mort.fcast, fert.fcast, mig = NULL, australia) : Please ensure that mortality, migration and population data have the same age dimension
Is there any other way to solve this? Thanks