# NOT RUN {
yfile=system.file("extdata", "rawfvc621_y.txt", package = "JMcmprsk")
cfile=system.file("extdata", "fvc621_c.txt", package = "JMcmprsk")
cread <- read.table(file = "rawfvc621_c.txt", header = T)
yread <- read.table(file = "fvc621_y.txt", header = T)
res <- jmc_long(long_data = yread, surv_data = cread, out = "FVC", cate = NULL,
FE = c("time", "FVC0", "FIB0", "CYC", "FVC0.CYC", "FIB0.CYC", "time.CYC"),
RE = "time", ID = "rowId", intcpt = 1, quad.points = 8, max.iter = 10000, quiet = FALSE)
coef(res)
anova(res,coeff="beta")
anova(res,coeff="gamma")
#make up two categorical variables and add them into yread
require(tidyverse)
mfile=system.file("extdata", "fvc621_m.txt", package = "JMcmprsk")
mread <- read.table(file = "fvc621_m.txt", header = T)
rowId <- c(1:nrow(cread))
sex <- sample(c("Feamle", "Male"), nrow(mread), replace = T)
race <- sample(c("White", "Black", "Asian", "Hispanic"), nrow(mread), replace = T)
cate_var <- data.frame(rowId, sex, race)
yread <- left_join(yread, cate_var, by = "rowId")
# run jmc_long function again for yread file with two added categorical variables
res2 <- jmc_long(long_data = yread, surv_data = cread, out = "FVC", cate = c("sex", "race"),
FE = c("time", "FVC0", "FIB0", "CYC", "FVC0.CYC", "FIB0.CYC", "time.CYC"),
RE = "time", ID = "rowId", intcpt = 1, quad.points = 8, max.iter = 10000, quiet = TRUE)
# }
Run the code above in your browser using DataLab