Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using model estimates when plotting bar graphs to display significance and CIs

    Hi all,

    I'm analysing results of a discrete choice experiment to understand predictors of choice for different types of psychologist visits vs choosing to go without a visit. I have used estimates from a mixed logit model to predict how changes to different attributes (e.g., visit costs, wait times etc.) from a given base level would affect uptake of visits (e.g., if visit costs increase from $50 to $90, by what percentage would the preference for a visit go down). I want to then show these changes in uptake relative to the base case in a bar chart, for changes of different attributes. Not all coefficient estimates from the mixed logit model are significant, and therefore I want to use a different colour in the bars for predicted uptake changes derived based on insignificant coefficients, and use an option like rcap to display confidence intervals as a measure of prediction uncertainty.

    I suspect I would need locals to recall the saved estimates from the model and feed this information into the changes derived in uptake relative to the base level? I'm not familiar with using locals and would appreciate some advice on how to approach this. I have included some code used to estimate the model (here I've used a multinomial logit which takes a shorter time to run and reduced the number of variables) and code for predicting a change in uptake when the cost changes, along with a sample dataset. This illustrates just one case for simplicity, but in the actual analysis I would have the levels of different attributes changing, some of which are based on insignificant estimates which I want to differentiate from the significant ones. I'm unsure of how to recall the model estimates and link them to the prediction uptake changes derived, and then display these in the graph.

    Any help with this task would be greatly appreciated.

    Many thanks.

    Code:
    decode alt, gen(alt1)
    destring id_cset, replace
    
    *Model estimates
    global X base_visitIPM base_visitTH base_urbanTH time_cont wait_cont wait_qd cost_cont hub1 first_th1
    clogit y ASC_IP ASC_MIX ASC_TH $X, group(id_cset) vce(cluster id)
    est save mnl, replace
    
    keep if set==1
    
    *Replace all effects with zeros
    foreach x in $X {
        replace `x'=0
    }
    
    *Set levels to base case 
    replace time_cont=0.5 if (alt1=="IP"|alt1=="Mix")
    replace wait_cont=0.75 if alt1~="None"
    replace wait_qd=wait_cont*wait_cont if alt1~="None"
    replace cost_cont=50 if alt1~="None"
        
    *Generate predictions for base case 
    predict basecase
    
    *Cost changes from $50 to $90 for in-person visits
    replace cost_cont = 90 if alt1=="IP"
    predict cost90
    
    *Change in uptake predictions relative to basecase
    gen dcost=cost90-basecase
    
    *Calculate average difference
    egen cost_up_ip=mean(dcost) if alt==1
    egen cost_up_mix=mean(dcost) if alt==2
    egen cost_up_th=mean(dcost) if alt==3
    egen cost_up_none=mean(dcost) if alt==4
    gen cost_uptake=cost_up_ip if alt==1
    replace cost_uptake=cost_up_mix if alt==2
    replace cost_uptake=cost_up_th if alt==3
    replace cost_uptake=cost_up_none if alt==4
    drop cost_up_ip-cost_up_none
    keep if id==1
    
    *Bar graph for change in opt-out (going without visit) when cost increases from $50 to $90
    graph hbar (mean) cost_uptake if alt==4

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input float id byte set int id_cset byte alt str4 alt1 float(y ASC_IP ASC_MIX ASC_TH base_visitIPM base_visitTH base_urbanTH time_cont wait_cont wait_qd cost_cont hub1 first_th1)
     1 1  11 1 "IP"   0 1 0 0 0 0 0 2.5   2     4 120 0 0
     1 1  11 2 "Mix"  0 0 1 0 1 0 0 1.5   2     4  90 0 1
     1 1  11 3 "TH"   1 0 0 1 0 0 0   0   5    25  50 0 0
     1 1  11 4 "None" 0 0 0 0 0 0 0   0   0     0   0 0 0
     1 2  12 1 "IP"   0 1 0 0 1 0 0 1.5   9    81  50 0 0
     1 2  12 2 "Mix"  0 0 1 0 0 0 0 1.5 .75 .5625 120 1 0
     1 2  12 3 "TH"   1 0 0 1 0 0 1   0   5    25  50 1 0
     1 2  12 4 "None" 0 0 0 0 0 0 0   0   0     0   0 0 0
     1 3  13 1 "IP"   1 1 0 0 1 0 0 1.5   5    25   0 0 0
     1 3  13 2 "Mix"  0 0 1 0 1 0 0 2.5 .25 .0625 120 0 0
     1 3  13 3 "TH"   0 0 0 1 0 0 1   0 .75 .5625 120 0 0
     1 3  13 4 "None" 0 0 0 0 0 0 0   0   0     0   0 0 0
     1 4  14 1 "IP"   0 1 0 0 0 0 0 3.5 .75 .5625 120 0 0
     1 4  14 2 "Mix"  0 0 1 0 1 0 0  .5 .25 .0625   0 0 1
     1 4  14 3 "TH"   1 0 0 1 0 1 0   0 .25 .0625   0 0 0
     1 4  14 4 "None" 0 0 0 0 0 0 0   0   0     0   0 0 0
     1 5  15 1 "IP"   0 1 0 0 1 0 0 1.5   2     4 120 0 0
     1 5  15 2 "Mix"  0 0 1 0 1 0 0 1.5   2     4  50 1 0
     1 5  15 3 "TH"   1 0 0 1 0 1 0   0   2     4  50 1 0
     1 5  15 4 "None" 0 0 0 0 0 0 0   0   0     0   0 0 0
     1 6  16 1 "IP"   0 1 0 0 0 0 0 2.5   5    25  90 0 0
     1 6  16 2 "Mix"  0 0 1 0 1 0 0  .5   2     4  90 0 1
     1 6  16 3 "TH"   0 0 0 1 0 0 0   0 .25 .0625  90 0 0
     1 6  16 4 "None" 1 0 0 0 0 0 0   0   0     0   0 0 0
     1 7  17 1 "IP"   0 1 0 0 1 0 0  .5   9    81  50 0 0
     1 7  17 2 "Mix"  1 0 1 0 0 0 0 3.5   5    25   0 1 1
     1 7  17 3 "TH"   0 0 0 1 0 0 0   0 .75 .5625 120 1 0
     1 7  17 4 "None" 0 0 0 0 0 0 0   0   0     0   0 0 0
     1 8  18 1 "IP"   0 1 0 0 0 0 0 1.5   2     4  90 0 0
     1 8  18 2 "Mix"  1 0 1 0 0 0 0  .5   2     4  50 1 1
     1 8  18 3 "TH"   0 0 0 1 0 0 0   0 .75 .5625  90 1 0
     1 8  18 4 "None" 0 0 0 0 0 0 0   0   0     0   0 0 0
     2 1  21 1 "IP"   1 1 0 0 0 0 0 2.5   2     4 120 0 0
     2 1  21 2 "Mix"  0 0 1 0 1 0 0 1.5   2     4  90 0 1
     2 1  21 3 "TH"   0 0 0 1 0 0 0   0   5    25  50 0 0
     2 1  21 4 "None" 0 0 0 0 0 0 0   0   0     0   0 0 0
     2 2  22 1 "IP"   0 1 0 0 1 0 0 1.5   9    81  50 0 0
     2 2  22 2 "Mix"  1 0 1 0 0 0 0 1.5 .75 .5625 120 1 0
     2 2  22 3 "TH"   0 0 0 1 0 0 1   0   5    25  50 1 0
     2 2  22 4 "None" 0 0 0 0 0 0 0   0   0     0   0 0 0
     2 3  23 1 "IP"   0 1 0 0 1 0 0 1.5   5    25   0 0 0
     2 3  23 2 "Mix"  1 0 1 0 1 0 0 2.5 .25 .0625 120 0 0
     2 3  23 3 "TH"   0 0 0 1 0 0 1   0 .75 .5625 120 0 0
     2 3  23 4 "None" 0 0 0 0 0 0 0   0   0     0   0 0 0
     2 4  24 1 "IP"   0 1 0 0 0 0 0 3.5 .75 .5625 120 0 0
     2 4  24 2 "Mix"  1 0 1 0 1 0 0  .5 .25 .0625   0 0 1
     2 4  24 3 "TH"   0 0 0 1 0 1 0   0 .25 .0625   0 0 0
     2 4  24 4 "None" 0 0 0 0 0 0 0   0   0     0   0 0 0
     2 5  25 1 "IP"   1 1 0 0 1 0 0 1.5   2     4 120 0 0
     2 5  25 2 "Mix"  0 0 1 0 1 0 0 1.5   2     4  50 1 0
     2 5  25 3 "TH"   0 0 0 1 0 1 0   0   2     4  50 1 0
     2 5  25 4 "None" 0 0 0 0 0 0 0   0   0     0   0 0 0
     2 6  26 1 "IP"   0 1 0 0 0 0 0 2.5   5    25  90 0 0
     2 6  26 2 "Mix"  1 0 1 0 1 0 0  .5   2     4  90 0 1
     2 6  26 3 "TH"   0 0 0 1 0 0 0   0 .25 .0625  90 0 0
     2 6  26 4 "None" 0 0 0 0 0 0 0   0   0     0   0 0 0
     2 7  27 1 "IP"   0 1 0 0 1 0 0  .5   9    81  50 0 0
     2 7  27 2 "Mix"  0 0 1 0 0 0 0 3.5   5    25   0 1 1
     2 7  27 3 "TH"   1 0 0 1 0 0 0   0 .75 .5625 120 1 0
     2 7  27 4 "None" 0 0 0 0 0 0 0   0   0     0   0 0 0
     2 8  28 1 "IP"   0 1 0 0 0 0 0 1.5   2     4  90 0 0
     2 8  28 2 "Mix"  0 0 1 0 0 0 0  .5   2     4  50 1 1
     2 8  28 3 "TH"   1 0 0 1 0 0 0   0 .75 .5625  90 1 0
     2 8  28 4 "None" 0 0 0 0 0 0 0   0   0     0   0 0 0
     3 1  31 1 "IP"   1 1 0 0 1 0 0  .5   2     4  90 0 0
     3 1  31 2 "Mix"  0 0 1 0 0 0 0 2.5   5    25  50 0 0
     3 1  31 3 "TH"   0 0 0 1 0 0 0   0   5    25  90 0 0
     3 1  31 4 "None" 0 0 0 0 0 0 0   0   0     0   0 0 0
     3 2  32 1 "IP"   0 1 0 0 1 0 0 1.5 .75 .5625  90 0 0
     3 2  32 2 "Mix"  0 0 1 0 0 0 0 2.5 .25 .0625  90 1 1
     3 2  32 3 "TH"   1 0 0 1 0 0 1   0 .75 .5625   0 1 0
     3 2  32 4 "None" 0 0 0 0 0 0 0   0   0     0   0 0 0
     3 3  33 1 "IP"   0 1 0 0 0 0 0 1.5 .75 .5625 120 0 0
     3 3  33 2 "Mix"  1 0 1 0 1 0 0 1.5 .25 .0625   0 1 1
     3 3  33 3 "TH"   0 0 0 1 0 1 0   0   2     4  50 1 0
     3 3  33 4 "None" 0 0 0 0 0 0 0   0   0     0   0 0 0
     3 4  34 1 "IP"   0 1 0 0 1 0 0 3.5   5    25 120 0 0
     3 4  34 2 "Mix"  0 0 1 0 0 0 0 1.5   5    25 120 0 0
     3 4  34 3 "TH"   0 0 0 1 0 0 0   0 .75 .5625 120 0 0
     3 4  34 4 "None" 1 0 0 0 0 0 0   0   0     0   0 0 0
     3 5  35 1 "IP"   0 1 0 0 0 0 0 1.5   5    25  50 0 0
     3 5  35 2 "Mix"  0 0 1 0 0 0 0 3.5 .75 .5625  50 1 1
     3 5  35 3 "TH"   0 0 0 1 0 0 1   0 .75 .5625  90 1 0
     3 5  35 4 "None" 1 0 0 0 0 0 0   0   0     0   0 0 0
     3 6  36 1 "IP"   0 1 0 0 1 0 0 3.5   9    81  50 0 0
     3 6  36 2 "Mix"  0 0 1 0 1 0 0  .5   5    25  90 0 1
     3 6  36 3 "TH"   0 0 0 1 0 1 0   0   2     4  90 0 0
     3 6  36 4 "None" 1 0 0 0 0 0 0   0   0     0   0 0 0
     3 7  37 1 "IP"   0 1 0 0 1 0 0 2.5 .75 .5625 120 0 0
     3 7  37 2 "Mix"  0 0 1 0 0 0 0 3.5   2     4  90 1 0
     3 7  37 3 "TH"   1 0 0 1 0 0 1   0 .25 .0625  50 1 0
     3 7  37 4 "None" 0 0 0 0 0 0 0   0   0     0   0 0 0
     3 8  38 1 "IP"   0 1 0 0 0 0 0 2.5   2     4   0 0 0
     3 8  38 2 "Mix"  1 0 1 0 0 0 0  .5 .25 .0625  50 1 1
     3 8  38 3 "TH"   0 0 0 1 0 0 0   0   2     4  50 1 0
     3 8  38 4 "None" 0 0 0 0 0 0 0   0   0     0   0 0 0
     4 1  41 1 "IP"   0 1 0 0 1 0 0 3.5   2     4 120 0 0
     4 1  41 2 "Mix"  0 0 1 0 1 0 0 2.5   5    25   0 1 1
     4 1  41 3 "TH"   0 0 0 1 0 0 0   0   5    25  90 1 0
     4 1  41 4 "None" 1 0 0 0 0 0 0   0   0     0   0 0 0
     4 2  42 1 "IP"   1 1 0 0 1 0 0  .5 .75 .5625  50 0 0
     4 2  42 2 "Mix"  0 0 1 0 1 0 0  .5   2     4   0 0 0
     4 2  42 3 "TH"   0 0 0 1 0 1 0   0 .25 .0625   0 0 0
     4 2  42 4 "None" 0 0 0 0 0 0 0   0   0     0   0 0 0
     4 3  43 1 "IP"   0 1 0 0 1 0 0 2.5   2     4  50 0 0
     4 3  43 2 "Mix"  0 0 1 0 0 0 0 3.5 .75 .5625 120 0 0
     4 3  43 3 "TH"   0 0 0 1 0 1 0   0   5    25 120 0 0
     4 3  43 4 "None" 1 0 0 0 0 0 0   0   0     0   0 0 0
     4 4  44 1 "IP"   0 1 0 0 0 0 0 1.5   9    81   0 0 0
     4 4  44 2 "Mix"  0 0 1 0 1 0 0 2.5 .75 .5625  90 0 1
     4 4  44 3 "TH"   0 0 0 1 0 0 1   0   2     4  50 0 0
     4 4  44 4 "None" 1 0 0 0 0 0 0   0   0     0   0 0 0
     4 5  45 1 "IP"   0 1 0 0 0 0 0 3.5   9    81 120 0 0
     4 5  45 2 "Mix"  0 0 1 0 0 0 0 1.5 .75 .5625  50 0 1
     4 5  45 3 "TH"   0 0 0 1 0 1 0   0 .75 .5625   0 0 0
     4 5  45 4 "None" 1 0 0 0 0 0 0   0   0     0   0 0 0
     4 6  46 1 "IP"   1 1 0 0 0 0 0  .5   2     4  90 0 0
     4 6  46 2 "Mix"  0 0 1 0 0 0 0  .5   5    25  90 1 1
     4 6  46 3 "TH"   0 0 0 1 0 0 1   0   2     4  90 1 0
     4 6  46 4 "None" 0 0 0 0 0 0 0   0   0     0   0 0 0
     4 7  47 1 "IP"   0 1 0 0 0 0 0 3.5   2     4  90 0 0
     4 7  47 2 "Mix"  0 0 1 0 1 0 0 3.5 .25 .0625  90 1 1
     4 7  47 3 "TH"   0 0 0 1 0 0 1   0   2     4 120 1 0
     4 7  47 4 "None" 1 0 0 0 0 0 0   0   0     0   0 0 0
     4 8  48 1 "IP"   1 1 0 0 0 0 0  .5   5    25   0 0 0
     4 8  48 2 "Mix"  0 0 1 0 0 0 0 2.5   2     4 120 0 0
     4 8  48 3 "TH"   0 0 0 1 0 0 0   0 .75 .5625  90 0 0
     4 8  48 4 "None" 0 0 0 0 0 0 0   0   0     0   0 0 0
     5 1  51 1 "IP"   1 1 0 0 0 0 0 1.5   2     4   0 0 0
     5 1  51 2 "Mix"  0 0 1 0 1 0 0 3.5   5    25  50 1 0
     5 1  51 3 "TH"   0 0 0 1 0 0 1   0   5    25  50 1 0
     5 1  51 4 "None" 0 0 0 0 0 0 0   0   0     0   0 0 0
     5 2  52 1 "IP"   0 1 0 0 0 0 0  .5   9    81 120 0 0
     5 2  52 2 "Mix"  1 0 1 0 0 0 0 3.5 .25 .0625   0 0 0
     5 2  52 3 "TH"   0 0 0 1 0 0 1   0   2     4 120 0 0
     5 2  52 4 "None" 0 0 0 0 0 0 0   0   0     0   0 0 0
     5 3  53 1 "IP"   0 1 0 0 0 0 0 3.5   5    25   0 0 0
     5 3  53 2 "Mix"  0 0 1 0 1 0 0  .5 .75 .5625 120 1 1
     5 3  53 3 "TH"   1 0 0 1 0 0 0   0   5    25   0 1 0
     5 3  53 4 "None" 0 0 0 0 0 0 0   0   0     0   0 0 0
     5 4  54 1 "IP"   0 1 0 0 0 0 0 3.5 .75 .5625  50 0 0
     5 4  54 2 "Mix"  1 0 1 0 1 0 0  .5 .75 .5625   0 1 0
     5 4  54 3 "TH"   0 0 0 1 0 0 1   0 .75 .5625  50 1 0
     5 4  54 4 "None" 0 0 0 0 0 0 0   0   0     0   0 0 0
     5 5  55 1 "IP"   0 1 0 0 1 0 0 2.5 .75 .5625   0 0 0
     5 5  55 2 "Mix"  0 0 1 0 1 0 0 1.5   5    25  50 1 1
     5 5  55 3 "TH"   1 0 0 1 0 0 1   0 .25 .0625   0 1 0
     5 5  55 4 "None" 0 0 0 0 0 0 0   0   0     0   0 0 0
     5 6  56 1 "IP"   0 1 0 0 0 0 0 2.5   9    81  90 0 0
     5 6  56 2 "Mix"  0 0 1 0 1 0 0 3.5   2     4  90 1 1
     5 6  56 3 "TH"   0 0 0 1 0 0 0   0   2     4 120 1 0
     5 6  56 4 "None" 1 0 0 0 0 0 0   0   0     0   0 0 0
     5 7  57 1 "IP"   0 1 0 0 0 0 0 2.5   5    25  90 0 0
     5 7  57 2 "Mix"  0 0 1 0 1 0 0 2.5 .75 .5625 120 1 0
     5 7  57 3 "TH"   0 0 0 1 0 1 0   0 .25 .0625  90 1 0
     5 7  57 4 "None" 1 0 0 0 0 0 0   0   0     0   0 0 0
     5 8  58 1 "IP"   0 1 0 0 1 0 0  .5 .75 .5625  50 0 0
     5 8  58 2 "Mix"  0 0 1 0 0 0 0  .5   5    25  50 0 0
     5 8  58 3 "TH"   1 0 0 1 0 0 0   0   2     4   0 0 0
     5 8  58 4 "None" 0 0 0 0 0 0 0   0   0     0   0 0 0
     6 1  61 1 "IP"   1 1 0 0 1 0 0  .5   2     4  90 0 0
     6 1  61 2 "Mix"  0 0 1 0 0 0 0 2.5   5    25  50 0 0
     6 1  61 3 "TH"   0 0 0 1 0 0 0   0   5    25  90 0 0
     6 1  61 4 "None" 0 0 0 0 0 0 0   0   0     0   0 0 0
     6 2  62 1 "IP"   1 1 0 0 1 0 0 1.5 .75 .5625  90 0 0
     6 2  62 2 "Mix"  0 0 1 0 0 0 0 2.5 .25 .0625  90 1 1
     6 2  62 3 "TH"   0 0 0 1 0 0 1   0 .75 .5625   0 1 0
     6 2  62 4 "None" 0 0 0 0 0 0 0   0   0     0   0 0 0
     6 3  63 1 "IP"   1 1 0 0 0 0 0 1.5 .75 .5625 120 0 0
     6 3  63 2 "Mix"  0 0 1 0 1 0 0 1.5 .25 .0625   0 1 1
     6 3  63 3 "TH"   0 0 0 1 0 1 0   0   2     4  50 1 0
     6 3  63 4 "None" 0 0 0 0 0 0 0   0   0     0   0 0 0
     6 4  64 1 "IP"   0 1 0 0 1 0 0 3.5   5    25 120 0 0
     6 4  64 2 "Mix"  0 0 1 0 0 0 0 1.5   5    25 120 0 0
     6 4  64 3 "TH"   1 0 0 1 0 0 0   0 .75 .5625 120 0 0
     6 4  64 4 "None" 0 0 0 0 0 0 0   0   0     0   0 0 0
     6 5  65 1 "IP"   1 1 0 0 0 0 0 1.5   5    25  50 0 0
     6 5  65 2 "Mix"  0 0 1 0 0 0 0 3.5 .75 .5625  50 1 1
     6 5  65 3 "TH"   0 0 0 1 0 0 1   0 .75 .5625  90 1 0
     6 5  65 4 "None" 0 0 0 0 0 0 0   0   0     0   0 0 0
     6 6  66 1 "IP"   0 1 0 0 1 0 0 3.5   9    81  50 0 0
     6 6  66 2 "Mix"  0 0 1 0 1 0 0  .5   5    25  90 0 1
     6 6  66 3 "TH"   1 0 0 1 0 1 0   0   2     4  90 0 0
     6 6  66 4 "None" 0 0 0 0 0 0 0   0   0     0   0 0 0
     6 7  67 1 "IP"   1 1 0 0 1 0 0 2.5 .75 .5625 120 0 0
     6 7  67 2 "Mix"  0 0 1 0 0 0 0 3.5   2     4  90 1 0
     6 7  67 3 "TH"   0 0 0 1 0 0 1   0 .25 .0625  50 1 0
     6 7  67 4 "None" 0 0 0 0 0 0 0   0   0     0   0 0 0
     6 8  68 1 "IP"   0 1 0 0 0 0 0 2.5   2     4   0 0 0
     6 8  68 2 "Mix"  1 0 1 0 0 0 0  .5 .25 .0625  50 1 1
     6 8  68 3 "TH"   0 0 0 1 0 0 0   0   2     4  50 1 0
     6 8  68 4 "None" 0 0 0 0 0 0 0   0   0     0   0 0 0
     7 1  71 1 "IP"   0 1 0 0 1 0 0 3.5   2     4 120 0 0
     7 1  71 2 "Mix"  0 0 1 0 1 0 0 2.5   5    25   0 1 1
     7 1  71 3 "TH"   0 0 0 1 0 0 0   0   5    25  90 1 0
     7 1  71 4 "None" 1 0 0 0 0 0 0   0   0     0   0 0 0
     7 2  72 1 "IP"   1 1 0 0 1 0 0  .5 .75 .5625  50 0 0
     7 2  72 2 "Mix"  0 0 1 0 1 0 0  .5   2     4   0 0 0
     7 2  72 3 "TH"   0 0 0 1 0 1 0   0 .25 .0625   0 0 0
     7 2  72 4 "None" 0 0 0 0 0 0 0   0   0     0   0 0 0
     7 3  73 1 "IP"   0 1 0 0 1 0 0 2.5   2     4  50 0 0
     7 3  73 2 "Mix"  0 0 1 0 0 0 0 3.5 .75 .5625 120 0 0
     7 3  73 3 "TH"   0 0 0 1 0 1 0   0   5    25 120 0 0
     7 3  73 4 "None" 1 0 0 0 0 0 0   0   0     0   0 0 0
     7 4  74 1 "IP"   0 1 0 0 0 0 0 1.5   9    81   0 0 0
     7 4  74 2 "Mix"  0 0 1 0 1 0 0 2.5 .75 .5625  90 0 1
     7 4  74 3 "TH"   0 0 0 1 0 0 1   0   2     4  50 0 0
     7 4  74 4 "None" 1 0 0 0 0 0 0   0   0     0   0 0 0
     7 5  75 1 "IP"   0 1 0 0 0 0 0 3.5   9    81 120 0 0
     7 5  75 2 "Mix"  0 0 1 0 0 0 0 1.5 .75 .5625  50 0 1
     7 5  75 3 "TH"   0 0 0 1 0 1 0   0 .75 .5625   0 0 0
     7 5  75 4 "None" 1 0 0 0 0 0 0   0   0     0   0 0 0
     7 6  76 1 "IP"   1 1 0 0 0 0 0  .5   2     4  90 0 0
     7 6  76 2 "Mix"  0 0 1 0 0 0 0  .5   5    25  90 1 1
     7 6  76 3 "TH"   0 0 0 1 0 0 1   0   2     4  90 1 0
     7 6  76 4 "None" 0 0 0 0 0 0 0   0   0     0   0 0 0
     7 7  77 1 "IP"   0 1 0 0 0 0 0 3.5   2     4  90 0 0
     7 7  77 2 "Mix"  0 0 1 0 1 0 0 3.5 .25 .0625  90 1 1
     7 7  77 3 "TH"   0 0 0 1 0 0 1   0   2     4 120 1 0
     7 7  77 4 "None" 1 0 0 0 0 0 0   0   0     0   0 0 0
     7 8  78 1 "IP"   1 1 0 0 0 0 0  .5   5    25   0 0 0
     7 8  78 2 "Mix"  0 0 1 0 0 0 0 2.5   2     4 120 0 0
     7 8  78 3 "TH"   0 0 0 1 0 0 0   0 .75 .5625  90 0 0
     7 8  78 4 "None" 0 0 0 0 0 0 0   0   0     0   0 0 0
     8 1  81 1 "IP"   0 1 0 0 1 0 0 3.5   2     4 120 0 0
     8 1  81 2 "Mix"  0 0 1 0 1 0 0 2.5   5    25   0 1 1
     8 1  81 3 "TH"   0 0 0 1 0 0 0   0   5    25  90 1 0
     8 1  81 4 "None" 1 0 0 0 0 0 0   0   0     0   0 0 0
     8 2  82 1 "IP"   0 1 0 0 1 0 0  .5 .75 .5625  50 0 0
     8 2  82 2 "Mix"  0 0 1 0 1 0 0  .5   2     4   0 0 0
     8 2  82 3 "TH"   0 0 0 1 0 1 0   0 .25 .0625   0 0 0
     8 2  82 4 "None" 1 0 0 0 0 0 0   0   0     0   0 0 0
     8 3  83 1 "IP"   0 1 0 0 1 0 0 2.5   2     4  50 0 0
     8 3  83 2 "Mix"  0 0 1 0 0 0 0 3.5 .75 .5625 120 0 0
     8 3  83 3 "TH"   0 0 0 1 0 1 0   0   5    25 120 0 0
     8 3  83 4 "None" 1 0 0 0 0 0 0   0   0     0   0 0 0
     8 4  84 1 "IP"   0 1 0 0 0 0 0 1.5   9    81   0 0 0
     8 4  84 2 "Mix"  0 0 1 0 1 0 0 2.5 .75 .5625  90 0 1
     8 4  84 3 "TH"   0 0 0 1 0 0 1   0   2     4  50 0 0
     8 4  84 4 "None" 1 0 0 0 0 0 0   0   0     0   0 0 0
     8 5  85 1 "IP"   0 1 0 0 0 0 0 3.5   9    81 120 0 0
     8 5  85 2 "Mix"  0 0 1 0 0 0 0 1.5 .75 .5625  50 0 1
     8 5  85 3 "TH"   0 0 0 1 0 1 0   0 .75 .5625   0 0 0
     8 5  85 4 "None" 1 0 0 0 0 0 0   0   0     0   0 0 0
     8 6  86 1 "IP"   0 1 0 0 0 0 0  .5   2     4  90 0 0
     8 6  86 2 "Mix"  0 0 1 0 0 0 0  .5   5    25  90 1 1
     8 6  86 3 "TH"   0 0 0 1 0 0 1   0   2     4  90 1 0
     8 6  86 4 "None" 1 0 0 0 0 0 0   0   0     0   0 0 0
     8 7  87 1 "IP"   0 1 0 0 0 0 0 3.5   2     4  90 0 0
     8 7  87 2 "Mix"  0 0 1 0 1 0 0 3.5 .25 .0625  90 1 1
     8 7  87 3 "TH"   0 0 0 1 0 0 1   0   2     4 120 1 0
     8 7  87 4 "None" 1 0 0 0 0 0 0   0   0     0   0 0 0
     8 8  88 1 "IP"   0 1 0 0 0 0 0  .5   5    25   0 0 0
     8 8  88 2 "Mix"  0 0 1 0 0 0 0 2.5   2     4 120 0 0
     8 8  88 3 "TH"   0 0 0 1 0 0 0   0 .75 .5625  90 0 0
     8 8  88 4 "None" 1 0 0 0 0 0 0   0   0     0   0 0 0
     9 1  91 1 "IP"   0 1 0 0 1 0 0 3.5   2     4 120 0 0
     9 1  91 2 "Mix"  1 0 1 0 1 0 0 2.5   5    25   0 1 1
     9 1  91 3 "TH"   0 0 0 1 0 0 0   0   5    25  90 1 0
     9 1  91 4 "None" 0 0 0 0 0 0 0   0   0     0   0 0 0
     9 2  92 1 "IP"   0 1 0 0 1 0 0  .5 .75 .5625  50 0 0
     9 2  92 2 "Mix"  0 0 1 0 1 0 0  .5   2     4   0 0 0
     9 2  92 3 "TH"   1 0 0 1 0 1 0   0 .25 .0625   0 0 0
     9 2  92 4 "None" 0 0 0 0 0 0 0   0   0     0   0 0 0
     9 3  93 1 "IP"   1 1 0 0 1 0 0 2.5   2     4  50 0 0
     9 3  93 2 "Mix"  0 0 1 0 0 0 0 3.5 .75 .5625 120 0 0
     9 3  93 3 "TH"   0 0 0 1 0 1 0   0   5    25 120 0 0
     9 3  93 4 "None" 0 0 0 0 0 0 0   0   0     0   0 0 0
     9 4  94 1 "IP"   0 1 0 0 0 0 0 1.5   9    81   0 0 0
     9 4  94 2 "Mix"  1 0 1 0 1 0 0 2.5 .75 .5625  90 0 1
     9 4  94 3 "TH"   0 0 0 1 0 0 1   0   2     4  50 0 0
     9 4  94 4 "None" 0 0 0 0 0 0 0   0   0     0   0 0 0
     9 5  95 1 "IP"   0 1 0 0 0 0 0 3.5   9    81 120 0 0
     9 5  95 2 "Mix"  0 0 1 0 0 0 0 1.5 .75 .5625  50 0 1
     9 5  95 3 "TH"   1 0 0 1 0 1 0   0 .75 .5625   0 0 0
     9 5  95 4 "None" 0 0 0 0 0 0 0   0   0     0   0 0 0
     9 6  96 1 "IP"   0 1 0 0 0 0 0  .5   2     4  90 0 0
     9 6  96 2 "Mix"  1 0 1 0 0 0 0  .5   5    25  90 1 1
     9 6  96 3 "TH"   0 0 0 1 0 0 1   0   2     4  90 1 0
     9 6  96 4 "None" 0 0 0 0 0 0 0   0   0     0   0 0 0
     9 7  97 1 "IP"   0 1 0 0 0 0 0 3.5   2     4  90 0 0
     9 7  97 2 "Mix"  1 0 1 0 1 0 0 3.5 .25 .0625  90 1 1
     9 7  97 3 "TH"   0 0 0 1 0 0 1   0   2     4 120 1 0
     9 7  97 4 "None" 0 0 0 0 0 0 0   0   0     0   0 0 0
     9 8  98 1 "IP"   0 1 0 0 0 0 0  .5   5    25   0 0 0
     9 8  98 2 "Mix"  0 0 1 0 0 0 0 2.5   2     4 120 0 0
     9 8  98 3 "TH"   1 0 0 1 0 0 0   0 .75 .5625  90 0 0
     9 8  98 4 "None" 0 0 0 0 0 0 0   0   0     0   0 0 0
    10 1 101 1 "IP"   1 1 0 0 1 0 0  .5   2     4  90 0 0
    10 1 101 2 "Mix"  0 0 1 0 0 0 0 2.5   5    25  50 0 0
    10 1 101 3 "TH"   0 0 0 1 0 0 0   0   5    25  90 0 0
    10 1 101 4 "None" 0 0 0 0 0 0 0   0   0     0   0 0 0
    10 2 102 1 "IP"   1 1 0 0 1 0 0 1.5 .75 .5625  90 0 0
    10 2 102 2 "Mix"  0 0 1 0 0 0 0 2.5 .25 .0625  90 1 1
    10 2 102 3 "TH"   0 0 0 1 0 0 1   0 .75 .5625   0 1 0
    10 2 102 4 "None" 0 0 0 0 0 0 0   0   0     0   0 0 0
    10 3 103 1 "IP"   0 1 0 0 0 0 0 1.5 .75 .5625 120 0 0
    10 3 103 2 "Mix"  0 0 1 0 1 0 0 1.5 .25 .0625   0 1 1
    10 3 103 3 "TH"   1 0 0 1 0 1 0   0   2     4  50 1 0
    10 3 103 4 "None" 0 0 0 0 0 0 0   0   0     0   0 0 0
    end
    label values alt alt
    label def alt 1 "IP", modify
    label def alt 2 "Mix", modify
    label def alt 3 "TH", modify
    label def alt 4 "None", modify

  • #2
    PS: Apologies but the above description of the problem has some errors. What I need to do is generate the confidence intervals for the mean predictions, and then plot them on the bar graphs. I assume it makes more sense to do this for the absolute value of each prediction, as opposed to the change from the base case prediction? Can I use the ci command to generate confidence intervals and store them for each case and use them for the graphs?
    Last edited by Ashani Abayasekara; 25 Feb 2026, 22:49.

    Comment


    • #3
      I haven't tried to follow what you're doing. It doesn't seem that the data example can be followed by the code you give. I stopped reading the code once I realised that

      Code:
       decode alt, gen(alt1)
      must have been applied before the data example. But one key point can be made.

      rcap isn't an option; it is a subcommand of twoway.

      graph hbar is quite separate from graph twoway. It doesn't have an option or any other way to add capped spikes to indicate intervals.

      To get bar charts for estimates together with capped spikes, you would need to use twoway entirely.

      You're focusing on what you think is the problem, how to use local macros, but I can't see that local macros need have any bearing on the kind of graph you want, for which point estimates, upper and lower bounds need to be in separate variables.

      EDIT

      Andrew Musau is right (next post)! But I don't think this new functionality has any bearing on the question in #1. The confidence intervals concerned depend on a previous fit. They aren't to be calcuated on the fly by graph bar.
      Last edited by Nick Cox; 26 Feb 2026, 05:18.

      Comment


      • #4
        In Stata 19 and later versions, you can directly plot means and their confidence intervals using graph bar.

        Code:
        webuse nlsw88, clear
        graph hbar (meanci) wage if union, over(occupation, sort(1)) ytitle(Mean Wage)
        Click image for larger version

Name:	Graph.png
Views:	1
Size:	17.9 KB
ID:	1785043

        Last edited by Andrew Musau; 26 Feb 2026, 05:00.

        Comment


        • #5
          Originally posted by Nick Cox View Post
          EDIT

          Andrew Musau is right (next post)! But I don't think this new functionality has any bearing on the question in #1. The confidence intervals concerned depend on a previous fit. They aren't to be calcuated on the fly by graph bar.
          Thanks, Nick. I also couldn't follow #1. For the OP, my advice is to simplify your example and show us exactly what you want. Usually, one uses a postestimation command such as margins to create predictions with confidence intervals, and the command takes care of the averaging.

          Comment


          • #6
            Thanks very much Nick and Andrew. My apologies for the incorrect code and confusing question. Based on some thought, I can give you a clearer explanation now. I have generated predictions (using mixlpred after a mixed logit model) for a base case and different scenarios, and have calculated the mean values and lower and upper bounds for each of these, given in the data attached below. I now want to use a two-way scatterplot to display the mean values for each case along with the confidence intervals (CIs). I'm including the code I've used so far, which plots the data vertically. I would ideally like the CIs to appear horizontally cutting across the point estimates, but when I specify the "horizontal" option they appear separate from the point estimates. Can you please advice on how I can plot this horizontally? The graph is too crowded at the moment and perhaps a rotation would help.

            Thanks Andrew, that's great that Stata 19 has the capability to plot CIs directly. Unfortunately I don't have access to this version yet. In Stata 18, is it possible to shade the bars in a different colour if the estimates are statistically significant?

            Code:
            * Example generated by -dataex-. For more info, type help dataex
            clear
            input str40 case float(mean lb ub name)
            "basecase"        8.403861  8.197536  8.610185  1
            "cost0ip"         4.868747 4.7648525  4.972641  2
            "cost0mix"        5.189644  5.069697  5.309591  3
            "cost0th"         6.301103   6.14507  6.457137  4
            "cost90ip"       10.788922 10.513484  11.06436  5
            "cost90mix"      10.330223 10.077703 10.582744  6
            "cost90th"        9.205196  8.983466  9.426926  7
            "cost120ip"       11.90376 11.597588  12.20993  8
            "cost120mix"      11.18094 10.910663 11.451218  9
            "cost120th"       9.492736  9.266344  9.719129 10
            "time12_ip"       9.679237  9.441087   9.91739 11
            "time12_mix"      9.453546  9.226126  9.680965 12
            "time23_ip"      10.703915 10.439976 10.967853 13
            "time23_mix"      10.26097 10.018143 10.503798 14
            "time34_ip"       11.46816 11.184854 11.751467 15
            "time34_mix"      10.84528  10.59172 11.098838 16
            "th_hub"          7.730806  7.537704  7.923907 17
            "firstvth"        9.273496  9.049671  9.497319 18
            "psyvisit_ip"     8.550832 8.3407545  8.760908 19
            "psyvisit_mix"    8.489151  8.282082   8.69622 20
            "psyvisit_th"     8.414045  8.207556  8.620534 21
            "psyurban_th"     8.601499 8.3927765  8.810222 22
            "wait2wk_mix"     7.769783  7.577094  7.962473 23
            "wait2wk_th"      8.079879   7.87906  8.280698 24
            "wait13mnth_ip"   9.945031  9.699471 10.190592 25
            "wait13mnth_mix"  9.670025   9.43754   9.90251 26
            "wait13mnth_th"   8.962431  8.747188  9.177675 27
            "wait46mnth_ip"  11.855512 11.560594 12.150432 28
            "wait46mnth_mix" 11.147346 10.886342  11.40835 29
            "wait46mnth_th"   9.488602  9.265595  9.711608 30
            "wait612mnth_ip"  12.95809 12.636929  13.27925 31
            end
            label values name name
            label def name 1 "Base", modify
            label def name 2 "No fee IP", modify
            label def name 3 "No fee MIX", modify
            label def name 4 "No fee TH", modify
            label def name 5 "Fee $90 IP", modify
            label def name 6 "Fee $90 MIX", modify
            label def name 7 "Fee $90 TH", modify
            label def name 8 "Fee $120 IP", modify
            label def name 9 "Fee $120 MIX", modify
            label def name 10 "Fee $120 TH", modify
            label def name 11 "1-2 hrs IP", modify
            label def name 12 "1-2 hrs MIX", modify
            label def name 13 "2-3 hrs IP", modify
            label def name 14 "2-3 hrs MIX", modify
            label def name 15 "3-4 hrs IP", modify
            label def name 16 "3-4 hrs MIX", modify
            label def name 17 "TH hub", modify
            label def name 18 "1st visit TH", modify
            label def name 19 "Visiting IP", modify
            label def name 20 "Visiting MIX", modify
            label def name 21 "Visiting TH", modify
            label def name 22 "Urban TH", modify
            label def name 23 "Wait <2wk MIX", modify
            label def name 24 "Wait <2wk TH", modify
            label def name 25 "Wait 1-3mo IP", modify
            label def name 26 "Wait 1-3mo MIX", modify
            label def name 27 "Wait 1-3mo TH", modify
            label def name 28 "Wait 4-6mo IP", modify
            label def name 29 "Wait 4-6mo MIX", modify
            label def name 30 "Wait 4-6mo TH", modify
            label def name 31 "Wait 6-12mo IP", modify
            Code:
            summ mean if case=="basecase"
            local baseline = r(mean)
            display `baseline'
            
            twoway ///
                (scatter mean name, mlabel(name) mlabsize(vsmall)) ///
                (rcap ub lb name,) if case~="basecase", ///
                xline(`baseline') ytitle(% opt-out) xtitle(Attributes and levels) legend(pos(6) order(1 "Predicted opt-out" 2 "95% confidence interval"))

            Comment


            • #7
              Thanks for the revised example. I think I understand most of what you want, This may help. myaxis is from the Stata Journal.

              Code:
              * Example generated by -dataex-. For more info, type help dataex
              clear
              input str40 case float(mean lb ub name)
              "basecase"        8.403861  8.197536  8.610185  1
              "cost0ip"         4.868747 4.7648525  4.972641  2
              "cost0mix"        5.189644  5.069697  5.309591  3
              "cost0th"         6.301103   6.14507  6.457137  4
              "cost90ip"       10.788922 10.513484  11.06436  5
              "cost90mix"      10.330223 10.077703 10.582744  6
              "cost90th"        9.205196  8.983466  9.426926  7
              "cost120ip"       11.90376 11.597588  12.20993  8
              "cost120mix"      11.18094 10.910663 11.451218  9
              "cost120th"       9.492736  9.266344  9.719129 10
              "time12_ip"       9.679237  9.441087   9.91739 11
              "time12_mix"      9.453546  9.226126  9.680965 12
              "time23_ip"      10.703915 10.439976 10.967853 13
              "time23_mix"      10.26097 10.018143 10.503798 14
              "time34_ip"       11.46816 11.184854 11.751467 15
              "time34_mix"      10.84528  10.59172 11.098838 16
              "th_hub"          7.730806  7.537704  7.923907 17
              "firstvth"        9.273496  9.049671  9.497319 18
              "psyvisit_ip"     8.550832 8.3407545  8.760908 19
              "psyvisit_mix"    8.489151  8.282082   8.69622 20
              "psyvisit_th"     8.414045  8.207556  8.620534 21
              "psyurban_th"     8.601499 8.3927765  8.810222 22
              "wait2wk_mix"     7.769783  7.577094  7.962473 23
              "wait2wk_th"      8.079879   7.87906  8.280698 24
              "wait13mnth_ip"   9.945031  9.699471 10.190592 25
              "wait13mnth_mix"  9.670025   9.43754   9.90251 26
              "wait13mnth_th"   8.962431  8.747188  9.177675 27
              "wait46mnth_ip"  11.855512 11.560594 12.150432 28
              "wait46mnth_mix" 11.147346 10.886342  11.40835 29
              "wait46mnth_th"   9.488602  9.265595  9.711608 30
              "wait612mnth_ip"  12.95809 12.636929  13.27925 31
              end
              label values name name
              label def name 1 "Base", modify
              label def name 2 "No fee IP", modify
              label def name 3 "No fee MIX", modify
              label def name 4 "No fee TH", modify
              label def name 5 "Fee $90 IP", modify
              label def name 6 "Fee $90 MIX", modify
              label def name 7 "Fee $90 TH", modify
              label def name 8 "Fee $120 IP", modify
              label def name 9 "Fee $120 MIX", modify
              label def name 10 "Fee $120 TH", modify
              label def name 11 "1-2 hrs IP", modify
              label def name 12 "1-2 hrs MIX", modify
              label def name 13 "2-3 hrs IP", modify
              label def name 14 "2-3 hrs MIX", modify
              label def name 15 "3-4 hrs IP", modify
              label def name 16 "3-4 hrs MIX", modify
              label def name 17 "TH hub", modify
              label def name 18 "1st visit TH", modify
              label def name 19 "Visiting IP", modify
              label def name 20 "Visiting MIX", modify
              label def name 21 "Visiting TH", modify
              label def name 22 "Urban TH", modify
              label def name 23 "Wait <2wk MIX", modify
              label def name 24 "Wait <2wk TH", modify
              label def name 25 "Wait 1-3mo IP", modify
              label def name 26 "Wait 1-3mo MIX", modify
              label def name 27 "Wait 1-3mo TH", modify
              label def name 28 "Wait 4-6mo IP", modify
              label def name 29 "Wait 4-6mo MIX", modify
              label def name 30 "Wait 4-6mo TH", modify
              label def name 31 "Wait 6-12mo IP", modify
              
              summ mean if case=="basecase"
              local baseline = r(mean)
              display `baseline'
              
              twoway ///
                  (scatter mean name, mlabel(name) mlabsize(vsmall)) ///
                  (rcap ub lb name,) if case~="basecase", ///
                  xline(`baseline') ytitle(% opt-out) xtitle(Attributes and levels) legend(pos(6) order(1 "Predicted opt-out" 2 "95% confidence interval"))
              
              gen wanted = case != "basecase"
              
              scatter name mean if wanted, yla(2/31, valuelabel labsize(small) noticks) ysc(reverse) ///
              || rcap ub lb name if wanted, horizontal xsc(alt) ///
                  xline(`baseline') xtitle(% opt-out: Predicted values and 95% confidence intervals) ytitle(Attributes and levels) legend(off) name(G1, replace)
                  
              myaxis name2 = name, sort(mean mean) subset(wanted)
              
              scatter name2 mean if wanted, yla(1/30, valuelabel labsize(small) noticks) ysc(reverse) ///
              || rcap ub lb name2 if wanted, horizontal xsc(alt) ///
                  xline(`baseline') xtitle(% opt-out: Predicted values and 95% confidence intervals) ytitle(Attributes and levels) legend(off) name(G2, replace)
              Click image for larger version

Name:	ashani1.png
Views:	1
Size:	96.8 KB
ID:	1785055


              Click image for larger version

Name:	ashani2.png
Views:	1
Size:	97.1 KB
ID:	1785056

              Comment


              • #8
                Thanks so much Nick, this is great and exactly what I wanted. Just wondered if there's a way to edit the spaces between names on the y-axis? For e.g., I'd like to leave some extra space between selected labels to indicate it's a separate attribute (e.g., space between "Fee $120 TH" and "1-2 hrs IP" in the first graph.

                Comment


                • #9
                  The answer lies in the fact that you got what you asked for. A sequence of consecutive integers implies equal spacing. If you want extra spaces, add gaps in the sequence.

                  More at https://journals.sagepub.com/doi/pdf...867X0800800208 or https://journals.sagepub.com/doi/pdf...6867X241297949

                  Naturally, the more gaps you add, the more pressure there is on the text labels remaining readable.

                  If this is for a thesis or a report or a paper, you may just be able to control how much space the display takes in total, perhaps even an entire page.

                  In any case, options like ysize() can help. You will have noticed that the legend disappeared in the code for #8.

                  Comment


                  • #10
                    Here is a demonstration. You'll want to go further, but this should be enough to show the main idea.

                    Code:
                    * Example generated by -dataex-. For more info, type help dataex
                    clear
                    input str40 case float(mean lb ub name)
                    "basecase"        8.403861  8.197536  8.610185  1
                    "cost0ip"         4.868747 4.7648525  4.972641  2
                    "cost0mix"        5.189644  5.069697  5.309591  3
                    "cost0th"         6.301103   6.14507  6.457137  4
                    "cost90ip"       10.788922 10.513484  11.06436  6
                    "cost90mix"      10.330223 10.077703 10.582744  7
                    "cost90th"        9.205196  8.983466  9.426926  8
                    "cost120ip"       11.90376 11.597588  12.20993  9
                    "cost120mix"      11.18094 10.910663 11.451218  10
                    "cost120th"       9.492736  9.266344  9.719129  11
                    "time12_ip"       9.679237  9.441087   9.91739 13
                    "time12_mix"      9.453546  9.226126  9.680965 14
                    "time23_ip"      10.703915 10.439976 10.967853 15
                    "time23_mix"      10.26097 10.018143 10.503798 16
                    "time34_ip"       11.46816 11.184854 11.751467 17
                    "time34_mix"      10.84528  10.59172 11.098838 18
                    "th_hub"          7.730806  7.537704  7.923907 20
                    "firstvth"        9.273496  9.049671  9.497319 21
                    "psyvisit_ip"     8.550832 8.3407545  8.760908 22
                    "psyvisit_mix"    8.489151  8.282082   8.69622 23
                    "psyvisit_th"     8.414045  8.207556  8.620534 24
                    "psyurban_th"     8.601499 8.3927765  8.810222 25
                    "wait2wk_mix"     7.769783  7.577094  7.962473 26
                    "wait2wk_th"      8.079879   7.87906  8.280698 27
                    "wait13mnth_ip"   9.945031  9.699471 10.190592 28
                    "wait13mnth_mix"  9.670025   9.43754   9.90251 29
                    "wait13mnth_th"   8.962431  8.747188  9.177675 30
                    "wait46mnth_ip"  11.855512 11.560594 12.150432 31
                    "wait46mnth_mix" 11.147346 10.886342  11.40835 32
                    "wait46mnth_th"   9.488602  9.265595  9.711608 33
                    "wait612mnth_ip"  12.95809 12.636929  13.27925 34
                    end
                    label values name name
                    label def name 1 "Base", modify
                    label def name 2 "No fee IP", modify
                    label def name 3 "No fee MIX", modify
                    label def name 4 "No fee TH", modify
                    label def name 6 "Fee $90 IP", modify
                    label def name 7 "Fee $90 MIX", modify
                    label def name 8 "Fee $90 TH", modify
                    label def name 9 "Fee $120 IP", modify
                    label def name 10 "Fee $120 MIX", modify
                    label def name 11 "Fee $120 TH", modify
                    label def name 13 "1-2 hrs IP", modify
                    label def name 14 "1-2 hrs MIX", modify
                    label def name 15 "2-3 hrs IP", modify
                    label def name 16 "2-3 hrs MIX", modify
                    label def name 17 "3-4 hrs IP", modify
                    label def name 18 "3-4 hrs MIX", modify
                    label def name 20 "TH hub", modify
                    label def name 21 "1st visit TH", modify
                    label def name 22 "Visiting IP", modify
                    label def name 23 "Visiting MIX", modify
                    label def name 24 "Visiting TH", modify
                    label def name 25 "Urban TH", modify
                    label def name 26 "Wait <2wk MIX", modify
                    label def name 27 "Wait <2wk TH", modify
                    label def name 28 "Wait 1-3mo IP", modify
                    label def name 29 "Wait 1-3mo MIX", modify
                    label def name 30 "Wait 1-3mo TH", modify
                    label def name 31 "Wait 4-6mo IP", modify
                    label def name 32 "Wait 4-6mo MIX", modify
                    label def name 33 "Wait 4-6mo TH", modify
                    label def name 34 "Wait 6-12mo IP", modify
                    
                    summ mean if case=="basecase"
                    local baseline = r(mean)
                    display `baseline'
                    
                    gen wanted = case != "basecase"
                    
                    scatter name mean if wanted, yla(2/4 6/11 13/18 20/34, valuelabel labsize(small) noticks) ysc(reverse) ///
                    || rcap ub lb name if wanted, horizontal xsc(alt) ///
                        xline(`baseline') xtitle(% opt-out: Predicted values and 95% confidence intervals) ytitle(Attributes and levels) legend(off)
                    Click image for larger version

Name:	ashani3.png
Views:	1
Size:	67.0 KB
ID:	1785064

                    Comment


                    • #11
                      Thank you very much.

                      Comment

                      Working...
                      X