Oct 7, 2014

Random graphs (32): Dot plot with confidence intervals

// Read in data points
input str50 variable_str coeff se
"Discrimination in being hired" .18 .08
"Vocational index" 1.97 .53
end

// Switch to numeric
encode variable_str, gen(variable) 

// Create variable for -by-
recode variable (1 = 2 "Model 2") (2 = 1 "Model 1"), gen(model)

// Calculate 95 % CI's
gen loci = coeff - 1.96 * se
gen hici = coeff + 1.96 * se

twoway (dot coeff variable, by(model, legend(off) note("")) ///
                               horizontal dotextend(no)) ///
       (rcap hici loci variable, horizontal) ///
       , legend(off) ylabel(1/2, valuelabels) ///
         xline(0) ytitle("") ///
         ysize(4) yscale(range(0 3))