📄 varirf_cgraph.ado
字号:
*! version 2.2.12 17mar2005
program define varirf_cgraph, rclass
version 8.0
syntax anything(name=gcmds id="specific graphs") /*
*/ [, /*
*/ INdividual /*
*/ LSTep(numlist max=1 integer >=0 <=500) /*
*/ USTep(numlist max=1 integer >0 <=500) /*
*/ noCI /*
*/ Level(passthru) /*
*/ set(string) /*
graph option */ SAving(string) /*
graph option */ name(string) /*
graph option */ TItle(string) /*
graph option */ iscale(string) /*
graph option */ imargin(string) /*
*/ CILines /*
*/ CI1opts(string asis) /*
*/ CI2opts(string asis) /*
*/ ciopts1(string asis) /*
*/ ciopts2(string asis) /*
*/ PLOT1opts(string asis) /*
*/ PLOT2opts(string asis) /*
*/ PLOT3opts(string asis) /*
*/ PLOT4opts(string asis) /*
*/ * /*
*/ ]
if "`individual'" == "" {
local getcombine getcombine
}
else local getcombine gettwoway
_get_gropts, graphopts(`options') getallowed(scheme) `getcombine'
if `"`s(scheme)'"' != "" {
local scheme `"scheme(`s(scheme)')"'
}
local graphopts `"`s(graphopts)'"'
local twg_opts `"`s(twowayopts)'"'
local comb_opts `"`s(combineopts)'"'
/* comb_options only allowed when individual is not specified */
if "`individual'" != "" {
_get_gropts, graphopts(`graphopts') getcombine
if `"`s(combineopts)'"' != "" {
di as err "{cmd:graph_combine_opts} cannot " /*
*/ "be specified with {cmd:individual}"
exit 198
}
}
if "`ustep'" != "" & "`lstep'" != "" {
if `ustep' < `lstep' {
di as err "{cmd:ustep()} cannot be less that " /*
*/ "{cmd:lstep()}."
exit 198
}
}
/* check noci and level options and re-map them if specified*/
if "`ci'" != "" & "`level'" != "" {
di as err "{cmd:noci} and {cmd:level()} cannot both " /*
*/ "be specified"
exit 198
}
local zero `0'
local 0 ", `level'"
local backopt `options'
syntax [, level(cilevel)]
local 0 `zero'
local options `backopt'
if "`ci'" != "" & "`cilines'" != "" {
di as err "{cmd:noci} and {cmd:cilines} cannot both " /*
*/ "be specified"
exit 198
}
if "`ci'" != "" & `"`ciopts1'`ci1opts'"' != "" {
di as err "{cmd:noci} and {cmd:ci1opts()} cannot both " /*
*/ "be specified"
exit 198
}
if "`ci'" != "" & `"`ciopts2'`ci2opts'"' != "" {
di as err "{cmd:noci} and {cmd:ci2opts()} cannot both " /*
*/ "be specified"
exit 198
}
local g_ciopts1 `"`ciopts1' `ci1opts'"'
local g_ciopts2 `"`ciopts2' `ci2opts'"'
if "`ci'" != "" {
local g_ci noci
local ci
}
if "`cilines'" != "" {
local g_cilines cilines
local cilines
}
if "`level'" != "" {
local g_level `level'
local level
}
else {
local g_level $S_level
}
local plist plot1opts plot2opts plot3opts plot4opts
foreach plopt of local plist {
if `"``plopt''"' != "" {
local g_`plopt' `"``plopt''"'
}
}
if `"`title'"' != "" {
local c_tmac `"title(`title')"'
local c_tmacs `"`title'"'
}
if "`individual'" != "" & `"`saving'"' != "" {
di as error "{p 0 4 2}no combined graph requested " ///
`"{cmd:saving(`saving')} not valid{p_end}"'
exit 198
}
if "`individual'" != "" & `"`name'"' != "" {
di as error "{p 0 4 2}no combined graph requested " ///
`"{cmd:saving(`saving')} not valid{p_end}"'
exit 198
}
if "`individual'" != "" & `"`iscale'"' != "" {
di as error "{p 0 4 2}no combined graph requested " ///
`"{cmd:iscale(`iscale')} not valid{p_end}"'
exit 198
}
if `"`saving'"' != "" {
SAVEPARSE `saving'
local c_file `"`r(fname)'"'
local c_replace "`r(replace)'"
if "`c_replace'" != "" {
local c_replace ", `c_replace'"
}
local c_save `"saving("`c_file'" `c_replace')"'
local c_saves `"`c_file'`c_replace'"'
}
if `"`name'"' != "" {
NAMEPARSE `name'
local cn_name `"`r(name)'"'
local cn_replace "`r(replace)'"
if "`cn_replace'" != "" {
local cn_replace ", `cn_replace'"
}
local cn_save `"name(`cn_name'`cn_replace')"'
local cn_saves `"`cn_name'`cn_replace'"'
}
/* set a new irf data file */
if `"`set'"' != "" {
irf set `set'
}
if `"$S_vrffile"' == "" {
di as err "no irf file active"
exit 198
}
preserve
_virf_use `"$S_vrffile"'
sort irfname impulse response step
qui sum step
local mstep = r(max)
if "`ustep'" != "" {
local g_ustep `ustep'
}
if "`lstep'" != "" {
local g_lstep `lstep'
}
local j 0
while `"`gcmds'"' != "" {
gettoken gline gcmds : gcmds , match(parns)
local 0 `"`gline'"'
local 0copy `"`0'"'
syntax anything(id="graph stats" name=gline) /*
*/ [, /*
*/ noCI /*
*/ Level(passthru) /*
*/ LSTep(numlist max=1 integer >=0 <=500) /*
*/ USTep(numlist max=1 integer >0 <=500) /*
*/ SAving(string) /*
*/ name(string) /*
*/ SUBtitle(string) /*
*/ CILines /*
*/ CI1opts(string asis) /*
*/ CI2opts(string asis) /*
*/ ciopts1(string asis) /*
*/ ciopts2(string asis) /*
*/ PLOT1opts(string asis) /*
*/ PLOT2opts(string asis) /*
*/ PLOT3opts(string asis) /*
*/ PLOT4opts(string asis) /*
*/ * /*
*/ ]
_get_gropts, graphopts(`options')
local itw_opts `"`s(graphopts)'"'
local ++j
local popts2ck ciopts1 ciopts2 ci1opts ci2opts
foreach opq of local popts2ck {
local `opq'm `"`g_`opq'' ``opq''"'
}
local plist plot1opts plot2opts plot3opts plot4opts
foreach plopt of local plist {
local `plopt'm `"`g_`plopt'' ``plopt''"'
}
if "`ustep'" == "" {
if "`g_ustep'" != "" {
local ustep `g_ustep'
}
else {
local ustep `mstep'
}
}
if "`lstep'" == "" {
if "`g_lstep'" != "" {
local lstep `g_lstep'
}
else {
local lstep 0
}
}
if "`lstep'" == "" {
di as err "minimum step not defined"
exit 498
}
if "`ustep'" == "" {
di as err "maximum step not defined"
exit 498
}
if `ustep' < `lstep' {
di as err "{cmd:ustep()} cannot be less "/*
*/ "that {cmd:lstep()}."
exit 198
}
local ifstep "& step >= `lstep' & step <= `ustep'"
if "`ci'" != "" & "`level'" != "" {
di as err "{cmd:noci} and {cmd:level()} " /*
*/ "cannot both be specified"
exit 198
}
if "`ci'" != "" | "`g_ci'" != "" {
local cim noci
}
else {
local cim
}
if "`cilines'" != "" | "`g_cilines'" != "" {
if "`ci'" != "" | "`g_ci'" != "" {
di as err "{cmd:noci} and {cmd:cilines} " ///
" cannot both be specified"
exit 198
}
}
if "`cilines'" != "" | "`g_cilines'" != "" {
local ciplot rline
}
else {
local ciplot rarea
}
if "`level'" != "" & "`g_ci'" != "" {
di as err "{cmd:level()} and {cmd:noci} cannot " /*
*/ "both be specified "
exit 198
}
if "`level'" == "" {
local level `g_level'
}
if `"`saving'"' != "" {
SAVEPARSE `saving'
local s_file `"`r(fname)'"'
local s_replace "`r(replace)'"
if "`s_replace'" != "" {
local s_replace ", `s_replace'"
}
local s_save `"saving("`s_file'"`s_replace')"'
local s_saves `"`s_file'`s_replace'"'
}
if `"`name'"' != "" {
NAMEPARSE `name'
local sn_name "`r(name)'"
local sn_replace "`r(replace)'"
if "`sn_replace'" != "" {
local sn_replace ", `sn_replace'"
}
local name `"name(`sn_name' `sn_replace')"'
local name_s `"`sn_name' `sn_replace'"'
}
gettoken tmp1 tmp2 : gline , parse("()")
local base `gline'
if `"`tmp2'"' != `""' {
di as err "specific graphs not properly "/*
*/ `"specified in `0'"'
exit 198
}
gettoken irfname base : base
local validirfs : char _dta[irfnames]
local tmp_ck : subinstr local validirfs "`irfname'" /*
*/ "`irfname'", count( local ck_found) word
if `ck_found' < 1 {
di as err "`irfname' is not a valid irfname"
exit 498
}
local ckvec : char _dta[`irfname'_model]
gettoken impulse base : base
local validimps : char _dta[`irfname'_order]
local tmp_ck : subinstr local validimps "`impulse'" /*
*/ "`impulse'", count( local ck_found) word
if `ck_found' < 1 {
di as err "`impulse' is not a valid impulse"
exit 498
}
gettoken response stats : base
local tmp_ck : subinstr local validimps "`response'" /*
*/ "`response'", count( local ck_found) word
if `ck_found' < 1 {
di as err "`response' is not a valid response"
exit 498
}
local n_stats : word count `stats'
if `n_stats' < 1 {
di as err "no statistics to graph"
exit 198
}
capture noi confirm variable `stats'
if _rc > 0 {
di as err "`stats' not valid"
exit 198
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -