# Multiple measurements within groups test

I am measuring the X, Y, Z variables of i subjects in k states, and for each subject and state i am taking j measurements. What is the proper way to test for differences between the k states?

It seems likes a one way repeated measure ANOVA problem, however how should I deal with the fact that in each subject and within each state i take j measurements of X, Y, Z? Should I take the mean of the Xj, Yj, Zj within each subject and state and with this mean do a one way repeated measures ANOVA?

Many thanks?

I think you want a mixed model (aka multilevel model, hierarchical linear model, etc). Instead of modeling $Y = XB + e$ with $e \sim \mathcal{N}(0, \sigma)$ these model $Y = XB + Z\gamma + e$