Dear users,
After a long time looking for a way to do it, I come to you as my last hope. I have a dataset in which students pick other students for their teams. There are two variables of interest: the gender of the individual picking and the gender of the individual pick. I want to plot in a graphic the probability of being selected depending on those two variables (so, the probability that a boy picks a boy and a girl, and the probability a girl picks a boy and a girl, 4 bars in total). I already achieved being able to count how many boys and grils each student picks, and therefore the probability of being picken. This is the graph I get:

Now I want to add the confidence intervals to that graph. I have already computed them with collapse, in the following way:
And this is how the data looks like:
The only problem now, is puttin those two things together. I have tried using the graph twoway command, but the result it gives is very weird, since I have not any additional variable to group them, so the two CI and the two bars for each variable of each gender stay on top of each other. I cannot for the sake of me figure out a way to add it, as simple as it may be.
If someone has some idea of how to do it, I would be extremely thankful.
After a long time looking for a way to do it, I come to you as my last hope. I have a dataset in which students pick other students for their teams. There are two variables of interest: the gender of the individual picking and the gender of the individual pick. I want to plot in a graphic the probability of being selected depending on those two variables (so, the probability that a boy picks a boy and a girl, and the probability a girl picks a boy and a girl, 4 bars in total). I already achieved being able to count how many boys and grils each student picks, and therefore the probability of being picken. This is the graph I get:
Code:
graph bar maleprobmean femaleprobmean, over(female)
Now I want to add the confidence intervals to that graph. I have already computed them with collapse, in the following way:
Code:
collapse (mean) maleprobmean = maleprob_team femaleprobmean = femaleprob_team (sd) sdmaleprob = maleprob_team sdfemaleprob = femaleprob_team (count) nmale = maleprob_team nfemale = femaleprob_team, by(female) generate himale = maleprobmean + invttail(nmale-1,0.025)*(sdmaleprob / sqrt(nmale)) generate lomale = maleprobmean - invttail(nmale-1,0.025)*(sdmaleprob / sqrt(nmale)) generate hifemale = femaleprobmean + invttail(nfemale-1,0.025)*(sdfemaleprob / sqrt(nfemale)) generate lofemale = femaleprobmean - invttail(nfemale-1,0.025)*(sdfemaleprob / sqrt(nfemale))
female | maleprobmean | femaleprobmean | sdmaleprob | sdfemaleprob | nmale | nfemale | himale | lomale | hifemale | lofemale |
Male | .2157536 | .0935449 | .1723743 | .129409 | 854 | 854 | .2273309 | .2041763 | .1022365 | .0848533 |
Female | .0963259 | .2172072 | .1362991 | .1678487 | 873 | 881 | .1053798 | .087272 | .228306 | .2061084 |
The only problem now, is puttin those two things together. I have tried using the graph twoway command, but the result it gives is very weird, since I have not any additional variable to group them, so the two CI and the two bars for each variable of each gender stay on top of each other. I cannot for the sake of me figure out a way to add it, as simple as it may be.
If someone has some idea of how to do it, I would be extremely thankful.
Comment