*! version 1.0.0 NJC 6 Dec 1996 STB-35 gr22 program define bsmplot version 4.0 local varlist "req ex min(2) max(2)" local if "opt" local in "opt" #delimit ; local options "Window(int 3) Gap(int 6) L2title(str) L1title(str) T1title(str) Symbol(str) Connect(str) XLAbel(str) YLAbel(str) *" ; #delimit cr parse "`*'" if mod(`window',2) == 0 { di in r "window length must be odd" exit 198 } if `window' < 3 { di in r "window length must be at least 3" exit 198 } preserve if "`if'" != "" | "`in'" != "" { qui keep `if' `in' } tempvar smooth parse "`varlist'", parse(" ") sort `2' local sm "h" local nh = (`window' - 1) / 2 while `nh' > 1 { local sm = "`sm'" + "h" local nh = `nh' - 1 } smooth `sm' `1', gen(`smooth') if "`xlabel'" == "" { local xlabel "xlabel" } else { local xlabel "xlabel(`xlabel')" } if "`ylabel'" == "" { local ylabel "ylabel" } else { local ylabel "ylabel(`ylabel')" } if "`symbol'" == "" { local symbol "iii" } if "`connect'" == "" { local connect "||s" } if "`t1title'" == "" { local t1title "`window'-term binomial smoothing" } if "`l2title'" == "" { local varlab : variable label `1' if "`varlab'" != "" { local l2title "`varlab'" } else { local l2title "`1'" } } if "`l1title'" == "" { local l1title " " } #delimit ; graph `1' `smooth' `smooth' `2', c(`connect') sy(`symbol') `xlabel' `ylabel' t1title("`t1title'") l2title("`l2title'") l1title("`l1title'") gap(`gap') `options' ; #delimit cr end