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
Creating treatment and control groups for regression modelThis is a continuation of my previous post Grouping values within a variable that Clyde Schechter ha…
Filling a time-invariant dummy variable down for new years in panel data after expanding a datasetHi I am looking to fill in missing observations for a dummy variable for firms (which each have an …
How to avoid duplicates using rangejoin?Hello everyone! My goal is matching firms from two datasets with minimum difference in their Market…
Transpose (rotating) data by group (variable)Dear all, I need to transpose my dataset so that I can calculate the pairwise correlation matrix fo…
Latent class analysis (LCA) plugin - assertion is false -errorHello, I've been trying to use the LCA plugin from Penn State for my analysis using Stata/IC. I succ…
Subscribe to:
Post Comments (Atom)
0 Response to Means around Switches in a Panel
Post a Comment