# Which statistical model to use when trying to find the beginning of a time-dependent increase

I have a repeated measures data set with time as the independent variable and a single dependent variable, y. That is, for each subject, I have a certain (small, from 1 to 3) number of measurements. The maximum time point of all measurements is a certain clinical event (diagnosis).

Visually, I see that until (roughly) a certain time point, y is independent of time. However, as the measurements approach the time of diagnosis, I can see that the measured variable starts to rise. In principle, this is the relationship that I think I observe:

$$y(x) = \begin{cases} a & x < x_1\\ a + bx & x \ge x_1\\ \end{cases}$$

My question is: how to get an estimate and confidence intervals of $x_1$.

• In r the segments package will fit that model in a frequentist framework. – atiretoo Dec 7 '15 at 12:27

The model you describe reminds me of changepoint models. Like you said, the model parameters change, in your case $b$, with respect to some changepoint $x_1$.

There might be several ways to estimate such models. One way is to use Markov chain Monte Carlo (MCMC). This would provide estimates of the uncertainty of your parameter fits as well.

OpenBugs is a softwarte frequently used in the context of MCMC. One example is about changepoint models. Maybe this will help. http://www.openbugs.net/Examples/Stagnant.html

Such time-dependent covariates can be modeled such that their effects are smooth functions of time. A flexible and relative simple way to do this is to string out the observations into a tall and thin format and to do an after-the-fit cluster sandwich or cluster bootstrap adjustment for intra-cluster correlation, a cluster being a patient. Rather than trying to create a "fall off the cliff" threshold, keep the time functions smooth using regression splines. The tall thin dataset would have final diagnosis as $Y$, duplicated for every record for the patient. The predictors would be a spline of time until diagnosis, the independent variable $x$ (possibly expanded into splines), and a tensor spline interaction surface of the two variables (all cross-products of the spline terms for time and $x$). When finished you can plot time, $x$, and probability of positive diagnosis from the fitted binary logistic model, on a 3-d wireframe plot or in a color image plot or contour plot.

With this setup every patient can have a different number of measurements, and different measurement times.

• So just to translate back into the terms of the OP, your Y is 0/1 status indicating if the observation corresponds to disease diagnosis, and your independent predictor x is the OP's response variable y. – atiretoo Dec 7 '15 at 14:36
• Yes, sorry I missed the notation. I like to reserve $Y$ and $y$ to strictly refer to outcome/response/dependent variables. – Frank Harrell Dec 7 '15 at 14:49
• Thank you, this sounds really promising, but I am afraid that this is still a bit over my head (specifically, what does it mean to "string out the observations"? stack them? Also, I don't know what after-the-fit cluster sandwich is... Why would each record be duplicated?). Could you point my nose toward more reading? Notabene what really interests me is to propose / estimate the disease onset to test it with other methods. – January Dec 7 '15 at 15:49
• Yes, stack them. The cluster adjustment for standard errors, etc., can be done by the R rms package robcov or bootcov functions. You duplicate the outcomes just to allow the association of $x$ and outcome to vary over time, i.e., make it easy to specify interactions. Logistic regression is a direct method that recognizes what are really the independent and dependent variables. The other approach you alluded to is fairly indirect. For case studies remotely similar to this see my handouts at biostat.mc.vanderbilt.edu/RmS#Materials . Start with the Titanic case study. – Frank Harrell Dec 7 '15 at 18:40