Hi,
I am trying to create a graph of means and confidence intervalls for 6 different variables (feelings of safety in own home (=in der Wohnung), own neigbourhood (=in der Wohngegend) and public transportation (=im ÖPNV) each during the day (=tagsüber) and at night (=nachts) ). I was not able to produce this graph with the original data so I saved the estimation results in a matrix and load them as a new dataset. Dataex produced the following input-command.
I then try to build a twoway graph containing the 3 bars for feelings of safety during the day and 3 bars for feelings of safety at night, which also contain the confidence intervalls and the means of each variable. The problem arises with the scatter-command because even though I format the variable means as %4,2f beforehand and even try to force it also in the scatter-command, the marker labels are portrayed with all the decimal places instead of only two (I couldn't upload a picture, so you just have to trust me on this).
If I try to specify mlabformat as an option to the scatter-command, Stata tells me "option mlabformat() not allowed" (I have no idea why, because the Stata help suggests that mlabformat should be a viable option). In the dataset itself, the format-command seemed to have worked as the variable "mean" is displayed in the specified format.
I spent hours googling my problem and reading stata help files and documentations and am at the end of my wits and nerves and really hope, anybody can shed some light on the situation.
All the best,
Judith
I am trying to create a graph of means and confidence intervalls for 6 different variables (feelings of safety in own home (=in der Wohnung), own neigbourhood (=in der Wohngegend) and public transportation (=im ÖPNV) each during the day (=tagsüber) and at night (=nachts) ). I was not able to produce this graph with the original data so I saved the estimation results in a matrix and load them as a new dataset. Dataex produced the following input-command.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str6 A byte(F10 A_B) double(A1 A2 A3 A4 mean min95 max95) float(F10_l F10_r) "F10a_A" 1 1 .31692161751240105 1.594665509658167 24.623643493240863 73.46476937958832 3.7123626063490436 3.6978947227735097 3.7268304899245774 .8 1.2 "F10a_B" 2 1 .4475622840404713 3.0959242581165918 32.59555139108329 63.86096206675938 3.5986991324056077 3.5814830728246037 3.6159151919866117 1.8 2.2 "F10a_C" 3 1 1.5737449551613583 10.219580310965979 44.33890636776225 43.86776836611006 3.3050069814482024 3.2829948945864245 3.3270190683099803 2.8 3.2 "F10b_A" 1 2 1.1167070610878893 6.112374489240198 37.12656320687904 55.644355242792656 3.472985666313755 3.4528994550503387 3.493071877577171 .8 1.2 "F10b_B" 2 2 6.598747820791035 23.626501218841124 44.18227196227794 25.59247899808948 2.8876848213766553 2.8583587391852046 2.917010903568106 1.8 2.2 "F10b_C" 3 2 15.092746289606 34.9326186549468 35.45368391155193 14.520951143894886 2.494028399097355 2.459035448792599 2.5290213494021105 2.8 3.2 end label values F10 F10 label def F10 1 "in der Wohnung", modify label def F10 2 "in der Wohngegend", modify label def F10 3 "im ÖPNV", modify label values A_B A_B label def A_B 1 "tagsüber", modify label def A_B 2 "nachts", modify label values mean Sicherheitsgefühl
I then try to build a twoway graph containing the 3 bars for feelings of safety during the day and 3 bars for feelings of safety at night, which also contain the confidence intervalls and the means of each variable. The problem arises with the scatter-command because even though I format the variable means as %4,2f beforehand and even try to force it also in the scatter-command, the marker labels are portrayed with all the decimal places instead of only two (I couldn't upload a picture, so you just have to trust me on this).
If I try to specify mlabformat as an option to the scatter-command, Stata tells me "option mlabformat() not allowed" (I have no idea why, because the Stata help suggests that mlabformat should be a viable option). In the dataset itself, the format-command seemed to have worked as the variable "mean" is displayed in the specified format.
Code:
format mean %4,2f
graph twoway (bar mean F10_l if A_B==1, barw(0.3) bcolor(navy) yscale(range(1 4))) (rcap min95 max95 F10_l if A_B==1, color("214 220 229")) (scatter mean F10_l if A_B==1, yvarformat(%4,2f) yscale(range(1 4)) msymbol(none) mlabel(mean) mlabposition(8) mlabgap(1) mlabcolor(white) mlabsize(vsmall)) ///
(bar mean F10_r if A_B==2, barw(0.3) bcolor(red)) (rcap min95 max95 F10_r if A_B==2, color("214 220 229")) (scatter mean F10_r if A_B==2, yvarformat(%4,2f) yscale(range(1 4)) msymbol(none) mlabel(mean) mlabposition(8) mlabgap(1) mlabcolor(white) mlabsize(vsmall)), ///
name(F10_mean_b, replace) xlabel(1 "in der Wohnung" 2 "in der Wohngegend" 3 "im ÖPNV", labsize(vsmall)) ytitle("Mittelwert", size(medsmall)) ylabel(1 "sehr unsicher" 2 "eher unsicher" 3 "eher sicher" 4 "sehr sicher", labsize(vsmall) angle(0)) title("Sicherheitsgefühl alleine/ohne Begleitung", size(12pt) span) subtitle(" ") ///
legend(size(small) symxsize(small) order(1 4 2) label(1 "tagsüber") label(4 "nachts") label(2 "Konfidenzintervall") rows(1))
All the best,
Judith

Comment