# \donttest{
#The life tables generated in the example have 3 columns, which correspond to 3 states:
#1: health; 2: unhealthiness; 3: death;
data <- lifedata
y <- data[,1]
X <- data[,-1]
# This example will take about 30 mins.
out <- bayesmlogit(y, X ,samp=1000, burn=500,verbose=10)
trans <- out$outwstepwidth
mlifeTable(y,X,trans =trans,
groupby = c("male","black","hispanic"),
no_control = "mar",
startages=50,
age.gap=1,
states=3,
file_path=".")
# To name each subgroup, try the subgroup.names option.
mlifeTable(y,X,trans =trans,
groupby = c("male","black","hispanic"),
no_control = "mar",
states=3,
startages=50,
age.gap=1,
file_path=".",
subgroup.names= c("F-W","M-W","M-B","F-B","F-H","M-H"))
# To generate plots, try the mlifeTable_plot option
mlifeTable(y,X,trans =trans,
groupby = c("male","black","hispanic"),
no_control = "mar",
states=3,
startages=50,
age.gap=1,
nums = 400,
file_path=".",
subgroup.names= c("F-W","M-W","M-B","F-B","F-H","M-H"),
mlifeTable_plot = T,
cred = 0.84)
# To specify a variable at a fixed value other than the mean value. Try option "values".
mlifeTable(y,X,trans =trans,
groupby = c("male","black","hispanic"),
no_control = "mar",
values = list("cohort" = 36),
states=3,
startages=50,
age.gap=1,
nums = 400,
file_path=".",
subgroup.names= c("F-W","M-W","M-B","F-B","F-H","M-H"),
mlifeTable_plot = T,
cred = 0.84)
# }
Run the code above in your browser using DataLab