Such a table can be generated by Stata or another software. In the example below, you have a table with means and confidence intervals for 5 variables called x1, x2, x3, x4 and x5. This approach may also be applied if you prefer a first principles solution to a user-written program. This approach can be used if a table containing the means and the limits of the intervals is already available. Something like this may be supported in community-contributed commands such as coefplot, a wonderful command I never use.Next to this correct answer, I would like to add an alternative approach for Stata. Xtitle("Repair record 1978") ytitle(Price (USD)) legend(order(1 "Domestic" 2 "Foreign")) || rcap lb_price ub_price rep78_R if foreign = 1, lcol(orange) /// || rcap lb_price ub_price rep78_L if foreign = 0, lcol(blue) /// || scatter mean_price rep78_R if foreign = 1, c(L) lcol(orange) msym(Th) mcol(orange) /// Twoway scatter mean_price rep78_L if foreign = 0, c(L) lcol(blue) msym(Oh) mcol(blue) /// The offset idea no doubt has occurred to many people as what is often done in literature, but it was written up in this Stata Journal tip by James Cui. With four or more groups you often need to think harder. With say three groups to compare, I would shift one estimate left, one right and leave the third in the middle. Nor do I follow why you would want to insist on the same colour and marker symbol for two groups, but that may reflect some different logic or need of yours for your real problem. I dislike the parenthesis notation for different graph commands within the same command line, as there are quite enough parentheses already. In this example the offset is small enough and the range of the data is such that I get the x axis labels that make sense automatically, although in other problems you might need to spell out directly what you want. For paired estimates and confidence intervals I displace displays left and right. Stata doesn't support what you need directly within twoway graphics so some work setting up offsets is needed. Using the same seed wouldn't help even in principle. The graph would just look too much like a small child's drawing. Jittered spikes or capped bars for confidence intervals would just look a mess and they wouldn't be guaranteed to align with jittered markers for point estimates either. But it is documented that jitter() applies to points using scatter or graph matrix and if it applied elsewhere that would be documented explicitly.īut this isn't a cause for regret. The post you cite from 2007 isn't making a suggestion that jitter() isn't allowed with twoway rcap: it's correctly stating that as a fact. (rcap lb_price ub_price rep78 if foreign = 1, ///Ĭ(L) lcol(black) msym(O) mcol(black) jitter(10) jitterseed(123)) ///Ĭ(L) lcol(black) msym(O) mcol(black) jitter(10) jitterseed(456)) /// (rcap lb_price ub_price rep78 if foreign = 0, /// (scatter mean_price rep78 if foreign = 1, /// Twoway (scatter mean_price rep78 if foreign = 0, ///Ĭ(L) lcol(black) msym(O) mcol(black) ) /// Gen ub_price = mean_price + invttail(n_price-1,0.025)*(sd_price / sqrt(n_price)) Gen lb_price = mean_price - invttail(n_price-1,0.025)*(sd_price / sqrt(n_price)) (count) n_price = price, by(foreign rep78) * Generate required statistics by repair record and foreign I am open to solutions that plot CIs around means using a plotting command other than rcap. I can't find reference to the jitter option in the current rcap documentation, so I assume this is still the case. This post on Statalist from 2005 suggests that rcap does not support jitter. I had hoped that by using the jitterseed option with the same seed, I would be able to offset both the marker from scatter and the CIs from rcap to the same location on the plot. It accepts the option, there is no error, but it does not jitter the CIs. While this works for scatter, it does not appear to work for rcap, which I am using to plot the CIs. I tried to use the jitter option to randomly offset the points on the plot. However, it is difficult to distinguish between the CIs when they overlap, even if I use different colours or line styles. I am trying to create a plot that has a mean values over time, and associated confidence intervals (CIs), for two groups ( foreign=0 and foreign=1) using twoway scatter and rcap.