You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

91 lines
2.7 KiB
Plaintext

*! traj Oct 09, 2013 Bobby L Jones
program trajplot
version 9
syntax ,[ model(integer 1) xlabel(str) ylabel(str) xtitle(str) ytitle(str) ///
legendLabels(str) CI NOLEGEND DROPOUT ]
preserve
tempname A plotVarNames
capture confirm matrix e(plot`model')
if _rc != 0 {
display as error "plot data not found"
exit _rc
}
if "`dropout'" == "dropout" {
if "`ci'" == "ci" {
display "ci not supported for dropout probability"
local ci = ""
}
}
mat Piv = e(groupSize`model')
mat A = e(plot`model')
svmat A, names(col)
local ng = e(numGroups`model')
local plotCmd = " "
local orderTxt = " "
forvalues i = 1/`ng' {
local orderTxt "`orderTxt' `i'"
local pi`i' : display %4.1f round( el( Piv, 1, `i' ), .1 )
if "`dropout'" == "dropout" {
local plotCmd "`plotCmd' (line Dropout`i' trajT, lwidth(thick))"
}
else {
local plotCmd "`plotCmd' (line Est`i' trajT, lwidth(thick))"
}
local label`i' "`i' `pi`i''%"
}
if "`ci'" == "ci" {
forvalues i = 1/`ng' {
local plotCmd "`plotCmd' (scatter Avg`i' trajT, mstyle(p`i'))"
local plotCmd "`plotCmd' (line L95`i' trajT, lpattern(dash) lcolor(black))"
local plotCmd "`plotCmd' (line U95`i' trajT, lpattern(dash) lcolor(black))"
}
}
else {
forvalues i = 1/`ng' {
if "`dropout'" == "dropout" {
local plotCmd "`plotCmd' (scatter Dropout`i' trajT, mstyle(p`i'))"
}
else {
local plotCmd "`plotCmd' (scatter Avg`i' trajT, mstyle(p`i'))"
}
}
}
if "`nolegend'" == "nolegend" {
local plotCmd "`plotCmd', ytitle(`ytitle') xtitle(`xtitle') yscale(titlegap(*5)) xscale(titlegap(*5)) legend(off) ylabel(`ylabel') xlabel(`xlabel') scale(1.2)"
}
else {
local plotCmd "`plotCmd' ,legend(ring(1) cols(2) pos(6) order(`"`orderTxt'"') "
}
if "`legendLabels'" != "" & "`nolegend'" == "" {
local plotCmd "`plotCmd' `legendLabels' )"
}
if "`legendLabels'" == "" & "`nolegend'" == "" {
local plotCmd "`plotCmd' label(1 "`label1'") label(2 "`label2'") label(3 "`label3'") "
local plotCmd "`plotCmd' label(4 "`label4'") label(5 "`label5'") label(6 "`label6'") "
local plotCmd "`plotCmd' label(7 "`label7'") label(8 "`label8'") label(9 "`label9'") "
local plotCmd "`plotCmd' label(10 "`label10'") label(11 "`label11'") label(12 "`label12'") "
local plotCmd "`plotCmd' label(14 "`label14'") label(15 "`label15'") label(16 "`label16'") )"
}
if "`nolegend'" != "nolegend" {
local plotCmd "`plotCmd' ytitle(`ytitle') xtitle(`xtitle') ylabel(`ylabel') xlabel(`xlabel') yscale(titlegap(*5)) xscale(titlegap(*5)) scale(1.2)"
}
twoway `plotCmd'
restore
end
/* end of trajplot.ado */