Hi Statalist,
I am currently working with a panel dataset that contains grade levels (K1 to K4) (variable "grade_self"). My outcome of interest is "GPA" (values 1 to 5) and my treatment variable is "treatment" (values 0 and 1). I want to use the "regress" command to calculate first-differences between two consecutive grade levels. Currently my regression command (without controls) looks like this:
For a sub-analysis, I want to calculate the treatment effect only for certain cases. For this purpose, I have created a new variable named "matched":
With this variable, I marked some of the classes in certain grade levels with a 1. (The condition for this is that the number of removed class repeaters matches the observed change in class size). Classes can potentially receive a 1 at any grade level above K1 and more than once. I have coded it so that classes receive a 0 in the corresponding previous year before they are marked with "1" (if they are not marked with "1" already) and would now like to calculate the first-difference from 0 to 1. However, it can happen that "1->0" transitions occur in the panel data set. For example:
Class A:
In this example, it is important to me that Stata only calculates the first-difference between K1 and K2 (0->1) and the first-difference between K3 and K4 (0->1). However, no first-difference between K2 and K3 (1->0) should be calculated. However, I also want Stata to calculate the first-difference between two grade levels of a class that both receive a 1 in the "matched" variable, as in Class B:
Class B:
So in class B, I would like to calculate first-differences between K2 and K3, and between K3 and K4.
In summary, I want to analyze all "0->1" and all "1->1" transitions, but never a "1->0" transition. My question is how I can implement this in Stata. I am very grateful for any help!
I am currently working with a panel dataset that contains grade levels (K1 to K4) (variable "grade_self"). My outcome of interest is "GPA" (values 1 to 5) and my treatment variable is "treatment" (values 0 and 1). I want to use the "regress" command to calculate first-differences between two consecutive grade levels. Currently my regression command (without controls) looks like this:
Code:
reg D.(GPA treatment), noconstant
Code:
bys ID_t (wave): gen matched = . bys ID_t (wave): replace matched = 1 if ((L.class_size_teacher - L.number_repeater_removals) == class_size_teacher) & ((L.grade_self + 1) == grade_self) & !missing(class_size_teacher, L.class_size_teacher, L.number_repeater_removals, LID) bys ID_t (wave): replace matched = 0 if F.matched==1 & matched==.
Class A:
| K1 | 0 |
| K2 | 1 |
| K3 | 0 |
| K4 | 1 |
Class B:
| K1 | . |
| K2 | 0 |
| K3 | 1 |
| K4 | 1 |
In summary, I want to analyze all "0->1" and all "1->1" transitions, but never a "1->0" transition. My question is how I can implement this in Stata. I am very grateful for any help!

Comment