Consider the following simulation
Here we have 10000 hypothetical students, their GREs and GPAs, the former clustered around 150, the latter around 2.7. Suppose I want to create an intervention of sorts (i.e., tutoring), which will be a negative function of GPA and GRE- this makes sense, since 4.0 kids wouldn't need tutoring, and kids with 170s on their GREs denote the same. In other words, how would I assign a binomial variable, such that the better performing students are less likely to be assigned to the intervention of interest. This code appears to do what I want, but I was curious if anyone had a different, perhaps better approach? I'm trying my hand at model based inference, so I was curious if I was doing the right thing or not!
Code:
clear * set obs 10000 set seed 1066 g id =_n order id, first qbys id: g gpa = rnormal(runiform(1.5,4),.005) g gre = floor((gpa*10)+runiform(120,130)) g tutoring = (gpa*30) - (gre*10) cls // get the min and max of tutoring su tutoring, meanonly // create the rescales tutoring g tutorprob = ( tutoring - r(min) ) / ( r(max)-r(min) ) * 1
