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
xtgraphI am trying to use -xtgraph- to plot cross-sectional mean and sd of a variable in a panel dataset. H…
Generate a new binary variable from different variables in a datasetHello everyone, I have a dataset with many “employment status” variables, such as full-time job is c…
ebmeans with imputed data?Is there a way to calculate ebmeans with mi data? Trying to get a "mean" of a latent variable that I…
Cpoisson LSDVMy outcome is counts left-censored at y<1000. I have panel data and want to run a model with fixe…
Estimate Cohen´s (d) for within-subjects?Dear all, Which is the right formula for Cohen´s (d) for within-subjects? There are many formulas a…
Subscribe to:
Post Comments (Atom)
0 Response to Finding observations that are strictly dominated: how do I eliminate multiple loops
Post a Comment