Hi,
I have an unbalanced panel and I need to compute variable B in year t as the variance of variable A in t-1, t-2, and t-3. In other words, I need to calculate a variable based on rolling windows of the past three years.
I believe my starting point should be the following:
tsset ID year
by ID: egen B = var(A)
However, I need to ask Stata to take into account the values of variable A only for t-1, t-2, and t-3. Any help would be much appreciated.
Thanks,
Giuseppe
I have an unbalanced panel and I need to compute variable B in year t as the variance of variable A in t-1, t-2, and t-3. In other words, I need to calculate a variable based on rolling windows of the past three years.
I believe my starting point should be the following:
tsset ID year
by ID: egen B = var(A)
However, I need to ask Stata to take into account the values of variable A only for t-1, t-2, and t-3. Any help would be much appreciated.
Thanks,
Giuseppe
Comment