# Multilevel Modeling: Clustering by both individual and time, is this okay?

I'm trying to run a multilevel model where I have approximately 30 individuals and anywhere from 20-50 time points per individual. I can cluster them by the individual since the dataset is longitudinal in nature, but there's also reason to believe that each time point is different from the others due to changing environments. With this in mind, would one double-cluster by both individual and time? Or would this introduce biases in the parameter estimates?

I'm not well-versed in multilevel models so I'm not sure if just clustering by individual is enough to account for changing environments associated with time (in my case, every individual is subjected to the same changes).

I already tried running the model with double-clusters and the model runs perfectly fine, so there isn't any issue as stated in this question here. However, I'm just concerned that whatever results I am getting is biased or has errors in it.

Depending on your predilection, you could use either a fixed or random effects specification for this model. If you are more on the econometric side, you would probably use fixed effects (see this previous CV post). If not, then you would use a cross-classified random effects model. This model treats individual and time as "error terms," which are uncorrelated random intercepts, with means of 0 and estimated variances. The random intercept for year is shared by all individuals whereas the random intercept for individuals is shared across all years for a given individual. The individual by year interaction is absorbed into the level-1 residual error $$e_{ij}$$. You can further create a random intercept for the interaction of individual by year and use likelihood ratio testing to determine whether the model with this random interaction effect fits better than the model with just the two main effect random intercepts.