Can logistic regression be used when the dataset has observations from the same users but are unique per day I have a dataset that captures user information by day (the users are unique per day but often have observations on multiple days) and I want to analyze a binary outcome.
Is there a more appropriate model than logistic regression or can I control for date or user?
How can I do so? This is what I have in Python as you can see the model fit is not ideal. I did not include user or date in my model.
model = smf.logit('flag~C(variable1)+variable2+variable3+C(variable4)',data=df).fit()


Logit Regression Results
Dep. Variable:  cflag   No. Observations:   1402311
Model:  Logit   Df Residuals:   1402304
Method: MLE Df Model:   6
Date:   Fri, 02 Oct 2020    Pseudo R-squ.:  0.02904
Time:   13:39:03    Log-Likelihood: -5.6997e+05
converged:  True    LL-Null:    -5.8702e+05
Covariance Type:    nonrobust   LLR p-value:    0.000

`` 

 A: If you have multiple observations on the same individual then the assumption of independence among observations no longer holds. You need to control for user in that case. Whether you also control for date depends on your understanding of the subject matter.
For a logistic model that can be done with a mixed-effects model, in which you keep track of the individual associated with each observation while some aspects of the model are allowed to vary among individuals. The simplest is modeling a random distribution of individual-specific intercepts that represent the log-odds at the (possibly hypothetical) baseline covariate conditions, while influences of covariates beyond the baseline are fixed, assumed to be the same for all individuals. The combination of random and fixed effects makes it a mixed-effects model. There are over 4000 threads on this site that are tagged mixed-model.
If you think that there is a systematic change in the log-odds of an outcome over time, then you could add a measure of that time as a predictor. Depending on the nature of your data, you might better handle event occurrence over time with a survival model.
