How to test differences of three categories within the same individuals? Suppose I can observe $Y_{ijt}$,  $i = 1,2,..., n$ , $j  = 1,2,3$ and $t = $ 3 weeks, 1 months, half a year and one year.
I am interested in whether

*

*$E(Y|j=1,k) = E(Y|j = 2,k)= E(Y|j=3,k)$

*$E(Y|j, k) = \alpha_j + \beta_j k $
At first, I thought it was a simple question that I can simply use ANOVA for different periods of time in the first case, and for the second I can run simple linear regression at given $j = 1,2,3$. Yet I realized that for each individual $i$ at given time period $t = k$, $Y_{i1k}$, $Y_{i2k}$ , $Y_{i3k}$ are likely correlated, which render ANOVA ineffective. I am what kind of model should I build to tackle these two questions that I want to tackle?

You can account for the covariance between time periods by using multilevel modeling. Marginal models directly model the population mean, so they may be most useful for you in this question of interest.
You could fit a marginal model such as this one (I'm assuming you meant t when typing k) and conduct the appropriate tests on coefficients.
$E(Y) = \beta_1 + \beta_2 I(j = 2) + \beta_3 I(j = 3) + \beta_4 t + \beta_5 I(j = 2) t + \beta_6 I(j = 3)t$
Marginal models can be fit using the nlme package (or gee for non-identity link functions) in R or PROC MIXED (PROC GENMOD for non-identity link functions) in SAS.
