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
-margins- . *(not estimable)Hi folks, I could not get outputs after -margins. Following are estimations followed by -margins- o…
Fixed effect or first differencegen gr_rate = D.lnuclms reg lnunclms ez y1982-y1988 Given this model, either the within transformati…
Problem with #delimitI am unable to use the delimit command. Asking for help with Code: help delimit Gives the follow…
Reshape data to long - no stub, time in long formatDear all, I have a dataset in a bit oddly shaped. The time (the data is hourly for 30 years) is alr…
Removing middle of a string between certain charactersHello Statalist, I have a string variable which is interspersed with HTML tags (e.g. "<br>" o…
Subscribe to:
Post Comments (Atom)
0 Response to Means around Switches in a Panel
Post a Comment