I am graphing a continuous variable, lets say BMI, among two groups, lets say Black/African American, with a "before" and "after". I am not yet at the point where I figured out how to get the two groups with the before and after values on the graph. But before that, I need to figure out how to at least do one. Since this is not published data, I am using dummy data. I started with -stripplot- since it seems to have more functionality than -dotplot-.
This code works for generating the graph below:
I tried adding in standard error bars, but starting first with just standard deviation for coding simplicity at this point. I tried with the -addplot- option and -rcap- but can't seem to get it to work.
Returns the error:
Other lingering questions:
This code works for generating the graph below:
Code:
stripplot AgeAtEnrollment , over (BlackAficanAmerican) stack centre vertical refline(lw(medium black)) reflevel(mean) xla(, noticks) xla(, nogrid) yla (,nogrid)
Code:
ci variances BMI if BlackAficanAmerican == 1, sd local b_lsdv = r(sd)*-1 local b_usdv = r(sd) ci variances BMI if BlackAficanAmerican == 0, sd local w_lsdv = r(sd)*-1 local w_usdv = r(sd) stripplot BMI , over (BlackAficanAmerican) stack centre vertical refline(lw(medium black)) reflevel(mean) xla(, noticks) xla(, nogrid) yla (,nogrid) addplot (rcap `b_lsdv' `b_usdv' BMI if BlackAficanAmerican==1) addplot (rcap `w_lsdv' `w_usdv' BMI if BlackAficanAmerican==0)
Code:
option addplot() not allowed r(198);
- How do I bring the two groups closer together? The blank space is not useful
- How can I spread the dots out if they are overlapping? Like how -dotplot- with the -center- option functions. In my code above -center- does not seem to do this.
- Ultimately, I would like the "before" and "after" paired comparison within each factor (Non-black and Black) to be close to each other, but farther from the other paired comparison
Comment