I have a dataset that looks as follows. For each state, I know which individuals are accepted (acc = 1) or rejected (acc = 0) on the basis of two scores x and y. A want to say that a rejection is bad if there is an individual in that state that is accepted and that has worse scores on both x and y. I can compute this looping through states, accepted, and rejected candidates, see below. However, I was looking for suggestions on how to make the program more efficient.
gen obs = _n
gen bad = 0 if acc = 0
gen obs = _n
glevelsof state if acc == 1
local stloop "`r(levels)'"
foreach s in `stloop' {
glevels of obs if state == `s' & acc == 1
local accit "`r(levels)'"
glevelsof obs if fstate == `s' if acc == 0
local nsuit "`r(levels)'"
foreach i in `nsuit' {
foreach ac in `accit' {
if x[`i'] > x[`ac'] & y[`i'] > y[`ac'] {
replace bad = 1 if obs == `i'
continue ,break
}
}
}
}
Related Posts with Finding observations that are strictly dominated: how do I eliminate multiple loops
Cannot use python in Stata 16.1 in CatalinaCannot use python in Stata 16.1 in Catalina Today, 03:38 I have tried to solve the problem, but it …
Questions about "xtrifreg" - Unconditional quantile regression with fixed effects?Dear Statalists, (1) Can anyone help me check robustness for xtrifreg please? And how can I run sim…
Cannot use python in Stata 16.1 in CatalinaI have tried to solve the problem, but it seems to be stubborn. What to do? I installed the new vers…
Ologit: conditional marginal effect and semi-elastictyDear All, After estimating an ordered logit model, I want to to calculate and draw the plot of cond…
Questions about "xtrifreg" - Unconditional quantile regression with fixed effects?Dear Statalists, (1) Can anyone help me check robustness for "xtrifreg" please? And how can I run s…
Subscribe to:
Post Comments (Atom)
0 Response to Finding observations that are strictly dominated: how do I eliminate multiple loops
Post a Comment