Mixed effects modeling using R with time varying predictors I have a data set where the response (dependent) variable measured only at a single time point. However the predictors can be both longitudinal as well as measured at a single time point. Here is an reproducible example :
dat <- data.frame(
  id=rep(1:100),
  y = rbinom(n = 100, size = 1, prob = 0.45),
  x_cat = as.factor(rbinom(n = 100, size = 1, prob = 0.2)),
  x1_w1 = rnorm(n = 100, mean = 10, sd = 7),
  x1_w2 = rnorm(n = 100, mean = 10, sd = 7),
  x2_w1 = as.factor(rbinom(n = 100, size = 1, prob = 0.4)),
  x2_w2 = as.factor(rbinom(n = 100, size = 1, prob = 0.48))

)

> head(dat)
  id y x_cat     x1_w1     x1_w2 x2_w1 x2_w2
1  1 0     0 12.592883 14.124617     1     0
2  2 1     1 10.615650 12.672418     0     0
3  3 1     0 10.597431 21.168571     0     0
4  4 1     0  4.338312  5.257146     0     0
5  5 1     0  9.671094  5.704907     0     0
6  6 1     0 19.468497  6.862050     0     0

So for each id , there is a binary response y , a categorical predictor  x_cat which measured only at a single time point. 
Also x1 is a longitudinal (time varying) continuous predictor which measured at two time points (x1_w1 , x1_w2) and x2 is a longitudinal (time varying) categorical predictor which measured at two time points (x2_w1 , x2_w2).
Basically I need to create a prediction model to predict y based on the predictors.Since there are longitudinal predictors , the standard logistic regression using glm may not be suitable . Because longitudinal predictors and correlated with each other.
So based on the resources I followed , I think that the most suitable alternative is the mixed model approach. May be using glmer or lmer functions in lme4 package.
I referred this example which is quite relevant to my situation. it is recommended in there too:
https://www.researchgate.net/post/How_to_estimate_time_dependent_covariates_effects_in_logistic_regression
There are lot of examples of how to use this lme4 package when the response variable is also longitudinal.But i couldn't find any suitable tutorial/example when the response is measured at only one time point like in my situation.
So can any one help me to figure out how to apply lme4 or (any suitable package) to my situation ? 
Any help would be highly appreciated.
Thank you 
 A: With 2 potentially time-varying predictors measured at the same 2 time points for all cases (except for some missing values*) but only one time point for determining outcome, you don't have a serious problem. The trick will be in using your knowledge of the subject matter to come up with the best way to incorporate those values into the model.
Yes, the 2 values of a predictor at different time points are likely to be correlated, but correlated predictors occur all the time in practice in regression. Those don't pose the same problems as the multiple correlated outcomes that must be dealt with in repeated measures designs or time-series analysis.
One danger in just including the 2 measurements as separate fixed effects, however, is what can happen with multicollinearity among predictors: sometimes neither of a pair of highly correlated predictors is found to be "significant" due to high variance in the individual regression coefficient estimates, even though they are truly associated with outcome. So you are wise to think about ways to deal with that. 
How best to include those 2 values of the 2 predictors into the model thus depends on your understanding of the subject matter. Do you think that the outcome will depend primarily on the value measured closest to the outcome time, on their average (for the continuous predictor), or maybe on their rate of change (or difference for the categorical predictor)? Your answer to that question will point the way.
I've bounced back and forth in thinking about whether a mixed-effects model would be helpful here. As I type this I'm leaning against it. The choice of mixed-effects model would also depend on whether nearest-in-time, averages, or differences of predictor values are what matters to outcome, and without multiple correlated outcomes I don't see much to be gained from a mixed model in this case.

*See questions tagged data-imputation for ways to deal with missing values. Multiple imputation is probably the most reliable in general, but simpler methods might work for you.
