I am interested in simulating data in which two factors are partially as opposed to fully crossed.
In data with fully crossed factors, all individuals are exposed to all cases of the other factor. An example of this would be a psychology study in which individual raters (factor 1) view the same set of targets (factor 2). Say there are 10 targets total. Each rater views all 10 targets. Simulating such fully crossed data has been shown in presentations by Isabel Canette (StataCorp) here and Joseph Coveney in this thread.
The simulation I'm currently trying to figure out is the partially crossed case. Going back to the psychology study example, say rater 1 views targets 1-4, rater 2 views targets 3-6, rater 3 views targets 5-8, rater 4 views targets 7-10, rater 5 views targets 1-2 and 6-7. With this few raters, it is easy enough to code up, but beginning to be tricky b/c you have to code each rater separately:
My question how do I generalize the code such that I can simulate a partially crossed structure for hundreds of individual raters and 50+ targets. Is there a way to narrow the possibilities (e.g., 30% of raters share at least two targets) to make the coding more tractable?
Any insights are greatly appreciated.
In data with fully crossed factors, all individuals are exposed to all cases of the other factor. An example of this would be a psychology study in which individual raters (factor 1) view the same set of targets (factor 2). Say there are 10 targets total. Each rater views all 10 targets. Simulating such fully crossed data has been shown in presentations by Isabel Canette (StataCorp) here and Joseph Coveney in this thread.
The simulation I'm currently trying to figure out is the partially crossed case. Going back to the psychology study example, say rater 1 views targets 1-4, rater 2 views targets 3-6, rater 3 views targets 5-8, rater 4 views targets 7-10, rater 5 views targets 1-2 and 6-7. With this few raters, it is easy enough to code up, but beginning to be tricky b/c you have to code each rater separately:
Code:
clear* set version 16 set seed 1357 set sortseed 793 * raters (rid) set obs 5 // number of raters gen rid = _n // rater identifier *targets (tid) expand 4 replace tid = _n-2 if rid==2 replace tid = _n-4 if rid==3 replace tid = _n-6 if rid==4 replace tid = _n-16 if rid==5 replace tid = _n-13 if rid==5 & rating_num>=3
Any insights are greatly appreciated.
Comment