Hi Antonio, I'm not sure of the issues with your analysis, but we're
working on a revision of yourcast that should make these easier.
Gary
--
*Gary King* - Albert J. Weatherhead III University Professor - Director,
IQSS <http://iq.harvard.edu/> - Harvard University
GaryKing.org - King(a)Harvard.edu - @KingGary <https://twitter.com/kinggary> -
617-500-7570 - Assistant <king-assist(a)iq.harvard.edu>: 617-495-9271
On Fri, Apr 28, 2017 at 9:41 PM, 林晓 <linxiao6(a)mail2.sysu.edu.cn> wrote:
> Dear Professor King,
> I was doing some literature reading and I came across your software. I try
> the package with my own data but I got some error.
> I modified my data and make it look like the example data in the file path
> of the package. yourprep runs smoothly with some data like below:
>
> dta$data$`204500`
> rspi2 popu2 time
> 2004 NA 4858042 1994
> 2005 NA 4785805 1995
> 2006 NA 4704201 1996
> 2007 0.006431800 4592693 1997
> 2008 0.005454000 4522168 1998
> 2009 0.005908178 4432729 1999
> 2010 0.005238223 4317368 2000
> 2011 0.005180368 4237330 2001
> 2012 0.004544100 4176305 2002
> 2013 0.004363600 4098927 2003
> 2014 0.003821751 4056178 2004
> 2015 0.003390900 3958900 2005
> 2016 NA NA 2006
> 2017 NA NA 2007
> 2018 NA NA 2008
> 2019 NA NA 2009
> 2020 NA NA 2010
> 2021 NA NA 2011
> 2022 NA NA 2012
> 2023 NA NA 2013
> 2024 NA NA 2014
> 2025 NA NA 2015
>
> But then I got error with yourcast() command.
>
> The scripts run below:
> > dta <- yourprep(dpath='./GARY_KING_CHINA_mortality',index.code="ggggaa",
> tag="csid",
> + year.var=TRUE, sample.frame=c(2004,2015,2016,2025),
> + G.names="cntry.codes.txt", adjacency="adjacency.txt",
> + verbose=TRUE,summary=FALSE)
> Loading cross section files and checking for errors...
> csid204500.txt
> csid204501.txt
> csid204505.txt
> csid204510.txt
> csid204515.txt
> csid204520.txt
> csid204525.txt
> csid204530.txt
> csid204535.txt
> csid204540.txt
> csid204545.txt
> csid204550.txt
> csid204555.txt
> csid204560.txt
> csid204565.txt
> csid204570.txt
> csid204575.txt
> csid204580.txt
> csid204585.txt
> Loading auxiliary files...
> cntry.codes.txt
> adjacency.txt
> ...Finished
> Total number of cross sections: 19
>
> ylc <- yourcast(formula=log(rspi2/popu2) ~ time, dataobj=dta,
> model="LC",debug =TRUE)
> Error in seq.default(smpvec[ind], smpvec[ln], by = 1) :
> wrong sign in 'by' argument
>
> Thank you for your help!
>
> Antonio Lam
>
Dear Professor King,
I was doing some literature reading and I came across your software. I try the package with my own data but I got some error.
I modified my data and make it look like the example data in the file path of the package. yourprep runs smoothly with some data like below:
dta$data$`204500`
rspi2 popu2 time
2004 NA 4858042 1994
2005 NA 4785805 1995
2006 NA 4704201 1996
2007 0.006431800 4592693 1997
2008 0.005454000 4522168 1998
2009 0.005908178 4432729 1999
2010 0.005238223 4317368 2000
2011 0.005180368 4237330 2001
2012 0.004544100 4176305 2002
2013 0.004363600 4098927 2003
2014 0.003821751 4056178 2004
2015 0.003390900 3958900 2005
2016 NA NA 2006
2017 NA NA 2007
2018 NA NA 2008
2019 NA NA 2009
2020 NA NA 2010
2021 NA NA 2011
2022 NA NA 2012
2023 NA NA 2013
2024 NA NA 2014
2025 NA NA 2015
But then I got error with yourcast() command.
The scripts run below:
> dta <- yourprep(dpath='./GARY_KING_CHINA_mortality',index.code="ggggaa", tag="csid",
+ year.var=TRUE, sample.frame=c(2004,2015,2016,2025),
+ G.names="cntry.codes.txt", adjacency="adjacency.txt",
+ verbose=TRUE,summary=FALSE)
Loading cross section files and checking for errors...
csid204500.txt
csid204501.txt
csid204505.txt
csid204510.txt
csid204515.txt
csid204520.txt
csid204525.txt
csid204530.txt
csid204535.txt
csid204540.txt
csid204545.txt
csid204550.txt
csid204555.txt
csid204560.txt
csid204565.txt
csid204570.txt
csid204575.txt
csid204580.txt
csid204585.txt
Loading auxiliary files...
cntry.codes.txt
adjacency.txt
...Finished
Total number of cross sections: 19
ylc <- yourcast(formula=log(rspi2/popu2) ~ time, dataobj=dta, model="LC",debug =TRUE)
Error in seq.default(smpvec[ind], smpvec[ln], by = 1) :
wrong sign in 'by' argument
Thank you for your help!
Antonio Lam
Hi,
I was reading the example for array.yourcast in the pdf and I noticed that
the documentation mentions that multiple arrays can be returned depending
on the number of geographic regions in the dataset. Since we are using data
from chp.2.6.1 in this example, which contains data for both Hungary & New
Zealand, how come running array.yourcast(ylc.allc) only returns one array
and not two (1 for each country)? Is the array for Hungary, or NZ, or both?
Is there a way to return one for each geographic region?
Thank you in advance for the help.
Dear Professors,
I am using YourCast in forecasting disease-specific mortalities in
China. The data I input is in following format in .csv format. As
showed, there are missings in between observed years.
YourCast works quite well for LC and OLS model. However, when I try
model "map" to smooth over age and cities, I met two problem.
year sex2 city2 age r2 time
1987 0 0 10 0.05 0
1988 0 0 10 0.05 1
1989 0 0 10 NA 2
1990 0 0 10 NA 3
1991 0 0 10 0 4
1992 0 0 10 0 5
1993 0 0 10 NA 6
1994 0 0 10 NA 7
1995 0 0 10 NA 8
1996 0 0 10 NA 9
1997 0 0 10 NA 10
1998 0 0 10 NA 11
1999 0 0 10 NA 12
2000 0 0 10 NA 13
2001 0 0 10 NA 14
2002 0 0 10 0 15
2003 0 0 10 0.12 16
2004 0 0 10 0.14 17
2005 0 0 10 0.27 18
2006 0 0 10 0.08 19
2007 0 0 10 0 20
2008 0 0 10 0 21
2009 0 0 10 NA 22
2010 0 0 10 NA 23
2011 0 0 10 0.07 24
2012 0 0 10 NA 25
2013 0 0 10 NA 26
2014 0 0 10 NA 27
2015 0 0 10 NA 28
2016 0 0 10 NA 29
2017 0 0 10 NA 30
2018 0 0 10 NA 31
2019 0 0 10 NA 32
2020 0 0 10 NA 33
1. length of age; the file name is in csidggggaa.csv format and I have
age group 0, 1, 5, 10, 15,20,...,85, and file names are db100100.csv
db100101.csv db100105.csv db100110.csv...etc. (1001 represents cities)
YourCast returns " 'names' attribute [19] must be the same length as the
vector [18] " and I guess it maybe related to the name of age group?
> db1<-yourprep(tag="db", year.var=TRUE, index.code="ggggaa",
+ G.names="G.name.txt",sample.frame=c(1987,2011,2012,2030))
Loading cross section files and checking for errors...
...Finished
Total number of cross sections: 76
> db1m<-yourcast(formula=log(r2+0.001)~time+sex2, dataobj=db1,
model="map", sample.frame=c
+ (1987,2011,2012,2030))
...
Running MAP model
Preparing for smoothing over age groups
Preparing for smoothing of time trend over age groups
Preparing for smoothing over time
Error in names(whoyg) <- age.char :
'names' attribute [19] must be the same length as the vector [18]
Data is inconsistent.
Error in m$coeff : $ operator is invalid for atomic vectors
2. A second issue happend after I use only age group 10 to 85 to bypass
the 1st problem. Here is what I get
> db1<-yourprep(tag="db", year.var=TRUE, index.code="ggggaa",
+ G.names="G.name.txt",sample.frame=c(1987,2011,2012,2030))
Loading cross section files and checking for errors...
...Finished
Total number of cross sections: 64
> db1m<-yourcast(formula=log(r2+0.001)~time+sex2, dataobj=db1,
model="map", sample.frame=c
+ (1987,2011,2012,2030))
...
Running MAP model
Preparing for smoothing over age groups
Preparing for smoothing of time trend over age groups
Preparing for smoothing over time
Choleski for symmetric, positive definite matrix
sample.improper.normal, warning:ranks (chol and code) do not agree
[1] 48 48 32
Error in backsolve(CH, diag(dim)) :
singular matrix in 'backsolve'. First zero in diagonal [33]
In addition: Warning message:
In chol.default(wmat, pivot = T) :
the matrix is either rank-deficient or indefinite
Data is inconsistent.
Error in m$coeff : $ operator is invalid for atomic vectors
Thank you so much for your comments!
Weiming Zhu MD. PhD.
China Center for Health Development Studies
Peking University
I've been reading through the R code to better understand some challenges I've had working with YourCast.
>From documentation in the code, I see that the country correlations (alternately referred to inside yourcast by "adjacency" or "proximity") must take the values 0,1,2.
Does anyone have more knowledge about what these values mean? It seems that 0 represents no correlation. So, is "2" a higher degree of correlation than "1"?
Thanks for any insights.
Regards,
Ethan
--
Ethan Sharygin
University of Washington
Institute for Health Metrics and Evaluation
An addendum: if it helps, I found the code of the problematic function, digitpull, at
https://github.com/IQSS/YourCast/blob/master/R/cast.funcs.R
and the YourCast code for the Lee Carter model here
https://github.com/IQSS/YourCast/blob/master/R/lc.funcs.R
The error is being thrown at this step (from cast.funcs.R):
if (min(abs(v)) < 10^(stopdig-1)) {
stop(message="narrowest element in v not as wide as stopdig in proc digitpull()")
}
Here is the code in the Lee Carter model that is calling digitpull, as well as its arguments. In the comment, I explain what the value was, according to the debugger, at the time of the crash (plus a question mark if I can't find it):
who.cntry.digits <- get("who.cntry.digits", envir=ewho) # who.cntry.digits=3
who.digit.first <- get("who.digit.first", envir=ewho) # who.digit.first=0
digit.cntry.begin <- who.digit.first + 1 # =1 (?)
digit.cntry.end <- who.digit.first + who.cntry.digits # =4 (?)
whoinsampy <- get("whoinsampy", envir= ewho) # see below for example content
cs.vec <- as.numeric(names(whoinsampy));
cs.cntry.vec <- digitpull(cs.vec,digit.cntry.begin,digit.cntry.end)
This is what whoinsampy looks like:
Browse[1]> whoinsampy
$`00400`
depvar
004001970 -1.064245
004001971 -1.094867
004001972 -1.125606
004001973 -1.166485
... [etc, for each age group up to 004110]
I feel close to understanding this error, but I can't quite grasp it.
|-----Original Message-----
|From: yourcast-bounces(a)lists.gking.harvard.edu [mailto:yourcast-
|bounces(a)lists.gking.harvard.edu] On Behalf Of Ethan Sharygin
|Sent: Wednesday, October 02, 2013 11:42 AM
|Cc: yourcast(a)lists.gking.harvard.edu
|Subject: Re: [yourcast] Error in yourcast step after successful
|yourprep.
|
|Thanks, Nicholas, for the tip. That did get past that error!
|
|A few new things have happened that are interesting. YourCast seems to
|crash without covariates, which I was able to debug (details below).
|Unfortunately, when I add covariates, I still get a strange error. I'm
|hoping you or someone else might have seen this before too, and got past
|it.
|
|I'll document this in reverse order-first, the problem after adding a
|covariate (arbitrarily defined "time", equal to year-30---as in the
|example in the YourCast vignette). Second, for the record, I've
|described the problem I generated when YourCast did not have a covariate
|(might be a bug in the way the lists containing the data are named when
|there is only one covariate).
|
|____YourCast returns an error in digitpull().____
|
|I can't tell what is generating this error. I've tried changing the
|number of digits in the age group and country codes, but to no avail so
|far.
|
|> dta<-yourprep(dpath=paste(wd,"rawmini",sep=""),# path to text files
|+ year.var=TRUE,# year is a column
|+ tag="mxmale",# file names begin with mxmale
|+ index.code="gggaaa",# 3-digit region and 3-digit age
|+ sample.frame=c(1970,2011,2012,2036),# start,end of model yrs and
|forecast
|+ )
|Loading cross section files and checking for errors...
|...Finished
|Total number of cross sections: 24
|> ylc<-yourcast(formula=log(allcause)~index,
|+ dataobj=dta,# name of yourprep data
|+ model="LC",# options:bayes,map,ols,poisson,lc
|+ sample.frame=c(1970,2011,2012,2036),# provide sample frame from
|yourprep step
|+ )
|Creating formulas for all cross-sections...
|Adding time to the covariate list...
|Applying formulas to data in each cross-section...
|Running model frames for data matrices...
|Building the covariates list...
|Standardizing covariates...
|Constructing the list of dependent variables...
|Creating the in-sample and out-sample periods for covariates...
|Creating lists for dependent variable,in-sample and out-sample...
|Saving preprocessing in the
|file...c:/research/gbdcast/_yourcast/data/yourcast.savetmp
|The size of yourcast.savetmp is = 30434
|Using LC model
|Error in digitpull(cs.vec, digit.age.begin, digit.age.end) :
| narrowest element in v not as wide as stopdig in proc digitpull()
|Data is inconsistent.
|Error in get("lst.output", envir = ewho) : object 'lst.output' not found
|
|Some things that might be helpful (?). I can't find cs.vec in any of the
|environments available after debugger().
|
|Browse[1]> digit.first
|digit.first
| 0
|Browse[1]> age.digits
|age.digits
| 3
|Browse[1]> ewho$age.vec
| [1] "000" "001" "005" "010" "015" "020" "025" "030" "035" "040" "045"
|"050"
|[13] "055" "060" "065" "070" "075" "080" "085" "090" "095" "100" "105"
|"110"
|
|
|
|____YourCast seems to crash without covariates.____
|
|To my eyes, it appears that yourcast is calling the matrix column with
|the dependent variable, "allcause", but that the matrix is not labeled
|this way when it is the only variable. This happened until I added a
|covariate to the input data (i.e., a new column in the text files read
|by yourprep).
|
|> wd<-"c:/research/gbdcast/_yourcast/data/"# update working directory
|> setwd(wd)
|> dta<-yourprep(dpath=paste(wd,"rawmini",sep=""),# path to text files
|+ year.var=TRUE,# year is a column
|+ tag="mxmale",# file names begin with mxmale
|+ index.code="gggaaa",# 3-digit region and 3-digit age
|+ G.names="isonames.txt",# file containing country abbvs
|+ sample.frame=c(1970,2011,2012,2036),# start,end of model yrs and
|forecast
|+ # adjacency="adjacency.txt",# file containing WHO adjacency info
|+ verbose=TRUE,# do not suppress output
|+ )
|Loading cross section files and checking for errors...
|mxmale004000.txt
|mxmale004001.txt
|.[etc, until]
|mxmale004110.txt
|Loading auxiliary files...
|isonames.txt
|...Finished
|Total number of cross sections: 24
|
|> ylc <- yourcast(formula=log(allcauses)~index, dataobj=dta, model="LC",
|sample.frame=c(1970,2011,2012,2036))
|Error in mat[, dth] : subscript out of bounds
|
|> debugger()
|Message: Error in mat[, dth] : subscript out of bounds
|Available environments had calls:
|1: yourcast(formula = log(allcauses) ~ index, dataobj = dta, model =
|"LC", sam
|2: input.to.model(datamat = dataobj$data, ff = formula, all.pow =
|low.pow, sam
|3: build.covs.depvar.lst(datamat, ff, all.pow, sample.frame, standard,
|verbose
|4: data.after.first.obv(datamat, ff)
|5: lapply(datamat, FUN = "first.obvy", dth, pop)
|6: FUN(X[[1]], ...)
|Enter an environment number, or 0 to exit Selection: 6
|Browsing in the environment with call:
| FUN(X[[1]], ...)
|Called from: debugger.look(ind)
|
|Browse[1]> ls()
|[1] "dth" "mat" "pop" "rnm"
|
|Browse[1]> dth
|[1] "allcauses"
|
|Browse[1]> mat
| mat
|0040001970 0.34498817
|0040001971 0.33458412
|0040001972 0.32445580
|0040001973 0.31145978
|0040001974 0.29705149
|. [ and so on, until .]
|0040002010 0.07250808
|0040002011 0.06872911
|0040002012 NA
|0040002013 NA
|0040002014 NA
|. [ etc, etc, until.]
|0040002035 NA
|0040002036 NA
|
|This error was fixed by adding a covariate to the source data, which
|resulting in the appropriate naming of the columns in the matrix "mat",
|e.g.:
|
|> dta$data
|$`004000`
| allcause time
|1970 0.34498817 1940
|1971 0.33458412 1941
|...[etc]
|
|And then mat[,dth] pulls from the correct column.
|
|
|From: Nicholas Martinez [mailto:martinez.nicholas@gmail.com]
|Sent: Tuesday, October 01, 2013 10:24 PM
|To: Ethan Sharygin
|Cc: yourcast(a)lists.gking.harvard.edu
|Subject: Re: [yourcast] Error in yourcast step after successful
|yourprep.
|
|Ethan,
|I had the same problem a couple of years ago. You have to pass the the
|frame you set in your.prep into the your.cast sample.frame.
|Try this.
|ylc <- yourcast(formula=log(allcauses)~index, dataobj=dta, model="LC",
|sample.frame=c(1970,2011,2012,2036))
|Hope that works.
|Best,
|Nicholas
|
|On Tue, Oct 1, 2013 at 8:52 PM, Ethan Sharygin <sharygin(a)uw.edu> wrote:
|Dear yourcast users or moderator,
|
|I am unable to get yourcast to run any model with data in yourprep. I've
|formatted my data into text files for each cross-sectional unit,
|following the example in the vignette/documentation for YourCast.
|
|Here is a stripped down example for one geographic unit, 24 age groups,
|years 1970-2036 (non-missing data for 1970-2011). No auxiliary files are
|used in this example.
|
|(1) The R command and output:
|> dta<-yourprep(dpath=paste(wd,"rawmini",sep=""),# path to text files
|+ year.var=TRUE,# year is a column
|+ tag="mxmale",# file names begin with mxmale
|+ index.code="gggaaa",# 3-digit region and 3-digit age
|+ sample.frame=c(1970,2011,2012,2036),# start,end of model yrs and
|forecast
|+ #G.names="isonames.txt",# file containing country abbvs
|+ #adjacency="mxmale.proxim.txt",# file containing adjacency info
|+ verbose=TRUE,# do not suppress output
|+ )
|Loading cross section files and checking for errors...
|mxmale004000.txt
|mxmale004001.txt
|mxmale004005.txt
|mxmale004010.txt
|mxmale004015.txt
|mxmale004020.txt
|mxmale004025.txt
|mxmale004030.txt
|mxmale004035.txt
|mxmale004040.txt
|mxmale004045.txt
|mxmale004050.txt
|mxmale004055.txt
|mxmale004060.txt
|mxmale004065.txt
|mxmale004070.txt
|mxmale004075.txt
|mxmale004080.txt
|mxmale004085.txt
|mxmale004090.txt
|mxmale004095.txt
|mxmale004100.txt
|mxmale004105.txt
|mxmale004110.txt
|...Finished
|Total number of cross sections: 24
|> ylc<-yourcast(formula=log(allcause)~index,
|+ dataobj=dta,# name of yourprep data
|+ model="LC",# options:bayes,map,ols,poisson,lc
|+ debug=TRUE,# add debug info to user space
|+ )
|Error in seq.default(smpvec[ind], smpvec[ln], by = 1) :
| wrong sign in 'by' argument
|
|(2) an example text file (mxmale004000.txt) for one age category (age 0)
|for one country (004)
|year allcause
|1970 .3449881673
|1971 .3345841169
|1972 .3244557977
|1973 .3114597797
|1974 .2970514894
|[truncated here to save space]
|2010 .0725080818
|2011 .0687291101
|2012 NA
|2013 NA
|2014 NA
|[and so on, NA values until 2036]
|
|Any insights would be appreciated, as I cannot distinguish how my data,
|after yourprep, are any different from the example in the documentation.
|
|Thanks sincerely,
|
|--
|Ethan Sharygin
|
|-
|---
|yourcast mailing list served by HUIT
|List Address: yourcast(a)lists.gking.harvard.edu
|Subscribe/Unsubscribe:
|http://lists.gking.harvard.edu/mailman/listinfo/yourcast
|Yourcast mailing list
|Yourcast(a)lists.gking.harvard.edu
|
|To unsubscribe from this list or get other information:
|
|https://lists.gking.harvard.edu/mailman/listinfo/yourcast
|
|-
|---
|yourcast mailing list served by HUIT
|List Address: yourcast(a)lists.gking.harvard.edu
|Subscribe/Unsubscribe:
|http://lists.gking.harvard.edu/mailman/listinfo/yourcast
|Yourcast mailing list
|Yourcast(a)lists.gking.harvard.edu
|
|To unsubscribe from this list or get other information:
|
|https://lists.gking.harvard.edu/mailman/listinfo/yourcast
Dear yourcast users or moderator,
I am unable to get yourcast to run any model with data in yourprep. I've formatted my data into text files for each cross-sectional unit, following the example in the vignette/documentation for YourCast.
Here is a stripped down example for one geographic unit, 24 age groups, years 1970-2036 (non-missing data for 1970-2011). No auxiliary files are used in this example.
(1) The R command and output:
> dta<-yourprep(dpath=paste(wd,"rawmini",sep=""),# path to text files
+ year.var=TRUE,# year is a column
+ tag="mxmale",# file names begin with mxmale
+ index.code="gggaaa",# 3-digit region and 3-digit age
+ sample.frame=c(1970,2011,2012,2036),# start,end of model yrs and forecast
+ #G.names="isonames.txt",# file containing country abbvs
+ #adjacency="mxmale.proxim.txt",# file containing adjacency info
+ verbose=TRUE,# do not suppress output
+ )
Loading cross section files and checking for errors...
mxmale004000.txt
mxmale004001.txt
mxmale004005.txt
mxmale004010.txt
mxmale004015.txt
mxmale004020.txt
mxmale004025.txt
mxmale004030.txt
mxmale004035.txt
mxmale004040.txt
mxmale004045.txt
mxmale004050.txt
mxmale004055.txt
mxmale004060.txt
mxmale004065.txt
mxmale004070.txt
mxmale004075.txt
mxmale004080.txt
mxmale004085.txt
mxmale004090.txt
mxmale004095.txt
mxmale004100.txt
mxmale004105.txt
mxmale004110.txt
...Finished
Total number of cross sections: 24
> ylc<-yourcast(formula=log(allcause)~index,
+ dataobj=dta,# name of yourprep data
+ model="LC",# options:bayes,map,ols,poisson,lc
+ debug=TRUE,# add debug info to user space
+ )
Error in seq.default(smpvec[ind], smpvec[ln], by = 1) :
wrong sign in 'by' argument
(2) an example text file (mxmale004000.txt) for one age category (age 0) for one country (004)
year allcause
1970 .3449881673
1971 .3345841169
1972 .3244557977
1973 .3114597797
1974 .2970514894
[truncated here to save space]
2010 .0725080818
2011 .0687291101
2012 NA
2013 NA
2014 NA
[and so on, NA values until 2036]
Any insights would be appreciated, as I cannot distinguish how my data, after yourprep, are any different from the example in the documentation.
Thanks sincerely,
--
Ethan Sharygin
Hi
I am using yourcast for the first time and I it doesn't seem to be working for me. Can anyone help?
I have data on deaths and population for 8 Australian states, with 19 age groups for each state. Attached is an example of a text file for this data
I have used yourprep to import the text files to R and that seems to work with no errors.
If I use yourcast over a single state or a single age group it appears to work ok. However, if I run it using more than one age and geographic profile I get the following error
> ylc <- yourcast(formula = log(deaths/erp)~ time,dataobj = dta,model = "ols",sample.frame = c(1995,2011,2012,2026))
Creating formulas for all cross-sections...
Applying formulas to data in each cross-section...
Running model frames for data matrices...
Building the covariates list...
Standardizing covariates...
Constructing the list of dependent variables...
Creating the in-sample and out-sample periods for covariates...
Creating lists for dependent variable,in-sample and out-sample...
Saving preprocessing in the file...K:/Research Staff Folders/Glenn/YourCast/yourcast.savetmp
The size of yourcast.savetmp is = 7201
Running OLS model...
Error in rlm[[i]]$coefficients : $ operator is invalid for atomic vectors
Data is inconsistent.
Error in get("lst.output", envir = ewho) : object 'lst.output' not found
Can anyone advise what I am doing wrong?
The following is all the code to create the text files, import them using yourprep and run yourcast
setwd("K:/Research Staff Folders/Glenn/YourCast/")
load("M:/Mortality/Australian Mortality.rdata")
load("M:/Population/Australian Base Population.rdata")
library(reshape2)
library(YourCast)
## Create data frame of existing ERP and death data (1995-2011)
toterp <- xtabs(count ~ age85mort + year + state,allpop)
mortality <- xtabs(count ~ age + yr + state,latestData)
yearList <- list(c("1995","1996","1997","1998","1999","2000","2001","2002","2003","2004",
"2005","2006","2007","2008","2009","2010","2011","2012","2013","2014","2015","2016","2017",
"2018","2019","2020","2021","2022","2023","2024","2025","2026"),c("deaths","erp","time"))
time <- c(1995:2026)
states <- c("nsw","vic","qld","sau","wau","tas","nte","act")
age <- c(1:19)
agegroup <- c("01","04","09","14","19","24","29","34","39","44","49","54","59","64","69","74","79","84","85")
stategroup <- c("1","2","3","4","5","6","7","8")
##### Creating text files via a loop makes Yourcast fall over, don't know why############################
for ( s in 1:8){
for (a in 1:19){
f1 <- c(toterp[a,c(25:41),s],rep(NA,15))
dim(f1) <- 32
f2 <- c(mortality[a,,s],rep(NA,15))
dim(f2) <- 32
f3 <- cbind(f2,f1,time)
dimnames(f3) <- yearList
write.table(f3,paste("K:/Research Staff Folders/Glenn/YourCast/Output/csid",stategroup[s],"000",agegroup[a],".txt",sep = ""))
}
}
dta <- yourprep("K:/Research Staff Folders/Glenn/YourCast/Output/",year.var = TRUE,sample.frame = c(1995,2011,2012,2026),G.names = "cntry.codes.txt",adjacency = "adjacency.txt")
ylc <- yourcast(formula = log(deaths/erp)~ time,dataobj = dta,model = "ols",sample.frame = c(1995,2011,2012,2026))
Thanks
Glenn Boardman
Data Analyst & Support Officer
Strategic Policy & Research
Department of Planning
Level 4, 140 William Street, Perth WA 6000
T: (08) 65519083
E: glenn.boardman(a)planning.wa.gov.au W: www.planning.wa.gov.au
DISCLAIMER
This email and any attachments are confidential and may contain legally privileged
and/or copyright material. You should not read, copy, use or disclose any of the
information contained in this email without authorisation. If you have received it in
error please contact us at once by return email and then delete both emails. There is
no warranty that this email is error or virus free.
Dear YourCast users:
A working Windows version of YourCast is now available on CRAN
(http://cran.r-project.org/web/packages/YourCast/index.html). Please
check CRAN (rather than Gary King's website) for the latest version of
this package.
Best,
--
Jon Bischof
Graduate Student
Department of Government
Harvard University
--
yourcast mailing list served by Harvard-MIT Data Center
List Address: yourcast(a)lists.gking.harvard.edu
Subscribe/Unsubscribe: http://lists.gking.harvard.edu/?info=yourcast