📄 varirf_ctable.ado
字号:
* first column opens and closes itself all subsequent columns only
* close themselves.
*/
local hd2ind0 =int((`lstepc'-4)/2)+1
/* calculate title offset and display title */
if "`individual'" != "" {
local mcols =0
foreach ns of local nsind {
local mcols = max(`mcols',`ns')
}
}
else {
local mcols = `ncols'
}
if `"`g_title'"' != "" {
if `mcols' >= `cpline' {
di
di as txt `"{center: `g_title'}"'
}
else {
di
local t1len = length(`"`g_title'"')
local t1ind = int( (`lstepc' + /*
*/ `mcols'*`lcol'-`t1len')/2 )
di as txt `"{col `t1ind'}`g_title'"'
}
}
local col 1
local ac = 1
/* BEGIN table display **********************************************/
local inew 1 /* start a new table */
while `col' <= `ncols' {
local bl : word `col' of `blen'
local colp1 = `col' + 1
local colm1 = `col' - 1
local blP1 : word `colp1' of `blen'
local k : word `col' of `k_list'
local k `k'
local nextc : word `colp1' of `k_list'
if `colm1' > 0 {
local lastc : word `colm1' of `k_list'
}
else {
local lastc 0
}
local lastc `lastc'
if "`nextc'" == "" {
local nextc 0
}
if `inew' {
local tline "{c TLC}{hline `lstepcm2'}{c TT}"
local tline2 "{c LT}{hline `lstepcm2'}{c +}"
local bline "{c BLC}{hline `lstepcm2'}{c BT}"
local cpos `lstepc'
local hd1dis "{c |}{col `lstepc'}{c |}"
local hd2dis "{c |}{col `hd2ind0'}step{col `lstepc'}{c |}"
forvalues s=1/`smax'{
local v : display %-`lstfmt'.0f step[`s']
local dline`s' `"as txt "{c |}" as txt "{col `stind0'}`v'""'
local dline`s' `"`dline`s'' as txt "{col `lstepc'}{c |}""'
}
local inew 0
local ac = 1
local tnotes2 `tnotes1'
if "`individual'" != "" {
local tnotes1
}
}
else{
if `ac' == `bl' {
local endblock 1
/* if end then check in same tbl cmd
*
* else check room for next block
*/
if "`blP1'" == "" {
local inew 1
}
else local inew = /*
*/ (("`individual'" != "") /*
*/ & (`k' != `nextc')) /*
*/ | (`cpos' + (1+`blP1')*`lcol' > `linesize' )
local ac 0
}
else {
local endblock 0
}
local ++ac
local npos = `cpos' + `lcol'
if !`endblock' {
local tline "`tline'{hline `lcolm1'}{c -}"
local tline2 "`tline2'{hline `lcolm1'}{c -}"
local bline "`bline'{hline `lcolm1'}{c -}"
}
else {
if `inew' {
local tline "`tline'{hline `lcolm1'}{c TRC}"
local tline2 "`tline2'{hline `lcolm1'}{c RT}"
local bline "`bline'{hline `lcolm1'}{c BRC}"
}
else {
local tline "`tline'{hline `lcolm1'}{c TT}"
local tline2 "`tline2'{hline `lcolm1'}{c +}"
local bline "`bline'{hline `lcolm1'}{c BT}"
}
}
local k_ut : word `col' of `k_ulist'
local tnotes1 `tnotes1' `k_ut'
local hd1ind = int((`lcol'- length("`k_ut'"))/2 )
local hd1p = `cpos' + `hd1ind'
local k_udis "(`k_ut')"
local hd1dis "`hd1dis'{col `hd1p'}`k_udis'"
if `endblock' {
local hd1dis "`hd1dis'{col `npos'}{c |}"
}
local sn : word `col' of `nlist'
local hd2ind = int((`lcol'-length("`sn'"))/2 )
local hd2p = `cpos' + `hd2ind'
local hd2dis "`hd2dis'{col `hd2p'}`sn'"
if `endblock' {
local hd2dis "`hd2dis'{col `npos'}{c |}"
}
local st : word `col' of `slist'
local stind = `stind0' + `cpos'
forvalues s=1/`smax'{
local v : display %-`lcfmt'.6g `st'`k_ut'[`s']
local tok1 "{col `stind'}`v'"
local tok2 "{col `npos'}{c |}"
local dline`s' `"`dline`s'' as res "`tok1'""'
if `endblock' {
local dline`s' `"`dline`s'' as txt "`tok2'""'
}
}
local cpos = `cpos' + `lcol'
local ++col
}
if `inew' {
local llcpos `lcpos'
local lcpos `cpos'
if "`k_head'" != "" {
local k_headp `k_head'
}
else{
local k_headp 0
}
local k_head `k'
if `k_headp' > 0 & `k_headp' != `k_head' & /*
*/ "`individual'" != "" {
local tnotes2b : list uniq tnotes2
local lev_k : word `k_headp' of `levlist'
FootNote "`lev_k'" /*
*/ "`tnotes2b'" "`irflist'" /*
*/ "`impl'" "`resl'"
local r_tnotes `r_tnotes' `tnotes2'
}
if "`individual'" != "" {
if `k_head' != `k_headp' {
Title `"`title`k''"' `k'
}
else {
Title `"`title`k''"' `k' /*
*/ "(continued)"
}
}
di
di as txt "`tline'"
di as txt "`hd1dis'"
di as txt "`hd2dis'"
di as txt "`tline2'"
forvalues s=1/`smax'{
di `dline`s''
local dline`s'
}
di as txt "`bline'"
local cpos 0
}
}
/* END table display ************************************************/
local tnotes2 : list uniq tnotes1
local lev_k : word `k' of `levlist'
FootNote "`lev_k'" "`tnotes2'" "`irflist'" "`impl'" "`resl'"
local r_tnotes `r_tnotes' `tnotes1'
/* saved results */
return scalar k = `K' /* number of tspecs */
return scalar k_umax = `k_umax' /* number of triples */
return scalar ncols = `ncols' /* number of columns */
return local tnotes `r_tnotes' /* triple id for each column */
local k_ulist : list uniq k_ulist
qui FootNote "0" "`k_ulist'" "`irflist'" "`impl'" "`resl'"
return add
end
/* check for invalid triples */
program CheckTriple, rclass
args irfname impulse response
local condition /*
*/ irfname == "`irfname'" & impulse == "`impulse'" & response == "`response'"
qui count if `condition'
if r(N)== 0 {
di as err /*
*/ `"There are no observations in which irfname is "`irfname'","' /*
*/ `" impulse is "`impulse'", and response is "`response'""'
exit 2000
}
return local condition `condition'
end
/* display the table footnotes, i.e. key for the triples */
program FootNote, rclass
args level tnotes irflist impl resl
if `level' < . {
di as txt "{p 0 4 4}`level'% lower and upper bounds reported{p_end}"
}
foreach k_u of local tnotes {
local irf : word `k_u' of `irflist'
local imp : word `k_u' of `impl'
local res : word `k_u' of `resl'
local key (`k_u') /*
*/ irfname = `irf', /*
*/ impulse = `imp', and /*
*/ response = `res'
di as txt `"{p 0 4 4}`key'{p_end}"'
/* return the triple id and the triple */
return local key`k_u' `irf' `imp' `res'
}
end
program Title
args title num cont
if `"`title'"' == "" {
local title Table `num'
}
di as txt _n `"`title' `cont'"'
end
exit
NOTES:
The syntax for a table specification (tspec) is:
(<irfname> <impulse> <response> <stats> [, <options> ])
where <irfname> identifies a name contained in the -irfname- variable,
<impulse> identifies a name contained in the -impulse- variable , <response>
identifies a name contained in the -response- variable, and <stats> is a
non-empty list of statistics, i.e. at least one of irf, oirf, coirf, decomp.
The -irfname-, -impulse-, and -response- variables are contained in the
currently set varirf data file (along with the variables in <stats>).
Each tspec will result in at least 1 to at most 4 columns for the table,
depending upon what is in <options>.
Each table contains blocks that are not ment to be broken into seperate
tables. Each block is determined by the contents of <options> for each
statistic in <stats>, and is displayed in the table by
<stat> [std<stat>] [<stat>_ll <stat>_ul]
where <stat> is one of the statistics in <stats>, std<stat> is the standard
error of <stat>, and <stat>_ll, <stat>_ul are the lower and upper confidence
limits for <stat>. Blocks are uniquely identified by the k_u macro and
<stat>.
Macros:
k - indexes each table specification (tspec)
k_u - indexes each unique triple (<irfname> <impulse> <response>)
tspec lists: Each of the following macros contains space delimited elements
corresponding to each value of k. The element is described.
levlist - the value in the -level()- option
column lists: Each of the following macros contains space delimited elements
corresponding to each column of the table. The element is described.
k_list - value of k
k_ulist - value of k_u
nlist - display header
slist - variable name
nsind - # of stats to display for the current tspec
blen - number of columns in the current block
triple lists: Each of the following macros contains space delimited elements
corresponding to each value of k_u (unique triple). The element is described.
irflist - irfname
impl - impulse
resl - response
Temporary variables:
jvar - the -j()- identifier in the -reshape- command. Here
jvar equals the value of `k_u' for the triple (irfname
impulse response) contained in the current tspec.
<stat>_ll - the lower CI limit for <stat> (see <stats> above)
<stat>_ul - the upper CI limit for <stat> (see <stats> above)
<end>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -