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.