Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
drizopoulos committed Oct 27, 2023
1 parent 10c8332 commit ef5878b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
18 changes: 13 additions & 5 deletions Development/jm/test_jm.R
Original file line number Diff line number Diff line change
Expand Up @@ -334,12 +334,20 @@ length(jm3$mcmc$bs_gammas)

data("pbc2", "pbc2.id", package = "JMbayes2")
pbc2$id_char <- as.character(pbc2$id)
pbc2$id_num <- as.numeric(pbc2$id_char)
# pbc2[1:100, c("id", "id_char", "id_num")]
# lapply(pbc2[, c("id", "id_char", "id_num")], summary)

pbc2.id$id_char <- as.character(pbc2.id$id)
pbc2.id$id_num <- as.numeric(pbc2.id$id_char)

pbc2.id$status2 <- as.numeric(pbc2.id$status != 'alive')
CoxFit <- coxph(Surv(years, status2) ~ sex, data = pbc2.id)
fm <- lme(log(serBilir) ~ year * sex, data = pbc2, random = ~ year | id_char)

Surv_object = CoxFit
Mixed_objects = fm
time_var = 'year'
functional_forms = NULL
data_Surv = NULL
id_var = NULL
priors = NULL
control = NULL
#


2 changes: 1 addition & 1 deletion R/jm.R
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ jm <- function (Surv_object, Mixed_objects, time_var, recurrent = FALSE,
}
# we need to check that the ordering of the subjects in the same in dataL and dataS.
# If not, then a warning and do it internally
if (!all(order(unique(idT)) == order(unique(dataL[[idVar]])))) {
if (!all(order(unique(idT)) == order(factor(unq_id, levels = unq_id)))) {
warning("It seems that the ordering of the subjects in the dataset used to fit the ",
"mixed models and the dataset used for the survival model is not the same. ",
"We set internally the datasets in the same order, but it would be best ",
Expand Down

0 comments on commit ef5878b

Please sign in to comment.