drizopoulos / JMbayes2

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

Interaction beween longitudinal outcomes #48

Closed Lisaleg closed 1 year ago

Lisaleg commented 1 year ago

Hello,

Many thanks for such an amazing package and the way you bring people to understand.

My question is about interaction between splines. I want to fit a bivariate Joint model with 2 longitudinal continuous outcomes that I will model with splines, each. How can I introduce an interaction term between these 2 ouctomes? Should I consider a bivariate linear mixed model with interaction prior to build a Joint model?

Many thanks for reading,

Best,

Lisa

drizopoulos commented 1 year ago

Dear Lisa,

It is not clear what kind of model you want to fit. Perhaps if your provide more info, I could help.

Best, Dimitris

Lisaleg commented 1 year ago

Hi Dimitis,

Thank you for your answer. My apoligies, I realize I was not clear, let me clarify my thoughts.

We have 2 longitudinal biomarkers (biomarker1, biomarker 2), and 3 types of event (1 event of interest, 2 competing events). We want to estimate the effect of Biomarker 1 on the hazard of each event, but we know that this effect is potentially strongly nonlinear, and this nonlinear effect may be strongly modified by Biomarker 2.

Two questions :

  1. To simplify, I first ignored the potential effect modification, and "just" estimated the nonlinear effect of the current value of Biomarker 1 on the hazard of each event, using poly2. I don't understand the output of the result of the survival model (mean value). I actually would like to plot the resulting estimated nonlinear effects and the confidence interval, as well as derive from it, hazard ratios and confidence intervals for different pairs of specific values of Biomarker1. Would it be possible and how ?

  2. Can we model the interaction between the two biomarkers in the survival models (e.g. between their current values), while accounting for their nonlinear effects on the hazards ? if yes, how ?

Sincerely,

Lisa

drizopoulos commented 1 year ago

If I understand correctly, you want a nonlinear effect of the biomarker on the log hazard scale. And also including an interaction between biomarkers. Then possibly something like the following could work:

jm(..., functional_forms = ~ value(y1) + poly2(y1) + value(y1):value(y2) + poly2(y1):value(y2))
Lisaleg commented 1 year ago

Many thanks for this code. I wil try this.

Best, Lisa

berithunsdieck commented 1 year ago

@drizopoulos If this code snippet for functional forms is used, the interaction is included twice, for example if you use "functional_forms=~value(y1):value(y2)" both value(y1):value(y2) and value(y2):value(y1) are estiamted in the model. Is this a bug or how can I get rid of it?

essipeltonen commented 11 months ago

I'm struggling with the same problem. I'm trying to fit a model with main effects together with interaction term of two longitudinal outcomes. If I use the code suggested above, edited to my purposes:

jm(..., functional_forms = ~ value(D_CMILK_100) + value(D_OAT_10) + value(D_CMILK_100) : value(D_OAT_10)))

I get estimates for main effects, that's right, but then I also get TWO estimates for interaction:

value(D_CMILK_100)              
value(D_CMILK_100):value(D_OAT_10)
value(D_OAT_10) 
value(D_OAT_10):value(D_CMILK_100)

I don't understand why there are two estimates, what are the meaning of those? I tried different ways of formatting the "functional_forms" part but there were always something strange it the output.

Thank you in advance if you could help with this problem.

drizopoulos commented 11 months ago

There is indeed an issue when including interactions between longitudinal outcomes. We are trying to see how this can be rectified.

lelbru commented 11 months ago

Dear Prof. Rizopoulos,

Related to the comments above, I wish to model a nonlinear relationship between the survival outcome and a longitudinal outcome. For example, instead of the linear relationship alphavalue(y) in the linear predictor, I am interested in a quadratic relationship alpha1value(y) + alpha2*[value(y)]^2.

For the linear relationship, I would simply set functional_forms = ~ value(y).

For the quadratic relationship, I am not sure exactly how the syntax works. Could it be specified like

functional_forms = ~ value(y) + I((value(y))^2)

or

functional_forms = ~ poly(value(y), degree = 2, raw = TRUE),

where the function I() is from base R and the function poly() is from the stats package?

It seems like an alternative could be to use the poly2() function from the JMbayes2 package, but I’m not sure exactly how that function works or how to incorporate it into the functional forms argument.

Thank you for the great package and the helpful articles!

drizopoulos commented 10 months ago

You should use ~ value(y) + poly2(value(y)). The I() function is not recognized in the internal computations that are done in C++.

lelbru commented 10 months ago

Thank you Prof. Rizopoulos!

One follow-up question: if a quadratic form is not correct, and instead I wanted to use a spline, could I use something like functional_forms = ~ ns(value(y), df = 3) ?

drizopoulos commented 10 months ago

No, splines are not implemented.

berithunsdieck commented 10 months ago

Is a third degree form possible instead of quadratic?

drizopoulos commented 10 months ago

Yes, using the poly3() function.