*! version 1.0.0 14may1995 program define ttoz version 4.0 preserve /* Save all the current stata stuff */ clear /* Clear everything so no conflicts */ global npts = 201 global df=2 quietly { set obs $npts gen x= . gen y = .} global D_sm1 "Xmin" global HJN_V1=-3. wdctl static D_sm1 5 5 25 10 wdctl edit HJN_V1 35 5 20 10 global D_sm2 "Xmax" global HJN_V2=3. wdctl static D_sm2 5 20 25 10 wdctl edit HJN_V2 35 20 20 10 global D_sm3 "df max" global HJN_V3=20 wdctl static D_sm3 5 35 25 10 wdctl edit HJN_V3 35 35 20 10 global D_sm4 "df" wdctl static D_sm4 5 95 30 12 wdctl static df 35 95 30 12 wdctl button "Run" 5 50 30 12 D_b1 wdctl button "Close" 5 65 30 12 D_b2 wdctl button "Help" 5 80 30 12 D_b3 global D_b1 "ttozdr" global D_b2 "exit 1234" global D_b3 "whelp ttoz" cap noi wdlg "t -> Z" $D_dlgx $D_dlgy 70 120 restore end program define ttozdr version 4.0 /* Get lower and upper x values and make sure they're legal */ scalar x1 = $HJN_V1 scalar x2 = $HJN_V2 local dfmax=$HJN_V3 if x1>=x2 { sstopbox stop "lower limit must be less than upper limit" exit} if `dfmax'<2 | `dfmax'>100 { sstopbox stop "dfmax must be between 2 and 100" exit} gph open gph pen 1 /* Get Z curve and plot it with graphics off to get scaling information */ replace x = x1 + ((_n-1)/($npts-1))*(x2-x1) replace y = exp(-(x^2)/2)/sqrt(2*_pi) summarize y local ymax=_result(6) pdf_t x y 2 summarize y local ymax1=_result(6) local ymax=max(`ymax',`ymax1') pdf_t x y 20 summarize y local ymax1=_result(6) local ymax=max(`ymax',_result(6)) local xmin=x1 local xmax=x2 * set graphics off * graph y x, c(l) s(i) xlabel ylabel l1(" ") l2(" ") b1(" ") b2(" ") * set graphics on * local ymin = _result(1) * local ymax = _result(2) * local xmin = _result(3) * local xmax = _result(4) /* Now plot it for real */ replace y = exp(-(x^2)/2)/sqrt(2*_pi) graph y x, c(l) s(i) xlabel ylabel xscale(`xmin',`xmax') /* */ yscale(0,`ymax') l1(" ") l2(" ") b1(" ") b2(" ") pen(3) /* Now plot t with 2 degrees of freedom so we can erase it at start of loop */ global df=2 pdf_t x y $df graph y x, c(l) s(i) xlabel ylabel xscale(`xmin',`xmax') /* */ yscale(0,`ymax') l1(" ") l2(" ") b1(" ") b2(" ") pen(1) /* Now do while loop over df */ while $df <= `dfmax' { /* Erase previous t pdf */ graph y x, c(l) s(i) xlabel ylabel xscale(`xmin',`xmax') /* */ yscale(0,`ymax') l1(" ") l2(" ") b1(" ") b2(" ") pen(0) /* Get new t pdf and draw it */ pdf_t x y $df graph y x, c(l) s(i) xlabel ylabel xscale(`xmin',`xmax') /* */ yscale(0,`ymax') l1(" ") l2(" ") b1(" ") b2(" ") pen(1) wdupdate global df=$df+1 } global df=`dfmax' gph text 1000 16000 0 0 t_`dfmax' and Z curves gph close end