admin管理员组文章数量:1291175
I'm trying to create a ratetable in R using the relsurv package with the mortality rates data I've constructed, but I keep getting the following error:
Here’s the code I’m using:
Defining the variables for age, year, and sex
age <- 0:10 # Ages from 0 to 10
year <- 2017:2019 # Years from 2017 to 2019
sex <- c("male", "female") # Sex (male and female)
Creating a mortality rate array with random values
tasso_mortalita_array <- array(runif(66, min = 0.0001, max = 0.0015),
dim = c(length(age), length(year), length(sex)),
dimnames = list(age = as.character(age),
year = as.character(year),
sex = sex))
Creating the ratetable
pop_ratetable <- ratetable(
tasso_mortalita_array,
dimnames = dimnames(tasso_mortalita_array), # Using the correct dimnames
dimid = c("age", "year", "sex"), # Dimension identifiers
factor = c(0, 0, 1), # 0 = continuous for age and year, 1 = categorical for sex
type = c(2, 3, 1), # Dimension types
cutpoints = list(
0:10, # Age from 0 to 10
as.Date(paste(2017:2019, "-01-01", sep = "")), # Years as Date
NULL # No cutpoint for sex
)
)
The error message I receive is:
Error in ratetable(tasso_mortalita_array, dimnames = dimnames(tasso_mortalita_array), :Aguments do not all have the same length (arg 2)
What I’ve checked so far:
The dimensions of the mortality_array
seem correct (11 ages, 3 years, 2 sexes).
The dimnames and cutpoints are also defined properly according to the documentation.
Can anyone help me understand why I am getting this error and how to fix it?
Thank you for your help!
本文标签: Error when creating a ratetable in R using the relsurv packageStack Overflow
版权声明:本文标题:Error when creating a ratetable in R using the relsurv package - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741525199a2383425.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论