Dear STATALIST Community,
I have an unbalanced panel, where individual status changes within groups. I want to compute mean score within plus/minus two periods whenever the status changes.
I tried to follow Cox (2002) and Cox (2011) and am able to determine switch using obs id [_n-1] but can't think of a way how to compute means around switches. I am attaching data file for your consideration.
For example, id 1’s status changes in year 2003, I would like to compute mean score within two pre-switch years, 2001 and 2002, and within two post-switch years, 2003 and 2004. The status changes again in year 2006, I now need to compute mean score within two pre-switch years -2004 and 2005 – and within two post-switch years - 2006 and 2007. Further, Id 2’s status changes in 2002, which has only one pre-switch year but two post-switch years. Likewise, the status changes again in 2007, with two pre-switch years and only one post-switch year.
Any help/guidance would be helpful!
Best wishes
Mg
Related Posts with Means around Switches in a Panel
Difficulty working with time variableHi, I thought I had cracked this but seemingly not: After having trouble importing variables conta…
Plotting GraphGood day, Please.!!! I need help with regard to the following; 1. How to plot a U-shape graph and 2.…
clogit interaction termsHi, Please can you advise how to do this code correctly. I want to run the clogit command within a …
Fixed Effects - different results reporting from xtreg,fe and xi commandsWould it be possible for someone to outline how the two approaches I have used differ, and which is …
Mediation with panel data (Stata version 12)Dear all, I would like to do a mediation analysis with panel data. This is the first time I conduct…
Subscribe to:
Post Comments (Atom)
0 Response to Means around Switches in a Panel
Post a Comment