I have many short time series (1-5 data points) that document the development of morphological traits (length and pigmentation) of some lab critters in response to different dietary supplement. I already know that, depending on dietary supplement, these traits increase at different rates (and depending on family but that's maybe not important for this question).

I now would like to test whether growth or pigmentation rates, across different diets, can affect survival. As I said the morphological information I have for every timepoint; survival is determined by how long the timeseries are (1-5: I believe this is referred to as (right) truncated and not censored data). I suspect that organisms who both grow and pigment too fast have a higher change of dying, depending on what diet they feed on, but I am not sure how to test it.

I have been trying with a GAM-framework, 0/1 as response, and morphological info filled with NA after death. Did not work, of course, but just to give you an idea:

mod = gam(Survival ~  Food + Time_num +
            s(Time_num, Length, by=Food, k=5) +
            s(Time_num, Pigmentation, by=Food, k=5) +
            s(Time_num, Length, Pigmentation, by=Food, k=5) +
            s(Family, Individual, bs="re")
          , family = "binomial", data=mod_data)

How can I account for truncation of individual time series? I would like to stay at the level of each individual (i.e. no family or treatment by timepoint averaging). R syntax would be appreciated.

EDIT: To clarify, I am interested in the time of survival (numeric 1-5 is sampling timepoints/dates), and how it is influenced by how fast organisms grow and/or become pigmented. The data (for all my ~1000 individuals) looks like this:

Individual 1A, Food A
Time:            1    2    3    4    5
Alive:           1    1    1    0    0
Length:          1.1  1.5  2.6  NA   NA
Pigmentation:    0.3  0.5  0.7  NA   NA

Individual 2A, Food A
Time:            1    2    3    4    5
Alive:           1    1    1    1    1
Length:          1.2  1.5  2.9  3.6  5.8
Pigmentation:    0.3  0.45 0.6  0.7  0.8

Individual 3A, Food B
Time:            1    2    3    4    5
Alive:           1    0    0    0    0
Length:          1.1  NA   NA   NA   NA
Pigmentation:    0.3  NA   NA   NA   NA


The 0/1 (dead/alive) response could of course be converted to 1-5, so I probably want that as my response in the end.

  • $\begingroup$ Can you describe more clearly what your outcome really is and how it is measured? The post suggests that it is the "length of a series" (expressed in days? hours?) but then suggests that it is a "yes/no" type of outcome, which is confusing. $\endgroup$ Commented Mar 5, 2019 at 16:10
  • $\begingroup$ Also, can you clarify whether or not you are interested in "time to death" for each individual or in "whether or not the individual died"? $\endgroup$ Commented Mar 5, 2019 at 16:12
  • $\begingroup$ Is there any reason not to use a Cox PH model ? $\endgroup$ Commented Mar 5, 2019 at 17:41

1 Answer 1


This is maybe not the answer you were looking for, but you should take a look at joint models.

These models are a combination of a survival model to consider events (death as 0/1 i your case) and a mixed model to take into account evolution of some factors over time (length and pigmentation for instance).

There is a R tutorial you can try. Here is what I'd try based on your example, but I'm no expert:

# Mixed-effects model fit
lmeFit.p1 <- lme(Time_num ~ Length + Pigmentation + Length:Pigmentation, 
                 data = mod_data, random = ~ Time_num | id)  

# Cox survival model fit
mod_data2 = mod_data #create your survival data
survFit.p1 <- coxph(Surv(Time, death) ~ Food + Time_num, data = mod_data2, x = TRUE)  

# Joint model
jointFit.p1 <- jointModel(lmeFit.p1, survFit.p1, timeVar = "Time_num",
                          method = "piecewise-PH-aGH") #maybe another method
  • $\begingroup$ this definitely got me thinking more in the right direction. I tried your specific example and could not yet get it to work because of differing sample sizes between longitudinal and event processes. I think this may be due to the random effect - I tried with cluster in the cox model without success. I'll spend more effort on this soon $\endgroup$
    – mluerig
    Commented Mar 6, 2019 at 22:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.