Generalized difference-in-difference model in panel data By "generalized", I mean the circumstance where I have more than 2 periods of time and 2 treatment groups whereas the typical  D-I-D model involes just 2 periods, 1 treatment group and 1 control group. Moreover, an individual may jump between these treatment groups, say some observations may fall in treatment group A in period t but falls in treatment group B or control group in period t+1.
    Are there any methods or models particularly that can solve the problem like this?
 A: The most common generalization is as follows (here I am following Bertrand et al. (2004), but for example Hansen (2007) also considers a similar approach):

Let $Y_{ist}$ be the outcome of interest for individual $i$ in group $s$ (such as a state) by time $t$ (such as a year) and $I_{st}$ be a dummy for whether the intervention has affected group $s$ at time $t$. One then typically estimates the following regression using OLS:
$Y_{ist}=A_s+B_t+cX_{ist}+\beta I_{st}+\epsilon_{ist}$
where $A_s$ and $B_t$ are fixed effects for states and years, respectively, $X_{ist}$ are relevant individual controls and $\epsilon_{ist}$ is an error term. The estimated impact of the intervention is then the OLS estimate $\hat \beta$.

When you have panel data the model is conceptually similar, but now you would typically consider individual fixed-effects. See Hansen (2007) -and also be aware of the autocorrelation issues-.
Imbens and Wooldridge (2008) provide a good overview and useful references for your question. They also have similar lecture notes focusing in difference-in-differences methods (http://www.nber.org/WNE/lect_10_diffindiffs.pdf).
Bertrand, M., Duflo, E. & Mullainathan, S. (2004). How Much Should We Trust Differences-In-Differences Estimates? The Quarterly Journal of Economics, 119(1), 249–275.
Hansen, C., (2007), “Generalized Least Squares Inference in Panel and Multilevel Models with Serial Correlation and Fixed Effects,” Journal of Econometrics.
Imbens, G. & Wooldridge, J. M. (2008). Recent developments in the econometrics of program evaluation.
