**Disaggregating Between and Within Person Effects** created on 3/22/24 by Maria Perica While cross-sectional data is able to tell us about between-person effects, only longitudinal data can provide information about within-person effects. It is important to note that between-person effects do not necessarily generalize to within-person effects - classic example: at the between-person group level, people are more likely to have a heart attack if they exercise less, but at the within-person level, //you// are more likely to have a heart attack while exercising than just chillin'. Two important things to consider when building these models: variable centering and detrending. Centering is important here, even when variables do not vary over time, but if variables vary over time then detrending also becomes important. __Centering__ * Centering is usually a straightforward thing - subtract the mean from your values! But it becomes complicated in multi-level models because there are multiple means you can be referring to (grand mean vs group/person-centered mean) * Generally three options re: centering in multi level models with longitudinal data. Option 1: don't. Option 2: grand-mean center aka average across the whole group/all timepoints and subtract from every variable datapoint. Option 3: person-mean center aka average across a person's timepoints and subtract their person-specific mean from their data. __ Detrending aka controlling for the effect of time__ * Couple ways to do this depending on which variables you think could be varying with time * Option 1: detrend nothing, Option 2: detrend only the predictor, Option 3: detrend predictor and outcome * There appears to be much debate on how to do this properly and whether you should detrend predictor, outcome or both. * At least one paper recommends just including a 'time' representing variable in your model and that does about as well as multi-step detrending processes (Wang & Maxwell,2015) * In our data, one way to do this is could be add 'visit number' into models as covariate (this would detrend your outcome variable) Sources: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3059070/, https://pubmed.ncbi.nlm.nih.gov/25822206/, https://centerstat.org/centering/