Random Response Unit

The text refers to two TrueBasic programs to simulate a random survey. The same simulation can be done in MATLAB using the scripts below. Just save the scripts to your work space, and then let MATLAB know that this is the directory where you want it to look for them. The names below are like the names in the text, but of course you can save them under any convenient name, and then refer to them that way -- just be sure that they have the file extension .m

ran1resp.m expects you to define three variables before running it:

ran2resp.m works the same way as ran1resp.m, but allows you to define an Estimate of the true fraction of yes people. It reports an estimate for the bias in your estimate(!) The bias is the average difference of your estimate from the true fraction of yes people. It cannot report the true bias, but only an estimate of it based on NRep simulations. You can add lines to look at other things, such as the distribution of the reported estimates of bias.