Improved Nice, Quick, Effective Sampler in R
I found a problem with the sampler I was using last week. It is an uncontrolled random sampler, which presents some problems when doing choice modeling.
To deal with the issue, I created a better one. This version is a stratified random sampler that samples from each income and auto group (which I need to have samples in all income/auto groups in order to develop and test my auto ownership model). The sampling process works like this:
- If there are more than 10 samples for an income/auto group, sample using last week's random method
- If there is at least 2 but not more than 10 samples, pick a random sample to be tested, put the rest into the develop group
- If there is 1 sample, put it in both
- If there are no samples in the group, print an error to the screen
The code is below: