Basic modeling question with time series as covariate I have a dataset with a bunch of entities (patients) and for each of these entities I have:


*

*A binary outcome specific to each entity (i.e. outcome does not vary in time)

*Some static predictors specific to each entity (e.g. gender, age)

*A single, time-varying measurement taken hourly for each entity, over some number of hours that is not necessarily the same for each (i.e. the time series for this measurement have different lengths)


I also suspect that the time-varying measurement has an effect on the outcome only when below a certain level.  In other words, doing something as simple as just taking the mean measurement over all time points does not accomplish what I want.
What I would like to do would be to have a "change point" in the time-based measurement below which it's effect on the outcome can differ from its effect above that point, or in other words, I want two coefficients for that one predictor.  I'm familiar with basic change point models but what I don't understand here is how I should literally structure my training data.  
I don't want to do this, because it repeats the static covariates for each measurement:
Entity  Hour Gender  Age  Measurement  Outcome
1       1    Male    42   3.3          1
1       2    Male    42   8.9          1
1       3    Male    42   1.1          1
...
2       1    Female  33   2.3          0
2       2    Female  33   5.9          0

What other choices do I have then?  What I'd really like is just one observation per entity but I'm not sure how to summarise the time series values into a single value for each when I also want the change point to be part of the estimation.
Does anybody have ideas on how to model something like this?  Would it be unheard of to try to make the change point value part of the model itself and then use information criteria or cross-validation scores to determine where the best change point is?  That could give me some sense of what change point is best but I'd love to keep that estimation all in one model if possible.
Confidence or credible intervals on the coefficients are a must and having the same for the change point would be nice too, though less necessary (and suggestions within the realm of R or python would be much appreciated).
Thanks!

P.S.  Also, any recommendations on how to better understand the effects of repeated covariates on estimation would be a huge help too.  I know that having repeated covariates mixed with non-repeated covariates is a bad thing, but maybe there are ways to adjust for the differences in true sample sizes?  Mixed-effects regression would be great if it was applicable here, but I don't see how it is if the outcome does not also vary in time with each hourly measurement.
 A: One of the possible ideas would be to fit the following model:
$$P(Y_i = 1| z_i, \mu_{it}) = z_i\alpha + \beta\sum_{t=1}^T1\{\mu_{it}< \gamma\},$$
where $Y_i$ is the outcome for individual $i$, $z_i$ are the time constant additional variables and $\mu_{it}$ is the time-varying measurement. The parameters of such model would be $\alpha,\beta$ and cutt-off parameter $\gamma$. The precise form of the last term can be adjusted. Currently it measures how many periods the measurement was below the specified level and $\beta$ is interpreted as the effect of measurement being below the specified level. 
Initially I would try to fit a range of values of prespecified $\gamma$, since it would not require any additional methods. If the results were favorable, i.e. $\beta$ being significant for a $\gamma$ being in some interval $(a,b)$ and non-significant for interval $(b,c)$, I would try to write down maximum likelihood function and fitting it numerically. 
Update: I thought a bit how to make the step function smooth. First it is instructive to rewrite it as 
$$S_i(\gamma)=\begin{cases}0, \text{if } \gamma<=\mu_{it}^{(1)},\\
j, \text{if } \mu_{it}^{(j)}<\gamma<=\mu_{it}^{(j+1)},\\
T, \text{if } \gamma\ge\mu_{it}^{(T)}.\end{cases}$$
Where $\mu_{it}^{(j)}$ $j=1,...,T$ are ordered values of $\mu_{it}$. We can divide by $T$ if we want, but that is not important. Having this function we can smooth it in various ways. Since we need derivatives, we cannot use linear approximation, but we can use splines (R implementation of splines helpfully provides derivatives too), or we can choose certain parametric function (various cdfs naturally come to mind) and simply fit it through the given points. The latter option would require investigating the data to see which cdf to choose. Or we can choose to expand MLE problem to fit a cdf too. 
At first suppose that $S_i(\gamma)$ can be approximated by a single parametric cdf $F(\gamma|\theta)$, where $\theta$ is the parameter vector. If $F$ has a density $f$, the MLE for $\theta$ would be
$$\prod_{i=1}^{NT}f(\mu_{it}|\theta).$$
We can make $\theta$ be a function of $z_i$ to loosen the hypothesis of a single $F$ for all $\mu_{it}$. 
Naturally these thoughts are only conjectures, but I think both of these approaches can be made operational.
