2
$\begingroup$

I want to implement logistic regression with time varying covariates, as the following form of logistic regression:

enter image description here

Which function in R can I use?

My data set looks like this:

ID TSTART TSTOP EVENT   x1     x2    x3    x4    x5 
1    0      1     0    1.28   0.02  0.87  1.22  0.06 
1    1      2     0    1.05  -0.06  0.92  0.73  0.02 
1    2      3     1    1.22  -0.06  0.89  0.48  0.01 
2    0      1     0    1.06  0.11   0.81  0.84  0.20 
2    1      2     0    1.06  0.08   0.88  0.69  0.14 
2    2      3     0    0.97  0.08   0.91  0.81  0.17 
3    0      1     0    0.87  -0.03  0.79  0.61  0.00 
3    1      2     0    0.87  -0.03  0.79  0.61  0.00 
3    2      3     1    0.83  -0.14  0.95  0.57  -0.02

$\endgroup$

1 Answer 1

1
$\begingroup$

Judging from your data, you seem to have recurring time intervals and repeated IDs. If you presume that the different IDs and the different time intervals do not influence the outcome, you can use ordinary logistic regression, in R this is implemented e.g. in the function glm() from the stats package.

You can also use this function if you do presume some influences of the ID and the time interval on the outcome but presume those influences to be completely independent of each other. E.g. the data for ID 1 gives you no clue about the data for ID 2. Then you would simply add interaction terms with factors to your linear formula for glm, one factor with levels being the IDs and one with levels being the time intervals.

However, if you presume that the data for one ID are correlated with the data of other IDs, or similarly for time intervals, you want to consider random effect models, which are implemented in R e.g. in the glmm package.

There are further possibilities, but that should get you going.

$\endgroup$

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.