# How to predict values in one variables using previous observations of another variable, when observation times are different across participants?

We have observations of individuals at various points in their life. We are curious if Variable A predicts later values of Variable B (i.e., if being high on A early on means you will be high on B later on). To give a concrete example, does the amount of calcium you drink predict later bone density?

The trick is that everyone was observed at different time points.

Here is some example data to help imagine what I mean.

Person  Age A   B
1       12  2   4
1       15  3   7
1       17  4   8
2       14  1   2
2       20  1   8


I know it will require a mixed effects model. But I'm unsure how to model the relationship between A and B.

My initial thought was to have each value of A predict the next observation of B. The problem is that there are different amounts of time passing between each observation for each person. Another thought would be to dichotomize the data. Perhaps take the median age across all individuals and then compute the averages of A and B for each person below and above that value. That's not ideal because it loses some data by averaging.