I am not sure whether there is an error on my part or whether this is a problem with Stata. Here is the (somewhat lengthy) code I am using (see my comments marked in red):
Code:
* set scheme lean1 (install scheme if necessary): cap set scheme lean1 if _rc { net install gr0002_3, from("http://www.stata-journal.com/software/sj4-3") set scheme lean1 } local m0 = 68 local m1 = 69 local sd = 3.1 local n = 100 local se = `sd'/sqrt(`n') local alpha = 0.05 local z = invnorm(1-`alpha'/2) local lower = `m0'-`z'*`se' local upper = `m0'+`z'*`se' if `m0' < `m1' { local beta = normal((`upper'-`m1')/`se') - /// normal(-(`m1'-`lower')/`se') local crit = `upper' local area1 = max(`lower',`m1'-4*`se') local area2 = `crit' } else { local beta = normal((`m1'-`lower')/`se') - /// normal(-(`upper'-`m1')/`se') local crit = `lower' local area1 = `crit' local area2 = min(`m1'+4*`se',`upper') } local power = 1-`beta' local tcrit : di round(`crit',0.01) local tbeta : di round(`beta',.001) local tpower : di round(`power',.001) local xtit1 = "kritischer Wert = `tcrit', {&alpha}{subscript:zweiseitig} = `alpha', " local xtit2 = "{&beta} = `tbeta', Power = `tpower'" local subt1 = "{it:n} = `n', H{subscript:0}: {&mu} = `m0', " local subt2 = "H{subscript:1}: {&mu} = `m1', {&sigma} = `sd'" twoway function y=normalden(x,`m0',`se'), /// range(`=`m0'-4*`se'' `=`m0'+4*`se'') /// recast(area) color("255 255 212") || /// function y=normalden(x,`m1',`se'), /// range(`=`m1'-4*`se'' `=`m1'+4*`se'') /// recast(area) color("255 255 212") || /// function y=normalden(x,`m0',`se'), /// range(`=`m0'-4*`se'' `=`m0'-`z'*`se'') /// recast(area) color(blue) || /// function y=normalden(x,`m0',`se'), /// range(`=`m0'+`z'*`se'' `=`m0'+4*`se'') /// recast(area) color(blue) || /// function y=normalden(x,`m1',`se'), range(`=`area1'' `=`area2'') /// recast(area) color("240 59 32") || /// function y=normalden(x,`m0',`se'), /// range(`=`m0'-4*`se'' `=`m0'+4*`se'') color(black) /// lw(vthin) lp(solid) || /// function y=normalden(x,`m1',`se'), /// range(`=`m1'-4*`se'' `=`m1'+4*`se'') color(black) /// lw(vthin) lp(solid) /// title("Power eines Einstichproben-{it:z}-Tests", size(medsmall)) /// subtitle("`subt1'`subt2'", size(small)) /// xtitle(`"`xtit1'`xtit2'"', size(small)) xlabel(`m0' `m1', labs(small)) /// text(0 `m0' "{&mu}0", size(vsmall) place(s)) /// text(0 `m1' "{&mu}1", size(vsmall) place(s)) /// text(0 `=`crit'' `"`tcrit'"', size(vsmall) place(s) col(blue)) /// ytitle("Wahrscheinlichkeitsdichte", size(small)) ylab(, labs(small)) /// text(0.6 68 "Akzeptanz-" "region H{subscript:0}", size(6pt) place(c) /// // <-- correctly centered box bc(white) fc(white) lstyle(none) bex) /// text(0.6 69 "Akzeptanz-" "region H{subscript:1}", size(6pt) place(c) /// // <-- not centered box bc(white) fc(white) lstyle(none) bex) /// legend(off) scheme(lean1)
0 Response to Graph: text not centered within textbox
Post a Comment