Modeling Contextual Effects in Longitudinal Studies