drizopoulos / JMbayes2

Extended Joint Models for Longitudinal and Survival Data
https://drizopoulos.github.io/JMbayes2/
79 stars 23 forks source link

Error encountered with jm function when supplying a survreg model #15

Closed grosenf1-nih closed 2 years ago

grosenf1-nih commented 2 years ago

I was trying out other types of survival models with your example and ran into this issue.

library(JMbayes2)
#> Warning: package 'JMbayes2' was built under R version 4.1.2
#> Loading required package: survival
#> Loading required package: nlme
#> Loading required package: GLMMadaptive
#> Warning: package 'GLMMadaptive' was built under R version 4.1.2
#> Loading required package: splines

# AFT model for the composite event death or transplantation
pbc2.id$status2 <- as.numeric(pbc2.id$status != 'alive')
AFT <- survreg(Surv(years, status2) ~ sex, data = pbc2.id, dist = "loglogistic")

# a linear mixed model for log serum bilirubin
fm1 <- lme(log(serBilir) ~ year * sex, data = pbc2, random = ~ year | id)

# a linear mixed model for the prothrombin time
fm2 <- lme(prothrombin ~ year * sex, data = pbc2, random = ~ year | id)

# a mixed effects logistic regression model for ascites
fm3 <- mixed_model(ascites ~ year + sex, data = pbc2,
                   random = ~ year | id, family = binomial())

# the joint model that links all sub-models
jointFit <- jm(AFT, list(fm1, fm2, fm3), time_var = "year",
               n_iter = 12000L, n_burnin = 2000L, n_thin = 5L)
#> Error in checkForRemoteErrors(val): 3 nodes produced errors; first error: matrix multiplication: incompatible matrix dimensions: 4680x1 and 2x1
summary(jointFit)
#> Error in summary(jointFit): object 'jointFit' not found

Created on 2022-02-15 by the reprex package (v2.0.1)

drizopoulos commented 2 years ago

Thanks for reporting this issue. It has been resolved in the current development version on GitHub.