Hello,
First of all, I found that due to bug, I had multiple posts/replies regarding the similar questions in this forum and sorry for the mess and confusion.
Now, in stata, I am trying to do robustness checks of outliers (or extreme values) by group and I am encountering issues with its implementation.
First, I would like to trim/winsorize by group using this code:
however, the error says:
. when i try only
this, it works perfectly fine but I wanted to do it by group. Could someone help me with this?
Second, I am running multiple regressions with panel data (that has multiple countries/sectors/years). and I would like to ensure that for each file the regression for different LHS are based on the common sample (i.e. ensure that results across LHS are not driven by differences in sample). For instance, if I say i have list of LHS: var1 var2 var3, then all three variables are missing if either var1 or var2 or var3 is missing. This way it doesn't depend on the fixed effects and i should get a consistent sample. And by doing this i can check that you are not loosing too many observations at the same time. Having this in mind, I wanted to implement this method but i don't have much idea how to actually make them in Stata code. Maybe someone could give me any insights on the structure/code that I can use, please?
Thanks so much in advance!
First of all, I found that due to bug, I had multiple posts/replies regarding the similar questions in this forum and sorry for the mess and confusion.
Now, in stata, I am trying to do robustness checks of outliers (or extreme values) by group and I am encountering issues with its implementation.
First, I would like to trim/winsorize by group using this code:
Code:
foreach var in `varlist' { bys group: replace `var' = `r(p1)' if `var' < `r(p1)' bys group: replace `var' = `r(p99)' if `var' > `r(p99)' }
Code:
"if not found"
Code:
foreach var in `varlist' { replace `var' = `r(p1)' if `var' < `r(p1)' replace `var' = `r(p99)' if `var' > `r(p99)' }
Second, I am running multiple regressions with panel data (that has multiple countries/sectors/years). and I would like to ensure that for each file the regression for different LHS are based on the common sample (i.e. ensure that results across LHS are not driven by differences in sample). For instance, if I say i have list of LHS: var1 var2 var3, then all three variables are missing if either var1 or var2 or var3 is missing. This way it doesn't depend on the fixed effects and i should get a consistent sample. And by doing this i can check that you are not loosing too many observations at the same time. Having this in mind, I wanted to implement this method but i don't have much idea how to actually make them in Stata code. Maybe someone could give me any insights on the structure/code that I can use, please?
Thanks so much in advance!
Comment