Computed theoretical power for N=100 and N=200 scenarios
This commit is contained in:
39
Modules/ado/plus/m/maplist.ado
Normal file
39
Modules/ado/plus/m/maplist.ado
Normal file
@ -0,0 +1,39 @@
|
||||
program def maplist, rclass
|
||||
*! NJC 1.0.0 22 August 2000
|
||||
version 6.0
|
||||
gettoken list 0 : 0, parse(",")
|
||||
if "`list'" == "" | "`list'" == "," {
|
||||
di in r "nothing in list"
|
||||
exit 198
|
||||
}
|
||||
syntax , Map(str asis) [ Global(str) Noisily Symbol(str) ]
|
||||
|
||||
if "`symbol'" == "" { local symbol "@" }
|
||||
|
||||
if !index(`"`map'"',"`symbol'") {
|
||||
di in r "map( ) does not contain `symbol'"
|
||||
exit 198
|
||||
}
|
||||
|
||||
if length("`global'") > 8 {
|
||||
di in r "global name must be <=8 characters"
|
||||
exit 198
|
||||
}
|
||||
|
||||
tokenize `list'
|
||||
while "`1'" != "" {
|
||||
local result : subinstr local map "`symbol'" "`1'", all
|
||||
capture local 1 = `result'
|
||||
if _rc {
|
||||
di in r "inappropriate map?"
|
||||
exit _rc
|
||||
}
|
||||
local newlist "`newlist'`1' "
|
||||
mac shift
|
||||
}
|
||||
|
||||
if "`noisily'" != "" { di "`newlist'" }
|
||||
if "`global'" != "" { global `global' "`newlist'" }
|
||||
return local list `newlist'
|
||||
end
|
||||
|
2
Modules/ado/plus/m/maplist.hlp
Normal file
2
Modules/ado/plus/m/maplist.hlp
Normal file
@ -0,0 +1,2 @@
|
||||
.h listutil
|
||||
|
321
Modules/ado/plus/m/meta.dlg
Normal file
321
Modules/ado/plus/m/meta.dlg
Normal file
@ -0,0 +1,321 @@
|
||||
/*
|
||||
|
||||
*! meta dialog version 1.0.1, 13 May 2003, T. J. Steichen, steichen@triad.rr.com
|
||||
*! for meta version 2.06, Mar 1998, Stephen Sharp, stephen.j.sharp@gsk.com
|
||||
*! Jonathan Sterne, jonathan.sterne@bristol.ac.uk
|
||||
|
||||
Fixed and random-effects meta-analysis, with graphics
|
||||
-----------------------------------------------------
|
||||
|
||||
Syntax: meta { theta | exp(theta) } { se_theta | var_theta | ll ul [cl] }
|
||||
[if exp] [in range] [ , id(strvar) var ci graph(f|r|e) eform print
|
||||
ebayes level(#) fmult(#) boxysca(#) boxshad(#) cline ltrunc(#) rtrunc(#)]
|
||||
|
||||
To install in User Statistics menu via Stata commands:
|
||||
. window menu append item "stUserStatistics" "Meta-analysis of Effects (&meta)" "db meta"
|
||||
. window menu refresh
|
||||
To permanently install, place the commands in your -profile.do- file.
|
||||
*/
|
||||
|
||||
VERSION 8.0
|
||||
|
||||
INCLUDE _std_small
|
||||
INCLUDE header
|
||||
|
||||
HELP hlp1, view("help meta")
|
||||
RESET res1, label("Reset")
|
||||
|
||||
DIALOG main, label("meta 2.06 - Meta-analysis of Effects") tabtitle("Main")
|
||||
BEGIN
|
||||
GROUPBOX gb_data 10 5 330 _ht5h, ///
|
||||
label("Type of Data:")
|
||||
RADIO r_se 15 25 100 ., ///
|
||||
label("Theta, SE") first ///
|
||||
onclickon(script main_se_on) ///
|
||||
onclickoff(script main_se_off) ///
|
||||
option(NONE)
|
||||
RADIO r_var 115 25 100 ., ///
|
||||
label("Theta, Var") middle ///
|
||||
onclickon(script main_var_on) ///
|
||||
onclickoff(script main_var_off) ///
|
||||
option("var")
|
||||
RADIO r_ci 215 25 110 ., ///
|
||||
label("exp(Theta), CI") last ///
|
||||
onclickon(script main_ci_on) ///
|
||||
onclickoff(script main_ci_off) ///
|
||||
option("ci")
|
||||
|
||||
TEXT tx_se 15 45 320 ., ///
|
||||
label("Vars for theta, se(theta), in that order")
|
||||
VARLIST vl_se @ _ss @ ., ///
|
||||
label("Vars for theta, se(theta)")
|
||||
|
||||
TEXT tx_var @ 45 320 ., ///
|
||||
label("Vars for theta, var(theta), in that order")
|
||||
VARLIST vl_var @ _ss @ ., ///
|
||||
label("Vars for theta, var(theta)")
|
||||
|
||||
TEXT tx_ci @ 45 320 ., ///
|
||||
label("Vars for exp(theta), CI_LL, CI_UL, in that order")
|
||||
VARLIST vl_ci @ _ss @ ., ///
|
||||
label("Vars for exp(theta), CI_LL, CI_UL")
|
||||
|
||||
CHECKBOX cb_id 10 100 100 ., ///
|
||||
label("ID Variable:") ///
|
||||
onclickon(main.vn_id.enable) ///
|
||||
onclickoff(main.vn_id.disable)
|
||||
VARNAME vn_id 110 100 230 ., ///
|
||||
label("ID Variable") ///
|
||||
option("id")
|
||||
|
||||
CHECKBOX cb_eform 10 130 150 ., ///
|
||||
label("Use exp(theta)") ///
|
||||
option("eform")
|
||||
CHECKBOX cb_print 10 150 150 ., ///
|
||||
label("Print details") ///
|
||||
option("print")
|
||||
CHECKBOX cb_ebayes 10 170 300 ., ///
|
||||
label("Generate Empirical Bayes variables") ///
|
||||
option("ebayes")
|
||||
|
||||
CHECKBOX cb_level 220 130 75 ., ///
|
||||
label("CI Level:") ///
|
||||
onclickon(main.ed_level.enable) ///
|
||||
onclickoff(main.ed_level.disable)
|
||||
EDIT ed_level 300 @ 40 ., ///
|
||||
label("Level") numonly default(95) ///
|
||||
option("level")
|
||||
END
|
||||
|
||||
DIALOG graph, tabtitle("Graph Options")
|
||||
BEGIN
|
||||
GROUPBOX gb_graph 10 10 330 _ht2h, ///
|
||||
label("Graph Estimates:")
|
||||
RADIO r_none 15 30 65 ., ///
|
||||
label("None") first ///
|
||||
onclickon(program graph_off) ///
|
||||
onclickoff(program graph_on) ///
|
||||
option(NONE)
|
||||
RADIO r_fixed 80 30 65 ., ///
|
||||
label("Fixed") middle ///
|
||||
option("graph(f)")
|
||||
RADIO r_random 145 30 75 ., ///
|
||||
label("Random") middle ///
|
||||
option("graph(r)")
|
||||
RADIO r_ebayes 230 30 95 ., ///
|
||||
label("Emp. Bayes") last ///
|
||||
option("graph(e)")
|
||||
|
||||
CHECKBOX cb_cline 15 80 150 ., ///
|
||||
label("Draw Estimate line") ///
|
||||
option("cline")
|
||||
|
||||
CHECKBOX cb_fmult 200 80 95 ., ///
|
||||
label("Font scale:") ///
|
||||
onclickon(graph.ed_fmult.enable) ///
|
||||
onclickoff(graph.ed_fmult.disable)
|
||||
EDIT ed_fmult 300 @ 40 ., ///
|
||||
label("Font scale") numonly default(1) ///
|
||||
option("fmult")
|
||||
|
||||
CHECKBOX cb_boxy 200 110 95 ., ///
|
||||
label("Box yscale:") ///
|
||||
onclickon(graph.ed_boxy.enable) ///
|
||||
onclickoff(graph.ed_boxy.disable)
|
||||
EDIT ed_boxy 300 @ 40 ., ///
|
||||
label("Box yscale") numonly default(1) ///
|
||||
option("boxysca")
|
||||
|
||||
CHECKBOX cb_boxs 200 130 95 ., ///
|
||||
label("Box shade:") ///
|
||||
onclickon(graph.ed_boxs.enable) ///
|
||||
onclickoff(graph.ed_boxs.disable)
|
||||
EDIT ed_boxs 300 @ 40 ., ///
|
||||
label("Box shading") numonly default(0) ///
|
||||
option("boxshad")
|
||||
|
||||
CHECKBOX cb_ltrunc 15 110 95 ., ///
|
||||
label("Left truncate:") ///
|
||||
onclickon(graph.ed_ltrunc.enable) ///
|
||||
onclickoff(graph.ed_ltrunc.disable)
|
||||
EDIT ed_ltrunc 125 @ 40 ., ///
|
||||
label("Left truncate") numonly ///
|
||||
option("ltrunc")
|
||||
|
||||
CHECKBOX cb_rtrunc 15 130 105 ., ///
|
||||
label("Right truncate:") ///
|
||||
onclickon(graph.ed_rtrunc.enable) ///
|
||||
onclickoff(graph.ed_rtrunc.disable)
|
||||
EDIT ed_rtrunc 125 @ 40 ., ///
|
||||
label("Right truncate") numonly ///
|
||||
option("rtrunc")
|
||||
|
||||
GROUPBOX gb_gopts7 10 155 330 _ht1h, ///
|
||||
label("Allowed Graph7 Options:")
|
||||
EDIT ed_gopts7 15 175 320 ., ///
|
||||
label("Graph7 Options")
|
||||
END
|
||||
|
||||
INCLUDE ifin
|
||||
|
||||
SCRIPT main_se_on
|
||||
BEGIN
|
||||
main.tx_se.show
|
||||
main.vl_se.show
|
||||
main.tx_se.enable
|
||||
main.vl_se.enable
|
||||
|
||||
main.tx_var.disable
|
||||
main.vl_var.disable
|
||||
main.tx_var.hide
|
||||
main.vl_var.hide
|
||||
|
||||
main.tx_ci.disable
|
||||
main.vl_ci.disable
|
||||
main.tx_ci.hide
|
||||
main.vl_ci.hide
|
||||
END
|
||||
|
||||
SCRIPT main_se_off
|
||||
BEGIN
|
||||
main.tx_se.disable
|
||||
main.vl_se.disable
|
||||
main.tx_se.hide
|
||||
main.vl_se.hide
|
||||
END
|
||||
|
||||
SCRIPT main_var_on
|
||||
BEGIN
|
||||
main.tx_var.show
|
||||
main.vl_var.show
|
||||
main.tx_var.enable
|
||||
main.vl_var.enable
|
||||
|
||||
main.tx_se.disable
|
||||
main.vl_se.disable
|
||||
main.tx_se.hide
|
||||
main.vl_se.hide
|
||||
|
||||
main.tx_ci.disable
|
||||
main.vl_ci.disable
|
||||
main.tx_ci.hide
|
||||
main.vl_ci.hide
|
||||
END
|
||||
|
||||
SCRIPT main_var_off
|
||||
BEGIN
|
||||
main.tx_var.disable
|
||||
main.vl_var.disable
|
||||
main.tx_var.hide
|
||||
main.vl_var.hide
|
||||
END
|
||||
|
||||
SCRIPT main_ci_on
|
||||
BEGIN
|
||||
main.tx_ci.show
|
||||
main.vl_ci.show
|
||||
main.tx_ci.enable
|
||||
main.vl_ci.enable
|
||||
|
||||
main.tx_se.disable
|
||||
main.vl_se.disable
|
||||
main.tx_se.hide
|
||||
main.vl_se.hide
|
||||
|
||||
main.tx_var.disable
|
||||
main.vl_var.disable
|
||||
main.tx_var.hide
|
||||
main.vl_var.hide
|
||||
END
|
||||
|
||||
SCRIPT main_ci_off
|
||||
BEGIN
|
||||
main.tx_ci.disable
|
||||
main.vl_ci.disable
|
||||
main.tx_ci.hide
|
||||
main.vl_ci.hide
|
||||
END
|
||||
|
||||
PROGRAM graph_on
|
||||
BEGIN
|
||||
call graph.cb_cline.enable
|
||||
call graph.cb_fmult.enable
|
||||
call graph.cb_boxy.enable
|
||||
call graph.cb_boxs.enable
|
||||
call graph.cb_ltrunc.enable
|
||||
call graph.cb_rtrunc.enable
|
||||
call graph.gb_gopts7.enable
|
||||
call graph.ed_gopts7.enable
|
||||
if graph.cb_fmult {
|
||||
call graph.ed_fmult.enable
|
||||
}
|
||||
if graph.cb_boxy {
|
||||
call graph.ed_boxy.enable
|
||||
}
|
||||
if graph.cb_boxs {
|
||||
call graph.ed_boxs.enable
|
||||
}
|
||||
if graph.cb_ltrunc {
|
||||
call graph.ed_ltrunc.enable
|
||||
}
|
||||
if graph.cb_rtrunc {
|
||||
call graph.ed_rtrunc.enable
|
||||
}
|
||||
END
|
||||
|
||||
PROGRAM graph_off
|
||||
BEGIN
|
||||
call graph.cb_cline.disable
|
||||
call graph.cb_fmult.disable
|
||||
call graph.cb_boxy.disable
|
||||
call graph.cb_boxs.disable
|
||||
call graph.cb_ltrunc.disable
|
||||
call graph.cb_rtrunc.disable
|
||||
call graph.gb_gopts7.disable
|
||||
call graph.ed_gopts7.disable
|
||||
if graph.cb_fmult {
|
||||
call graph.ed_fmult.disable
|
||||
}
|
||||
if graph.cb_boxy {
|
||||
call graph.ed_boxy.disable
|
||||
}
|
||||
if graph.cb_boxs {
|
||||
call graph.ed_boxs.disable
|
||||
}
|
||||
if graph.cb_ltrunc {
|
||||
call graph.ed_ltrunc.disable
|
||||
}
|
||||
if graph.cb_rtrunc {
|
||||
call graph.ed_rtrunc.disable
|
||||
}
|
||||
END
|
||||
|
||||
PROGRAM command
|
||||
BEGIN
|
||||
put "meta "
|
||||
if main.r_se {
|
||||
varlist main.vl_se
|
||||
}
|
||||
if main.r_var {
|
||||
varlist main.vl_var
|
||||
}
|
||||
if main.r_ci {
|
||||
varlist main.vl_ci
|
||||
}
|
||||
INCLUDE _ifin_pr
|
||||
beginoptions
|
||||
option radio(main r_se r_var r_ci)
|
||||
optionarg main.vn_id
|
||||
option radio(graph r_none r_fixed r_random r_ebayes)
|
||||
option main.cb_eform
|
||||
option main.cb_print
|
||||
option main.cb_ebayes
|
||||
option graph.cb_cline
|
||||
optionarg graph.ed_fmult
|
||||
optionarg graph.ed_boxy
|
||||
optionarg graph.ed_boxs
|
||||
optionarg graph.ed_ltrunc
|
||||
optionarg graph.ed_rtrunc
|
||||
put graph.ed_gopts7
|
||||
endoptions
|
||||
END
|
118
Modules/ado/plus/m/meta_dialog.hlp
Normal file
118
Modules/ado/plus/m/meta_dialog.hlp
Normal file
@ -0,0 +1,118 @@
|
||||
{smcl}
|
||||
{* 12apr2004}{...}
|
||||
{hline}
|
||||
help for {cmd:meta_dialog}{right:(SJ4-2: pr0012)}
|
||||
{hline}
|
||||
|
||||
|
||||
{title:Submenu and dialogs for meta-analysis commands} {result:(Stata 8 only)}
|
||||
|
||||
|
||||
{title:Description}
|
||||
|
||||
{p 4 4 2}
|
||||
The {cmd:meta_dialog} package provides Stata 8 dialog boxes ({cmd:.dlg} files)
|
||||
and the commands needed to create a {hi:Meta-Analysis} submenu that contains
|
||||
the publicly available meta-analysis commands. The 14 commands included
|
||||
in this package that may be placed on the menu are {cmd:meta}, {cmd:metan},
|
||||
{cmd:metap}, {cmd:metareg}, {cmd:metacum}, {cmd:funnel}, {cmd:metafunnel},
|
||||
{cmd:labbe}, {cmd:metannt}, {cmd:metaninf}, {cmd:metainf}, {cmd:galbr},
|
||||
{cmd:metabias}, and {cmd:metatrim}.
|
||||
|
||||
{p 4 4 2}
|
||||
The menu commands (shown below) are placed in your personal Stata
|
||||
{cmd:profile.do} file. They create the submenu on the
|
||||
StataCorp-defined {hi:User} menu.
|
||||
|
||||
{p 4 4 2}
|
||||
You can determine if you have defined a {cmd:profile.do} file by starting
|
||||
Stata and observing whether a line of the form
|
||||
|
||||
{p 8}{result:running C:\data\stata\profile.do} ...
|
||||
|
||||
{p 4 4 2}
|
||||
appears on the screen as part of the initiation sequence. If it does,
|
||||
add the commands below to that file and resave the file. If the
|
||||
line does not appear, you have not defined a profile. Create a
|
||||
plain text file containing the commands below, name it {cmd:profile.do}, and
|
||||
save it somewhere in the Stata path.
|
||||
|
||||
{p 4 4 2}
|
||||
You may choose not to create the menu and run the dialogs directly
|
||||
from the Stata 8 command line via the {cmd:db {it:name}} command. If so,
|
||||
|
||||
{col 5}{hline 69}
|
||||
{col 5}command...{col 19}runs...{col 36}description...
|
||||
{col 5}{hline 69}
|
||||
{col 5}{dialog meta:db meta}{col 19}{help meta:meta 2.06}{col 36}Meta-analysis of Effects
|
||||
{col 5}{dialog metan:db metan}{col 19}{help metan:metan 1.74}{col 36}Meta-analysis of Binary and Continuous
|
||||
{col 5}{dialog metap:db metap}{col 19}{help metap:metap 2.0.0}{col 36}Meta-analysis of p-values
|
||||
{col 5}{dialog metareg:db metareg}{col 19}{help metareg:metareg 1.06}{col 36}Meta-analysis Regression
|
||||
{col 5}{dialog metacum:db metacum}{col 19}{help metacum:metacum 1.02}{col 36}Cumulative Meta-analysis
|
||||
{col 5}{dialog funnel:db funnel}{col 19}{help funnel:funnel 1.04}{col 36}Metan-based Funnel Graph
|
||||
{col 5}{dialog metafunnel:db metafunnel}{col 19}{help metafunnel:metafunnel 1.02}{col 36}Funnel Graph (vertical)
|
||||
{col 5}{dialog labbe:db labbe}{col 19}{help labbe:labbe 1.21}{col 36}Metan-based L'abbe Graph
|
||||
{col 5}{dialog metannt:db metannt}{col 19}{help metannt:metannt 1.0}{col 36}Metan-based NNT
|
||||
{col 5}{dialog metaninf:db metaninf}{col 19}{help metaninf:metaninf 1.0.1}{col 36}Metan-based Influence Analysis
|
||||
{col 5}{dialog metainf:db metainf}{col 19}{help metainf:metainf 3.0.0}{col 36}Meta-based Influence Analysis
|
||||
{col 5}{dialog galbr:db galbr}{col 19}{help galbr:galbr 2.0}{col 36}Galbraith Plot for Heterogeneity
|
||||
{col 5}{dialog metabias:db metabias}{col 19}{help metabias:metabias 1.2.2}{col 36}Publication Bias in Meta-analysis
|
||||
{col 5}{dialog metatrim:db metatrim}{col 19}{help metatrim:metatrim 1.0.5}{col 36}Trim and Fill Analysis
|
||||
{col 5}{hline 69}
|
||||
|
||||
|
||||
{title:Menu creation commands}
|
||||
|
||||
{p 4 4 2}
|
||||
Put the following commands in your {cmd:profile.do} (the lines are long and may wrap on the screen):{input}
|
||||
|
||||
{hline}{asis}
|
||||
|
||||
if _caller() >= 8 {
|
||||
window menu clear
|
||||
window menu append submenu "stUser" "&Meta-Analysis"
|
||||
window menu append item "Meta-Analysis" "Of Binary and Continuous (meta&n)" "db metan"
|
||||
window menu append item "Meta-Analysis" "Of Effects (&meta)" "db meta"
|
||||
window menu append item "Meta-Analysis" "Of p-values (meta&p)" "db metap"
|
||||
window menu append item "Meta-Analysis" "Cumulative (meta&cum)" "db metacum"
|
||||
window menu append item "Meta-Analysis" "Regression (meta®)" "db metareg"
|
||||
window menu append item "Meta-Analysis" "Funnel Graph, metan-based (f&unnel)" "db funnel"
|
||||
window menu append item "Meta-Analysis" "Funnel Graph, &vertical (metafunnel)" "db metafunnel"
|
||||
window menu append item "Meta-Analysis" "L'abbe Graph, metan-based (&labbe)" "db labbe"
|
||||
window menu append item "Meta-Analysis" "NNT, metan-based (metann&t)" "db metannt"
|
||||
window menu append item "Meta-Analysis" "Influence Analysis, metan-based (metan&inf)" "db metaninf"
|
||||
window menu append item "Meta-Analysis" "Influence Analysis, meta-based (metain&f)" "db metainf"
|
||||
window menu append item "Meta-Analysis" "Galbraith Plot for Heterogeneity (&galbr)" "db galbr"
|
||||
window menu append item "Meta-Analysis" "Publication Bias (meta&bias)" "db metabias"
|
||||
window menu append item "Meta-Analysis" "Trim and Fill Analysis (metatrim)" "db met&atrim"
|
||||
window menu refresh
|
||||
}
|
||||
|
||||
|
||||
{smcl}
|
||||
{hline}
|
||||
{sf}{txt}
|
||||
{title:Notes}
|
||||
|
||||
{p 4 4 2}
|
||||
Dialogs are available only in Stata 8 or later; thus, the leading
|
||||
{cmd:if _caller() >= 8 {c -(}} and trailing {cmd:{c )-}} lines above are
|
||||
needed only if you also run Stata 7. Leaving these lines in will not cause
|
||||
problems.
|
||||
|
||||
{p 4 4 2}
|
||||
The easiest way to capture these commands is to open this help file in your
|
||||
text editor, copy the lines, and then paste them into {cmd:profile.do}.
|
||||
|
||||
|
||||
{title:Author}
|
||||
|
||||
{p 4 8 2}
|
||||
Thomas J. Steichen, steichen@triad.rr.com
|
||||
|
||||
|
||||
{title:Also see}
|
||||
|
||||
Manual: {hi:[P] dialogs; [P] window menu; [R] db}
|
||||
|
||||
{p 4 13 2}Online: help for {help dialogs}; {help window}; {help db}
|
918
Modules/ado/plus/m/metabias.ado
Normal file
918
Modules/ado/plus/m/metabias.ado
Normal file
@ -0,0 +1,918 @@
|
||||
*! metabias version 1.2.2 07feb01 TJS (STB-61: sbe19.4)
|
||||
program define metabias, rclass
|
||||
version 6.0
|
||||
* version 1.0.0 24oct97 TJS STB-41 sbe19
|
||||
* version 1.1.2 21apr98 TJS Unweighted Egger analysis only STB-44 sbe19.1
|
||||
* version 1.1.3 1oct99 TJS fixed stratified bug STB-44 sbe19.1
|
||||
* version 1.2.0 17feb00 TJS Version 6 and gweight option (STB-57: sbe19.2)
|
||||
* version 1.2.1 31jan01 TJS touched for version 7.0
|
||||
*
|
||||
*! syntax: metabias varlist [if] [in]
|
||||
*! [ , Graph(str) GWeight Vari CI BY(varname) LEvel(real 95) * ]
|
||||
|
||||
if ("`*'" == "") {
|
||||
di "Syntax is:"
|
||||
di in wh "metabias " in gr "{ theta { se | var } | " _c
|
||||
di in gr "exp(theta) | ll ul [cl] } [" _c
|
||||
di in wh "if " in gr "exp] [" in wh "in " in gr "range]"
|
||||
di in gr " [ " in wh ", by(" in gr "by_var"in wh ")" _c
|
||||
di in gr " { " in wh "v" in gr "ar | " in wh "ci" in gr " } " _c
|
||||
di in wh "g" in gr "raph" in wh "(" in gr "{ " in wh "b" _c
|
||||
di in gr "egg | " in wh "e" in gr "gger }" in wh ")"
|
||||
di in wh " gw" in gr "eight" in wh " lev" _c
|
||||
di in gr "el" in wh "(" in gr "#" in wh ") " in gr "graph_options ]"
|
||||
di _n in gr " where { a | b |...} means choose" _c
|
||||
di in gr " one and only one of {a, b, ...}"
|
||||
exit
|
||||
}
|
||||
|
||||
* Setup
|
||||
syntax varlist(numeric min=2 max=4) [if] [in] /*
|
||||
*/ [ , Graph(str) Vari CI BY(varname) LEvel(real 95) * ]
|
||||
* Note: option GWeight is passed via * directly to the graphics subs
|
||||
marksample touse
|
||||
tokenize `varlist'
|
||||
|
||||
tempvar byg theta setheta var w sw vt wtheta swtheta
|
||||
tempvar zz Ts wl swl RRm bylabel
|
||||
tempname k ks sdks p zu pcc zcc c sks svks sk oe sbv sv
|
||||
* v7 fix
|
||||
tempvar bylabl
|
||||
|
||||
local theta `1'
|
||||
if "`3'" == "" { local setheta `2' }
|
||||
else {
|
||||
tempvar ll ul cl
|
||||
local ll `2'
|
||||
local ul `3'
|
||||
local cl `4'
|
||||
}
|
||||
|
||||
* input error traps
|
||||
if "`ci'" != "" & "`vari'" != "" {
|
||||
di _n in re "Error: options 'ci' and 'var' cannot " _c
|
||||
di in re "be specified together."
|
||||
exit
|
||||
}
|
||||
if "`ci'" == "ci" & "`ul'" != "" {
|
||||
di _n in bl "Note: option 'ci' specified."
|
||||
}
|
||||
if "`ci'" == "ci" & "`ul'" == "" {
|
||||
di _n in re "Error: option 'ci' specified but varlist " _c
|
||||
di in re "has only 2 variables."
|
||||
exit
|
||||
}
|
||||
if "`ci'" != "ci" & "`vari'" != "vari" & "`ul'" != "" {
|
||||
di _n in bl "Warning: varlist has 3 variables but option " _c
|
||||
di in bl "'ci' not specified; 'ci' assumed."
|
||||
local ci "ci"
|
||||
local vari ""
|
||||
}
|
||||
if "`vari'" == "vari" & "`ul'" != "" {
|
||||
di _n in re "Error: option 'var' specified but varlist " _c
|
||||
di in re "has more than 2 variables."
|
||||
exit
|
||||
}
|
||||
if "`vari'" == "vari" & "`ul'" == "" {
|
||||
di _n in bl "Note: option 'var' specified."
|
||||
}
|
||||
if "`vari'" != "vari" & "`ul'" == "" {
|
||||
di _n in bl "Note: default data input format (theta, " _c
|
||||
di in bl "se_theta) assumed."
|
||||
}
|
||||
|
||||
* Select data to analyze
|
||||
if "`ul'" == "" { markout `touse' `theta' `setheta' }
|
||||
else { markout `touse' `theta' `ll' `ul' }
|
||||
|
||||
preserve /* Note: data preserved here */
|
||||
|
||||
* Generate `by' groups
|
||||
if "`by'" != "" {
|
||||
confirm var `by'
|
||||
sort `by'
|
||||
qui by `by': gen byte `byg' = _n==1
|
||||
qui replace `byg' = sum(`byg')
|
||||
local byn = `byg'[_N]
|
||||
}
|
||||
else {
|
||||
qui gen byte `byg' = 1
|
||||
local byn = 1
|
||||
}
|
||||
|
||||
* Generate `by' labels -- if required
|
||||
if ("`by'" != "") {
|
||||
capture decode `by', gen(`bylabel')
|
||||
if _rc != 0 {
|
||||
local type : type `by'
|
||||
if substr("`type'",1,3) != "str" {
|
||||
qui gen str8 `bylabel' = string(`by')
|
||||
}
|
||||
else { qui gen `type' `bylabel' = `by' }
|
||||
}
|
||||
* v7 fix
|
||||
encode `bylabel', gen(`bylabl')
|
||||
}
|
||||
|
||||
* Do calculations
|
||||
* initial calculations...
|
||||
if "`vari'" == "vari" { qui replace `setheta' = sqrt(`setheta')}
|
||||
|
||||
if "`ci'" == "ci" {
|
||||
capture confirm variable `cl'
|
||||
if _rc~=0 { qui gen `zz' = invnorm(.975) }
|
||||
else {
|
||||
qui replace `cl' = `cl' * 100 if `cl' < 1
|
||||
qui gen `zz' = -1 * invnorm((1- `cl' / 100) / 2 )
|
||||
qui replace `zz' = invnorm(.025) if `zz'==.
|
||||
}
|
||||
qui gen `setheta' = ( ln(`ul') - ln(`ll')) / 2 / `zz'
|
||||
qui replace `theta' = ln(`theta')
|
||||
}
|
||||
|
||||
if "`if'" != "" { ifexp "`if'" }
|
||||
|
||||
if "`by'" != "" {
|
||||
scalar `sk' = 0
|
||||
scalar `sks' = 0
|
||||
scalar `svks' = 0
|
||||
scalar `sbv' = 0
|
||||
scalar `sv' = 0
|
||||
}
|
||||
|
||||
* loop through by-values
|
||||
local j = 1
|
||||
while `j' <= `byn' { /* start of loop for each `by' group */
|
||||
|
||||
summ `touse' if `touse' & `byg' == `j', meanonly
|
||||
local data = _result(1)
|
||||
|
||||
* Calculate stats
|
||||
qui {
|
||||
gen `var' = `setheta'^2
|
||||
gen `w' = 1/`var'
|
||||
egen `sw' = sum(`w') if `touse' & `byg' == `j'
|
||||
gen `vt' = `var' - 1 / `sw'
|
||||
gen `wtheta' = `w' * `theta'
|
||||
egen `swtheta' = sum(`wtheta') if `touse' & `byg' == `j'
|
||||
gen `Ts' = (`theta' - `swtheta' / `sw') / sqrt(`vt')
|
||||
gen `wl' = `w' * `theta'
|
||||
egen `swl' = sum(`wl') if `touse' & `byg' == `j'
|
||||
gen `RRm' = `swl' / `sw'
|
||||
scalar `oe' = `RRm'
|
||||
}
|
||||
|
||||
qui capture ktau2 `var' `Ts' if `touse' & `byg' == `j'
|
||||
if _rc == 0 {
|
||||
scalar `k' = $S_1
|
||||
scalar `ks' = $S_4
|
||||
scalar `sdks' = $S_5
|
||||
scalar `p' = $S_6
|
||||
scalar `zu' = $S_7
|
||||
scalar `pcc' = $S_8
|
||||
scalar `zcc' = $S_9
|
||||
scalar `c' = $S_10
|
||||
}
|
||||
else if _rc == 2001 {
|
||||
scalar `k' = `data'
|
||||
scalar `ks' = .
|
||||
scalar `sdks' = .
|
||||
scalar `p' = .
|
||||
scalar `zu' = .
|
||||
scalar `pcc' = .
|
||||
scalar `zcc' = .
|
||||
scalar `c' = .
|
||||
}
|
||||
else {
|
||||
di in re "error " _rc " in call to ktau2"
|
||||
exit
|
||||
}
|
||||
|
||||
if "`by'" != "" & `k' > 1 {
|
||||
scalar `sk' = `sk' + `k'
|
||||
scalar `sks' = `sks' + `ks'
|
||||
scalar `svks' = `svks' + `sdks'^2
|
||||
}
|
||||
|
||||
* Egger's bias test
|
||||
tempvar prec snd
|
||||
qui gen `prec'= 1 / `setheta'
|
||||
qui gen `snd' = `theta' / `setheta'
|
||||
qui regr `snd' `prec' if `touse' & `byg' == `j'
|
||||
capture matrix b = get(_b)
|
||||
if _rc == 0 {
|
||||
local df = e(N) - 2
|
||||
local bias = b[1,2]
|
||||
capture matrix V = get(VCE)
|
||||
if _rc == 0 {
|
||||
local pb = tprob(`df', b[1,2] / sqrt(V[2,2]))
|
||||
* 1.1.3 fix
|
||||
* if "`by'" != "" {
|
||||
if "`by'" != "" & V[2,2] != 0 & `data' > 0 {
|
||||
scalar `sbv' = `sbv' + `bias' / V[2,2]
|
||||
scalar `sv' = `sv' + 1 / V[2,2]
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
local bias = .
|
||||
local pb = .
|
||||
}
|
||||
|
||||
* Display results
|
||||
if "`by'" != "" {
|
||||
* use this display if a by_var was specified...
|
||||
* .....display output header
|
||||
if `j' == 1 {
|
||||
di " "
|
||||
di in gr "Tests for Publication Bias"
|
||||
di " "
|
||||
local sp = 8 - length("`by'")
|
||||
#delimit ;
|
||||
di in gr "-------------------------------------------------"
|
||||
"------------------------------" ;
|
||||
di in gr " | | Begg's Begg's"
|
||||
" cont. corr. | Egger's " ;
|
||||
di in gr _skip(`sp') "`by' | n | score s.d. z"
|
||||
" p z p | bias p" ;
|
||||
di in gr "---------+------+--------------------------------"
|
||||
"---------------+--------------" ;
|
||||
#delimit cr
|
||||
local scs " "
|
||||
}
|
||||
* v7 fix
|
||||
* local sp = 8 - length(`bylabel')
|
||||
local blab: label (`bylabl') `j'
|
||||
local sp = 8 - length("`blab'")
|
||||
|
||||
if `c' == 1 {
|
||||
local cs "*"
|
||||
local scs "*"
|
||||
}
|
||||
else {local cs " "}
|
||||
* .....display results for each by-value
|
||||
if `data' > 0 {
|
||||
* v7 fix
|
||||
di in gr _skip(`sp') "`blab' | " in ye %4.0f `k' _c
|
||||
* di in gr _skip(`sp') `bylabel' " | " in ye %4.0f `k' _c
|
||||
di in gr " |" in ye %4.0f `ks' in gr "`cs' " _c
|
||||
di in ye %6.3f `sdks' " " %6.2f `zu' " " %6.3f `p' " " _c
|
||||
di in ye %6.2f `zcc' " " %6.3f `pcc' in gr " |" _c
|
||||
di in ye %6.2f `bias' " " %6.3f `pb'
|
||||
}
|
||||
* .....do stratified calculations
|
||||
if `j' == `byn' {
|
||||
scalar `zu' = `sks' / sqrt(`svks')
|
||||
scalar `p' = 2 * (1 - normprob(abs(`zu')))
|
||||
scalar `zcc' = sign(`sks')*(abs(`sks') - 1) / sqrt(`svks')
|
||||
scalar `pcc' = 2 * (1 - normprob(abs(`zcc')))
|
||||
scalar `k' = `sk'
|
||||
scalar `ks' = `sks'
|
||||
scalar `sdks' = sqrt(`svks')
|
||||
drop `sw' `wl' `swl' `RRm'
|
||||
qui egen `sw' = sum(`w') if `touse'
|
||||
qui gen `wl' = `w' * `theta'
|
||||
qui egen `swl' = sum(`wl') if `touse'
|
||||
qui gen `RRm' = `swl' / `sw'
|
||||
scalar `oe' = `RRm'
|
||||
|
||||
qui regr `snd' `prec' if `touse'
|
||||
capture matrix b = get(_b)
|
||||
if _rc == 0 {
|
||||
matrix V = get(VCE)
|
||||
local df = e(N) - 2
|
||||
local bias = b[1,2]
|
||||
local pb = tprob(`df', b[1,2]/sqrt(V[2,2]))
|
||||
}
|
||||
else {
|
||||
local bias = .
|
||||
local pb = .
|
||||
}
|
||||
|
||||
local bias = `sbv' / `sv'
|
||||
local pb = 1 - normprob(`bias' / sqrt(1 / `sv'))
|
||||
|
||||
* .....and display overall (stratified) results
|
||||
di in gr "---------+------+----------------------------" _c
|
||||
di in gr "-------------------+--------------"
|
||||
di in gr " overall | " in ye %4.0f `sk' _c
|
||||
di in gr " |" in ye %4.0f `sks' in gr "`scs' " _c
|
||||
di in ye %6.3f sqrt(`svks') " " %6.2f `zu' " " %6.3f `p' _c
|
||||
di in ye " " %6.2f `zcc' " " %6.3f `pcc' in gr " |" _c
|
||||
di in ye %6.2f `bias' " " %6.3f `pb'
|
||||
di in gr "---------------------------------------------" _c
|
||||
di in gr "----------------------------------"
|
||||
if "`scs'" == "*" {
|
||||
di in gr _skip(21) "`scs' (corrected for ties)"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
|
||||
* use this display if no by_var was specified...
|
||||
* Begg's
|
||||
di _n in gr "Tests for Publication Bias"
|
||||
di _n in gr "Begg's Test"
|
||||
di " "
|
||||
di in gr " adj. Kendall's Score (P-Q) = " in ye %7.0f `ks'
|
||||
di _c in gr " Std. Dev. of Score = " in ye %7.2f `sdks'
|
||||
if `c' == 1 { di in gr " (corrected for ties)" }
|
||||
else { di " " }
|
||||
di in gr " Number of Studies = " in ye %7.0f `k'
|
||||
di in gr " z = " in ye %7.2f `zu'
|
||||
di in gr " Pr > |z| = " in ye %7.3f `p'
|
||||
di _c in gr " z = " in ye %7.2f `zcc'
|
||||
di in gr " (continuity corrected)"
|
||||
di _c in gr " Pr > |z| = " in ye %7.3f `pcc'
|
||||
di in gr " (continuity corrected)"
|
||||
|
||||
* Egger's
|
||||
tempvar prec snd
|
||||
qui gen `prec'= 1 / `setheta'
|
||||
qui gen `snd' = `theta' / `setheta'
|
||||
qui regr `snd' `prec' if `touse'
|
||||
capture matrix b = get(_b)
|
||||
if _rc == 0 {
|
||||
matrix V = get(VCE)
|
||||
local obs = e(N)
|
||||
local df = `obs' - 2
|
||||
matrix colnames b = slope bias
|
||||
matrix rownames V = slope bias
|
||||
matrix colnames V = slope bias
|
||||
matrix post b V, dep(Std_Eff) dof(`df') obs(`obs')
|
||||
di _n in gr "Egger's test"
|
||||
matrix mlout, level(`level')
|
||||
}
|
||||
else {
|
||||
di _n in gr "Egger's Test" _n
|
||||
di in ye " - undefined for only 1 study"
|
||||
}
|
||||
}
|
||||
|
||||
cap drop `var' `w' `sw' `vt' `wtheta' `swtheta'
|
||||
cap drop `Ts' `wl' `swl' `RRm'
|
||||
local j = `j' + 1
|
||||
|
||||
} /* end of loop for each `by' group */
|
||||
|
||||
* Graph a bias plot
|
||||
local g = lower(substr("`graph'",1,1))
|
||||
if "`g'" == "b" {
|
||||
beggph `theta' `setheta' `touse', level(`level') `ci' `options'
|
||||
}
|
||||
if "`g'" == "e" {
|
||||
egggph `theta' `setheta' `touse', level(`level') `options'
|
||||
}
|
||||
|
||||
* Save globals
|
||||
global S_1 = `k'
|
||||
global S_2 = `ks'
|
||||
global S_3 = `sdks'
|
||||
global S_4 = `p'
|
||||
global S_5 = `pcc'
|
||||
global S_6 = `bias'
|
||||
global S_7 = `pb'
|
||||
global S_8 = `oe'
|
||||
|
||||
* return globals
|
||||
return scalar k = `k'
|
||||
return scalar score = `ks'
|
||||
return scalar score_sd = `sdks'
|
||||
return scalar Begg_p = `p'
|
||||
return scalar Begg_pcc = `pcc'
|
||||
return scalar Egger_bc = `bias'
|
||||
return scalar Egger_p = `pb'
|
||||
return scalar effect = `oe'
|
||||
|
||||
exit
|
||||
end
|
||||
|
||||
* ***************************************************
|
||||
|
||||
program define beggph
|
||||
version 6.0
|
||||
|
||||
* creates the Begg funnel plot graph
|
||||
|
||||
* Setup
|
||||
|
||||
syntax varlist(min=3 max=3) [if] [in] [, CI L1title(str) /*
|
||||
*/ L2title(str) Connect(str) Symbol(str) SOrt Pen(str) /*
|
||||
*/ T2title(str) B2title(str) YLAbel(str) XLAbel(str) /*
|
||||
*/ LEVel(integer $S_level) GAp(str) GWeight * ]
|
||||
tokenize `varlist'
|
||||
|
||||
tempvar touse theta setheta
|
||||
|
||||
local theta `1'
|
||||
local setheta `2'
|
||||
local touse `3'
|
||||
|
||||
preserve
|
||||
|
||||
* Graph options
|
||||
if "`connect'" == "" { local connect "lll." }
|
||||
else {
|
||||
local lll = length("`connect'")
|
||||
if `lll' == 1 { local connect "`connect'll." }
|
||||
else if `lll' == 2 { local connect "`connect'l." }
|
||||
else if `lll' == 3 { local connect "`connect'." }
|
||||
}
|
||||
local connect "co(`connect')"
|
||||
|
||||
if "`symbol'" == "" { local symbol "iiio" }
|
||||
else {
|
||||
local lll = length("`symbol'")
|
||||
if `lll' == 1 { local symbol "`symbol'iio" }
|
||||
else if `lll' == 2 { local symbol "`symbol'io" }
|
||||
else if `lll' == 3 { local symbol "`symbol'o" }
|
||||
}
|
||||
local symbol "sy(`symbol')"
|
||||
|
||||
if "`pen'" == "" { local pen "3552" }
|
||||
else {
|
||||
local lll = length("`pen'")
|
||||
if `lll' == 1 { local pen "`pen'552" }
|
||||
else if `lll' == 2 {
|
||||
local pen = "`pen'" + substr("`pen'",2,1) + "2"
|
||||
}
|
||||
else if `lll' == 3 { local pen "`pen'2" }
|
||||
}
|
||||
local pen "pen(`pen')"
|
||||
|
||||
if "`l2title'" == "" {
|
||||
local l2title : variable label `theta'
|
||||
if "`l2title'" == "" { local l2title "`theta'" }
|
||||
}
|
||||
if "`ci'" == "" { local l2title "l2(`l2title')" }
|
||||
else { local l2title "l2(log[`l2title'])" }
|
||||
|
||||
if "`l1title'" == "" { local l1title "" "" }
|
||||
local l1title "l1(`l1title')"
|
||||
|
||||
if "`b2title'" == "" {
|
||||
local b2title : variable label `theta'
|
||||
if "`b2title'" == "" { local b2title "`theta'" }
|
||||
}
|
||||
if "`ci'" == "" { local b2title = "b2(s.e. of: `b2title')" }
|
||||
else { local b2title = "b2(s.e. of: log[`b2title'])" }
|
||||
|
||||
if `"`t2title'"' == `""' {
|
||||
local t2title = "Begg's funnel plot with pseudo"
|
||||
local t2title = "`t2title' `level'% confidence limits"
|
||||
local t2title "t2(`"`t2title'"')"
|
||||
}
|
||||
else if `"`t2title'"' == `"."' { local t2title }
|
||||
else { local t2title "t2(`"`t2title'"')" }
|
||||
|
||||
if "`xlabel'" == "" { local xlabel "xla" }
|
||||
else { local xlabel "xlabel(`xlabel')" }
|
||||
|
||||
if "`ylabel'" == "" { local ylabel "yla" }
|
||||
else { local ylabel "ylabel(`ylabel')" }
|
||||
|
||||
if "`sort'" == "" { local sort "sort" }
|
||||
|
||||
if "`gap'" == "" { local gap "gap(3)" }
|
||||
else { local gap "gap(`gap')" }
|
||||
|
||||
tempvar ll2 ul2 z mmm var w sw wl swl RRm
|
||||
tempname oe
|
||||
|
||||
qui {
|
||||
if `level' < 1 { local `level' =`level' * 100 }
|
||||
local z = -1 * invnorm((1 - `level' / 100) / 2)
|
||||
local obs1=_N+1
|
||||
set obs `obs1'
|
||||
replace `setheta'=0 in `obs1'
|
||||
replace `theta' = . in `obs1'
|
||||
gen `var' = `setheta'^2
|
||||
gen `w' = 1/`var'
|
||||
egen `sw' = sum(`w') if `touse'
|
||||
gen `wl' = `w' * `theta'
|
||||
egen `swl' = sum(`wl') if `touse'
|
||||
gen `RRm' = `swl' / `sw'
|
||||
scalar `oe' = `RRm'
|
||||
egen `mmm' = min(`RRm')
|
||||
replace `RRm' = `mmm' if `setheta' == 0
|
||||
gen `ll2' = `RRm' - `z' * `setheta'
|
||||
gen `ul2' = `RRm' + `z' * `setheta'
|
||||
}
|
||||
|
||||
if "`gweight'" != "" {
|
||||
tempvar ww
|
||||
qui gen `ww' = `w'
|
||||
qui replace `ww' = 1 if `setheta' == 0
|
||||
local gw "[w=`ww']"
|
||||
}
|
||||
else { local gw "" }
|
||||
|
||||
#delimit ;
|
||||
graph `RRm' `ll2' `ul2' `theta' `setheta' `gw' if `touse',
|
||||
`connect' `symbol' `t2title' `l2title' `b2title'
|
||||
`l1title' `xlabel' `ylabel' `sort' `pen' `gap' `options';
|
||||
#delimit cr
|
||||
|
||||
exit
|
||||
end
|
||||
|
||||
* ***************************************************
|
||||
|
||||
program define egggph
|
||||
version 6.0
|
||||
|
||||
* creates the Egger regression asymmetry plot graph
|
||||
|
||||
* Setup
|
||||
|
||||
syntax varlist(min=3 max=3) [if] [in] [, LEVel(integer 95) GWeight /*
|
||||
*/ GAp(str) Connect(str) Symbol(str) SOrt Pen(str) T2title(str) /*
|
||||
*/ B2title(str) YLAbel(str) XLAbel(str) L1title(str) L2title(str) *]
|
||||
|
||||
tokenize `varlist'
|
||||
|
||||
tempvar touse theta setheta
|
||||
|
||||
local theta `1'
|
||||
local setheta `2'
|
||||
local touse `3'
|
||||
|
||||
preserve
|
||||
|
||||
* Graph options
|
||||
if "`connect'" == "" { local connect ".ll" }
|
||||
else {
|
||||
local lll = length("`connect'")
|
||||
if `lll' == 1 { local connect "`connect'll" }
|
||||
else if `lll' == 2 { local connect "`connect'l" }
|
||||
}
|
||||
local connect "co(`connect')"
|
||||
|
||||
if "`symbol'" == "" { local symbol "oid" }
|
||||
else {
|
||||
local lll = length("`symbol'")
|
||||
if `lll' == 1 { local symbol "`symbol'id" }
|
||||
else if `lll' == 2 { local symbol "`symbol'd" }
|
||||
}
|
||||
local symbol "sy(`symbol')"
|
||||
|
||||
if "`pen'" == "" { local pen "233" }
|
||||
else {
|
||||
local lll = length("`pen'")
|
||||
if `lll' == 1 { local pen "`pen'33" }
|
||||
else if `lll' == 2 {local pen = "`pen'" + substr("`pen'",2,1)}
|
||||
}
|
||||
local pen "pen(`pen')"
|
||||
|
||||
if "`l2title'" == "" { local l2title "standardized effect" }
|
||||
local l2title "l2(`l2title')"
|
||||
|
||||
if "`l1title'" == "" { local l1title "" "" }
|
||||
local l1title "l1(`l1title')"
|
||||
|
||||
if "`b2title'" == "" { local b2title "precision" }
|
||||
local b2title = "b2(`b2title')"
|
||||
|
||||
if `"`t2title'"' == `""' {
|
||||
local t2title = "Egger's publication bias plot"
|
||||
local t2title "t2(`"`t2title'"')"
|
||||
}
|
||||
else if `"`t2title'"' == `"."' { local t2title t2(" ")}
|
||||
else { local t2title "t2(`"`t2title'"')" }
|
||||
|
||||
|
||||
if "`xlabel'" == "" { local xlabel "xla" }
|
||||
else { local xlabel "xlabel(`xlabel')" }
|
||||
|
||||
if "`ylabel'" == "" { local ylabel "yla" }
|
||||
else { local ylabel "ylabel(`ylabel')" }
|
||||
|
||||
if "`sort'" == "" { local sort "sort" }
|
||||
|
||||
if "`gap'" == "" { local gap "gap(3)" }
|
||||
else { local gap "gap(`gap')" }
|
||||
|
||||
qui {
|
||||
local obs1 = _N + 1
|
||||
local obs2 = _N + 2
|
||||
local obs3 = _N + 3
|
||||
set obs `obs3'
|
||||
replace `setheta' = 0 in `obs1'/`obs3'
|
||||
replace `theta' = . in `obs1'/`obs3'
|
||||
tempvar prec snd
|
||||
gen `prec' = 1 / `setheta' if `setheta' > 0
|
||||
gen `snd' = `theta' / `setheta' if `setheta' > 0
|
||||
replace `prec' = 0 if `prec' == .
|
||||
regr `snd' `prec' if `touse'
|
||||
tempvar reg ci
|
||||
capture matrix b = get(_b)
|
||||
if _rc == 0 {
|
||||
matrix V = get(VCE)
|
||||
local df = e(N) - 2
|
||||
gen `reg' = b[1,2] + `prec' * b[1,1]
|
||||
gen `ci' = .
|
||||
#delimit ;
|
||||
replace `ci' = b[1,2] - sqrt(V[2,2])
|
||||
* invt(`df', `level'/100) in `obs2' ;
|
||||
replace `ci' = b[1,2] + sqrt(V[2,2])
|
||||
* invt(`df', `level'/100) in `obs3' ;
|
||||
#delimit cr
|
||||
}
|
||||
else {
|
||||
gen `reg' = .
|
||||
gen `ci' = .
|
||||
}
|
||||
}
|
||||
|
||||
if "`gweight'" != "" {
|
||||
tempvar ww
|
||||
qui gen `ww' = 1 / `setheta'^2
|
||||
qui replace `ww' = 1 if `setheta' == 0
|
||||
local gw "[w=`ww']"
|
||||
}
|
||||
else { local gw "" }
|
||||
|
||||
#delimit ;
|
||||
graph `snd' `reg' `ci' `prec' `gw' if `touse', yli(0) xli(0)
|
||||
`connect' `symbol' `t2title' `l2title' `b2title'
|
||||
`l1title' `xlabel' `ylabel' `sort' `pen' `gap' `options';
|
||||
#delimit cr
|
||||
|
||||
exit
|
||||
end
|
||||
|
||||
* ***************************************************
|
||||
|
||||
*! ktau2 version 4.1.0 26sep97 TJS
|
||||
program define ktau2
|
||||
version 4.0
|
||||
|
||||
* modification of ktau to allow N==2, un-continuity-corrected
|
||||
* z and p values, and to pass more parameters
|
||||
|
||||
local varlist "req ex min(2) max(2)"
|
||||
local if "opt"
|
||||
local in "opt"
|
||||
parse "`*'"
|
||||
parse "`varlist'", parse(" ")
|
||||
local x "`1'"
|
||||
local y "`2'"
|
||||
tempname k N NN pval score se tau_a tau_b
|
||||
tempname xt xt2 xt3 yt yt2 yt3
|
||||
tempvar doit nobs order work
|
||||
mark `doit' `in' `if'
|
||||
markout `doit' `x' `y'
|
||||
quietly count if `doit'
|
||||
scalar `N' = _result(1)
|
||||
if `N' < 2 { error 2001 }
|
||||
local Nmac = `N'
|
||||
qui {
|
||||
gen long `order' = _n /* restore ordering at end */
|
||||
replace `doit' = -`doit'
|
||||
sort `doit' /* put obs for computation first */
|
||||
gen double `work' = 0 /* using type double is fastest */
|
||||
scalar `k' = 2
|
||||
while (`k' <= `N') {
|
||||
local kk = `k' - 1
|
||||
#delimit ;
|
||||
replace `work' = `work'
|
||||
+ sign((`x' - `x'[`k'])*(`y' - `y'[`k']))
|
||||
in 1/`kk' ; /* using "in" is fastest */
|
||||
#delimit cr
|
||||
scalar `k' = `k' + 1
|
||||
}
|
||||
replace `work' = sum(`work') in 1/`Nmac'
|
||||
scalar `score' = `work'[`N']
|
||||
/* Calculate ties on `x' */
|
||||
egen long `nobs' = count(`x') in 1/`Nmac', by(`x')
|
||||
tempvar nobsxm
|
||||
egen `nobsxm' = max(`nobs')
|
||||
/* Calculate correction term for ties on `x' */
|
||||
replace `work' = sum((`nobs' - 1)*(2*`nobs' + 5)) in 1/`Nmac'
|
||||
scalar `xt' = `work'[`N']
|
||||
/* Calculate correction term for pairs of ties on `x' */
|
||||
replace `work' = sum(`nobs' - 1) in 1/`Nmac'
|
||||
scalar `xt2' = `work'[`N']
|
||||
/* Calculate correction term for triplets of ties on `x' */
|
||||
replace `work' = sum((`nobs' - 1)*(`nobs' - 2)) in 1/`Nmac'
|
||||
scalar `xt3' = `work'[`N']
|
||||
/* Calculate ties on `y' */
|
||||
drop `nobs'
|
||||
egen long `nobs' = count(`y') in 1/`Nmac', by(`y')
|
||||
tempvar nobsym
|
||||
egen `nobsym' = max(`nobs')
|
||||
/* Calculate correction term for ties on `y' */
|
||||
replace `work' = sum((`nobs' - 1)*(2*`nobs' + 5)) in 1/`Nmac'
|
||||
scalar `yt' = `work'[`N']
|
||||
/* Calculate correction term for pairs of ties on `y' */
|
||||
replace `work' = sum(`nobs' - 1) in 1/`Nmac'
|
||||
scalar `yt2' = `work'[`N']
|
||||
/* Calculate correction term for triplets of ties on `y' */
|
||||
replace `work' = sum((`nobs' - 1)*(`nobs' - 2)) in 1/`Nmac'
|
||||
scalar `yt3' = `work'[`N']
|
||||
/* Compute Kendall's tau-a, tau-b, s.e. of score, and pval */
|
||||
scalar `NN' = `N'*(`N' - 1)
|
||||
scalar `tau_a' = 2*`score'/`NN'
|
||||
scalar `tau_b' = 2*`score'/sqrt((`NN' - `xt2')*(`NN' - `yt2'))
|
||||
#delimit ;
|
||||
scalar `se' = `NN'*(2*`N' + 5);
|
||||
tempname tmax;
|
||||
scalar `tmax' = max(`nobsxm', `nobsym');
|
||||
if `tmax' > 1 { scalar `se' = `se'
|
||||
- (`xt' - `yt')
|
||||
+ `xt3'*`yt3'/(9*`NN'*(`N' - 2))
|
||||
+ `xt2'*`yt2'/(2*`NN') } ;
|
||||
scalar `se' = sqrt((1/18)*`se');
|
||||
#delimit cr
|
||||
local zcc = (abs(`score') - 1) / `se'
|
||||
local z = `score '/ `se'
|
||||
tempname pvalcc
|
||||
if `score' == 0 {
|
||||
scalar `pval' = 1
|
||||
scalar `pvalcc' = 1
|
||||
}
|
||||
else scalar `pvalcc' = 2*(1 - normprob((abs(`score') - 1)/`se'))
|
||||
else scalar `pval' = 2*(1 - normprob(abs(`score')/`se'))
|
||||
/* Restore original ordering of data set */
|
||||
sort `order'
|
||||
}
|
||||
/* Print results */
|
||||
#delimit ;
|
||||
di _n
|
||||
in gr " Number of obs = " in ye %7.0f `N' _n
|
||||
in gr "Kendall's tau-a = " in ye %12.4f `tau_a' _n
|
||||
in gr "Kendall's tau-b = " in ye %12.4f `tau_b' _n
|
||||
in gr "Kendall's score = " in ye %7.0f `score' _n
|
||||
in gr " SE of score = " in ye %11.3f `se' _c ;
|
||||
if `xt2' > 0 | `yt2' > 0 { di in gr " (corrected for ties)" _c } ;
|
||||
di _n(2)
|
||||
in gr "Test of Ho: `x' and `y' independent" _n
|
||||
in gr " z = " in ye %12.2f `z' _n
|
||||
in gr " Pr > |z| = " in ye %12.4f = `pval' _n(2)
|
||||
in gr " z = " in ye %12.2f sign(`score')*`zcc' _n
|
||||
in gr " Pr > |z| = " in ye %12.4f = `pvalcc'
|
||||
in gr " (continuity corrected)" ;
|
||||
#delimit cr
|
||||
local c = 0
|
||||
if `xt2' > 0 | `yt2' > 0 { local c = 1 }
|
||||
global S_1 = `N'
|
||||
global S_2 = `tau_a'
|
||||
global S_3 = `tau_b'
|
||||
global S_4 = `score'
|
||||
global S_5 = `se'
|
||||
global S_6 = `pval'
|
||||
global S_7 = `z'
|
||||
global S_8 = `pvalcc'
|
||||
global S_9 = `zcc'
|
||||
global S_10 = `c'
|
||||
end
|
||||
|
||||
* ***************************************************
|
||||
|
||||
*! ifexp version 1.2.1 19nov98 TJS
|
||||
program define ifexp
|
||||
version 5.0
|
||||
|
||||
while substr("`1'",1,2) != "if" {
|
||||
macro shift
|
||||
}
|
||||
|
||||
local if "required"
|
||||
local options "noVARlabel noVALlabel noUNabbrev noSPace Color(str)"
|
||||
parse "`*'"
|
||||
parse "`if'", parse(" ><=&|!()")
|
||||
|
||||
if "`color'" == "" {local color = "b"} /* set display color */
|
||||
local color = lower(substr("`color'",1,1))
|
||||
if index("wbgyr","`color'") == 0 {local color = "b"}
|
||||
|
||||
if "`if'" != "" {
|
||||
local ifst " if " /* handle leading "if " */
|
||||
local lif = 5
|
||||
macro shift
|
||||
|
||||
if "`space'" != "nospace" { /* set up space */
|
||||
local sp " "
|
||||
local sp1 = 1
|
||||
}
|
||||
else { local sp1 = 0 }
|
||||
|
||||
di
|
||||
while "`1'" != "" { /* start main loop on tokens */
|
||||
capture confirm variable `1' /* var name ? */
|
||||
local rc _rc
|
||||
|
||||
local m = 0
|
||||
local n = length("`1'")
|
||||
if `n' + `lif' > 78 { /* no room for token ? */
|
||||
di in `color' "`ifst'"
|
||||
local ifst "> "
|
||||
local lif = 5
|
||||
local n = 0
|
||||
}
|
||||
/* is punctuation */
|
||||
if "`1'" == "==" { local ifst "`ifst'`1'`sp'" }
|
||||
else if "`1'" == "<=" { local ifst "`ifst'`1'`sp'" }
|
||||
else if "`1'" == ">=" { local ifst "`ifst'`1'`sp'" }
|
||||
else if "`1'" == "!=" { local ifst "`ifst'`1'`sp'" }
|
||||
else if "`1'" == "<" { local ifst "`ifst'`1'`sp'" }
|
||||
else if "`1'" == ">" { local ifst "`ifst'`1'`sp'" }
|
||||
else if "`1'" == "=" { local ifst "`ifst'`1'`sp'" }
|
||||
else if "`1'" == "&" { local ifst "`ifst'`1'`sp'" }
|
||||
else if "`1'" == "|" { local ifst "`ifst'`1'`sp'" }
|
||||
else if "`1'" == "!" { local ifst "`ifst'`1'`sp'" }
|
||||
else if "`1'" == "(" { local ifst "`ifst'`1'`sp'" }
|
||||
else if "`1'" == ")" { local ifst "`ifst'`1'`sp'" }
|
||||
|
||||
else if `rc' == 0 { /* is a variable name */
|
||||
local tif "`1'"
|
||||
if "`unabbrev'" != "nounabbrev" { /* allow unabbrev */
|
||||
unabbrev `1'
|
||||
local tif "$S_1"
|
||||
}
|
||||
if "`varlabel'" != "novarlabel" { /* allow var label ? */
|
||||
local vrl : variable label `1'
|
||||
if "`vrl'" != "" { local tif "`vrl'" } /* var label ? */
|
||||
}
|
||||
|
||||
local wc: word count `tif' /* process > 1 word in label */
|
||||
local w 1
|
||||
while `w' < `wc' {
|
||||
local wif: word `w' of `tif'
|
||||
local wm = length("`wif'")
|
||||
if `wm' + `lif' > 78 {
|
||||
di in `color' "`ifst'"
|
||||
local ifst "> "
|
||||
local lif = 5
|
||||
local n = `m'
|
||||
local m = 0
|
||||
}
|
||||
else {
|
||||
local lif = `lif' + `wm' + `sp1'
|
||||
local ifst "`ifst'`wif'`sp'"
|
||||
local w = `w' + 1
|
||||
}
|
||||
}
|
||||
local tif: word `wc' of `tif' /* do last or only word */
|
||||
|
||||
local m = length("`tif'") /* no room for token ? */
|
||||
if `m' + `lif' > 78 {
|
||||
di in `color' "`ifst'"
|
||||
local ifst "> "
|
||||
local lif = 5
|
||||
local n = `m'
|
||||
local m = 0
|
||||
}
|
||||
local ifst "`ifst'`tif'`sp'"
|
||||
local vll : value label `1'
|
||||
}
|
||||
|
||||
else { /* is a value */
|
||||
local tif "`1'" /* allow value label ? */
|
||||
if "`vll'" != "" & "`vallabel'" != "novallabel" {
|
||||
local lv : label `vll' `1'
|
||||
if "`lv'" != "" { local tif "`lv'" } /* value label ? */
|
||||
}
|
||||
|
||||
local wc: word count `tif' /* process > 1 word in label */
|
||||
local w 1
|
||||
while `w' < `wc' {
|
||||
local wif: word `w' of `tif'
|
||||
local wm = length("`wif'")
|
||||
if `wm' + `lif' > 78 {
|
||||
di in `color' "`ifst'"
|
||||
local ifst "> "
|
||||
local lif = 5
|
||||
local n = `m'
|
||||
local m = 0
|
||||
}
|
||||
else {
|
||||
local lif = `lif' + `wm' + `sp1'
|
||||
local ifst "`ifst'`wif'`sp'"
|
||||
local w = `w' + 1
|
||||
}
|
||||
}
|
||||
local tif: word `wc' of `tif' /* do last or only word */
|
||||
|
||||
local m = length("`tif'") /* no room for token ? */
|
||||
if `m' + `lif' > 78 {
|
||||
di in `color' "`ifst'"
|
||||
local ifst "> "
|
||||
local lif = 5
|
||||
local n = `m'
|
||||
local m = 0
|
||||
}
|
||||
local ifst "`ifst'`tif'`sp'"
|
||||
}
|
||||
/* set new line length */
|
||||
if `m' > 0 { local lif = `lif' + `m' + `sp1' }
|
||||
else { local lif = `lif' + `n' + `sp1' }
|
||||
macro shift /* next token */
|
||||
} /* end main loop on tokens */
|
||||
|
||||
di in `color' "`ifst'" /* display expanded if */
|
||||
|
||||
global S_1 "`ifst'"
|
||||
exit
|
||||
end
|
188
Modules/ado/plus/m/metabias.dlg
Normal file
188
Modules/ado/plus/m/metabias.dlg
Normal file
@ -0,0 +1,188 @@
|
||||
/*
|
||||
*! metabias dialog version 1.0.1, 13 May 2003, T. J. Steichen, steichen@triad.rr.com
|
||||
*! for metabias version 1.2.4, 08 Sep 2003, T. J. Steichen, steichen@triad.rr.com
|
||||
|
||||
Tests for publication bias in meta-analysis
|
||||
-------------------------------------------
|
||||
|
||||
Syntax: metabias { theta { se_theta | var_theta } | exp(theta) ll ul [cl] }
|
||||
[ if exp ] [ in range ] [, by(by_var) { var | ci }
|
||||
graph({ begg | egger }) gweight level(#) graph_options ]
|
||||
|
||||
Install in User Statistics menu via Stata commands:
|
||||
. window menu append item "stUserStatistics" "meta&bias (Publication Bias in Meta-analysis)" "db metabias"
|
||||
. window menu refresh
|
||||
To permanently install, place the commands in your -profile.do- file.
|
||||
*/
|
||||
|
||||
VERSION 8.0
|
||||
|
||||
INCLUDE _std_small
|
||||
INCLUDE header
|
||||
|
||||
HELP hlp1, view("help metabias")
|
||||
RESET res1, label("Reset")
|
||||
|
||||
DIALOG main, label("metabias 1.2.4 - Publication Bias in Meta-analysis") tabtitle("Main")
|
||||
BEGIN
|
||||
GROUPBOX gb_data 10 5 330 _ht5h, ///
|
||||
label("Type of Data:")
|
||||
RADIO r_se 15 25 100 ., ///
|
||||
label("Theta, SE") first ///
|
||||
onclickon(script main_se_on) ///
|
||||
onclickoff(script main_se_off) ///
|
||||
option(NONE)
|
||||
RADIO r_var 115 25 100 ., ///
|
||||
label("Theta, Var") middle ///
|
||||
onclickon(script main_var_on) ///
|
||||
onclickoff(script main_var_off) ///
|
||||
option("var")
|
||||
RADIO r_ci 215 25 110 ., ///
|
||||
label("exp(Theta), CI") last ///
|
||||
onclickon(script main_ci_on) ///
|
||||
onclickoff(script main_ci_off) ///
|
||||
option("ci")
|
||||
|
||||
TEXT tx_se 15 45 320 ., ///
|
||||
label("Vars for theta, se(theta), in that order")
|
||||
VARLIST vl_se @ _ss @ ., ///
|
||||
label("Vars for theta, se(theta)")
|
||||
|
||||
TEXT tx_var @ 45 320 ., ///
|
||||
label("Vars for theta, var(theta), in that order")
|
||||
VARLIST vl_var @ _ss @ ., ///
|
||||
label("Vars for theta, var(theta)")
|
||||
|
||||
TEXT tx_ci @ 45 320 ., ///
|
||||
label("Vars for exp(theta), CI_LL, CI_UL, in that order")
|
||||
VARLIST vl_ci @ _ss @ ., ///
|
||||
label("Vars for exp(theta), CI_LL, CI_UL")
|
||||
|
||||
CHECKBOX cb_by 10 100 100 ., ///
|
||||
label("By Variable:") ///
|
||||
onclickon(main.vn_by.enable) ///
|
||||
onclickoff(main.vn_by.disable)
|
||||
VARNAME vn_by 110 100 230 ., ///
|
||||
label("By Variable") ///
|
||||
option("by")
|
||||
|
||||
GROUPBOX gb_graph 10 130 330 _ht3h, ///
|
||||
label("Graph:")
|
||||
RADIO r_none 15 150 100 ., ///
|
||||
label("None") first ///
|
||||
onclickon(main.cb_gwt.disable) ///
|
||||
option(NONE)
|
||||
RADIO r_begg 115 150 100 ., ///
|
||||
label("Begg") middle ///
|
||||
onclickon(main.cb_gwt.enable) ///
|
||||
option("graph(begg)")
|
||||
RADIO r_egger 215 150 100 ., ///
|
||||
label("Egger") last ///
|
||||
onclickon(main.cb_gwt.enable) ///
|
||||
option("graph(egger)")
|
||||
|
||||
CHECKBOX cb_gwt 15 175 300 ., ///
|
||||
label("Size Graph Symbol by Weights") ///
|
||||
option("gweight")
|
||||
END
|
||||
|
||||
INCLUDE ifin
|
||||
|
||||
SCRIPT main_se_on
|
||||
BEGIN
|
||||
main.tx_se.show
|
||||
main.vl_se.show
|
||||
main.tx_se.enable
|
||||
main.vl_se.enable
|
||||
|
||||
main.tx_var.disable
|
||||
main.vl_var.disable
|
||||
main.tx_var.hide
|
||||
main.vl_var.hide
|
||||
|
||||
main.tx_ci.disable
|
||||
main.vl_ci.disable
|
||||
main.tx_ci.hide
|
||||
main.vl_ci.hide
|
||||
END
|
||||
|
||||
SCRIPT main_se_off
|
||||
BEGIN
|
||||
main.tx_se.disable
|
||||
main.vl_se.disable
|
||||
main.tx_se.hide
|
||||
main.vl_se.hide
|
||||
END
|
||||
|
||||
SCRIPT main_var_on
|
||||
BEGIN
|
||||
main.tx_var.show
|
||||
main.vl_var.show
|
||||
main.tx_var.enable
|
||||
main.vl_var.enable
|
||||
|
||||
main.tx_se.disable
|
||||
main.vl_se.disable
|
||||
main.tx_se.hide
|
||||
main.vl_se.hide
|
||||
|
||||
main.tx_ci.disable
|
||||
main.vl_ci.disable
|
||||
main.tx_ci.hide
|
||||
main.vl_ci.hide
|
||||
END
|
||||
|
||||
SCRIPT main_var_off
|
||||
BEGIN
|
||||
main.tx_var.disable
|
||||
main.vl_var.disable
|
||||
main.tx_var.hide
|
||||
main.vl_var.hide
|
||||
END
|
||||
|
||||
SCRIPT main_ci_on
|
||||
BEGIN
|
||||
main.tx_ci.show
|
||||
main.vl_ci.show
|
||||
main.tx_ci.enable
|
||||
main.vl_ci.enable
|
||||
|
||||
main.tx_se.disable
|
||||
main.vl_se.disable
|
||||
main.tx_se.hide
|
||||
main.vl_se.hide
|
||||
|
||||
main.tx_var.disable
|
||||
main.vl_var.disable
|
||||
main.tx_var.hide
|
||||
main.vl_var.hide
|
||||
END
|
||||
|
||||
SCRIPT main_ci_off
|
||||
BEGIN
|
||||
main.tx_ci.disable
|
||||
main.vl_ci.disable
|
||||
main.tx_ci.hide
|
||||
main.vl_ci.hide
|
||||
END
|
||||
|
||||
PROGRAM command
|
||||
BEGIN
|
||||
put "metabias "
|
||||
if main.r_se {
|
||||
varlist main.vl_se
|
||||
}
|
||||
if main.r_var {
|
||||
varlist main.vl_var
|
||||
}
|
||||
if main.r_ci {
|
||||
varlist main.vl_ci
|
||||
}
|
||||
INCLUDE _ifin_pr
|
||||
beginoptions
|
||||
option radio(main r_se r_var r_ci)
|
||||
optionarg main.vn_by
|
||||
option radio(main r_none r_begg r_egger)
|
||||
option main.cb_gwt
|
||||
endoptions
|
||||
END
|
211
Modules/ado/plus/m/metabias.hlp
Normal file
211
Modules/ado/plus/m/metabias.hlp
Normal file
@ -0,0 +1,211 @@
|
||||
.-
|
||||
help for ^metabias^ (STB-41: sbe19; STB-44: sbe19.1; STB-57: sbe19.2;
|
||||
STB-58: sbe19.3; STB-61: sbe19.4)
|
||||
.-
|
||||
|
||||
Tests for publication bias in meta-analysis
|
||||
-------------------------------------------
|
||||
|
||||
^metabias^ { theta { se_theta | var_theta } | exp(theta) ll ul [cl] }
|
||||
[ ^if^ exp ] [ ^in^ range ] [^, by(^by_var^)^ { ^v^ar | ^ci^ }
|
||||
^g^raph^(b^egg | ^e^gger^) gw^eight ^l^evel^(^#^)^ graph_options ]
|
||||
|
||||
where { a | b |...} means choose one and only one of {a, b, ...}.
|
||||
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
^metabias^ performs the Begg and Mazumdar adjusted rank correlation test for
|
||||
publication bias and performs the Egger, et al., regression asymmetry test for
|
||||
publication bias. As options, it provides a funnel graph of the data or the
|
||||
regression asymmetry plot.
|
||||
|
||||
The Begg adjusted rank correlation test is a direct statistical analogue of
|
||||
the visual funnel graph. Note that both the test and the funnel graph have
|
||||
low power for detecting publication bias. The Begg and Mazumdar procedure
|
||||
tests for publication bias by determining if there is a significant
|
||||
correlation between the effect estimates and their variances. ^metabias^
|
||||
carries out this test by, first, standardizing the effect estimates to
|
||||
stabilize the variances and, second, performing an adjusted rank correlation
|
||||
test based on Kendall's tau.
|
||||
|
||||
The Egger, et al., regression asymmetry test and the regression asymmetry plot
|
||||
tend to suggest the presence of publication bias more frequently than the Begg
|
||||
approach. The Egger test detects funnel plot asymmetry by determining whether
|
||||
the intercept deviates significantly from zero in a regression of the
|
||||
standardized effect estimates against their precision.
|
||||
|
||||
Egger, et al., claim that the test predicts the discordance (if any) of
|
||||
meta-analytic results and single large trials, but no formal analysis of
|
||||
coverage (i.e., nominal significance level) or power has been performed.
|
||||
|
||||
The user provides the effect estimate, ^theta^, to ^metabias^ as a log
|
||||
risk ratio, log odds ratio, or other direct measure of effect. Along
|
||||
with theta, the user supplies a measure of theta's variability (i.e.,
|
||||
its standard error, ^se_theta^, or its variance, ^var_theta^).
|
||||
Alternatively, the user may provide the exponentiated form,
|
||||
^exp(theta)^, (i.e., a risk ratio or odds ratio) and its confidence
|
||||
interval, ^(ll, ul)^.
|
||||
|
||||
The funnel graph plots ^theta^ versus ^se_theta^. Guide lines to assist in
|
||||
visualizing the funnel are plotted at the variance-weighted (fixed effects)
|
||||
meta-analytic effect estimate and at pseudo confidence interval limits about
|
||||
that effect estimate (i.e., at ^theta +/- z * se_theta^, where ^z^ is the
|
||||
standard Normal variate for the confidence level specified by option ^level()^.
|
||||
Asymmetry on the right of the graph (where studies with high standard error
|
||||
are plotted) may give evidence of publication bias.
|
||||
|
||||
The regression asymmetry graph plots the standardized effect estimates,
|
||||
^theta / se_theta^, versus precision, ^1 / se_theta^, along with the
|
||||
regression line and the confidence interval about the intercept. Failure of
|
||||
this confidence interval to include zero indicates asymmetry in the funnel
|
||||
plot and may give evidence of publication bias. Guide lines at x = 0 and
|
||||
y = 0 are plotted to assist in visually determining if zero is in the
|
||||
confidence interval.
|
||||
|
||||
^metabias^ will perform stratified versions of both the Begg and Mazumdar test
|
||||
and the Egger regression asymmetry test when option ^by(by_var)^ is specified.
|
||||
Variable ^by_var^ indicates the categorical variable that defines the strata.
|
||||
The procedure reports results for each strata and for the stratified tests.
|
||||
The graphs, if selected, plot only the combined unstratified data.
|
||||
|
||||
|
||||
Options
|
||||
-------
|
||||
|
||||
^by(by_var)^ requests that the stratified tests be carried out with
|
||||
strata defined by ^by_var^.
|
||||
|
||||
^var^ indicates that ^var_theta^ was supplied on the command line
|
||||
instead of ^se_theta^. Option ^ci^ should not be specified when
|
||||
option ^var^ is specified.
|
||||
|
||||
^ci^ indicates that ^exp(theta)^ and its confidence interval, ^(ll,
|
||||
ul)^, were supplied on the command line instead of ^theta^ and
|
||||
^se_theta^. Option ^var^ should not be specified when option ^ci^ is
|
||||
specified.
|
||||
|
||||
^graph(begg)^ requests the Begg funnel graph showing the data, the
|
||||
fixed-effects (variance-weighted) meta-analytic effect, and the pseudo
|
||||
confidence interval limits about the meta-analytic effect.
|
||||
|
||||
^graph(egger)^ requests the Egger regression asymmetry plot showing the
|
||||
standardized effect estimates versus precision, the regression line, and
|
||||
the confidence interval about the intercept.
|
||||
|
||||
^gweight^ requests that the graphic symbols representing the data in the
|
||||
plot be sized proportional to the inverse variance.
|
||||
|
||||
^level()^ sets the confidence level % for the pseudo confidence intervals;
|
||||
the default is 95%.
|
||||
|
||||
^graph_options^ are those allowed with ^graph, twoway^. For
|
||||
^graph(begg)^, the default graph_options include ^connect(lll.)^,
|
||||
^symbol(iiio)^, and ^pen(3552)^ for displaying the meta-analytic
|
||||
effect, the pseudo confidence interval limits (two lines), and the
|
||||
data points, respectively. For ^graph(egger)^, the default
|
||||
graph_options include ^connect(.ll)^, ^symbol(oid)^, and ^pen(233)^
|
||||
for displaying the data points, regression line, and the confidence
|
||||
interval about the intercept, respectively. Setting ^t2title(.)^
|
||||
blanks out the default ^t2title^ in either graph.
|
||||
|
||||
|
||||
Required input variables
|
||||
------------------------
|
||||
|
||||
^theta^ the effect estimate
|
||||
^se_theta^ the corresponding standard error
|
||||
|
||||
or
|
||||
|
||||
^theta^ the effect estimate
|
||||
^var_theta^ the corresponding variance
|
||||
|
||||
or
|
||||
|
||||
^exp(theta)^ the risk (or odds) ratio
|
||||
^ll^ the lower limit of the risk ratio's confidence interval
|
||||
^ul^ the upper limit of the risk ratio's confidence interval
|
||||
[^cl^] optional (see below)
|
||||
|
||||
|
||||
Optional input variable
|
||||
-----------------------
|
||||
|
||||
^cl^ contains the confidence level of the confidence interval defined by ^ll^
|
||||
and ^ul^. If ^cl^ is not provided, the procedure assumes that each confidence
|
||||
interval is at the 95% confidence level. ^cl^ allows the user to provide the
|
||||
confidence level, by study, when the confidence interval is not at the default
|
||||
level. ^cl^ can be specified with or without a decimal point. For example,
|
||||
90 and .90 are equivalent and may be mixed (i.e., 90, .95, 80, .90 etc.).
|
||||
|
||||
|
||||
Note
|
||||
----
|
||||
|
||||
If your data are in raw count format, program ^metan^ can be used to
|
||||
facilitate conversion to effect format. ^metan^ automatically adds
|
||||
^exp(theta)^ and ^se_theta^ variables to the dataset, calling them
|
||||
^_ES^ and ^_seES^. You must manually generate ^theta^ as the natural
|
||||
log of ^_ES^ (for example, ^gen _lnES = ln(_ES)^) then input the
|
||||
effect-format variables, ^_lnES^ and ^_seES^, using ^metabias^'s
|
||||
default input method.
|
||||
|
||||
|
||||
|
||||
Saved values
|
||||
------------
|
||||
|
||||
The following items are saved in the global ^S_^# macros and are returned in ^r()^.
|
||||
|
||||
^S_1 r(k)^ number of studies
|
||||
^S_2 r(score)^ Begg's score
|
||||
^S_3 r(score_sd)^ s.d. of Begg's score
|
||||
^S_4 r(Begg_p)^ Begg's p value
|
||||
^S_5 r(Begg_pcc)^ Begg's p, continuity corrected
|
||||
^S_6 r(Egger_bc)^ Egger's bias coefficient
|
||||
^S_7 r(Egger_p)^ Egger's p value
|
||||
^S_8 r(effect)^ overall effect (log scale)
|
||||
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
. ^metabias logrr selogrr, graph(begg)^
|
||||
. ^metabias logrr varlogrr if site==3, var graph(egger)^
|
||||
. ^metabias rr ll ul, ci by(site)^
|
||||
. ^metabias logor selogor if region==4, graph(egger) level(90)^
|
||||
|
||||
|
||||
Note
|
||||
----
|
||||
|
||||
^metabias^ calls program ^ktau2^, a modification of the ^ktau^ program
|
||||
supplied with Stata. ^ktau2^ is included in the distribution files
|
||||
for this version of ^metabias^.
|
||||
|
||||
|
||||
References
|
||||
----------
|
||||
|
||||
Begg, C. B., Mazumdar, M., 1994. Operating characteristics of a rank
|
||||
correlation test for publication bias. Biometrics 50: 1088-1101.
|
||||
|
||||
Egger, M., Smith, G. D., Schneider, M., Minder, C., 1997. Bias in
|
||||
meta-analysis detected by a simple, graphical test. British Medical
|
||||
Journal 315: 629-634.
|
||||
|
||||
|
||||
Author
|
||||
------
|
||||
|
||||
Thomas J. Steichen, RJRT, steicht@@rjrt.com
|
||||
|
||||
|
||||
Also see
|
||||
--------
|
||||
|
||||
STB: STB-41 sbe19; STB-44 sbe19.1
|
||||
Manual: [R] spearman
|
||||
On-line: help for @meta@, @metan@, and @ktau@ (if installed)
|
302
Modules/ado/plus/m/metacum.dlg
Normal file
302
Modules/ado/plus/m/metacum.dlg
Normal file
@ -0,0 +1,302 @@
|
||||
/*
|
||||
|
||||
*! metacum dialog version 1.0.1, 13 May 2003, T. J. Steichen, steichen@triad.rr.com
|
||||
*! for metacum version 1.02, Jan 1998, Jonathan Sterne, jonathan.sterne@bristol.ac.uk
|
||||
|
||||
metacum VERSION 1.02 jan1998
|
||||
|
||||
Cumulative meta-analysis, with graphics
|
||||
---------------------------------------
|
||||
|
||||
Syntax: metacum { theta | exp(theta) } { se_theta | var_theta | ll ul [cl] }
|
||||
[if exp] [in range] effect(f|r) [ , id(strvar) var ci eform level(#)
|
||||
graph cline ltrunc(#) rtrunc(#) csize(#) fmult(#) ]
|
||||
|
||||
To install in User Statistics menu via Stata commands:
|
||||
. window menu append item "stUserStatistics" "Cumulative meta-analysis (meta&cum)" "db metacum"
|
||||
. window menu refresh
|
||||
To permanently install, place the commands in your -profile.do- file.
|
||||
*/
|
||||
|
||||
VERSION 8.0
|
||||
|
||||
INCLUDE _std_small
|
||||
INCLUDE header
|
||||
|
||||
HELP hlp1, view("help metacum")
|
||||
RESET res1, label("Reset")
|
||||
|
||||
DIALOG main, label("metacum 1.02 - Cumulative Meta-analysis") tabtitle("Main")
|
||||
BEGIN
|
||||
GROUPBOX gb_data 10 5 330 _ht5h, ///
|
||||
label("Type of Data:")
|
||||
RADIO r_se 15 25 100 ., ///
|
||||
label("Theta, SE") first ///
|
||||
onclickon(script main_se_on) ///
|
||||
onclickoff(script main_se_off) ///
|
||||
option(NONE)
|
||||
RADIO r_var 115 25 100 ., ///
|
||||
label("Theta, Var") middle ///
|
||||
onclickon(script main_var_on) ///
|
||||
onclickoff(script main_var_off) ///
|
||||
option("var")
|
||||
RADIO r_ci 215 25 110 ., ///
|
||||
label("exp(Theta), CI") last ///
|
||||
onclickon(script main_ci_on) ///
|
||||
onclickoff(script main_ci_off) ///
|
||||
option("ci")
|
||||
|
||||
TEXT tx_se 15 45 320 ., ///
|
||||
label("Vars for theta, se(theta), in that order")
|
||||
VARLIST vl_se @ _ss @ ., ///
|
||||
label("Vars for theta, se(theta)")
|
||||
|
||||
TEXT tx_var @ 45 320 ., ///
|
||||
label("Vars for theta, var(theta), in that order")
|
||||
VARLIST vl_var @ _ss @ ., ///
|
||||
label("Vars for theta, var(theta)")
|
||||
|
||||
TEXT tx_ci @ 45 320 ., ///
|
||||
label("Vars for exp(theta), CI_LL, CI_UL, in that order")
|
||||
VARLIST vl_ci @ _ss @ ., ///
|
||||
label("Vars for exp(theta), CI_LL, CI_UL")
|
||||
|
||||
CHECKBOX cb_id 10 100 100 ., ///
|
||||
label("ID Variable:") ///
|
||||
onclickon(main.vn_id.enable) ///
|
||||
onclickoff(main.vn_id.disable)
|
||||
VARNAME vn_id 110 100 230 ., ///
|
||||
label("ID Variable") ///
|
||||
option("id")
|
||||
|
||||
GROUPBOX gb_effect 10 130 110 _ht3h, ///
|
||||
label("Pooling Model:")
|
||||
RADIO r_fixed 15 145 65 ., ///
|
||||
label("Fixed") first ///
|
||||
option("effect(f)")
|
||||
RADIO r_random 15 165 75 ., ///
|
||||
label("Random") last ///
|
||||
option("effect(r)")
|
||||
|
||||
CHECKBOX cb_level 160 145 75 ., ///
|
||||
label("CI Level:") ///
|
||||
onclickon(main.ed_level.enable) ///
|
||||
onclickoff(main.ed_level.disable)
|
||||
EDIT ed_level 240 @ 40 ., ///
|
||||
label("Level") ///
|
||||
numonly default(95) ///
|
||||
option("level")
|
||||
|
||||
CHECKBOX cb_eform 160 165 120 ., ///
|
||||
label("Use exp(theta)") ///
|
||||
option("eform")
|
||||
END
|
||||
|
||||
|
||||
DIALOG graph, tabtitle("Graph")
|
||||
BEGIN
|
||||
CHECKBOX cb_graph 10 10 330 _ht7h, ///
|
||||
groupbox ///
|
||||
onclickon(program graph_on) ///
|
||||
onclickoff(program graph_off) ///
|
||||
label("Draw Graph:") ///
|
||||
option("graph")
|
||||
|
||||
CHECKBOX cb_cline 20 35 150 ., ///
|
||||
label("Draw Estimate line") ///
|
||||
option("cline")
|
||||
|
||||
CHECKBOX cb_ltrunc 20 60 95 ., ///
|
||||
label("Left truncate:") ///
|
||||
onclickon(graph.ed_ltrunc.enable) ///
|
||||
onclickoff(graph.ed_ltrunc.disable)
|
||||
EDIT ed_ltrunc 130 @ 40 ., ///
|
||||
label("Left truncate") numonly ///
|
||||
option("ltrunc")
|
||||
|
||||
CHECKBOX cb_rtrunc 20 80 105 ., ///
|
||||
label("Right truncate:") ///
|
||||
onclickon(graph.ed_rtrunc.enable) ///
|
||||
onclickoff(graph.ed_rtrunc.disable)
|
||||
EDIT ed_rtrunc 130 @ 40 ., ///
|
||||
label("Right truncate") numonly ///
|
||||
option("rtrunc")
|
||||
|
||||
CHECKBOX cb_fmult 195 60 95 ., ///
|
||||
label("Font scale:") ///
|
||||
onclickon(graph.ed_fmult.enable) ///
|
||||
onclickoff(graph.ed_fmult.disable)
|
||||
EDIT ed_fmult 290 60 40 ., ///
|
||||
label("Font scale") ///
|
||||
numonly default("1") ///
|
||||
option("fmult")
|
||||
|
||||
CHECKBOX cb_csize 195 80 95 ., ///
|
||||
label("Circle size:") ///
|
||||
onclickon(graph.ed_csize.enable) ///
|
||||
onclickoff(graph.ed_csize.disable)
|
||||
EDIT ed_csize 290 80 40 ., ///
|
||||
label("Circle size") ///
|
||||
numonly default("180") ///
|
||||
option("csize")
|
||||
|
||||
GROUPBOX gb_gopts7 10 145 330 _ht2h, ///
|
||||
label("Allowed Graph7 Options:")
|
||||
EDIT ed_gopts7 15 165 320 ., ///
|
||||
label("Graph7 Options")
|
||||
END
|
||||
|
||||
INCLUDE ifin
|
||||
|
||||
SCRIPT main_se_on
|
||||
BEGIN
|
||||
main.tx_se.show
|
||||
main.vl_se.show
|
||||
main.tx_se.enable
|
||||
main.vl_se.enable
|
||||
|
||||
main.tx_var.disable
|
||||
main.vl_var.disable
|
||||
main.tx_var.hide
|
||||
main.vl_var.hide
|
||||
|
||||
main.tx_ci.disable
|
||||
main.vl_ci.disable
|
||||
main.tx_ci.hide
|
||||
main.vl_ci.hide
|
||||
END
|
||||
|
||||
SCRIPT main_se_off
|
||||
BEGIN
|
||||
main.tx_se.disable
|
||||
main.vl_se.disable
|
||||
main.tx_se.hide
|
||||
main.vl_se.hide
|
||||
END
|
||||
|
||||
SCRIPT main_var_on
|
||||
BEGIN
|
||||
main.tx_var.show
|
||||
main.vl_var.show
|
||||
main.tx_var.enable
|
||||
main.vl_var.enable
|
||||
|
||||
main.tx_se.disable
|
||||
main.vl_se.disable
|
||||
main.tx_se.hide
|
||||
main.vl_se.hide
|
||||
|
||||
main.tx_ci.disable
|
||||
main.vl_ci.disable
|
||||
main.tx_ci.hide
|
||||
main.vl_ci.hide
|
||||
END
|
||||
|
||||
SCRIPT main_var_off
|
||||
BEGIN
|
||||
main.tx_var.disable
|
||||
main.vl_var.disable
|
||||
main.tx_var.hide
|
||||
main.vl_var.hide
|
||||
END
|
||||
|
||||
SCRIPT main_ci_on
|
||||
BEGIN
|
||||
main.tx_ci.show
|
||||
main.vl_ci.show
|
||||
main.tx_ci.enable
|
||||
main.vl_ci.enable
|
||||
|
||||
main.tx_se.disable
|
||||
main.vl_se.disable
|
||||
main.tx_se.hide
|
||||
main.vl_se.hide
|
||||
|
||||
main.tx_var.disable
|
||||
main.vl_var.disable
|
||||
main.tx_var.hide
|
||||
main.vl_var.hide
|
||||
END
|
||||
|
||||
SCRIPT main_ci_off
|
||||
BEGIN
|
||||
main.tx_ci.disable
|
||||
main.vl_ci.disable
|
||||
main.tx_ci.hide
|
||||
main.vl_ci.hide
|
||||
END
|
||||
|
||||
PROGRAM graph_on
|
||||
BEGIN
|
||||
call graph.cb_cline.enable
|
||||
call graph.cb_fmult.enable
|
||||
call graph.cb_ltrunc.enable
|
||||
call graph.cb_rtrunc.enable
|
||||
call graph.cb_csize.enable
|
||||
call graph.gb_gopts7.enable
|
||||
call graph.ed_gopts7.enable
|
||||
if graph.cb_fmult {
|
||||
call graph.ed_fmult.enable
|
||||
}
|
||||
if graph.cb_ltrunc {
|
||||
call graph.ed_ltrunc.enable
|
||||
}
|
||||
if graph.cb_rtrunc {
|
||||
call graph.ed_rtrunc.enable
|
||||
}
|
||||
if graph.cb_csize {
|
||||
call graph.ed_csize.enable
|
||||
}
|
||||
END
|
||||
|
||||
PROGRAM graph_off
|
||||
BEGIN
|
||||
call graph.cb_cline.disable
|
||||
call graph.cb_fmult.disable
|
||||
call graph.cb_ltrunc.disable
|
||||
call graph.cb_rtrunc.disable
|
||||
call graph.cb_csize.disable
|
||||
call graph.gb_gopts7.disable
|
||||
call graph.ed_gopts7.disable
|
||||
if graph.cb_fmult {
|
||||
call graph.ed_fmult.disable
|
||||
}
|
||||
if graph.cb_ltrunc {
|
||||
call graph.ed_ltrunc.disable
|
||||
}
|
||||
if graph.cb_rtrunc {
|
||||
call graph.ed_rtrunc.disable
|
||||
}
|
||||
if graph.cb_csize {
|
||||
call graph.ed_csize.disable
|
||||
}
|
||||
END
|
||||
|
||||
PROGRAM command
|
||||
BEGIN
|
||||
put "metacum "
|
||||
if main.r_se {
|
||||
varlist main.vl_se
|
||||
}
|
||||
if main.r_var {
|
||||
varlist main.vl_var
|
||||
}
|
||||
if main.r_ci {
|
||||
varlist main.vl_ci
|
||||
}
|
||||
INCLUDE _ifin_pr
|
||||
beginoptions
|
||||
option radio(main r_se r_var r_ci)
|
||||
optionarg main.vn_id
|
||||
option radio(main r_fixed r_random)
|
||||
option main.cb_eform
|
||||
optionarg main.ed_level
|
||||
option graph.cb_graph
|
||||
option graph.cb_cline
|
||||
optionarg graph.ed_ltrunc
|
||||
optionarg graph.ed_rtrunc
|
||||
optionarg graph.ed_fmult
|
||||
optionarg graph.ed_csize
|
||||
put graph.ed_gopts7
|
||||
endoptions
|
||||
END
|
349
Modules/ado/plus/m/metafunnel.ado
Normal file
349
Modules/ado/plus/m/metafunnel.ado
Normal file
@ -0,0 +1,349 @@
|
||||
*! Version 1.0.2, JACS, 18 August 2003
|
||||
program define metafunnel
|
||||
version 8.1
|
||||
* Graphs funnel plot, with standard error on the vertical axis
|
||||
|
||||
if ("`*'" == "") {
|
||||
di "Syntax is:"
|
||||
di in wh "metafunnel " in gr "{ theta { se | var } | " _c
|
||||
di in gr "exp(theta) | ll ul [cl] } [" _c
|
||||
di in wh "if " in gr "exp] [" in wh "in " in gr "range]"
|
||||
di in gr " [ " in wh ", by(" in gr "by_var"in wh ")" _c
|
||||
di in gr " { " in wh "v" in gr "ar | " in wh "ci" in gr " } " _c
|
||||
di in wh "nol" in gr "ines " in wh "forc" in gr "enull " _c
|
||||
di in wh "rev" in gr "erse " in wh "ef" in gr "orm"
|
||||
di in gr " graph_options ]"
|
||||
|
||||
exit
|
||||
}
|
||||
|
||||
syntax varlist(numeric min=2 max=4) [if] [in], [ by(varname) ///
|
||||
Var CI SUbtitle(str) NOLines FORCenull REVerse EForm ///
|
||||
XTitle(string) YTitle(string) XScale(string) YScale(string) ///
|
||||
MSymbol(string) * ]
|
||||
|
||||
tempvar touse theta setheta etheta zz
|
||||
tempvar ll2 ul2 vl z mmm vvar w sw wl swl RRm orign
|
||||
tempname oe
|
||||
|
||||
tokenize `varlist'
|
||||
local theta `1'
|
||||
|
||||
if "`3'" == "" {
|
||||
local setheta `2'
|
||||
}
|
||||
else {
|
||||
tempvar ll ul cl
|
||||
local ll `2'
|
||||
local ul `3'
|
||||
local cl `4'
|
||||
}
|
||||
|
||||
* input error traps
|
||||
if "`ci'" != "" & "`var'" != "" {
|
||||
di _n as error "Error: options 'ci' and 'var' cannot " _c
|
||||
di as error "be specified together."
|
||||
exit
|
||||
}
|
||||
if "`ci'" == "ci" & "`ul'" != "" {
|
||||
di _n as text "Note: option 'ci' specified."
|
||||
}
|
||||
if "`ci'" == "ci" & "`ul'" == "" {
|
||||
di _n as error "Error: option 'ci' specified but varlist " _c
|
||||
di as error "has only 2 variables."
|
||||
exit
|
||||
}
|
||||
if "`ci'" != "ci" & "`var'" != "var" & "`ul'" != "" {
|
||||
di _n as text "Warning: varlist has 3 variables but option " _c
|
||||
di as text "'ci' not specified; 'ci' assumed."
|
||||
local ci "ci"
|
||||
local var ""
|
||||
}
|
||||
if "`var'" == "var" & "`ul'" != "" {
|
||||
di _n as error "Error: option 'var' specified but varlist " _c
|
||||
di as error "has more than 2 variables."
|
||||
exit
|
||||
}
|
||||
if "`var'" == "var" & "`ul'" == "" {
|
||||
di _n as text "Note: option 'var' specified."
|
||||
}
|
||||
if "`var'" != "var" & "`ul'" == "" {
|
||||
di _n as text "Note: default data input format (theta, " _c
|
||||
di as text "se_theta) assumed."
|
||||
}
|
||||
|
||||
* Select data to analyze
|
||||
mark `touse' `if' `in'
|
||||
if "`ul'" == "" {
|
||||
markout `touse' `theta' `setheta'
|
||||
}
|
||||
else {
|
||||
markout `touse' `theta' `ll' `ul'
|
||||
}
|
||||
|
||||
preserve
|
||||
quietly keep if `touse'
|
||||
quietly count
|
||||
if r(N)==0 {
|
||||
di as error "No observations with nonmissing values of `by'"
|
||||
exit 999
|
||||
}
|
||||
|
||||
|
||||
* initial calculations...
|
||||
if "`var'" == "var" {
|
||||
qui replace `setheta' = sqrt(`setheta')
|
||||
}
|
||||
|
||||
if "`ci'" == "ci" {
|
||||
di _n as text "Warning: ci option assumes that ratio measures are being used"
|
||||
capture confirm variable `cl'
|
||||
if _rc~=0 {
|
||||
qui gen `zz' = invnorm(.975)
|
||||
}
|
||||
else {
|
||||
qui replace `cl' = `cl' * 100 if `cl' < 1
|
||||
qui gen `zz' = -1 * invnorm((1- `cl' / 100) / 2 )
|
||||
qui replace `zz' = invnorm(.025) if `zz'==.
|
||||
}
|
||||
qui gen `setheta' = ( ln(`ul') - ln(`ll')) / 2 / `zz'
|
||||
qui replace `theta' = ln(`theta')
|
||||
}
|
||||
|
||||
* Graph options
|
||||
|
||||
if "`xtitle'" == "" {
|
||||
local xti : variable label `theta'
|
||||
if "`xti'" == "" {
|
||||
local xti "`theta'"
|
||||
}
|
||||
}
|
||||
else if "`xtitle'" ~= "" {
|
||||
local xti "`xtitle'"
|
||||
}
|
||||
|
||||
if "`ytitle'" == "" {
|
||||
local yti : variable label `setheta'
|
||||
if "`yti'" == "" {
|
||||
local yti "s.e. of `theta'"
|
||||
}
|
||||
}
|
||||
else if "`ytitle'" ~= "" {
|
||||
local yti "`ytitle'"
|
||||
}
|
||||
|
||||
capture assert "`ysca'"==""
|
||||
if _rc~=0 {
|
||||
display as error "ysca option not permitted"
|
||||
exit 999
|
||||
}
|
||||
|
||||
if "`yscale'"~="" {
|
||||
local chkrev=index("`yscale'","rev")
|
||||
display "chkrev: `chkrev'"
|
||||
if `chkrev'~=0 & "`reverse'"=="" {
|
||||
local ysca "`yscale'"
|
||||
}
|
||||
if `chkrev'==0 & "`reverse'"=="" {
|
||||
local ysca "`yscale' reverse"
|
||||
}
|
||||
if `chkrev'~=0 & "`reverse'"~="" {
|
||||
display "Parsing yscale: ,`yscale' "
|
||||
tokenize `yscale'
|
||||
while "`1'"~="" {
|
||||
if index("`1'","rev")==0 {
|
||||
local ysca "`ysca' `1'"
|
||||
}
|
||||
mac shift
|
||||
}
|
||||
}
|
||||
if `chkrev'==0 & "`reverse'"~="" {
|
||||
local ysca "`yscale'"
|
||||
}
|
||||
}
|
||||
if "`yscale'"=="" {
|
||||
if "`reverse'"=="" {
|
||||
local ysca "reverse"
|
||||
}
|
||||
if "`reverse'"~="" {
|
||||
local ysca "noreverse"
|
||||
}
|
||||
}
|
||||
|
||||
if "`subtitle'" == "" {
|
||||
local subtitle = "Funnel plot with pseudo 95% confidence limits"
|
||||
}
|
||||
else if "`subtitle'" == "." { /* "." means blank it out */
|
||||
local subtitle "" ""
|
||||
}
|
||||
local subtitle "subtitle(`subtitle')"
|
||||
|
||||
if "`msymbol'"=="" {
|
||||
local symopt "O T S D + X Oh Th Sh Dh o t s d x oh th sh dh p"
|
||||
}
|
||||
if "`msymbol'"~="" {
|
||||
local symopt "`msymbol'"
|
||||
}
|
||||
local msymbol "msymbol(`symopt')"
|
||||
|
||||
qui {
|
||||
gen `orign'=_n
|
||||
|
||||
gen `vvar' = `setheta'^2
|
||||
gen `w' = 1/`vvar'
|
||||
egen `sw' = sum(`w') if `touse'
|
||||
gen `wl' = `w' * `theta'
|
||||
egen `swl' = sum(`wl') if `touse'
|
||||
sort `orign'
|
||||
gen `RRm' = `swl' / `sw'
|
||||
local rxl=`RRm'[1]
|
||||
scalar `oe' = `RRm'
|
||||
egen `mmm' = min(`RRm')
|
||||
replace `RRm' = `mmm' if `setheta' == 0
|
||||
|
||||
if "`forcenull'"~="" {
|
||||
local rxl=0
|
||||
}
|
||||
|
||||
sort `orign'
|
||||
local obs1=_N+1
|
||||
local obs2=_N+2
|
||||
local obs3=_N+3
|
||||
local obs4=_N+4
|
||||
local obs5=_N+5
|
||||
local obs6=_N+6
|
||||
set obs `obs6'
|
||||
replace `orign'=_n
|
||||
replace `theta'=`rxl' in `obs1'
|
||||
replace `theta'=`rxl' in `obs3'
|
||||
gen `ll2' = 0 in `obs1'
|
||||
gen `ul2' = 0 in `obs3'
|
||||
|
||||
sort `orign'
|
||||
qui summ `setheta'
|
||||
local maxse=r(max)
|
||||
replace `theta' = `rxl'-(1.96*`maxse') in `obs2'
|
||||
replace `theta' = `rxl'+(1.96*`maxse') in `obs4'
|
||||
replace `ll2' = `maxse' in `obs2'
|
||||
replace `ul2' = `maxse' in `obs4'
|
||||
|
||||
gen `vl' = 0 in `obs5'
|
||||
replace `vl' = `maxse' in `obs6'
|
||||
replace `theta' = `rxl' in `obs5'
|
||||
replace `theta' = `rxl' in `obs6'
|
||||
|
||||
label var `ll2' "Lower CI"
|
||||
label var `ul2' "Lower CI"
|
||||
label var `vl' "Pooled"
|
||||
if "`forcenull'"~="" {
|
||||
label var `vl' "No effect"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
* list `setheta' `ll2' `ul2' `vl' `theta' `orign'
|
||||
* display "RRm: `rxl'"
|
||||
|
||||
local funopt "yscale(`ysca') `subtitle' ytitle("`yti'") xtitle("`xti'")"
|
||||
|
||||
if "`by'"=="" {
|
||||
local yvar "`setheta'"
|
||||
local legopt "legend(off)"
|
||||
}
|
||||
|
||||
if "`by'"~="" {
|
||||
|
||||
qui levels `by', local(bylev)
|
||||
local lev: word count `bylev'
|
||||
if `lev'>20 {
|
||||
di as text "Note: distinct group markers available for only 19 groups"
|
||||
}
|
||||
sort `orign'
|
||||
qui drop if `by'==.&_n<`obs1'
|
||||
qui count if `by'~=.
|
||||
if r(N)==0 {
|
||||
di as error "No observations with nonmissing values of `by'"
|
||||
exit 999
|
||||
}
|
||||
|
||||
forvalues b=1/`lev' {
|
||||
local bylab ""
|
||||
local bygroup: word `b' of `bylev'
|
||||
tempname bg`b'
|
||||
qui gen `bg`b''=`setheta' if `by'==`bygroup'
|
||||
local bylab: label (`by') `b'
|
||||
if "`bylab"=="" {
|
||||
label variable `bg`b'' "`by'=`b'"
|
||||
}
|
||||
if "`bylab"~="" {
|
||||
label variable `bg`b'' "`bylab'"
|
||||
}
|
||||
}
|
||||
local yvar "`bg1'-`bg`lev''"
|
||||
|
||||
} /* end by processing */
|
||||
|
||||
if "`nolines'"=="nolines"&"`eform'"=="" {
|
||||
* display "clause 1"
|
||||
twoway (scatter `yvar' `theta', `legopt' `msymbol') ///
|
||||
if `touse', `funopt' `options'
|
||||
}
|
||||
|
||||
if "`nolines'"==""&"`eform'"=="" {
|
||||
* display "clause 2"
|
||||
twoway (scatter `yvar' `theta', `legopt' `msymbol') ///
|
||||
(line `ll2' `ul2' `vl' `theta', msymbol(none none none) ///
|
||||
clcolor(black black black) clpat(dash dash solid) ///
|
||||
clwidth(medium medium medium)) ///
|
||||
if `touse', `funopt' `options'
|
||||
}
|
||||
|
||||
if "`eform'"~="" {
|
||||
gen `etheta'=exp(`theta')
|
||||
if "`xtitle'"=="" {
|
||||
local xti : variable label `theta'
|
||||
if "`xti'" == "" {
|
||||
local xti "exp(`theta'), log scale"
|
||||
}
|
||||
else if "`xti'" ~= "" {
|
||||
local xti "exp(`xti'), log scale"
|
||||
}
|
||||
}
|
||||
|
||||
capture assert "`xsca'"==""
|
||||
if _rc~=0 {
|
||||
display as error "xsca option not permitted"
|
||||
exit 999
|
||||
}
|
||||
if "`xscale'"~="" {
|
||||
local chklog=index("`xscale'","log")
|
||||
if `chklog'==0 {
|
||||
local xsca "`xscale' log"
|
||||
}
|
||||
else if `chklog'~=0 {
|
||||
local xsca "`xscale'"
|
||||
}
|
||||
}
|
||||
else if "`xscale'"=="" {
|
||||
local xsca "log"
|
||||
}
|
||||
|
||||
if "`nolines'"=="nolines" {
|
||||
* display "clause 3"
|
||||
|
||||
twoway (scatter `yvar' `etheta', `legopt' `msymbol') ///
|
||||
if `touse', `funopt' xscale(`xsca') `options'
|
||||
}
|
||||
|
||||
if "`nolines'"=="" {
|
||||
* display "clause 4"
|
||||
local rxl=exp(`rxl')
|
||||
twoway (scatter `yvar' `etheta', `legopt' `msymbol') ///
|
||||
(line `ll2' `ul2' `vl' `etheta', msymbol(none none none) ///
|
||||
clcolor(black black black) clpat(dash dash solid) ///
|
||||
clwidth(medium medium medium)) ///
|
||||
if `touse', `funopt' xscale(`xsca') `options'
|
||||
}
|
||||
}
|
||||
end
|
||||
|
250
Modules/ado/plus/m/metafunnel.dlg
Normal file
250
Modules/ado/plus/m/metafunnel.dlg
Normal file
@ -0,0 +1,250 @@
|
||||
/*
|
||||
*! metafunnel dialog version 1.0.1, 20 Aug 2003, T. J. Steichen, steichen@triad.rr.com
|
||||
*! for metafunnel version 1.0.2, 18 Aug 2003, J.A.C. Sterne, Jonathan.Sterne@bristol.ac.uk
|
||||
|
||||
Graphs funnel plot, with standard error on the vertical axis
|
||||
------------------------------------------------------------
|
||||
|
||||
Syntax: metafunnel { theta {se|var} | exp(theta) ll ul [cl] } [ if exp ] [ in range ] [,
|
||||
BY(varname) Var CI
|
||||
SUbtitle(str) NOLines FORCEnull REVerse EForm
|
||||
XTitle(string) YTitle(string) XScale(string)
|
||||
YScale(string) MSymbol(string) * ]
|
||||
|
||||
|
||||
Install in User Statistics menu via Stata commands:
|
||||
. window menu append item "stUserStatistics" "metafunn&el (Funnel Graph, vertical)" "db metafunnel"
|
||||
. window menu refresh
|
||||
To permanently install, place the commands in your -profile.do- file.
|
||||
*/
|
||||
|
||||
VERSION 8.0
|
||||
|
||||
INCLUDE _std_medium
|
||||
INCLUDE header
|
||||
|
||||
HELP hlp1, view("help metafunnel")
|
||||
RESET res1, label("Reset")
|
||||
|
||||
DIALOG main, label("metafunnel 1.0.2 - Funnel Graph, vertical") tabtitle("Main")
|
||||
BEGIN
|
||||
|
||||
GROUPBOX gb_data 10 5 390 _ht5h, ///
|
||||
label("Type of Data:")
|
||||
RADIO r_se 15 25 100 ., ///
|
||||
label("Theta, SE") first ///
|
||||
onclickon(script main_se_on) ///
|
||||
onclickoff(script main_se_off) ///
|
||||
option(NONE)
|
||||
RADIO r_var 115 25 100 ., ///
|
||||
label("Theta, Var") middle ///
|
||||
onclickon(script main_var_on) ///
|
||||
onclickoff(script main_var_off) ///
|
||||
option("var")
|
||||
RADIO r_ci 215 25 110 ., ///
|
||||
label("exp(Theta), CI") last ///
|
||||
onclickon(script main_ci_on) ///
|
||||
onclickoff(script main_ci_off) ///
|
||||
option("ci")
|
||||
|
||||
TEXT tx_se 15 45 380 ., ///
|
||||
label("Vars for theta, se(theta), in that order")
|
||||
VARLIST vl_se @ _ss @ ., ///
|
||||
label("Vars for theta, se(theta)")
|
||||
|
||||
TEXT tx_var @ 45 380 ., ///
|
||||
label("Vars for theta, var(theta), in that order")
|
||||
VARLIST vl_var @ _ss @ ., ///
|
||||
label("Vars for theta, var(theta)")
|
||||
|
||||
TEXT tx_ci @ 45 380 ., ///
|
||||
label("Vars for exp(theta), CI_LL, CI_UL, in that order")
|
||||
VARLIST vl_ci @ _ss @ ., ///
|
||||
label("Vars for exp(theta), CI_LL, CI_UL")
|
||||
|
||||
CHECKBOX cb_by 10 100 100 ., ///
|
||||
label("By Variable:") ///
|
||||
onclickon(main.vn_by.enable) ///
|
||||
onclickoff(main.vn_by.disable)
|
||||
VARNAME vn_by 110 100 290 ., ///
|
||||
label("By Variable") ///
|
||||
option("by")
|
||||
|
||||
CHECKBOX ck_subtitle 10 130 55 ., ///
|
||||
label("Title:") ///
|
||||
onclickon(main.ed_subtitle.enable) ///
|
||||
onclickoff(main.ed_subtitle.disable)
|
||||
EDIT ed_subtitle 70 @ 330 ., ///
|
||||
label("Title") ///
|
||||
option("subtitle")
|
||||
|
||||
CHECKBOX ck_xtitle 10 155 55 ., ///
|
||||
label("X: title") ///
|
||||
onclickon(main.ed_xtitle.enable) ///
|
||||
onclickoff(main.ed_xtitle.disable)
|
||||
EDIT ed_xtitle 70 @ 160 ., ///
|
||||
label("X title") ///
|
||||
option("xtitle")
|
||||
|
||||
CHECKBOX ck_xscale 240 @ 60 ., ///
|
||||
label("scale") ///
|
||||
onclickon(main.ed_xscale.enable) ///
|
||||
onclickoff(main.ed_xscale.disable)
|
||||
EDIT ed_xscale 300 @ 100 ., ///
|
||||
label("X scale") ///
|
||||
option("xscale")
|
||||
|
||||
CHECKBOX ck_ytitle 10 175 55 ., ///
|
||||
label("Y: title") ///
|
||||
onclickon(main.ed_ytitle.enable) ///
|
||||
onclickoff(main.ed_ytitle.disable)
|
||||
EDIT ed_ytitle 70 @ 160 ., ///
|
||||
label("Y title") ///
|
||||
option("ytitle")
|
||||
|
||||
CHECKBOX ck_yscale 240 @ 60 ., ///
|
||||
label("scale") ///
|
||||
onclickon(main.ed_yscale.enable) ///
|
||||
onclickoff(main.ed_yscale.disable)
|
||||
EDIT ed_yscale 300 @ 100 ., ///
|
||||
label("Y scale") ///
|
||||
option("yscale")
|
||||
|
||||
|
||||
CHECKBOX ck_reverse 10 200 120 ., ///
|
||||
label("Reverse y-axis") ///
|
||||
option("reverse")
|
||||
|
||||
CHECKBOX ck_nolines 10 220 120 ., ///
|
||||
label("Suppress lines") ///
|
||||
option("nolines")
|
||||
|
||||
CHECKBOX ck_eform 150 200 120 ., ///
|
||||
label("Exponential form") ///
|
||||
option("eform")
|
||||
|
||||
CHECKBOX ck_forcenull 150 220 120 ., ///
|
||||
label("Force null") ///
|
||||
option("forcenull")
|
||||
|
||||
|
||||
CHECKBOX ck_msymbol 290 200 110 ., ///
|
||||
label("Marker Symb:") ///
|
||||
onclickon(main.ed_msymbol.enable) ///
|
||||
onclickoff(main.ed_msymbol.disable)
|
||||
EDIT ed_msymbol 290 220 110 ., ///
|
||||
label("M Symbol") ///
|
||||
option("msymbol")
|
||||
|
||||
|
||||
|
||||
END
|
||||
|
||||
INCLUDE ifin
|
||||
|
||||
SCRIPT main_se_on
|
||||
BEGIN
|
||||
main.tx_se.show
|
||||
main.vl_se.show
|
||||
main.tx_se.enable
|
||||
main.vl_se.enable
|
||||
|
||||
main.tx_var.disable
|
||||
main.vl_var.disable
|
||||
main.tx_var.hide
|
||||
main.vl_var.hide
|
||||
|
||||
main.tx_ci.disable
|
||||
main.vl_ci.disable
|
||||
main.tx_ci.hide
|
||||
main.vl_ci.hide
|
||||
END
|
||||
|
||||
SCRIPT main_se_off
|
||||
BEGIN
|
||||
main.tx_se.disable
|
||||
main.vl_se.disable
|
||||
main.tx_se.hide
|
||||
main.vl_se.hide
|
||||
END
|
||||
|
||||
SCRIPT main_var_on
|
||||
BEGIN
|
||||
main.tx_var.show
|
||||
main.vl_var.show
|
||||
main.tx_var.enable
|
||||
main.vl_var.enable
|
||||
|
||||
main.tx_se.disable
|
||||
main.vl_se.disable
|
||||
main.tx_se.hide
|
||||
main.vl_se.hide
|
||||
|
||||
main.tx_ci.disable
|
||||
main.vl_ci.disable
|
||||
main.tx_ci.hide
|
||||
main.vl_ci.hide
|
||||
END
|
||||
|
||||
SCRIPT main_var_off
|
||||
BEGIN
|
||||
main.tx_var.disable
|
||||
main.vl_var.disable
|
||||
main.tx_var.hide
|
||||
main.vl_var.hide
|
||||
END
|
||||
|
||||
SCRIPT main_ci_on
|
||||
BEGIN
|
||||
main.tx_ci.show
|
||||
main.vl_ci.show
|
||||
main.tx_ci.enable
|
||||
main.vl_ci.enable
|
||||
|
||||
main.tx_se.disable
|
||||
main.vl_se.disable
|
||||
main.tx_se.hide
|
||||
main.vl_se.hide
|
||||
|
||||
main.tx_var.disable
|
||||
main.vl_var.disable
|
||||
main.tx_var.hide
|
||||
main.vl_var.hide
|
||||
END
|
||||
|
||||
SCRIPT main_ci_off
|
||||
BEGIN
|
||||
main.tx_ci.disable
|
||||
main.vl_ci.disable
|
||||
main.tx_ci.hide
|
||||
main.vl_ci.hide
|
||||
END
|
||||
|
||||
PROGRAM command
|
||||
BEGIN
|
||||
put "metafunnel "
|
||||
if main.r_se {
|
||||
varlist main.vl_se
|
||||
}
|
||||
if main.r_var {
|
||||
varlist main.vl_var
|
||||
}
|
||||
if main.r_ci {
|
||||
varlist main.vl_ci
|
||||
}
|
||||
INCLUDE _ifin_pr
|
||||
beginoptions
|
||||
option radio(main r_se r_var r_ci)
|
||||
optionarg main.vn_by
|
||||
optionarg main.ed_subtitle
|
||||
optionarg main.ed_xtitle
|
||||
optionarg main.ed_ytitle
|
||||
optionarg main.ed_xscale
|
||||
optionarg main.ed_yscale
|
||||
option main.ck_nolines
|
||||
option main.ck_forcenull
|
||||
option main.ck_eform
|
||||
option main.ck_reverse
|
||||
optionarg main.ed_msymbol
|
||||
endoptions
|
||||
END
|
167
Modules/ado/plus/m/metafunnel.hlp
Normal file
167
Modules/ado/plus/m/metafunnel.hlp
Normal file
@ -0,0 +1,167 @@
|
||||
{smcl}
|
||||
{* 19aug2003}{...}
|
||||
{hline}
|
||||
help for {hi:metafunnel} {right:dialog: {dialog metafunnel}{space 20}}
|
||||
{hline}
|
||||
|
||||
{title:Funnel plots for meta-analysis}
|
||||
|
||||
{p 8 15 2}
|
||||
{cmd:metafunnel}
|
||||
{it:{ theta { se | var } | exp(theta) ll ul [cl] }}
|
||||
[{cmd:if} {it:exp}]
|
||||
[{cmd:in} {it:range}]
|
||||
[{cmd:,}
|
||||
{cmdab:ef:orm}
|
||||
{cmdab:nol:ine}
|
||||
{cmdab:rev:erse}
|
||||
{cmdab:forc:enull}
|
||||
{cmdab:graph_options}
|
||||
]
|
||||
|
||||
|
||||
{title:Description}
|
||||
|
||||
{p 4 4 2}
|
||||
{cmd:metafunnel} plots funnel plots. These graphical displays are used to
|
||||
examine whether the results of a meta-analysis may have been affected by
|
||||
publication or other types of bias.
|
||||
|
||||
|
||||
{title:Options}
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:by(}{it:byvarname}{cmd:)} displays subgroups according to the value
|
||||
of {it: byvarname}. The legend
|
||||
displays the value labels for the levels of {it: byvarname} if these are
|
||||
present; otherwise it displays the value of each level of{it: byvarname}.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:eform} exponentiates the treatment effect theta and displays the
|
||||
horizontal axis (treatment effect) on a log scale. This is useful for
|
||||
displaying ratio measures such as odds ratios and risk ratios.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:reverse} inverts the funnel plot so that larger studies are displayed
|
||||
at the bottom of the plot with smaller studies at the top.
|
||||
This may also be achieved by specifying {cmd:noreverse} as part of the
|
||||
{cmd: yscale(}{it:axis_description}{cmd:)} graphics option.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:noline} specifies that pseudo 95% confidence interval lines
|
||||
should not be included in the plot. The default is to include them.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:forcenull} forces the vertical line at the centre of the funnel
|
||||
to be plotted at the null treatment effect of zero (1 when the treatment
|
||||
effect is exponentiated). The default is for the line to be plotted at
|
||||
the value of the fixed effect summary estimate.
|
||||
|
||||
{title:Remarks}
|
||||
|
||||
{p 4 4 2}
|
||||
Funnel plots are simple graphical displays of a measure of study size
|
||||
on the vertical axis against intervention or treatment effect on the
|
||||
horizontal axis. The name "funnel plot" is based on the fact that the
|
||||
precision in the estimation of the underlying intervention or treatment
|
||||
effect will increase as the size of component studies increases. Results
|
||||
from small studies will therefore scatter more widely, with the spread
|
||||
narrowing among larger studies. In the absence of bias the plot will
|
||||
resemble a symmetrical inverted funnel.
|
||||
|
||||
{p 4 4 2}
|
||||
If there is bias, for example because smaller studies showing no
|
||||
statistically significant effects remain unpublished, then such
|
||||
publication bias will lead to an asymmetrical appearance of the funnel
|
||||
plot. It should be noted that although funnel plots have traditionally
|
||||
been used to examine evidence for publication bias, funnel plot asymmetry
|
||||
may reflect other types of bias, or even result from the true intervention
|
||||
or treatment effect differing between small and large studies. They should
|
||||
thus be seen as displaying the evidence for "small study effects" in general
|
||||
rather than publication bias in particular. These issues are discussed by
|
||||
Egger {it: et al.} (1997) and Sterne {it:et al.} (2001a).
|
||||
|
||||
{p 4 4 2}
|
||||
{cmd:metafunnel} uses the same syntax as other meta-analysis commands
|
||||
such as {help meta}, {help metabias}, {help metainf} and {help metatrim}.
|
||||
The user provides an estimate of the treatment or intervention effect,
|
||||
{it: theta}, together with its associated standard error {it: se_theta}
|
||||
(the default) or variance {it: var_theta}, (in which case the {cmd: var}
|
||||
option should be specified). Alternatively, the user provides {it:exp(theta)}
|
||||
(i.e., a risk ratio or odds ratio) and its confidence interval,
|
||||
{it: (ll, ul)}).
|
||||
|
||||
{p 4 4 2}
|
||||
The funnel plots are displayed in line with meta-analytic convention and
|
||||
the recommendations of Sterne et al. (2001b). The effect of the
|
||||
treatment or intervention in each study (horizontal axis) is plotted
|
||||
against the study size, as measured by the standard error of the treatment
|
||||
or intervention effect.
|
||||
(vertical axis). The vertical axis is reversed so that larger studies are
|
||||
displayed towards the top of the graph (this behaviour may be changed using
|
||||
the {cmd: reverse} option). Users who wish to plot the treatment effect on the vertical axis should use the {cmd:graph(begg)} option of
|
||||
the {help metabias} command. The {help funnel} command, which is part
|
||||
of the {help metan} package, also provides an alternative way to draw
|
||||
funnel plots.
|
||||
|
||||
{p 4 4 2}
|
||||
The plots include pseudo-95% confidence interval lines, which are
|
||||
drawn around the summary fixed-effect estimate of the intervention or
|
||||
treatment effect. The lines may be omitted using the {cmd:nolines} option.
|
||||
The user may also specify that the pseudo confidence limits are centred
|
||||
around a zero intervention effect using the {cmd:forcenull} option.
|
||||
|
||||
{p 4 4 2}
|
||||
When the {cmd:eform} option is used, the label of the horizontal axis
|
||||
(treatment effect, {it:theta}) is
|
||||
changed accordingly, unless there is a variable label for {cmd: theta} or
|
||||
the {cmd: xtitle(}{it:axis_title}{cmd:)} graphics option is used.
|
||||
|
||||
{p 4 4 2}
|
||||
By default, the subtitle "Funnel plot with pseudo 95% confidence limits"
|
||||
is displayed. This may be changed using the graphics option
|
||||
{cmd:subtitle(}{it:tinfo}{cmd:)}.
|
||||
|
||||
|
||||
{title:Examples}
|
||||
|
||||
{p 4 8 2}{cmd:. metafunnel meandiff semeandiff}
|
||||
|
||||
{p 4 8 2}{cmd:. metafunnel logor selogor, eform xtitle("Odds ratio (log scale)")}
|
||||
|
||||
{p 4 8 2}{cmd:. metafunnel sttd stderr, by(dose) subtitle(Funnel plot with subgroups) forcenull}
|
||||
|
||||
{p 4 8 2}{cmd:. metafunnel logor varlogor, var reverse nolines xtitle(log odds ratio)}
|
||||
|
||||
|
||||
|
||||
{title:Acknowledgements}
|
||||
|
||||
{p 4 4 2}
|
||||
{cmd:metafunnel} was written by Jonathan Sterne, University of Bristol.
|
||||
Portions of the code were originally written by Tom Steichen, who also
|
||||
gave helpful comments on an early version of the command and provided
|
||||
the dialog.
|
||||
|
||||
|
||||
{title:References}
|
||||
|
||||
{p 4 8 2}Egger, M., Davey Smith, G., Schneider, M., & Minder, C. (1997).
|
||||
Bias in meta-analysis detected by a simple, graphical test.
|
||||
{it:British Medical Journal} 315: 629-634
|
||||
|
||||
{p 4 8 2}Sterne, J.A.C., Egger, M. and Davey Smith, G. (2001a).
|
||||
Investigating and dealing with publication and other biases
|
||||
in meta-analysis. {it: British Medical Journal} 323: 101-105
|
||||
|
||||
{p 4 8 2}Sterne, J.A.C. & Egger, M. (2001b). Funnel plots for detecting
|
||||
bias in meta-analysis: guidelines on choice of axis.
|
||||
{it: Journal of Clinical Epidemiology} 54: 1046-1055
|
||||
|
||||
|
||||
{title:Also see}
|
||||
|
||||
{p 4 13 2}
|
||||
Online: help for {help meta}, {help metabias},
|
||||
{help metainf}, {help metatrim}, {help metan}, {help funnel} (if installed)
|
||||
{p_end}
|
146
Modules/ado/plus/m/metainf.ado
Normal file
146
Modules/ado/plus/m/metainf.ado
Normal file
@ -0,0 +1,146 @@
|
||||
*! metainf.ado AT version 3.0.0 March 2000 (STB-56: sbe26.1)
|
||||
* metainf.ado AT version 2.0.0 November 1998
|
||||
* metainf.ado AT version 1.0.0 February 1998
|
||||
|
||||
program define metainf
|
||||
version 6.0
|
||||
syntax varlist(min=2 max=2 numeric) [if] [in] [, id(varname) /*
|
||||
*/ random eform t1(str) t2(str) Format(str) print `options' *]
|
||||
tokenize `varlist'
|
||||
local E `1'
|
||||
local SE `2'
|
||||
preserve
|
||||
|
||||
* Dealing with if and in options
|
||||
if ("`if'"!="") {
|
||||
qui keep `if'
|
||||
}
|
||||
if ("`in'"!="") {
|
||||
qui keep `in'
|
||||
}
|
||||
|
||||
* Overall estimates
|
||||
qui meta `E' `SE', `eform'
|
||||
if "`random'"=="random" {
|
||||
local ove=$S_7
|
||||
local ll=$S_9
|
||||
* Global macro should be updated if meta change it name
|
||||
local ul=$S_0
|
||||
}
|
||||
else {
|
||||
local ove=$S_1
|
||||
local ll=$S_3
|
||||
local ul=$S_4
|
||||
}
|
||||
|
||||
* Meta-analysis estimate ommiting one study each step
|
||||
tempvar theta setheta ulth llth
|
||||
qui sum `E', detail
|
||||
local n=_result(1)
|
||||
qui {
|
||||
gen `theta'=.
|
||||
gen `setheta'=.
|
||||
gen `ulth'=.
|
||||
gen `llth'=.
|
||||
}
|
||||
local i=1
|
||||
tempvar s
|
||||
qui gen `s'=_n
|
||||
while (`i'<=`n') {
|
||||
qui {
|
||||
meta `E' `SE' if `s'!=`i', `eform'
|
||||
if "`random'"=="random" {
|
||||
replace `theta'=$S_7 in `i'
|
||||
replace `llth'=$S_9 in `i'
|
||||
replace `ulth'=$S_0 in `i'
|
||||
}
|
||||
else {
|
||||
replace `theta'=$S_1 in `i'
|
||||
replace `llth'=$S_3 in `i'
|
||||
replace `ulth'=$S_4 in `i'
|
||||
}
|
||||
}
|
||||
local i=`i'+1
|
||||
}
|
||||
|
||||
* Maximum and minimum CI values
|
||||
qui sum `llth', detail
|
||||
local mnx=r(min)
|
||||
qui sum `ulth', detail
|
||||
local mxx=r(max)
|
||||
|
||||
* Labeling plot
|
||||
if "`t2'" == "" {
|
||||
local t2 "Study ommited"
|
||||
}
|
||||
if "`t1'" == "" {
|
||||
if "`eform'"=="eform" & "`random'"=="" {
|
||||
local t1 "Meta-analysis fixed-effects estimates (exponential form)"
|
||||
}
|
||||
if "`eform'"=="" & "`random'"=="" {
|
||||
local t1 "Meta-analysis fixed-effects estimates (linear form)"
|
||||
}
|
||||
if "`eform'"=="eform" & "`random'"=="random" {
|
||||
local t1 "Meta-analysis random-effects estimates (exponential form)"
|
||||
}
|
||||
if "`eform'"=="" & "`random'"=="random" {
|
||||
local t1 "Meta-analysis random-effects estimates (linear form)"
|
||||
}
|
||||
}
|
||||
|
||||
* Numeric format
|
||||
if "`format'" == "" {
|
||||
local format "%5.2f"
|
||||
}
|
||||
|
||||
* Print option
|
||||
if "`print'"=="print" & "`eform'"=="" {
|
||||
dis
|
||||
dis in gre "`lab'"
|
||||
dis in gr "------------------------------------------------------------------------------"
|
||||
dis in gr _col(2) "Study ommited" _col(20) "|" _col(24) "Coef." _col(39) "[95% Conf. Interval]"
|
||||
dis in gr "-------------------+----------------------------------------------------------"
|
||||
local i=1
|
||||
while `i'<=`n' {
|
||||
if "`id'"=="" { local a=`s' in `i' }
|
||||
else { local a=`id' in `i'}
|
||||
local b=`theta' in `i'
|
||||
local c=`llth' in `i'
|
||||
local d=`ulth' in `i'
|
||||
display _col(2) "`a'" _col(20) in gr "|" in ye _col(24) `b' _col(39) `c' _col(52) `d'
|
||||
local i=`i'+1
|
||||
}
|
||||
dis in gr "-------------------+----------------------------------------------------------"
|
||||
dis _col(2) "Combined" _col(20) in gr "|" in ye _col(24) `ove' _col(39) `ll' _col(52) `ul'
|
||||
dis in gr "------------------------------------------------------------------------------"
|
||||
}
|
||||
else if "`print'"=="print" & "`eform'"=="eform" {
|
||||
dis
|
||||
dis in gre "`lab'"
|
||||
dis in gr "------------------------------------------------------------------------------"
|
||||
dis in gr _col(2) "Study ommited" _col(20) "|" _col(24) "e^coef." _col(39) "[95% Conf. Interval]"
|
||||
dis in gr "-------------------+----------------------------------------------------------"
|
||||
local i=1
|
||||
while `i'<=`n' {
|
||||
if "`id'"=="" {
|
||||
local a=`s' in `i'
|
||||
}
|
||||
else {
|
||||
local a=`id' in `i'
|
||||
}
|
||||
local b=`theta' in `i'
|
||||
local c=`llth' in `i'
|
||||
local d=`ulth' in `i'
|
||||
display _col(2) "`a'" _col(20) in gr "|" in ye _col(24) `b' _col(39) `c' _col(52) `d'
|
||||
local i=`i'+1
|
||||
}
|
||||
dis in gr "-------------------+----------------------------------------------------------"
|
||||
display _col(2) "Combined" _col(20) in gr "|" in ye _col(24) `ove' _col(39) `ll' _col(52) `ul'
|
||||
dis in gr "------------------------------------------------------------------------------"
|
||||
}
|
||||
|
||||
* Displaying plot
|
||||
hplot `theta' `llth' `ulth', r sy(o||) l("`id'") t1(`t1') t2(`t2') f(`format') /*
|
||||
*/ xline(`ove',`ll',`ul') xlab(`mnx',`ove',`ll',`ul',`mxx') xti(`ove',`ll',`ul') /*
|
||||
*/ xscale(`mnx',`mxx')
|
||||
end
|
79
Modules/ado/plus/m/metainf.dlg
Normal file
79
Modules/ado/plus/m/metainf.dlg
Normal file
@ -0,0 +1,79 @@
|
||||
/*
|
||||
|
||||
*! metainf dialog version 1.0.0, 13 May 2003, T. J. Steichen, steichen@triad.rr.com
|
||||
*! for metainf version 3.0.0, Mar 2000, Aurelio Tobias, atobias@isciii.es
|
||||
|
||||
Influence of a single study in meta-analysis estimation
|
||||
-------------------------------------------------------
|
||||
|
||||
Syntax: metainf theta setheta [if exp] [in range]
|
||||
[, id(labvar) eform random print graph_options]
|
||||
|
||||
|
||||
To install in User Statistics menu via Stata commands:
|
||||
. window menu append item "stUserStatistics" "Meta-based Influence Analysis (metain&f)" "db metainf"
|
||||
. window menu refresh
|
||||
To permanently install, place the commands in your -profile.do- file.
|
||||
*/
|
||||
|
||||
VERSION 8.0
|
||||
|
||||
INCLUDE _std_small
|
||||
INCLUDE header
|
||||
|
||||
HELP hlp1, view("help metainf")
|
||||
RESET res1, label("Reset")
|
||||
|
||||
DIALOG main, label("metainf 3.0.0 - Meta-based Influence Analysis") tabtitle("Main")
|
||||
BEGIN
|
||||
TEXT tx_effect 10 5 330 ., ///
|
||||
label("Vars for Effect Sizes: theta, se(theta), in that order")
|
||||
VARLIST vl_effect @ _ss @ ., ///
|
||||
label("Effect Sizes: theta, se(theta)")
|
||||
|
||||
CHECKBOX cb_id 10 60 40 ., ///
|
||||
label("ID:") ///
|
||||
onclickon(main.vn_id.enable) ///
|
||||
onclickoff(main.vn_id.disable)
|
||||
VARNAME vn_id 50 60 290 ., ///
|
||||
label("ID Variable") ///
|
||||
option("id")
|
||||
|
||||
GROUPBOX gb_pool 10 85 195 _ht3h, ///
|
||||
label("Pooling Model")
|
||||
RADIO r_fixed 15 100 185 ., ///
|
||||
label("Fixed, Inverse Variance") first ///
|
||||
option("fixed")
|
||||
RADIO r_random @ 125 @ ., ///
|
||||
label("Random, Inverse Variance") last ///
|
||||
option("random")
|
||||
|
||||
CHECKBOX cb_eform 230 95 200 ., ///
|
||||
label("Use exp(theta)") ///
|
||||
option("eform")
|
||||
CHECKBOX cb_print 230 125 200 ., ///
|
||||
label("Print Details") ///
|
||||
option("print")
|
||||
|
||||
GROUPBOX gb_hpopts 10 155 330 _ht1h, ///
|
||||
label("Allowed hplot Options:")
|
||||
EDIT ed_hpopts 15 175 320 ., ///
|
||||
label("hplot Options")
|
||||
END
|
||||
|
||||
INCLUDE ifin
|
||||
|
||||
|
||||
PROGRAM command
|
||||
BEGIN
|
||||
put "metainf "
|
||||
varlist main.vl_effect
|
||||
INCLUDE _ifin_pr
|
||||
beginoptions
|
||||
option radio(main r_fixed r_random)
|
||||
optionarg main.vn_id
|
||||
option main.cb_eform
|
||||
option main.cb_print
|
||||
put main.ed_hpopts
|
||||
endoptions
|
||||
END
|
96
Modules/ado/plus/m/metainf.hlp
Normal file
96
Modules/ado/plus/m/metainf.hlp
Normal file
@ -0,0 +1,96 @@
|
||||
.-
|
||||
help for ^metainf^ (STB-47: sbe26; STB-56: sbe26.1)
|
||||
.-
|
||||
|
||||
Influence of a single study in the meta-analysis estimates
|
||||
----------------------------------------------------------
|
||||
|
||||
^metainf^ theta setheta [^if^ exp] [^in^ range] [,^id(^labvar^)^ ^eform^ ^random^
|
||||
^print^ graph_options]
|
||||
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
^metainf^ investigate the influence of a single study on the overall meta-
|
||||
analysis estimate. This command shows graphically the results of an influence
|
||||
analysis, in which the meta-analysis estimates are computed omitting one study
|
||||
in each turn.
|
||||
|
||||
^theta^ is the effect estimated from the individual study, and ^setheta^ is its
|
||||
standard error. For example theta might be a difference in means, a log rate
|
||||
ratio, a log odds ratio, or a log hazard ratio.
|
||||
|
||||
If you have a dataset which contains data for all studies, then the @byvar@
|
||||
command can be used to derive the effect estimates and standard errors for the
|
||||
individual studies. For example:
|
||||
|
||||
. ^sort study^
|
||||
. ^byvar study, coef(group) se(group) generate:^
|
||||
. ^quietly poisson cases group, e(pyrs)^
|
||||
. ^sort study^
|
||||
. ^qui by study: keep if _n==1^
|
||||
. ^rename _C_1 logrr^
|
||||
. ^rename _S_1 logse^
|
||||
. ^metainf logrr logse, id(study)^
|
||||
|
||||
Alternatively, the @collapse@ command may be useful.
|
||||
|
||||
|
||||
Options
|
||||
-------
|
||||
|
||||
^id(^labvar^)^ is a variable which is used to label the studies.
|
||||
|
||||
^eform^ requests that the output is exponentiated.
|
||||
|
||||
^random^ request random-effects estimates. By default fixed-effects estimates
|
||||
are computed.
|
||||
|
||||
^print^ shows the estimates, and their 95% confidence interval, of the meta-
|
||||
analysis estimates omitting one study in each turn. These values are used to
|
||||
make the graphic.
|
||||
|
||||
All ^hplot^ options are also available.
|
||||
|
||||
|
||||
Note
|
||||
----
|
||||
|
||||
To run the ^metainf^ command, the ^meta^ [STB-43 sbe16.2, STB-42 sbe16.1,
|
||||
STB-38 sbe16] and the ^hplot^ (Cox 1999a, 1999b) command must be installed.
|
||||
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
. ^metainf logrr logse, print id(studyid)^
|
||||
. ^metainf logrr logse, random print id(studyid)^
|
||||
. ^metainf logrr logse, random eform id(studyid) format(%4.2f)^
|
||||
|
||||
|
||||
References
|
||||
----------
|
||||
|
||||
Cox NJ (1999a). -hplot- and -hbar- for presentation graphics. Proceedings
|
||||
of the 5th Stata UK user group meeting, London, UK.
|
||||
|
||||
Cox NJ (1999b). De tablas a gr<67>ficos, presentaciones en Stata. Proceedings
|
||||
of the 1st Iberian user group meeting, Cordoba, Spain.
|
||||
|
||||
|
||||
Author
|
||||
------
|
||||
|
||||
Aurelio Tobias
|
||||
Universidad Miguel Hernandez, Alicante, Spain
|
||||
email: bledatobias@@ctv.es
|
||||
|
||||
|
||||
Also see
|
||||
--------
|
||||
|
||||
On-line: help for @byvar@, @collapse@, @for@, @meta@ (if installed), @metareg@ (if
|
||||
installed), @metabias@ (if installed), @metacum@ (if installed), @galbr@
|
||||
(if installed), metap (if installed), @hplot@ (if installed)
|
||||
|
4454
Modules/ado/plus/m/metan.ado
Normal file
4454
Modules/ado/plus/m/metan.ado
Normal file
File diff suppressed because it is too large
Load Diff
838
Modules/ado/plus/m/metan.dlg
Normal file
838
Modules/ado/plus/m/metan.dlg
Normal file
@ -0,0 +1,838 @@
|
||||
/*
|
||||
|
||||
*! metan dialog version 1.0.5, 1 Apr 2004, T. J. Steichen, steichen@triad.rr.com
|
||||
*! for metan version 1.85, 15 Mar 2004, M. J. Bradburn, mike.bradburn@cancer.org.uk
|
||||
|
||||
Fixed and random effects meta-analysis
|
||||
--------------------------------------
|
||||
Syntax: metan varlist [if exp] [in range] [,
|
||||
label(namevar=name, yearvar=year)
|
||||
fixed random fixedi randomi peto
|
||||
rr or rd cornfield chi2 breslow notable nograph
|
||||
cohen hedges glass nostandard
|
||||
log sortby(sort_vars) ilevel(#) olevel(#) nokeep
|
||||
xlabel(#,..,#) force t1title(#,..,#) boxsha(#) boxsca(#) texts(#)
|
||||
saving(filename) nowt counts nostats nooverall
|
||||
group1(text) group2(text) effect(text) nobox eform
|
||||
wgt(weightvar) xtick(#,..,#)
|
||||
t2title(#,..,#) b1title(#,..,#) b2title(#,..,#)
|
||||
nointeger cc(#) by(byvar) nosubgroup sgweight legend(text) ]
|
||||
|
||||
To install in User Statistics menu via Stata commands:
|
||||
. window menu append item "stUserStatistics" "Meta-analysis of Binary and Continuous Data (meta&n)" "db metan"
|
||||
. window menu refresh
|
||||
To permanently install, place the commands in your -profile.do- file.
|
||||
|
||||
*/
|
||||
|
||||
VERSION 8.0
|
||||
|
||||
INCLUDE _std_medium
|
||||
INCLUDE _ht300
|
||||
DEFINE _dlgwd 450
|
||||
INCLUDE header
|
||||
|
||||
HELP hlp1, view("help metan")
|
||||
RESET res1, label("Reset")
|
||||
|
||||
DIALOG main, label("metan 1.85 - Meta-analysis of Binary & Continuous") tabtitle("Main")
|
||||
BEGIN
|
||||
GROUPBOX gb_data 10 5 310 _ht1h, ///
|
||||
label("Type of Data:")
|
||||
RADIO r_binary 15 25 60 ., ///
|
||||
label(" Count") first ///
|
||||
onclickon(script main_binary_on) ///
|
||||
onclickoff(script main_binary_off)
|
||||
RADIO r_continuous 75 25 90 ., ///
|
||||
label("Continuous") middle ///
|
||||
onclickon(script main_continuous_on) ///
|
||||
onclickoff(script main_continuous_off)
|
||||
RADIO r_effect_ci 165 25 75 ., ///
|
||||
label("Effect/CI") middle ///
|
||||
onclickon(script main_effect_ci_on) ///
|
||||
onclickoff(script main_effect_ci.off)
|
||||
RADIO r_effect_se 240 25 75 ., ///
|
||||
label("Effect/SE") last ///
|
||||
onclickon(script main_effect_se_on) ///
|
||||
onclickoff(script main_effect_se_off)
|
||||
|
||||
/* end GROUPBOX gb_data */
|
||||
|
||||
TEXT tx_binary 10 50 310 ., ///
|
||||
label("Vars for Counts: a, b, c, d, in that order")
|
||||
VARLIST vl_binary @ _ss @ ., ///
|
||||
label("Vars for a, b, c, d")
|
||||
|
||||
TEXT tx_contin_exp @ 50 310 ., ///
|
||||
label("Vars for Exp. Group: n, mean, sd, in that order")
|
||||
VARLIST vl_contin_exp @ _ss @ ., ///
|
||||
label("Experimental Group: n, mean, sd")
|
||||
TEXT tx_contin_ctl @ _ss 310 ., ///
|
||||
label("Vars for Control Group: n, mean, sd, in that order")
|
||||
VARLIST vl_contin_ctl @ _ss @ ., ///
|
||||
label("Control Group: n, mean, sd")
|
||||
|
||||
TEXT tx_effect_ci @ 50 310 ., ///
|
||||
label("Vars for Effects: theta, lowerCI, upperCI, in that order")
|
||||
VARLIST vl_effect_ci @ _ss @ ., ///
|
||||
label("Effect Sizes: theta, lowerCI, upperCI")
|
||||
|
||||
TEXT tx_effect_se @ 50 310 ., ///
|
||||
label("Vars for Effects: theta, se(theta), in that order")
|
||||
VARLIST vl_effect_se @ _ss @ ., ///
|
||||
label("Effect Sizes: theta, se(theta)")
|
||||
|
||||
/* end vars */
|
||||
|
||||
GROUPBOX gb_labels 10 130 310 _ht3h, ///
|
||||
label("Labels for Data:")
|
||||
CHECKBOX cb_name 20 150 70 ., ///
|
||||
label("Name:") ///
|
||||
onclickon(main.vn_name.enable) ///
|
||||
onclickoff(main.vn_name.disable)
|
||||
VARNAME vn_name 100 150 210 ., ///
|
||||
label("Name Variable")
|
||||
CHECKBOX cb_year 20 170 70 ., ///
|
||||
label("Year:") ///
|
||||
onclickon(main.vn_year.enable) ///
|
||||
onclickoff(main.vn_year.disable)
|
||||
VARNAME vn_year 100 170 210 ., ///
|
||||
label("Year Variable")
|
||||
|
||||
/* end GROUPBOX gb_labels */
|
||||
|
||||
GROUPBOX gb_by 10 200 310 45, ///
|
||||
label("By Variable:")
|
||||
CHECKBOX cb_by 20 220 70 ., ///
|
||||
label(" By:") ///
|
||||
onclickon(script main_by_on) ///
|
||||
onclickoff(script main_by_off)
|
||||
VARLIST vl_by 100 220 210 ., ///
|
||||
label("By Variable") ///
|
||||
option("by")
|
||||
|
||||
/* end GROUPBOX gb_by */
|
||||
|
||||
GROUPBOX gb_sortby 10 250 310 45, ///
|
||||
label("Sort Data:")
|
||||
CHECKBOX cb_sortby 20 270 70 ., ///
|
||||
label(" By:") ///
|
||||
onclickon(main.vl_sortby.enable) ///
|
||||
onclickoff(main.vl_sortby.disable)
|
||||
VARLIST vl_sortby 100 270 210 ., ///
|
||||
label("Name Variable") ///
|
||||
option("sortby")
|
||||
|
||||
/* end GROUPBOX gb_sortby */
|
||||
|
||||
GROUPBOX gb_opts 325 5 120 85, ///
|
||||
label("General Options:")
|
||||
|
||||
CHECKBOX cb_nokeep 330 25 70 ., ///
|
||||
label("noKeep") ///
|
||||
option("nokeep")
|
||||
|
||||
CHECKBOX cb_ilevel 330 45 60 ., ///
|
||||
label("ilevel:") ///
|
||||
onclickon(main.ed_ilevel.enable) ///
|
||||
onclickoff(main.ed_ilevel.disable)
|
||||
EDIT ed_ilevel 400 45 40 ., ///
|
||||
label("ilevel") ///
|
||||
numonly default(global S_level) ///
|
||||
option("ilevel")
|
||||
|
||||
CHECKBOX cb_olevel 330 65 60 ., ///
|
||||
label("olevel:") ///
|
||||
onclickon(main.ed_olevel.enable) ///
|
||||
onclickoff(main.ed_olevel.disable)
|
||||
EDIT ed_olevel 400 65 40 ., ///
|
||||
label("olevel") ///
|
||||
numonly default(global S_level) ///
|
||||
option("olevel")
|
||||
|
||||
/* end GROUPBOX gb_opts */
|
||||
|
||||
FRAME fr_wgt 325 95 120 60
|
||||
CHECKBOX cb_wgt 330 100 110 ., ///
|
||||
label("Weight Var") ///
|
||||
onclickon(main.vn_wgt.enable) ///
|
||||
onclickoff(main.vn_wgt.disable)
|
||||
VARNAME vn_wgt 330 121 110 ., ///
|
||||
label("Weight Variable") ///
|
||||
option("wgt")
|
||||
|
||||
/* end wgt */
|
||||
|
||||
GROUPBOX gb_by_opts 325 200 120 61, ///
|
||||
label("By Options:")
|
||||
|
||||
CHECKBOX cb_nosubgroup 330 220 100 ., ///
|
||||
label("noSubGroup") ///
|
||||
option("nosubgroup")
|
||||
|
||||
CHECKBOX cb_sgweight 330 240 100 ., ///
|
||||
label("sgWeight") ///
|
||||
option("sgweight")
|
||||
|
||||
/* end GROUPBOX gb_by_opts */
|
||||
|
||||
END
|
||||
|
||||
DIALOG metan_b, tabtitle("Binary...")
|
||||
BEGIN
|
||||
GROUPBOX gb_pool 0 10 210 _ht9h, ///
|
||||
label("Pooling Model")
|
||||
RADIO r_fixed 10 30 190 ., ///
|
||||
label("Fixed, Mantel-Haenszel") first ///
|
||||
onclickoff(program metan_b_bd) ///
|
||||
option("fixed")
|
||||
RADIO r_fixedi @ _ss @ ., ///
|
||||
label("Fixed, Inverse Variance") middle ///
|
||||
onclickoff(program metan_b_bd) ///
|
||||
option("fixedi")
|
||||
RADIO r_random @ _ss 195 ., ///
|
||||
label("Random (M-H heterogeneity)") middle ///
|
||||
onclickon(script metan_b_random_on) ///
|
||||
onclickoff(program metan_b_chi2) ///
|
||||
option("random")
|
||||
RADIO r_randomi @ _ss @ ., ///
|
||||
label("Random (I-V heterogeneity)") middle ///
|
||||
onclickon(script metan_b_random_on) ///
|
||||
onclickoff(program metan_b_chi2) ///
|
||||
option("randomi")
|
||||
RADIO r_peto @ _ss @ ., ///
|
||||
label("Peto") last ///
|
||||
onclickon(script metan_b_peto_on) ///
|
||||
onclickoff(program metan_b_cornfield) ///
|
||||
option("peto")
|
||||
|
||||
GROUPBOX gb_stat 220 10 120 _ht5h, ///
|
||||
label("Statistic")
|
||||
RADIO r_rr 230 30 80 ., ///
|
||||
label("RR") first ///
|
||||
onclickon(script metan_b_rr_on) ///
|
||||
onclickoff(program metan_b_rr_off) ///
|
||||
option("rr")
|
||||
RADIO r_or @ _ss @ ., ///
|
||||
label("OR") middle ///
|
||||
onclickon(program metan_b_or_on) ///
|
||||
onclickoff(program metan_b_or_off) ///
|
||||
option("or")
|
||||
RADIO r_rd @ _ss @ ., ///
|
||||
label("RD") last ///
|
||||
option("rd")
|
||||
|
||||
CHECKBOX cb_cornfield 10 140 200 ., ///
|
||||
label("Use Cornfield CI's") ///
|
||||
option("cornfield")
|
||||
CHECKBOX cb_chi2 10 160 200 ., ///
|
||||
label("Use Chi-2 Statistic") ///
|
||||
option("chi2")
|
||||
CHECKBOX cb_breslow 10 180 200 ., ///
|
||||
label("Use Breslow-Day test") ///
|
||||
option("breslow")
|
||||
|
||||
CHECKBOX cb_log 230 100 200 ., ///
|
||||
label("Log scaled") ///
|
||||
option("log")
|
||||
|
||||
CHECKBOX cb_eform 230 120 200 ., ///
|
||||
label("Exponentiate") ///
|
||||
option("eform")
|
||||
|
||||
CHECKBOX cb_notable 230 140 200 ., ///
|
||||
label("noTable") ///
|
||||
option("notable")
|
||||
CHECKBOX cb_nograph 230 160 200 ., ///
|
||||
label("noGraph") ///
|
||||
option("nograph")
|
||||
|
||||
CHECKBOX cb_cc 10 260 150 ., ///
|
||||
label("Continuity Correction:") ///
|
||||
onclickon(metan_b.ed_cc.enable) ///
|
||||
onclickoff(metan_b.ed_cc.disable)
|
||||
EDIT ed_cc 160 260 65 ., ///
|
||||
label("Continuity Correction") ///
|
||||
option("cc")
|
||||
|
||||
CHECKBOX cb_nointeger 230 260 200 ., ///
|
||||
label("noInteger") ///
|
||||
option("nointeger")
|
||||
END
|
||||
|
||||
DIALOG metan_c, tabtitle("Continuous...")
|
||||
BEGIN
|
||||
GROUPBOX gb_pool 0 10 210 _ht3h, ///
|
||||
label("Pooling Model")
|
||||
RADIO r_fixed 10 30 190 ., ///
|
||||
label("Fixed, Inverse Variance") first ///
|
||||
option("fixed")
|
||||
RADIO r_random @ _ss @ ., ///
|
||||
label("Random (I-V heterogeneity)") last ///
|
||||
option("random")
|
||||
|
||||
GROUPBOX gb_stat 220 10 120 _ht7h, ///
|
||||
label("Statistic")
|
||||
RADIO r_cohen 230 30 100 ., ///
|
||||
label("Cohen") first ///
|
||||
option("cohen")
|
||||
RADIO r_hedges @ _ss @ ., ///
|
||||
label("Hedges") middle ///
|
||||
option("hedges")
|
||||
RADIO r_glass @ _ss @ ., ///
|
||||
label("Glass") middle ///
|
||||
option("glass")
|
||||
RADIO r_nostandard @ _ss @ ., ///
|
||||
label("noStandard") last ///
|
||||
option("nostandard")
|
||||
|
||||
CHECKBOX cb_notable 230 140 200 ., ///
|
||||
label("noTable") ///
|
||||
option("notable")
|
||||
CHECKBOX cb_nograph 230 160 200 ., ///
|
||||
label("noGraph") ///
|
||||
option("nograph")
|
||||
|
||||
CHECKBOX cb_nointeger 230 260 200 ., ///
|
||||
label("noInteger") ///
|
||||
option("nointeger")
|
||||
|
||||
END
|
||||
|
||||
DIALOG metan_e, tabtitle("Effect...")
|
||||
BEGIN
|
||||
GROUPBOX gb_pool 0 10 210 _ht3h, ///
|
||||
label("Pooling Model")
|
||||
RADIO r_fixed 10 30 190 ., ///
|
||||
label("Fixed, Inverse Variance") first ///
|
||||
option("fixed")
|
||||
RADIO r_random @ _ss @ ., ///
|
||||
label("Random (I-V heterogeneity)") last ///
|
||||
option("random")
|
||||
|
||||
CHECKBOX cb_notable 230 140 200 ., ///
|
||||
label("noTable") ///
|
||||
option("notable")
|
||||
CHECKBOX cb_nograph 230 160 200 ., ///
|
||||
label("noGraph") ///
|
||||
option("nograph")
|
||||
|
||||
CHECKBOX cb_effect 10 110 100 ., ///
|
||||
label("Effect Label:") ///
|
||||
onclickon(metan_e.ed_effect.enable) ///
|
||||
onclickoff(metan_e.ed_effect.disable)
|
||||
EDIT ed_effect 115 @ 225 ., ///
|
||||
label("effect label") ///
|
||||
option("effect")
|
||||
|
||||
END
|
||||
|
||||
DIALOG graph, tabtitle("Graph Opts")
|
||||
BEGIN
|
||||
|
||||
CHECKBOX cb_saving 10 10 100 ., ///
|
||||
label("Save graph:") ///
|
||||
onclickon(graph.fi_saving.enable) ///
|
||||
onclickoff(graph.fi_saving.disable)
|
||||
FILE fi_saving 110 10 240 ., ///
|
||||
label("File Name") ///
|
||||
error("Save filename") ///
|
||||
dialogtitle("Save graph") ///
|
||||
filter("Stata Graphs|*.gph") ///
|
||||
save ///
|
||||
option("saving")
|
||||
|
||||
/* end saving */
|
||||
|
||||
GROUPBOX gb_xlabel 10 40 330 _ht3h, ///
|
||||
label("X-axis Tick Labels (comma between):")
|
||||
|
||||
CHECKBOX cb_xlabel 15 60 45 ., ///
|
||||
label("Set:") ///
|
||||
onclickon(script graph_xlabel_on) ///
|
||||
onclickoff(script graph_xlabel_off)
|
||||
EDIT ed_xlabel 65 @ 270 ., ///
|
||||
label("X Tick labels") ///
|
||||
option("xlabel")
|
||||
|
||||
CHECKBOX cb_force 15 80 320 ., ///
|
||||
label("Force Scale to Tick Range") ///
|
||||
option("force")
|
||||
|
||||
/* end tick labels */
|
||||
|
||||
CHECKBOX cb_counts 15 115 65 ., ///
|
||||
label("Counts") ///
|
||||
onclickon(script graph_counts_on) ///
|
||||
onclickoff(script graph_counts_off) ///
|
||||
option("counts")
|
||||
|
||||
CHECKBOX cb_nowt 15 145 85 ., ///
|
||||
label("noWeights") ///
|
||||
option("nowt")
|
||||
|
||||
CHECKBOX cb_nostats 15 165 85 ., ///
|
||||
label("noStats") ///
|
||||
option("nostats")
|
||||
|
||||
CHECKBOX cb_nooverall 115 145 85 ., ///
|
||||
label("noOverall") ///
|
||||
option("nooverall")
|
||||
|
||||
CHECKBOX cb_nobox 115 165 85 ., ///
|
||||
label("noBox") ///
|
||||
option("nobox")
|
||||
|
||||
/* end switches */
|
||||
|
||||
CHECKBOX cb_legend 115 185 70 ., ///
|
||||
label("Legend:") ///
|
||||
onclickon(graph.ed_legend.enable) ///
|
||||
onclickoff(graph.ed_legend.disable)
|
||||
EDIT ed_legend 190 @ 55 ., ///
|
||||
label("legend") ///
|
||||
option("legend")
|
||||
|
||||
CHECKBOX cb_grp1 85 115 55 ., ///
|
||||
label("Grp 1:") ///
|
||||
onclickon(graph.ed_grp1.enable) ///
|
||||
onclickoff(graph.ed_grp1.disable)
|
||||
EDIT ed_grp1 145 @ 90 ., ///
|
||||
label("Grp1") ///
|
||||
option("group1")
|
||||
|
||||
CHECKBOX cb_grp2 245 115 55 ., ///
|
||||
label("Grp 2:") ///
|
||||
onclickon(graph.ed_grp2.enable) ///
|
||||
onclickoff(graph.ed_grp2.disable)
|
||||
EDIT ed_grp2 305 @ 90 ., ///
|
||||
label("Grp2") ///
|
||||
option("group2")
|
||||
|
||||
CHECKBOX cb_boxy 255 145 95 ., ///
|
||||
label("Box yscale:") ///
|
||||
onclickon(graph.ed_boxy.enable) ///
|
||||
onclickoff(graph.ed_boxy.disable)
|
||||
EDIT ed_boxy 355 @ 40 ., ///
|
||||
label("Box yscale") numonly default(1) ///
|
||||
option("boxsca")
|
||||
|
||||
CHECKBOX cb_boxs 255 165 95 ., ///
|
||||
label("Box shade:") ///
|
||||
onclickon(graph.ed_boxs.enable) ///
|
||||
onclickoff(graph.ed_boxs.disable)
|
||||
EDIT ed_boxs 355 @ 40 ., ///
|
||||
label("Box shading") numonly default(4) ///
|
||||
option("boxsha")
|
||||
|
||||
CHECKBOX cb_texts 255 185 95 ., ///
|
||||
label("Font scale:") ///
|
||||
onclickon(graph.ed_texts.enable) ///
|
||||
onclickoff(graph.ed_texts.disable)
|
||||
EDIT ed_texts 355 @ 40 ., ///
|
||||
label("Font scale") numonly default(1) ///
|
||||
option("texts")
|
||||
|
||||
/* end sets */
|
||||
|
||||
GROUPBOX gb_gopts7 10 205 390 _ht1h, ///
|
||||
label("Allowed Graph7 Options:")
|
||||
EDIT ed_gopts7 15 225 380 ., ///
|
||||
label("Graph7 Options")
|
||||
|
||||
CHECKBOX cb_b1 15 255 390 ., ///
|
||||
label("Effect Direction Labels, option b1( ):") ///
|
||||
onclickon(script graph_b1_on) ///
|
||||
onclickoff(script graph_b1_off)
|
||||
TEXT tx_b1_l 10 275 25 ., ///
|
||||
label("Left:")
|
||||
EDIT ed_b1_l 35 275 160 ., ///
|
||||
label(" Left")
|
||||
TEXT tx_b1_r 205 275 35 ., ///
|
||||
label("Right:")
|
||||
EDIT ed_b1_r 240 275 160 ., ///
|
||||
label("Right")
|
||||
|
||||
/* end Graph7 opts */
|
||||
|
||||
END
|
||||
|
||||
INCLUDE ifin
|
||||
|
||||
SCRIPT main_binary_on
|
||||
BEGIN
|
||||
main.tx_binary.show
|
||||
main.vl_binary.show
|
||||
main.tx_binary.enable
|
||||
main.vl_binary.enable
|
||||
|
||||
main.tx_effect_ci.disable
|
||||
main.vl_effect_ci.disable
|
||||
main.tx_effect_ci.hide
|
||||
main.vl_effect_ci.hide
|
||||
|
||||
main.tx_effect_se.disable
|
||||
main.vl_effect_se.disable
|
||||
main.tx_effect_se.hide
|
||||
main.vl_effect_se.hide
|
||||
|
||||
main.tx_contin_exp.disable
|
||||
main.vl_contin_exp.disable
|
||||
main.tx_contin_exp.hide
|
||||
main.vl_contin_exp.hide
|
||||
|
||||
main.tx_contin_ctl.disable
|
||||
main.vl_contin_ctl.disable
|
||||
main.tx_contin_ctl.hide
|
||||
main.vl_contin_ctl.hide
|
||||
|
||||
graph.cb_counts.enable
|
||||
END
|
||||
|
||||
SCRIPT main_binary_off
|
||||
BEGIN
|
||||
main.tx_binary.disable
|
||||
main.vl_binary.disable
|
||||
main.tx_binary.hide
|
||||
main.vl_binary.hide
|
||||
|
||||
graph.cb_counts.disable
|
||||
END
|
||||
|
||||
SCRIPT main_continuous_on
|
||||
BEGIN
|
||||
main.tx_contin_exp.show
|
||||
main.vl_contin_exp.show
|
||||
main.tx_contin_exp.enable
|
||||
main.vl_contin_exp.enable
|
||||
|
||||
main.tx_contin_ctl.show
|
||||
main.vl_contin_ctl.show
|
||||
main.tx_contin_ctl.enable
|
||||
main.vl_contin_ctl.enable
|
||||
|
||||
main.tx_binary.disable
|
||||
main.vl_binary.disable
|
||||
main.tx_binary.hide
|
||||
main.vl_binary.hide
|
||||
|
||||
main.tx_effect_ci.disable
|
||||
main.vl_effect_ci.disable
|
||||
main.tx_effect_ci.hide
|
||||
main.vl_effect_ci.hide
|
||||
|
||||
main.tx_effect_se.disable
|
||||
main.vl_effect_se.disable
|
||||
main.tx_effect_se.hide
|
||||
main.vl_effect_se.hide
|
||||
END
|
||||
|
||||
SCRIPT main_continuous_off
|
||||
BEGIN
|
||||
main.tx_contin_exp.disable
|
||||
main.vl_contin_exp.disable
|
||||
main.tx_contin_exp.hide
|
||||
main.vl_contin_exp.hide
|
||||
|
||||
main.tx_contin_ctl.disable
|
||||
main.vl_contin_ctl.disable
|
||||
main.tx_contin_ctl.hide
|
||||
main.vl_contin_ctl.hide
|
||||
END
|
||||
|
||||
SCRIPT main_effect_ci_on
|
||||
BEGIN
|
||||
main.tx_effect_ci.show
|
||||
main.vl_effect_ci.show
|
||||
main.tx_effect_ci.enable
|
||||
main.vl_effect_ci.enable
|
||||
|
||||
main.tx_effect_se.disable
|
||||
main.vl_effect_se.disable
|
||||
main.tx_effect_se.hide
|
||||
main.vl_effect_se.hide
|
||||
|
||||
main.tx_binary.disable
|
||||
main.vl_binary.disable
|
||||
main.tx_binary.hide
|
||||
main.vl_binary.hide
|
||||
|
||||
main.tx_contin_exp.disable
|
||||
main.vl_contin_exp.disable
|
||||
main.tx_contin_exp.hide
|
||||
main.vl_contin_exp.hide
|
||||
|
||||
main.tx_contin_ctl.disable
|
||||
main.vl_contin_ctl.disable
|
||||
main.tx_contin_ctl.hide
|
||||
main.vl_contin_ctl.hide
|
||||
END
|
||||
|
||||
SCRIPT main_effect_ci_off
|
||||
BEGIN
|
||||
main.tx_effect_ci.disable
|
||||
main.vl_effect_ci.disable
|
||||
main.tx_effect_ci.hide
|
||||
main.vl_effect_ci.hide
|
||||
END
|
||||
|
||||
SCRIPT main_effect_se_on
|
||||
BEGIN
|
||||
main.tx_effect_se.show
|
||||
main.vl_effect_se.show
|
||||
main.tx_effect_se.enable
|
||||
main.vl_effect_se.enable
|
||||
|
||||
main.tx_effect_ci.disable
|
||||
main.vl_effect_ci.disable
|
||||
main.tx_effect_ci.hide
|
||||
main.vl_effect_ci.hide
|
||||
|
||||
main.tx_binary.disable
|
||||
main.vl_binary.disable
|
||||
main.tx_binary.hide
|
||||
main.vl_binary.hide
|
||||
|
||||
main.tx_contin_exp.disable
|
||||
main.vl_contin_exp.disable
|
||||
main.tx_contin_exp.hide
|
||||
main.vl_contin_exp.hide
|
||||
|
||||
main.tx_contin_ctl.disable
|
||||
main.vl_contin_ctl.disable
|
||||
main.tx_contin_ctl.hide
|
||||
main.vl_contin_ctl.hide
|
||||
END
|
||||
|
||||
SCRIPT main_effect_se_off
|
||||
BEGIN
|
||||
main.tx_effect_se.disable
|
||||
main.vl_effect_se.disable
|
||||
main.tx_effect_se.hide
|
||||
main.vl_effect_se.hide
|
||||
END
|
||||
|
||||
SCRIPT main_by_on
|
||||
BEGIN
|
||||
main.vl_by.enable
|
||||
main.gb_by_opts.enable
|
||||
main.cb_nosubgroup.enable
|
||||
main.cb_sgweight.enable
|
||||
END
|
||||
|
||||
SCRIPT main_by_off
|
||||
BEGIN
|
||||
main.vl_by.disable
|
||||
main.gb_by_opts.disable
|
||||
main.cb_nosubgroup.disable
|
||||
main.cb_sgweight.disable
|
||||
END
|
||||
|
||||
SCRIPT metan_b_random_on
|
||||
BEGIN
|
||||
metan_b.cb_breslow.disable
|
||||
metan_b.cb_chi2.disable
|
||||
END
|
||||
|
||||
SCRIPT metan_b_peto_on
|
||||
BEGIN
|
||||
metan_b.cb_breslow.disable
|
||||
metan_b.cb_cornfield.disable
|
||||
END
|
||||
|
||||
PROGRAM metan_b_bd
|
||||
BEGIN
|
||||
if metan_b.r_or {
|
||||
call metan_b.cb_breslow.enable
|
||||
}
|
||||
END
|
||||
|
||||
PROGRAM metan_b_chi2
|
||||
BEGIN
|
||||
if metan_b.r_or & !(metan_b.r_random | metan_b.r_randomi) {
|
||||
call metan_b.cb_chi2.enable
|
||||
}
|
||||
END
|
||||
|
||||
PROGRAM metan_b_cornfield
|
||||
BEGIN
|
||||
if metan_b.r_or {
|
||||
call metan_b.cb_cornfield.enable
|
||||
}
|
||||
END
|
||||
|
||||
SCRIPT metan_b_rr_on
|
||||
BEGIN
|
||||
metan_b.cb_log.enable
|
||||
metan_b.cb_eform.enable
|
||||
END
|
||||
|
||||
PROGRAM metan_b_or_on
|
||||
BEGIN
|
||||
call metan_b.cb_log.enable
|
||||
call metan_b.cb_eform.enable
|
||||
call metan_b.r_peto.enable
|
||||
if !metan_b.r_peto {
|
||||
call metan_b.cb_cornfield.enable
|
||||
}
|
||||
if !(metan_b.r_random | metan_b.r_randomi) {
|
||||
call metan_b.cb_chi2.enable
|
||||
}
|
||||
call metan_b.cb_breslow.enable
|
||||
END
|
||||
|
||||
PROGRAM metan_b_or_off
|
||||
BEGIN
|
||||
if !metan_b.r_rr {
|
||||
call metan_b.cb_log.disable
|
||||
call metan_b.cb_eform.disable
|
||||
}
|
||||
call metan_b.r_peto.disable
|
||||
call metan_b.cb_cornfield.disable
|
||||
call metan_b.cb_chi2.disable
|
||||
call metan_b.cb_breslow.disable
|
||||
END
|
||||
|
||||
PROGRAM metan_b_rr_off
|
||||
BEGIN
|
||||
if !metan_b.r_or {
|
||||
call metan_b.cb_log.disable
|
||||
call metan_b.cb_eform.disable
|
||||
}
|
||||
END
|
||||
|
||||
SCRIPT graph_xlabel_on
|
||||
BEGIN
|
||||
graph.ed_xlabel.enable
|
||||
graph.cb_force.enable
|
||||
END
|
||||
|
||||
SCRIPT graph_xlabel_off
|
||||
BEGIN
|
||||
graph.ed_xlabel.disable
|
||||
graph.cb_force.disable
|
||||
END
|
||||
|
||||
SCRIPT graph_counts_on
|
||||
BEGIN
|
||||
graph.cb_grp1.enable
|
||||
graph.cb_grp2.enable
|
||||
END
|
||||
|
||||
SCRIPT graph_counts_off
|
||||
BEGIN
|
||||
graph.cb_grp1.disable
|
||||
graph.cb_grp2.disable
|
||||
graph.cb_grp1.setoff
|
||||
graph.cb_grp2.setoff
|
||||
graph.ed_grp1.disable
|
||||
graph.ed_grp2.disable
|
||||
END
|
||||
|
||||
SCRIPT graph_b1_on
|
||||
BEGIN
|
||||
graph.tx_b1_l.enable
|
||||
graph.ed_b1_l.enable
|
||||
graph.tx_b1_r.enable
|
||||
graph.ed_b1_r.enable
|
||||
END
|
||||
|
||||
SCRIPT graph_b1_off
|
||||
BEGIN
|
||||
graph.tx_b1_l.disable
|
||||
graph.ed_b1_l.disable
|
||||
graph.tx_b1_r.disable
|
||||
graph.ed_b1_r.disable
|
||||
END
|
||||
|
||||
|
||||
PROGRAM command
|
||||
BEGIN
|
||||
put " metan "
|
||||
if main.r_binary {
|
||||
varlist main.vl_binary
|
||||
}
|
||||
if main.r_continuous {
|
||||
varlist main.vl_contin_exp main.vl_contin_ctl
|
||||
}
|
||||
if main.r_effect_ci {
|
||||
varlist main.vl_effect_ci
|
||||
}
|
||||
if main.r_effect_se {
|
||||
varlist main.vl_effect_se
|
||||
}
|
||||
INCLUDE _ifin_pr
|
||||
beginoptions
|
||||
if main.cb_name | main.cb_year {
|
||||
put "label("
|
||||
if main.cb_name {
|
||||
put "namevar=" main.vn_name
|
||||
}
|
||||
if main.cb_name & main.cb_year {
|
||||
put ", "
|
||||
}
|
||||
if main.cb_year {
|
||||
put "yearvar=" main.vn_year
|
||||
}
|
||||
put ") "
|
||||
}
|
||||
optionarg main.vl_sortby
|
||||
optionarg main.vl_by
|
||||
optionarg main.ed_ilevel
|
||||
optionarg main.ed_olevel
|
||||
optionarg main.vn_wgt
|
||||
option main.cb_nokeep
|
||||
option main.cb_nosubgroup
|
||||
option main.cb_sgweight
|
||||
if main.r_binary {
|
||||
if !main.vn_wgt {
|
||||
option radio(metan_b r_fixed r_fixedi r_random r_randomi r_peto)
|
||||
}
|
||||
option radio(metan_b r_rr r_or r_rd)
|
||||
option metan_b.cb_cornfield
|
||||
option metan_b.cb_chi2
|
||||
option metan_b.cb_breslow
|
||||
option metan_b.cb_log
|
||||
option metan_b.cb_eform
|
||||
option metan_b.cb_nograph
|
||||
option metan_b.cb_notable
|
||||
optionarg metan_b.ed_cc
|
||||
option metan_b.cb_nointeger
|
||||
}
|
||||
if main.r_continuous {
|
||||
if !main.vn_wgt {
|
||||
option radio(metan_c r_fixed r_random)
|
||||
}
|
||||
option radio(metan_c r_cohen r_hedges r_glass r_nostandard)
|
||||
option metan_c.cb_nograph
|
||||
option metan_c.cb_notable
|
||||
option metan_c.cb_nointeger
|
||||
}
|
||||
if main.r_effect_se | main.r_effect_ci {
|
||||
if !main.vn_wgt {
|
||||
option radio(metan_e r_fixed r_random)
|
||||
}
|
||||
optionarg metan_e.ed_effect
|
||||
option metan_e.cb_nograph
|
||||
option metan_e.cb_notable
|
||||
}
|
||||
optionarg graph.fi_saving
|
||||
optionarg graph.ed_xlabel
|
||||
option graph.cb_force
|
||||
option graph.cb_counts
|
||||
option graph.cb_nowt
|
||||
option graph.cb_nostats
|
||||
option graph.cb_nooverall
|
||||
option graph.cb_nobox
|
||||
optionarg graph.ed_grp1
|
||||
optionarg graph.ed_grp2
|
||||
optionarg graph.ed_texts
|
||||
optionarg graph.ed_legend
|
||||
optionarg graph.ed_boxy
|
||||
optionarg graph.ed_boxs
|
||||
put graph.ed_gopts7 " "
|
||||
if graph.cb_b1 {
|
||||
put "b1(*I:" graph.ed_b1_l "*" graph.ed_b1_r ") "
|
||||
}
|
||||
endoptions
|
||||
END
|
919
Modules/ado/plus/m/metan.hlp
Normal file
919
Modules/ado/plus/m/metan.hlp
Normal file
@ -0,0 +1,919 @@
|
||||
{smcl}
|
||||
{* 7Jul2008}{...}
|
||||
{hline}
|
||||
help for {hi:metan}, {hi:labbe}
|
||||
{hline}
|
||||
|
||||
|
||||
{title:Fixed and random effects meta-analysis}
|
||||
|
||||
{p 8 12 2}
|
||||
{cmd:metan}
|
||||
{it:varlist}
|
||||
[{cmd:if} {it:exp}]
|
||||
[{cmd:in} {it:range}]
|
||||
[{it:weight}]
|
||||
[{cmd:,}
|
||||
{it:measure_and_model_options}
|
||||
{it:options_for_continuous_data}
|
||||
{it:output_options}
|
||||
{it:forest_plot_options}
|
||||
]
|
||||
|
||||
{p 12 12 2}
|
||||
where {it:measure_and_model_options} may be
|
||||
|
||||
{p 12 12 2}
|
||||
{cmd:or}
|
||||
{cmd:rr}
|
||||
{cmd:rd}
|
||||
{cmd:fixed}
|
||||
{cmd:random}
|
||||
{cmd:fixedi}
|
||||
{cmd:peto}
|
||||
{cmd:cornfield}
|
||||
{cmd:chi2}
|
||||
{cmd:breslow}
|
||||
{cmdab:noint:eger}
|
||||
{cmd:cc(}{it:#}{cmd:)}
|
||||
{cmd:wgt(}{it:weightvar}{cmd:)}
|
||||
{cmd:second(}{it:model} or {it:estimates and description}{cmd:)}
|
||||
{cmd:first(}{it:estimates and description}{cmd:)}
|
||||
|
||||
{p 12 12 2}
|
||||
and where {it:options_for_continuous_data} may be
|
||||
|
||||
{p 12 12 2}
|
||||
{cmd:cohen}
|
||||
{cmd:hedges}
|
||||
{cmd:glass}
|
||||
{cmd:nostandard}
|
||||
{cmd:fixed}
|
||||
{cmd:random}
|
||||
|
||||
{p 12 12 2}
|
||||
and where {it:output_options} may be
|
||||
|
||||
{p 12 12 2}
|
||||
{cmd:by(}{it:byvar}{cmd:)}
|
||||
{cmd:nosubgroup}
|
||||
{cmd:sgweight}
|
||||
{cmd:log}
|
||||
{cmd:eform}
|
||||
{cmd:efficacy}
|
||||
{cmdab:il:evel(}{it:#}{cmd:)}
|
||||
{cmdab:ol:evel(}{it:#}{cmd:)}
|
||||
{cmd:sortby(}{it:varlist}{cmd:)}
|
||||
{cmd:label(}{it:namevar yearvar}{cmd:)}
|
||||
{cmd:nokeep}
|
||||
{cmd:notable}
|
||||
{cmd:nograph}
|
||||
{cmd:nosecsub}
|
||||
|
||||
{p 12 12 2}
|
||||
and where {it:forest_plot_options} may be
|
||||
|
||||
{p 12 12 2}
|
||||
{cmd:legend(}{it:string}{cmd:)}
|
||||
{cmdab:xla:bel(}{it:#},...{cmd:)}
|
||||
{cmdab:xt:ick(}{it:#},...{cmd:)}
|
||||
{cmd:boxsca(}{it:#}{cmd:)}
|
||||
{cmd:nobox}
|
||||
{cmd:nooverall}
|
||||
{cmd:nowt}
|
||||
{cmd:nostats}
|
||||
{cmd:group1(}{it:string}{cmd:)}
|
||||
{cmd:group2(}{it:string}{cmd:)}
|
||||
{cmd:effect(}{it:string}{cmd:)}
|
||||
{cmd:force}
|
||||
|
||||
{p 12 12 2}
|
||||
...with further {it:forest_plot_options} in the version 9 update
|
||||
|
||||
{p 12 12 2}
|
||||
{cmd:lcols(}{it:varlist}{cmd:)}
|
||||
{cmd:rcols(}{it:varlist}{cmd:)}
|
||||
{cmd:astext(}{it:#}{cmd:)}
|
||||
{cmd:double}
|
||||
{cmd:nohet}
|
||||
{cmd:summaryonly}
|
||||
{cmd:rfdist}
|
||||
{cmdab:rfl:evel(}{it:#}{cmd:)}
|
||||
{cmd:null(}{it:#}{cmd:)}
|
||||
{cmd:nulloff}
|
||||
{cmd:favours(}{it:string} # {it:string}{cmd:)}
|
||||
{cmd:firststats(}{it:string}{cmd:)}
|
||||
{cmd:secondstats(}{it:string}{cmd:)}
|
||||
{cmd:boxopt(}{it:}{cmd:)}
|
||||
{cmd:diamopt(}{it:}{cmd:)}
|
||||
{cmd:pointopt(}{it:}{cmd:)}
|
||||
{cmd:ciopt(}{it:}{cmd:)}
|
||||
{cmd:olineopt(}{it:}{cmd:)}
|
||||
{cmd:classic}
|
||||
{cmd:nowarning}
|
||||
{cmd:dp(}{it:#}{cmd:)}
|
||||
{it:graph_options}
|
||||
|
||||
|
||||
{p 8 12 2}
|
||||
{cmd:labbe}
|
||||
{it:varlist}
|
||||
[{cmd:if} {it:exp}]
|
||||
[{cmd:in} {it:range}]
|
||||
[{it:weight}]
|
||||
[{cmd:,}
|
||||
{cmd:nowt}
|
||||
{cmdab:per:cent}
|
||||
{cmd:or(}{it:#}{cmd:)}
|
||||
{cmd:rr(}{it:#}{cmd:)}
|
||||
{cmd:rd(}{it:#}{cmd:)}
|
||||
{cmd:null}
|
||||
{cmd:logit}
|
||||
{cmd:wgt(}{it:weightvar}{cmd:)}
|
||||
{cmd:symbol(}{it:symbolstyle}{cmd:)}
|
||||
{cmd:nolegend}
|
||||
{cmd:id(}{it:idvar}{cmd:)}
|
||||
{cmd:textsize(}{it:#}{cmd:)}
|
||||
{cmd:clockvar(}{it:clockvar}{cmd:)}
|
||||
{cmd:gap(}{it:#}{cmd:)}
|
||||
{it:graph_options}
|
||||
|
||||
|
||||
{title:Description}
|
||||
|
||||
{p 4 4 2}
|
||||
These routines provide facilities to conduct meta-analyses of data from
|
||||
more than one study and to graph the results. Either binary (event) or
|
||||
continuous data from two groups may be combined using the {cmd:metan}
|
||||
command. Additionally, intervention effect estimates with corresponding
|
||||
standard errors or confidence intervals may be meta-analysed. Several
|
||||
meta-analytic methods are available, and the results may be displayed
|
||||
graphically in a Forest plot. A test of whether
|
||||
the summary effect measure is equal to the null is given,
|
||||
as well as a test for heterogeneity, i.e., whether the true effect in all
|
||||
studies is the same. Heterogeneity is also quantified using the I-squared
|
||||
measure (Higgins et al 2003).
|
||||
|
||||
{p 4 4 2}
|
||||
{cmd:metan} (the main meta-analysis routine) requires either two, three, four
|
||||
or six variables to be declared. When four variables are specified
|
||||
these correspond to the number of events and non-events in the experimental group
|
||||
followed by those of the control group, and
|
||||
analysis of binary data is performed on the 2x2 table.
|
||||
With six variables, the data are assumed
|
||||
continuous and to be the sample size, mean and standard deviation of
|
||||
the experimental group followed by those of the control group.
|
||||
If three variables are specified these are assumed to be the effect estimate and
|
||||
its lower and upper confidence interval, and it is suggested that these are
|
||||
log transformed for odds ratios or risk ratios and the {cmd: eform} option used.
|
||||
If two variables are specified these are assumed to be the effect estimate and standard
|
||||
error; again, it is recommended that odds ratios or risk ratios are log transformed.
|
||||
|
||||
{p 4 4 2}
|
||||
{cmd:labbe} draws a L'Abbe plot for event data (proportion of successes in the
|
||||
two groups). This is an alternative to the graph produced by {cmd:metan}.
|
||||
|
||||
{p 4 4 2}
|
||||
{cmd:funnel} may be used for producing a "funnel plot", a graph of either the
|
||||
study sample size, standard error or precision (inverse of s.e.) against
|
||||
the effect size.
|
||||
|
||||
{p 4 4 2}
|
||||
Note that the {cmd:metan} command now requires
|
||||
Stata version 9 and has been updated
|
||||
with several new options. Changes are mainly to graphics options which
|
||||
are collected in the section {it: Further options in the v9 update for metan: Forest plot},
|
||||
or otherwise marked {it:v9 update}. The previous version is still available under
|
||||
the name -metan7-
|
||||
|
||||
|
||||
{title:Remarks on funnel (discontinued)}
|
||||
|
||||
{p 4 4 2}
|
||||
The {cmd:metafunnel} command has more options for
|
||||
funnel plots and version 8 graphics; as such {cmd:funnel} has been removed.
|
||||
See {help metafunnel} (if installed)
|
||||
|
||||
|
||||
|
||||
{title:Options for metan}
|
||||
|
||||
{dlgtab:Specifying the measure and model}
|
||||
|
||||
{p 4 4 2}
|
||||
These options apply to binary data.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:rr} pools risk ratios (the default).
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:or} pools odds ratios.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:rd} pools risk differences.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:fixed} specifies a fixed effect model using the method of
|
||||
Mantel and Haenszel (the default).
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:fixedi} specifies a fixed effect model using the inverse variance method.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:peto} specifies that Peto's method is used to pool odds ratios.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:random} specifies a random effects model using the method of
|
||||
DerSimonian & Laird.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:cornfield} computes confidence intervals for odds ratios by method of
|
||||
Cornfield, rather than the (default) Woolf method.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:chi2} displays chi-squared statistic (instead of z) for the test
|
||||
of significance of the pooled effect size. This is available only for
|
||||
odds ratios pooled using Peto or Mantel-Haenszel methods.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:breslow} produces Breslow-Day test for homogeneity of ORs.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:cc(}{it:#}{cmd:)} defines a fixed continuity correction to add in the case where
|
||||
a study contains a zero cell. By default, {cmd:metan}
|
||||
adds 0.5 to each cell of a trial where a zero is encountered when
|
||||
using Inverse-Variance, Der-Simonian & Laird or Mantel-Haenszel
|
||||
weighting to enable finite variance estimators to be derived.
|
||||
However, the {cmd:cc()} option allows the use of other constants
|
||||
(including none). See also the {cmd:nointeger} option.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:nointeger} allows the cell counts to be non-integers. This may be useful
|
||||
when a variable continuity correction is sought for studies containing
|
||||
zero cells, but also may be used in other circumstances, such as where a
|
||||
cluster-randomised trial is to be incorporated and the "effective sample
|
||||
size" is less than the total number of observations.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:wgt(}{it:weightvar}{cmd:)} specifies alternative weighting
|
||||
for any data type. The effect size is to be computed by assigning
|
||||
a weight of {it:weightvar} to the studies. When RRs or ORs are declared,
|
||||
their logarithms are weighted. You should only use this option if you are
|
||||
satisfied that the weights are meaningful.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:second(}{it:model} or {it:estimates and description}{cmd:)} ({it:v9 update})
|
||||
A second analysis may be performed using another method, using {cmd:fixed},
|
||||
{cmd:random} or {cmd:peto}. Alternatively, the user may define their own
|
||||
estimate and 95% CI based on calculations performed externally to {cmd:metan},
|
||||
along with a description of their method, in the format
|
||||
{it: es lci uci description}. The results of this analysis are then displayed
|
||||
in the table and forest plot. Note that if {cmd:by} is used then sub-estimates
|
||||
from the second method are not displayed with user defined estimates, for
|
||||
obvious reasons.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:first(}{it:estimates and description}{cmd:)} ({it:v9 update})
|
||||
Use of this command completely changes the way {cmd:metan} operates, as results
|
||||
are no longer based on any standard methods. The user defines their own
|
||||
estimate, 95% CI and description as in the above, and must supply their own
|
||||
weightings using {cmd:wgt(}{it:weightvar}{cmd:)} to control display of box sizes. Note
|
||||
that data must be supplied in the 2 or 3 variable syntax
|
||||
({it:theta se_theta} or {it:es lci uci}) and
|
||||
{cmd:by} may not be used used for obvious reasons.
|
||||
|
||||
{dlgtab:Continuous data}
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:cohen} pools standardised mean differences by the method of Cohen
|
||||
(the default).
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:hedges} pools standardised mean differences by the method of Hedges.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:glass} pools standardised mean differences by the method of Glass.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:nostandard} pools unstandardised mean differences.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:fixed} specifies a fixed effect model using the inverse variance method
|
||||
(the default).
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:random} specifies a random effects model using the DerSimonian & Laird
|
||||
method.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:nointeger} denotes that the number of observations in each arm does not
|
||||
need to be an integer. By default, the first and fourth variables specified
|
||||
(containing N_intervention and N_control respectively) may occasionally be
|
||||
non-integer (see entry for {cmd:nointeger} under binary data).
|
||||
|
||||
{dlgtab:Output}
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:by()} specifies that the meta-analysis is to be stratified
|
||||
according to the variable declared.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:sgweight} specifies that the display is to present the percentage
|
||||
weights within each subgroup separately. By default {cmd:metan} presents
|
||||
weights as a percentage of the overall total.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:log} reports the results on the log scale
|
||||
(valid for OR and RR analyses from raw data counts only).
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:nosubgroup} indicates that no within-group results are to be
|
||||
presented. By default {cmd:metan} pools trials both within and across
|
||||
all studies.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:eform} exponentiates all effect sizes and confidence intervals
|
||||
(valid only when the input variables are log odds ratios or log
|
||||
hazard ratios with standard error or confidence intervals).
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:efficacy} expresses results as the vaccine efficacy (the proportion
|
||||
of cases that would have been prevented in the placebo group that
|
||||
would have been prevented had they received the vaccination).
|
||||
Only available with odds ratios (OR) or risk ratios (RR).
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:ilevel(}{it:#}{cmd:)} specifies the coverage (eg 90,95,99 percent) for the
|
||||
individual trial confidence intervals. Default: {cmd:$S_level}.
|
||||
{cmd:ilevel()} and {cmd:olevel()} need not be the same. See {help set level}.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:olevel(}{it:#}{cmd:)} specifies the coverage (eg 90,95,99 percent) for the
|
||||
overall (pooled) trial confidence intervals. Default: {cmd:$S_level}.
|
||||
{cmd:ilevel()} and {cmd:olevel()} need not be the same. See {help set level}.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:sortby(}{it:varlist}{cmd:)} sorts by variable(s) in {it:varlist}
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:label([namevar=}{it:namevar}{cmd:], [yearvar=}{it:yearvar}{cmd:])}
|
||||
labels the data by its name, year or both. Either or both option/s
|
||||
may be left blank. For the table display the overall length of the
|
||||
label is restricted to 20 characters. The option {cmd:lcols()} will
|
||||
override this if invoked.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:nokeep} prevents the retention of study parameters in permanent
|
||||
variables (see saved results below).
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:notable} prevents display of table of results.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:nograph} prevents display of graph.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:nosecsub} ({it:v9 update}) prevents the display of sub-estimates
|
||||
using the second method if {cmd:second()}
|
||||
is used. Note that this is invoked automatically with user-defined
|
||||
estimates.
|
||||
|
||||
{dlgtab:Forest plot}
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:effect()} may be used when the effect size and its standard error
|
||||
are declared. This allows the graph to name the summary statistic used.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:nooverall} revents display of overall effect size on graph
|
||||
(automatically enforces the {cmd:nowt} option).
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:nowt} prevents display of study weight on the graph.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:nostats} prevents display of study statistics on graph.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:counts} ({it:v9 update}) displays data counts (n/N) for each group when using
|
||||
binary data, or the sample size, mean and SD for each group if mean
|
||||
differences are used (the latter is a new feature).
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:group1(}{it:string}{cmd:)}, {cmd:group2(}{it:string}{cmd:)} may be
|
||||
used with the {cmd:counts} option: the text should contain the
|
||||
names of the two groups.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:xlabel()} ({it:v9 update}) defines x-axis labels. This has been modified
|
||||
so that any number of points may defined. Also, there are no
|
||||
longer any checks made as to whether these points are sensible, so the
|
||||
user may define anything if the {cmd:force} option is used. Points must
|
||||
be comma separated.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:xtick()} adds tick marks to the x-axis. Points must
|
||||
be comma separated.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:force} forces the x-axis scale to be in the range specified
|
||||
by {cmd:xlabel()}.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:boxsca()} ({it:v9 update}) controls box scaling.
|
||||
This has been modified slightly so that the default is 100 (as in a
|
||||
percentage) and may be increased or decreased as such (e.g., 80 or 120 for
|
||||
20% smaller or larger respectively)
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:nobox} prevents a "weighted box" being drawn for each study
|
||||
and markers for point estimates only are shown.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:texts()} ({it:v9 update}) specifies font size for text display on graph.
|
||||
This has been modified slightly so that the default is 100 (as in a
|
||||
percentage) and may be increased or decreased as such (e.g., 80 or 120 for
|
||||
20% smaller or larger respectively)
|
||||
|
||||
{dlgtab:Further options for the forest plot in the v9 update}
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:lcols(}{it:varlist}{cmd:)}, {cmd:rcols(}{it:varlist}{cmd:)}
|
||||
define columns of additional data to
|
||||
the left or right of the graph. The first two columns on the right are
|
||||
automatically set to effect size and weight, unless suppressed using
|
||||
the options {cmd:nostats} and {cmd:nowt}. If {cmd:counts} is used this
|
||||
will be set as the third column. {cmd:textsize()} can be used to fine-tune
|
||||
the size of the text in order to acheive a satisfactory appearance.
|
||||
The columns are labelled with the variable label, or the variable name
|
||||
if this is not defined. The first variable specified in {cmd:lcols()} is assumed to be
|
||||
the study identifier and this is used in the table output.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:astext(}{it:#}{cmd:)}
|
||||
specifies the percentage of the graph to be taken up by text.
|
||||
The default is 50 and the percentage must be in the range 10-90.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:double}
|
||||
allows variables specified in {cmd:lcols} and {cmd:rcols} to run over two
|
||||
lines in the plot. This may be of use if long strings are to be used.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:nohet}
|
||||
prevents display of heterogeneity statistics in the graph.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:summaryonly}
|
||||
shows only summary estimates in the graph (may be of use for multiple
|
||||
subgroup analyses)
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:rfdist}
|
||||
displays the confidence interval of the approximate predictive
|
||||
distribution of a future trial, based on the extent of heterogeneity.
|
||||
This incorporates uncertainty in the location and spread of the random
|
||||
effects distribution using the formula {cmd: t(df) x sqrt(se2 + tau2)}
|
||||
where t is the t-distribution with k-2 degrees of freedom, se2 is the
|
||||
squared standard error and tau2 the heterogeneity statistic.
|
||||
The CI is then displayed with lines extending from the diamond. Note that
|
||||
with <3 studies the distribution is inestimable and effectively infinite, thus
|
||||
displayed with dotted lines, and where heterogeneity is zero there is still
|
||||
a slight extension as the t-statistic is always greater than the corresponding
|
||||
normal deviate. For further information see Higgins JPT, Thompson SG (2006)
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:rflevel(}{it:#}{cmd:)} specifies the coverage (eg 90,95,99 percent) for the
|
||||
confidence interval of the predictive distribution. Default: {cmd:$S_level}.
|
||||
See {help set level}.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:null(}{it:#}{cmd:)}
|
||||
displays the null line at a user-defined value rather than 0 or 1.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:nulloff}
|
||||
removes the null hypothesis line from the graph
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:favours(}{it:string} # {it:string}{cmd:)}
|
||||
applies a label saying something about the treatment effect to either
|
||||
side of the graph (strings are separated by the # symbol). This replaces
|
||||
the feature available in {cmd:b1title} in the previous version of metan.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:firststats(}{it:string}{cmd:)}, {cmd:secondstats(}{it:string}{cmd:)}
|
||||
labels overall user-defined estimates when these have been specified.
|
||||
Labels are displayed in the position usually given to the heterogeneity
|
||||
statistics.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:boxopt()}, {cmd:diamopt()}, {cmd:pointopt()}, {cmd:ciopt()}, {cmd:olineopt()}
|
||||
specify options for the graph routines within the program, allowing the
|
||||
user to alter the appearance of the graph. Any options associated with a
|
||||
particular graph command may be used, except some that would cause incorrect
|
||||
graph appearance. For example, diamonds are plotted using the {help twoway pcspike}
|
||||
command, so options for line styles are available (see {help line options});
|
||||
however, altering the x-y
|
||||
orientation with the option {cmd:horizontal} or {cmd:vertical} is not
|
||||
allowed. So, {cmd:diamopt(lcolor(green) lwidth(thick))} feeds into a command
|
||||
such as {cmd:pcspike(y1 x1 y2 x2, lcolor(green) lwidth(thick))}
|
||||
|
||||
{p 8 8 2}
|
||||
{cmd:boxopt()} controls the boxes and uses options for a weighted marker
|
||||
(e.g., shape, colour; but not size). See {help marker options}
|
||||
|
||||
{p 8 8 2}
|
||||
{cmd:diamopt()} controls the diamonds and uses options for pcspike (not horizontal/vertical).
|
||||
See {help line options}
|
||||
|
||||
{p 8 8 2}
|
||||
{cmd:pointopt()} controls the point estimate using marker options.
|
||||
See {help marker options} and {help marker label options}
|
||||
|
||||
{p 8 8 2}
|
||||
{cmd:ciopt()} controls the confidence intervals for studies using options
|
||||
for pcspike (not horizontal/vertical). See {help line options}
|
||||
|
||||
{p 8 8 2}
|
||||
{cmd:olineopt()} controls the overall effect line with options for an additional
|
||||
line (not position). See {help line options}
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:classic} specifies that solid black boxes without point estimate markers are used as
|
||||
in the previous version of metan.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:nowarning} switches off the default display of a note warning that studies are
|
||||
weighted from random effects anaylses.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:dp(}{it:#}{cmd:)} sets the number of decimal places that effect estimates are displayed with
|
||||
(default is 2).
|
||||
|
||||
{p 4 8 2}
|
||||
{it:graph_options}
|
||||
specifies overall graph options that would appear at the end of a {cmd:twoway}
|
||||
graph command. This allows the addition of titles, subtitles, captions etc.,
|
||||
control of margins, plot regions, graph size, aspect ratio and the use of schemes.
|
||||
As titles may be added in this way previous options {cmd:b2title} etc. are no
|
||||
longer necessary. See {search graph options}
|
||||
|
||||
|
||||
{title:Options for labbe}
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:nowt} declares that the plotted data points are to be the same size.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:percent} displays the event rates as percentages rather than proportions.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:null} draws a line corresponding to a null effect (ie p1=p2).
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:or(}{it:#}{cmd:)} draws a line corresponding to a fixed odds ratio of
|
||||
{it:#}.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:rd(}{it:#}{cmd:)} draws a line corresponding to a fixed risk difference of
|
||||
{it:#}.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:rr(}{it:#}{cmd:)} draws a line corresponding to a fixed risk ratio
|
||||
of {it:#}. See also the {cmd:rrn()} option.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:rrn(}{it:#}{cmd:)} draws a line corresponding to a fixed risk ratio
|
||||
(for the non-event) of {it:#}.
|
||||
The {cmd:rr()} and {cmd:rrn()} options may require explanation.
|
||||
Whereas the OR and RD are invariant to the definition of which of
|
||||
the binary outcomes is the "event" and which is the "non-event",
|
||||
the RR is not. That is, while the command {cmd:metan a b c d , or}
|
||||
gives the same result as {cmd:metan b a d c , or} (with direction
|
||||
changed), an RR analysis does not. The L'Abbe plot allows the display
|
||||
of either or both to be superimposed risk difference.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:logit} is for use with the {cmd:or()} option; it displays the
|
||||
probabilities on the logit scale ie log(p/1-p). On the logit scale the
|
||||
odds ratio is a linear effect, and so this makes it easier to assess the
|
||||
"fit" of the line.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:wgt(}{it:weightvar}{cmd:)} specifies alternative weighting by the specified variable
|
||||
(default is sample size).
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:symbol(}{it:symbolstyle}{cmd:)} allows the symbol to be changed (see help {help symbolstyle}) the
|
||||
default being hollow circles (or points if weights are not used).
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:nolegend} suppresses a legend being displayed (the default if more than one
|
||||
line corresponding to effect measures are specified).
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:id(}{it:idvar}{cmd:)} displays marker labels with the specified ID variable {it:idvar}.
|
||||
{cmd:clockvar()} and {cmd:gap()} may be used to fine-tune the display, which may become
|
||||
unreadable if studies are clustered together in the graph.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:textsize(}{it:#}{cmd:)} increases or decreases the text size of the id label by specifying
|
||||
{it:#} to be more or less than unity. The default is usually satisfactory, but may need to be adjusted.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:clockvar(}{it:clockvar}{cmd:)} specifies the position of {it:idvar} around the
|
||||
study point, as if it were a clock face (values must be integers- see {help clockposstyle}).
|
||||
This may be used to organise labels where studies are clustered together. By default, labels are positioned
|
||||
to the left (9 o'clock) if above the null and to the right (3 o'clock) if below. Missing values
|
||||
in {it:clockvar} will be assigned the default position, so this need not be specified for all observations.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:gap(}{it:#}{cmd:)} increases or decreases the gap between the study marker and the id label by specifying
|
||||
{it:#} to be more or less than unity. The default is usually satisfactory, but may need to be adjusted.
|
||||
|
||||
{p 4 8 2}
|
||||
{it:graph_options} are options for Stata 8 graphs (see help on {help graph}).
|
||||
|
||||
|
||||
{title:Remarks on metan}
|
||||
|
||||
{p 4 4 2}
|
||||
For two or three variables, a variance-weighted analysis is performed in
|
||||
a similar fashion to the {help meta} command; the two variable syntax
|
||||
is {it:theta} and {it:SE(theta)}. The 3 variable syntax is {it:theta},
|
||||
{it:lower ci (theta)}, {it:upper ci (theta)}. Note that in this situation
|
||||
"{it:theta}" is taken to be the logarithm of the effect size if the odds
|
||||
ratio or risk ratio is used. {hi:This differs from the equivalent in the {cmd:meta} command}.
|
||||
This program does not assume the three variables need log transformation:
|
||||
if odds ratios or risk ratios are combined, it is up to the user to
|
||||
log-transform them first. The {cmd:eform} option may be used to change
|
||||
back to the original scale if needed. By default the confidence
|
||||
intervals are assumed symmetric, and the studies are pooled by taking
|
||||
the variance to be equal to (CI width)/2z.
|
||||
|
||||
{p 4 4 2}
|
||||
Note that for graphs on the log scale (that is, ORs or RRs), values
|
||||
outside the range [10e-8,10e8] are not displayed, and similarly graphs of
|
||||
other measures (log ORs, RDs, SMDs) are restricted to the range [-10e8,10e8].
|
||||
A confidence interval which extends beyond this, or the specified scale
|
||||
if {cmd:force} is used, will have an arrow added at the end of the range.
|
||||
|
||||
{p 4 4 2}
|
||||
{hi: Further notes on v9 update:} If {cmd:by} is used with a string variable the
|
||||
stratification variable is not sorted alpha-numerically and the original
|
||||
order that the groups appear in the data is preserved. This may be of use if
|
||||
a particular display order is required; if not, {cmd:sortby} may be used.
|
||||
The option {cmd:counts} is now available for continuous data and displays
|
||||
sample size, mean and SD in each group. The estimate for heterogeneity between
|
||||
groups from a stratified analysis using the Mantel-Haenszel method, and
|
||||
arguably the Peto method, is invalid. Therefore this is not displayed in the
|
||||
output for either of these methods.
|
||||
|
||||
{p 4 4 2}
|
||||
Note that there is a small add-on program to calculate the confidence interval for
|
||||
the I-squared statistic- type {cmd:i2ci} after running metan. This uses the method
|
||||
described by Higgins & Thompson (2002), Appendix A2.
|
||||
|
||||
|
||||
{title:Remarks on labbe}
|
||||
|
||||
{p 4 4 2}
|
||||
By default the size of the plotting symbol is proportional to the sample
|
||||
size of the study. If weights are specified the plotting size will be
|
||||
proportional to the weight variable. Note that {cmd:labbe} has now been updated to version 8 graphics.
|
||||
All options work the same as in the previous version, and some minor graphics options have been added.
|
||||
|
||||
|
||||
|
||||
{title:Stored}
|
||||
|
||||
By default, {cmd:metan} adds the following new variables to the data set:
|
||||
|
||||
_ES Effect size (ES)
|
||||
_seES Standard error of ES
|
||||
or, when OR or RR are specfied:
|
||||
_selogES the standard error of its logarithm
|
||||
_LCI Lower confidence limit for ES
|
||||
_UCI Upper confidence limit for ES
|
||||
_WT Study percentage weight
|
||||
_SS Study sample size
|
||||
|
||||
|
||||
{title:Examples}
|
||||
|
||||
{p 4 8 2}
|
||||
All examples use a simulated example dataset (Ross Harris 2006)
|
||||
|
||||
{p 8 12 2}
|
||||
{stata "use http://fmwww.bc.edu/repec/bocode/m/metan_example_data":. use http://fmwww.bc.edu/repec/bocode/m/metan_example_data}
|
||||
|
||||
{p 4 8 2}
|
||||
Risk difference from raw cell counts, random effects model, "label" specification with counts displayed
|
||||
|
||||
{p 8 12 2}
|
||||
{cmd:. metan tdeath tnodeath cdeath cnodeath, }
|
||||
{p_end}
|
||||
{p 12 12 2}
|
||||
{cmd:rd random label(namevar=id, yearid=year) counts}
|
||||
{p_end}
|
||||
{p 12 12 2}
|
||||
{it:({stata "metan_examples metan_example_basic":click to run})}
|
||||
|
||||
{p 4 8 2}
|
||||
Sort by year, use data columns syntax. Text size increased, specify percentage of graph as text and
|
||||
two lines per study; suppress stats, weight, heterogeneity stats and table.
|
||||
|
||||
|
||||
{p 8 12 2}
|
||||
{cmd:. metan tdeath tnodeath cdeath cnodeath, }
|
||||
{p_end}
|
||||
{p 12 12 2}
|
||||
{cmd:sortby(year) lcols(id year country) rcols (population) }
|
||||
{p_end}
|
||||
{p 12 12 2}
|
||||
{cmd:textsize(110) astext(60) double nostats nowt nohet notable}
|
||||
{p_end}
|
||||
{p 12 12 2}
|
||||
{it:({stata "metan_examples metan_example_cols":click to run})}
|
||||
|
||||
{p 4 8 2}
|
||||
Analyse continuous data (6 parameter syntax), stratify by type of study, with weights summing to 100 within sub group,
|
||||
second analysis specified, display random effects distribution, show raw data counts, display
|
||||
"favours treatment vs. favours control" labels
|
||||
|
||||
{p 8 12 2}
|
||||
{cmd:. metan tsample tmean tsd csample cmean csd, }
|
||||
{p_end}
|
||||
{p 12 12 2}
|
||||
{cmd:by(type_study) sgweight fixed second(random) rfdist }
|
||||
{p_end}
|
||||
{p 12 12 2}
|
||||
{cmd:counts label(namevar = id) }
|
||||
{p_end}
|
||||
{p 12 12 2}
|
||||
{cmd:favours(Treatment reduces blood pressure # Treatment increases blood pressure)}
|
||||
{p_end}
|
||||
{p 12 12 2}
|
||||
{it:({stata "metan_examples metan_example_by":click to run})}
|
||||
|
||||
{p 4 8 2}
|
||||
Generate log odds ratio and standard error, analyse with 2 parameter syntax. Graph has exponential form,
|
||||
scale is forced within set limits and ticks added, effect label specified.
|
||||
|
||||
{p 8 12 2}
|
||||
{cmd:. gen logor = ln( (tdeath*cnodeath)/(tnodeath*cdeath) )}
|
||||
|
||||
{p 8 12 2}
|
||||
{cmd:. gen selogor = sqrt( (1/tdeath) + (1/tnodeath) + (1/cdeath) + (1/cnodeath) )}
|
||||
|
||||
{p 8 12 2}
|
||||
{cmd:. metan logor selogor, eform xlabel(0.5, 1, 1.5, 2, 2.5) }
|
||||
{p_end}
|
||||
{p 12 12 2}
|
||||
{cmd:force xtick(0.75, 1.25, 1.75, 2.25) effect(Odds ratio)}
|
||||
{p_end}
|
||||
{p 12 12 2}
|
||||
{it:({stata "metan_examples metan_example_2param":click to run})}
|
||||
|
||||
{p 4 8 2}
|
||||
Display diagnostic test data with 3 parameter syntax. Weight is number of positive diagnoses, axis label set
|
||||
and null specified at 50%. Overall effect estimate is not displayed, graph for visual examination only.
|
||||
|
||||
{p 8 12 2}
|
||||
{cmd:. metan percent lowerci upperci, wgt(n_positives) }
|
||||
{p_end}
|
||||
{p 12 12 2}
|
||||
{cmd:xlabel(0,10,20,30,40,50,60,70,80,90,100) force }
|
||||
{p_end}
|
||||
{p 12 12 2}
|
||||
{cmd:null(50) label(namevar=id) nooverall notable }
|
||||
{p_end}
|
||||
{p 12 12 2}
|
||||
{cmd:title(Sensitivity, position(6))}
|
||||
{p_end}
|
||||
{p 12 12 2}
|
||||
{it:({stata "metan_examples metan_example_diag":click to run})}
|
||||
|
||||
{p 4 8 2}
|
||||
User has analysed data with a non-standard technique and supplied effect estimates, weights and description of statistics.
|
||||
The scheme "Economist" has been used.
|
||||
|
||||
{p 8 12 2}
|
||||
{cmd:. metan OR ORlci ORuci, wgt(bweight) }
|
||||
{p_end}
|
||||
{p 12 12 2}
|
||||
{cmd:first(0.924 0.753 1.095 Bayesian) }
|
||||
{p_end}
|
||||
{p 12 12 2}
|
||||
{cmd:firststats(param V=3.86, p=0.012) }
|
||||
{p_end}
|
||||
{p 12 12 2}
|
||||
{cmd:label(namevar=id) }
|
||||
{p_end}
|
||||
{p 12 12 2}
|
||||
{cmd:xlabel(0.25, 0.5, 1, 2, 4) force }
|
||||
{p_end}
|
||||
{p 12 12 2}
|
||||
{cmd:null(1) aspect(1.2) scheme(economist)}
|
||||
{p_end}
|
||||
{p 12 12 2}
|
||||
{it:({stata "metan_examples metan_example_user":click to run})}
|
||||
|
||||
{p 4 8 2}
|
||||
Variable "counts" defined showing raw data. Options to change the box, effect estimate marker and confidence interval used,
|
||||
and the counts variable has been attached to the estimate marker as a label.
|
||||
|
||||
{p 8 12 2}
|
||||
{cmd:. gen counts = ". " + string(tdeath) + "/" + string(tdeath+tnodeath) }
|
||||
{p_end}
|
||||
{p 12 12 2}
|
||||
{cmd:+ ", " + string(cdeath) + "/" + string(cdeath+cnodeath)}
|
||||
|
||||
{p 8 12 2}
|
||||
{cmd: . metan tdeath tnodeath cdeath cnodeath, }
|
||||
{p_end}
|
||||
{p 12 12 2}
|
||||
{cmd:lcols(id year) notable }
|
||||
{p_end}
|
||||
{p 12 12 2}
|
||||
{cmd:boxopt( mcolor(forest_green) msymbol(triangle) ) }
|
||||
{p_end}
|
||||
{p 12 12 2}
|
||||
{cmd:pointopt( msymbol(triangle) mcolor(gold) msize(tiny) }
|
||||
{p_end}
|
||||
{p 12 12 2}
|
||||
{cmd:mlabel(counts) mlabsize(vsmall) mlabcolor(forest_green) mlabposition(1) ) }
|
||||
{p_end}
|
||||
{p 12 12 2}
|
||||
{cmd:ciopt( lcolor(sienna) lwidth(medium) )}
|
||||
{p_end}
|
||||
{p 12 12 2}
|
||||
{it:({stata "metan_examples metan_example_custom":click to run})}
|
||||
|
||||
{p 4 8 2}
|
||||
L'Abbe plot with labelled axes and display of risk ratio and risk difference.
|
||||
|
||||
{p 8 12 2}
|
||||
{cmd:. labbe tdeath tnodeath cdeath cnodeath, }
|
||||
{p_end}
|
||||
{p 12 12 2}
|
||||
{cmd:xlabel(0,0.25,0.5,0.75,1) ylabel(0,0.25,0.5,0.75,1) }
|
||||
{p_end}
|
||||
{p 12 12 2}
|
||||
{cmd:rr(1.029) rd(0.014) null}
|
||||
{p_end}
|
||||
{p 12 12 2}
|
||||
{it:({stata "metan_examples labbe_example":click to run})}
|
||||
|
||||
|
||||
|
||||
{title:Authors}
|
||||
|
||||
{p 4 4 0}
|
||||
Michael J Bradburn, Jonathan J Deeks, Douglas G Altman.
|
||||
Centre for Statistics in Medicine, University of Oxford,
|
||||
Wolfson College Annexe, Linton Road, Oxford, OX2 6UD, UK
|
||||
|
||||
{title:Version 9 update}
|
||||
|
||||
{p 4 4 0}
|
||||
Ross J Harris, Roger M Harbord, Jonathan A C Sterne.
|
||||
Department of Social Medicine, University of Bristol,
|
||||
Canynge Hall, Whiteladies Road, Bristol BS8 2PR, UK
|
||||
|
||||
{title:Other updates and improvements to code and help file}
|
||||
|
||||
{p 4 4 0}
|
||||
Patrick Royston. MRC Clinical Trials Unit, 222 Euston Road,
|
||||
London, NW1 2DA
|
||||
|
||||
{title:Acknowledgements}
|
||||
|
||||
{p 4 4 0}
|
||||
Thanks to Vince Wiggins, Kit Baum and Jeff Pitblado of Statacorp
|
||||
who offered advice and helped facilitate the version 9 update.
|
||||
Thanks also to all the people who helped with beta-testing and
|
||||
made comments and suggested improvements.
|
||||
|
||||
{title:References}
|
||||
|
||||
{p 4 4 0}
|
||||
Higgins JPT, Thompson SG, Deeks JJ,
|
||||
Altman DG. Measuring inconsistency in meta-analyses. BMJ
|
||||
2003; 327:557-560. {browse "http://dx.doi.org/10.1136/bmj.327.7414.557":http://dx.doi.org/10.1136/bmj.327.7414.557}
|
||||
|
||||
{p 4 4 0}
|
||||
Higgins JPT, Thompson SG (2006) Presenting random effects meta-analyses:
|
||||
where we are going wrong? (from presentation, work in preparation)
|
||||
|
||||
|
||||
{title:Also see}
|
||||
|
||||
STB: STB-44 sbe24
|
||||
On-line: help for {help metan7}, {help metannt}
|
||||
{help meta} (if installed), {help metacum} (if installed),
|
||||
{help metareg} (if installed), {help metabias} (if installed),
|
||||
{help metatrim} (if installed), {help metainf} (if installed),
|
||||
{help galbr} (if installed), {help metafunnel} (if installed)
|
||||
|
2507
Modules/ado/plus/m/metan7.ado
Normal file
2507
Modules/ado/plus/m/metan7.ado
Normal file
File diff suppressed because it is too large
Load Diff
838
Modules/ado/plus/m/metan7.dlg
Normal file
838
Modules/ado/plus/m/metan7.dlg
Normal file
@ -0,0 +1,838 @@
|
||||
/*
|
||||
|
||||
*! metan7 dialog version 1.0.5, 1 Apr 2004, T. J. Steichen, steichen@triad.rr.com
|
||||
*! for metan7 version 1.85, 15 Mar 2004, M. J. Bradburn, mike.bradburn@cancer.org.uk
|
||||
|
||||
Fixed and random effects meta-analysis
|
||||
--------------------------------------
|
||||
Syntax: metan7 varlist [if exp] [in range] [,
|
||||
label(namevar=name, yearvar=year)
|
||||
fixed random fixedi randomi peto
|
||||
rr or rd cornfield chi2 breslow notable nograph
|
||||
cohen hedges glass nostandard
|
||||
log sortby(sort_vars) ilevel(#) olevel(#) nokeep
|
||||
xlabel(#,..,#) force t1title(#,..,#) boxsha(#) boxsca(#) texts(#)
|
||||
saving(filename) nowt counts nostats nooverall
|
||||
group1(text) group2(text) effect(text) nobox eform
|
||||
wgt(weightvar) xtick(#,..,#)
|
||||
t2title(#,..,#) b1title(#,..,#) b2title(#,..,#)
|
||||
nointeger cc(#) by(byvar) nosubgroup sgweight legend(text) ]
|
||||
|
||||
To install in User Statistics menu via Stata commands:
|
||||
. window menu append item "stUserStatistics" "Meta-analysis of Binary and Continuous Data (meta&n)" "db metan7"
|
||||
. window menu refresh
|
||||
To permanently install, place the commands in your -profile.do- file.
|
||||
|
||||
*/
|
||||
|
||||
VERSION 8.0
|
||||
|
||||
INCLUDE _std_medium
|
||||
INCLUDE _ht300
|
||||
DEFINE _dlgwd 450
|
||||
INCLUDE header
|
||||
|
||||
HELP hlp1, view("help metan7")
|
||||
RESET res1, label("Reset")
|
||||
|
||||
DIALOG main, label("metan7 1.85 - Meta-analysis of Binary & Continuous") tabtitle("Main")
|
||||
BEGIN
|
||||
GROUPBOX gb_data 10 5 310 _ht1h, ///
|
||||
label("Type of Data:")
|
||||
RADIO r_binary 15 25 60 ., ///
|
||||
label(" Count") first ///
|
||||
onclickon(script main_binary_on) ///
|
||||
onclickoff(script main_binary_off)
|
||||
RADIO r_continuous 75 25 90 ., ///
|
||||
label("Continuous") middle ///
|
||||
onclickon(script main_continuous_on) ///
|
||||
onclickoff(script main_continuous_off)
|
||||
RADIO r_effect_ci 165 25 75 ., ///
|
||||
label("Effect/CI") middle ///
|
||||
onclickon(script main_effect_ci_on) ///
|
||||
onclickoff(script main_effect_ci.off)
|
||||
RADIO r_effect_se 240 25 75 ., ///
|
||||
label("Effect/SE") last ///
|
||||
onclickon(script main_effect_se_on) ///
|
||||
onclickoff(script main_effect_se_off)
|
||||
|
||||
/* end GROUPBOX gb_data */
|
||||
|
||||
TEXT tx_binary 10 50 310 ., ///
|
||||
label("Vars for Counts: a, b, c, d, in that order")
|
||||
VARLIST vl_binary @ _ss @ ., ///
|
||||
label("Vars for a, b, c, d")
|
||||
|
||||
TEXT tx_contin_exp @ 50 310 ., ///
|
||||
label("Vars for Exp. Group: n, mean, sd, in that order")
|
||||
VARLIST vl_contin_exp @ _ss @ ., ///
|
||||
label("Experimental Group: n, mean, sd")
|
||||
TEXT tx_contin_ctl @ _ss 310 ., ///
|
||||
label("Vars for Control Group: n, mean, sd, in that order")
|
||||
VARLIST vl_contin_ctl @ _ss @ ., ///
|
||||
label("Control Group: n, mean, sd")
|
||||
|
||||
TEXT tx_effect_ci @ 50 310 ., ///
|
||||
label("Vars for Effects: theta, lowerCI, upperCI, in that order")
|
||||
VARLIST vl_effect_ci @ _ss @ ., ///
|
||||
label("Effect Sizes: theta, lowerCI, upperCI")
|
||||
|
||||
TEXT tx_effect_se @ 50 310 ., ///
|
||||
label("Vars for Effects: theta, se(theta), in that order")
|
||||
VARLIST vl_effect_se @ _ss @ ., ///
|
||||
label("Effect Sizes: theta, se(theta)")
|
||||
|
||||
/* end vars */
|
||||
|
||||
GROUPBOX gb_labels 10 130 310 _ht3h, ///
|
||||
label("Labels for Data:")
|
||||
CHECKBOX cb_name 20 150 70 ., ///
|
||||
label("Name:") ///
|
||||
onclickon(main.vn_name.enable) ///
|
||||
onclickoff(main.vn_name.disable)
|
||||
VARNAME vn_name 100 150 210 ., ///
|
||||
label("Name Variable")
|
||||
CHECKBOX cb_year 20 170 70 ., ///
|
||||
label("Year:") ///
|
||||
onclickon(main.vn_year.enable) ///
|
||||
onclickoff(main.vn_year.disable)
|
||||
VARNAME vn_year 100 170 210 ., ///
|
||||
label("Year Variable")
|
||||
|
||||
/* end GROUPBOX gb_labels */
|
||||
|
||||
GROUPBOX gb_by 10 200 310 45, ///
|
||||
label("By Variable:")
|
||||
CHECKBOX cb_by 20 220 70 ., ///
|
||||
label(" By:") ///
|
||||
onclickon(script main_by_on) ///
|
||||
onclickoff(script main_by_off)
|
||||
VARLIST vl_by 100 220 210 ., ///
|
||||
label("By Variable") ///
|
||||
option("by")
|
||||
|
||||
/* end GROUPBOX gb_by */
|
||||
|
||||
GROUPBOX gb_sortby 10 250 310 45, ///
|
||||
label("Sort Data:")
|
||||
CHECKBOX cb_sortby 20 270 70 ., ///
|
||||
label(" By:") ///
|
||||
onclickon(main.vl_sortby.enable) ///
|
||||
onclickoff(main.vl_sortby.disable)
|
||||
VARLIST vl_sortby 100 270 210 ., ///
|
||||
label("Name Variable") ///
|
||||
option("sortby")
|
||||
|
||||
/* end GROUPBOX gb_sortby */
|
||||
|
||||
GROUPBOX gb_opts 325 5 120 85, ///
|
||||
label("General Options:")
|
||||
|
||||
CHECKBOX cb_nokeep 330 25 70 ., ///
|
||||
label("noKeep") ///
|
||||
option("nokeep")
|
||||
|
||||
CHECKBOX cb_ilevel 330 45 60 ., ///
|
||||
label("ilevel:") ///
|
||||
onclickon(main.ed_ilevel.enable) ///
|
||||
onclickoff(main.ed_ilevel.disable)
|
||||
EDIT ed_ilevel 400 45 40 ., ///
|
||||
label("ilevel") ///
|
||||
numonly default(global S_level) ///
|
||||
option("ilevel")
|
||||
|
||||
CHECKBOX cb_olevel 330 65 60 ., ///
|
||||
label("olevel:") ///
|
||||
onclickon(main.ed_olevel.enable) ///
|
||||
onclickoff(main.ed_olevel.disable)
|
||||
EDIT ed_olevel 400 65 40 ., ///
|
||||
label("olevel") ///
|
||||
numonly default(global S_level) ///
|
||||
option("olevel")
|
||||
|
||||
/* end GROUPBOX gb_opts */
|
||||
|
||||
FRAME fr_wgt 325 95 120 60
|
||||
CHECKBOX cb_wgt 330 100 110 ., ///
|
||||
label("Weight Var") ///
|
||||
onclickon(main.vn_wgt.enable) ///
|
||||
onclickoff(main.vn_wgt.disable)
|
||||
VARNAME vn_wgt 330 121 110 ., ///
|
||||
label("Weight Variable") ///
|
||||
option("wgt")
|
||||
|
||||
/* end wgt */
|
||||
|
||||
GROUPBOX gb_by_opts 325 200 120 61, ///
|
||||
label("By Options:")
|
||||
|
||||
CHECKBOX cb_nosubgroup 330 220 100 ., ///
|
||||
label("noSubGroup") ///
|
||||
option("nosubgroup")
|
||||
|
||||
CHECKBOX cb_sgweight 330 240 100 ., ///
|
||||
label("sgWeight") ///
|
||||
option("sgweight")
|
||||
|
||||
/* end GROUPBOX gb_by_opts */
|
||||
|
||||
END
|
||||
|
||||
DIALOG metan7_b, tabtitle("Binary...")
|
||||
BEGIN
|
||||
GROUPBOX gb_pool 0 10 210 _ht9h, ///
|
||||
label("Pooling Model")
|
||||
RADIO r_fixed 10 30 190 ., ///
|
||||
label("Fixed, Mantel-Haenszel") first ///
|
||||
onclickoff(program metan7_b_bd) ///
|
||||
option("fixed")
|
||||
RADIO r_fixedi @ _ss @ ., ///
|
||||
label("Fixed, Inverse Variance") middle ///
|
||||
onclickoff(program metan7_b_bd) ///
|
||||
option("fixedi")
|
||||
RADIO r_random @ _ss 195 ., ///
|
||||
label("Random (M-H heterogeneity)") middle ///
|
||||
onclickon(script metan7_b_random_on) ///
|
||||
onclickoff(program metan7_b_chi2) ///
|
||||
option("random")
|
||||
RADIO r_randomi @ _ss @ ., ///
|
||||
label("Random (I-V heterogeneity)") middle ///
|
||||
onclickon(script metan7_b_random_on) ///
|
||||
onclickoff(program metan7_b_chi2) ///
|
||||
option("randomi")
|
||||
RADIO r_peto @ _ss @ ., ///
|
||||
label("Peto") last ///
|
||||
onclickon(script metan7_b_peto_on) ///
|
||||
onclickoff(program metan7_b_cornfield) ///
|
||||
option("peto")
|
||||
|
||||
GROUPBOX gb_stat 220 10 120 _ht5h, ///
|
||||
label("Statistic")
|
||||
RADIO r_rr 230 30 80 ., ///
|
||||
label("RR") first ///
|
||||
onclickon(script metan7_b_rr_on) ///
|
||||
onclickoff(program metan7_b_rr_off) ///
|
||||
option("rr")
|
||||
RADIO r_or @ _ss @ ., ///
|
||||
label("OR") middle ///
|
||||
onclickon(program metan7_b_or_on) ///
|
||||
onclickoff(program metan7_b_or_off) ///
|
||||
option("or")
|
||||
RADIO r_rd @ _ss @ ., ///
|
||||
label("RD") last ///
|
||||
option("rd")
|
||||
|
||||
CHECKBOX cb_cornfield 10 140 200 ., ///
|
||||
label("Use Cornfield CI's") ///
|
||||
option("cornfield")
|
||||
CHECKBOX cb_chi2 10 160 200 ., ///
|
||||
label("Use Chi-2 Statistic") ///
|
||||
option("chi2")
|
||||
CHECKBOX cb_breslow 10 180 200 ., ///
|
||||
label("Use Breslow-Day test") ///
|
||||
option("breslow")
|
||||
|
||||
CHECKBOX cb_log 230 100 200 ., ///
|
||||
label("Log scaled") ///
|
||||
option("log")
|
||||
|
||||
CHECKBOX cb_eform 230 120 200 ., ///
|
||||
label("Exponentiate") ///
|
||||
option("eform")
|
||||
|
||||
CHECKBOX cb_notable 230 140 200 ., ///
|
||||
label("noTable") ///
|
||||
option("notable")
|
||||
CHECKBOX cb_nograph 230 160 200 ., ///
|
||||
label("noGraph") ///
|
||||
option("nograph")
|
||||
|
||||
CHECKBOX cb_cc 10 260 150 ., ///
|
||||
label("Continuity Correction:") ///
|
||||
onclickon(metan7_b.ed_cc.enable) ///
|
||||
onclickoff(metan7_b.ed_cc.disable)
|
||||
EDIT ed_cc 160 260 65 ., ///
|
||||
label("Continuity Correction") ///
|
||||
option("cc")
|
||||
|
||||
CHECKBOX cb_nointeger 230 260 200 ., ///
|
||||
label("noInteger") ///
|
||||
option("nointeger")
|
||||
END
|
||||
|
||||
DIALOG metan7_c, tabtitle("Continuous...")
|
||||
BEGIN
|
||||
GROUPBOX gb_pool 0 10 210 _ht3h, ///
|
||||
label("Pooling Model")
|
||||
RADIO r_fixed 10 30 190 ., ///
|
||||
label("Fixed, Inverse Variance") first ///
|
||||
option("fixed")
|
||||
RADIO r_random @ _ss @ ., ///
|
||||
label("Random (I-V heterogeneity)") last ///
|
||||
option("random")
|
||||
|
||||
GROUPBOX gb_stat 220 10 120 _ht7h, ///
|
||||
label("Statistic")
|
||||
RADIO r_cohen 230 30 100 ., ///
|
||||
label("Cohen") first ///
|
||||
option("cohen")
|
||||
RADIO r_hedges @ _ss @ ., ///
|
||||
label("Hedges") middle ///
|
||||
option("hedges")
|
||||
RADIO r_glass @ _ss @ ., ///
|
||||
label("Glass") middle ///
|
||||
option("glass")
|
||||
RADIO r_nostandard @ _ss @ ., ///
|
||||
label("noStandard") last ///
|
||||
option("nostandard")
|
||||
|
||||
CHECKBOX cb_notable 230 140 200 ., ///
|
||||
label("noTable") ///
|
||||
option("notable")
|
||||
CHECKBOX cb_nograph 230 160 200 ., ///
|
||||
label("noGraph") ///
|
||||
option("nograph")
|
||||
|
||||
CHECKBOX cb_nointeger 230 260 200 ., ///
|
||||
label("noInteger") ///
|
||||
option("nointeger")
|
||||
|
||||
END
|
||||
|
||||
DIALOG metan7_e, tabtitle("Effect...")
|
||||
BEGIN
|
||||
GROUPBOX gb_pool 0 10 210 _ht3h, ///
|
||||
label("Pooling Model")
|
||||
RADIO r_fixed 10 30 190 ., ///
|
||||
label("Fixed, Inverse Variance") first ///
|
||||
option("fixed")
|
||||
RADIO r_random @ _ss @ ., ///
|
||||
label("Random (I-V heterogeneity)") last ///
|
||||
option("random")
|
||||
|
||||
CHECKBOX cb_notable 230 140 200 ., ///
|
||||
label("noTable") ///
|
||||
option("notable")
|
||||
CHECKBOX cb_nograph 230 160 200 ., ///
|
||||
label("noGraph") ///
|
||||
option("nograph")
|
||||
|
||||
CHECKBOX cb_effect 10 110 100 ., ///
|
||||
label("Effect Label:") ///
|
||||
onclickon(metan7_e.ed_effect.enable) ///
|
||||
onclickoff(metan7_e.ed_effect.disable)
|
||||
EDIT ed_effect 115 @ 225 ., ///
|
||||
label("effect label") ///
|
||||
option("effect")
|
||||
|
||||
END
|
||||
|
||||
DIALOG graph, tabtitle("Graph Opts")
|
||||
BEGIN
|
||||
|
||||
CHECKBOX cb_saving 10 10 100 ., ///
|
||||
label("Save graph:") ///
|
||||
onclickon(graph.fi_saving.enable) ///
|
||||
onclickoff(graph.fi_saving.disable)
|
||||
FILE fi_saving 110 10 240 ., ///
|
||||
label("File Name") ///
|
||||
error("Save filename") ///
|
||||
dialogtitle("Save graph") ///
|
||||
filter("Stata Graphs|*.gph") ///
|
||||
save ///
|
||||
option("saving")
|
||||
|
||||
/* end saving */
|
||||
|
||||
GROUPBOX gb_xlabel 10 40 330 _ht3h, ///
|
||||
label("X-axis Tick Labels (comma between):")
|
||||
|
||||
CHECKBOX cb_xlabel 15 60 45 ., ///
|
||||
label("Set:") ///
|
||||
onclickon(script graph_xlabel_on) ///
|
||||
onclickoff(script graph_xlabel_off)
|
||||
EDIT ed_xlabel 65 @ 270 ., ///
|
||||
label("X Tick labels") ///
|
||||
option("xlabel")
|
||||
|
||||
CHECKBOX cb_force 15 80 320 ., ///
|
||||
label("Force Scale to Tick Range") ///
|
||||
option("force")
|
||||
|
||||
/* end tick labels */
|
||||
|
||||
CHECKBOX cb_counts 15 115 65 ., ///
|
||||
label("Counts") ///
|
||||
onclickon(script graph_counts_on) ///
|
||||
onclickoff(script graph_counts_off) ///
|
||||
option("counts")
|
||||
|
||||
CHECKBOX cb_nowt 15 145 85 ., ///
|
||||
label("noWeights") ///
|
||||
option("nowt")
|
||||
|
||||
CHECKBOX cb_nostats 15 165 85 ., ///
|
||||
label("noStats") ///
|
||||
option("nostats")
|
||||
|
||||
CHECKBOX cb_nooverall 115 145 85 ., ///
|
||||
label("noOverall") ///
|
||||
option("nooverall")
|
||||
|
||||
CHECKBOX cb_nobox 115 165 85 ., ///
|
||||
label("noBox") ///
|
||||
option("nobox")
|
||||
|
||||
/* end switches */
|
||||
|
||||
CHECKBOX cb_legend 115 185 70 ., ///
|
||||
label("Legend:") ///
|
||||
onclickon(graph.ed_legend.enable) ///
|
||||
onclickoff(graph.ed_legend.disable)
|
||||
EDIT ed_legend 190 @ 55 ., ///
|
||||
label("legend") ///
|
||||
option("legend")
|
||||
|
||||
CHECKBOX cb_grp1 85 115 55 ., ///
|
||||
label("Grp 1:") ///
|
||||
onclickon(graph.ed_grp1.enable) ///
|
||||
onclickoff(graph.ed_grp1.disable)
|
||||
EDIT ed_grp1 145 @ 90 ., ///
|
||||
label("Grp1") ///
|
||||
option("group1")
|
||||
|
||||
CHECKBOX cb_grp2 245 115 55 ., ///
|
||||
label("Grp 2:") ///
|
||||
onclickon(graph.ed_grp2.enable) ///
|
||||
onclickoff(graph.ed_grp2.disable)
|
||||
EDIT ed_grp2 305 @ 90 ., ///
|
||||
label("Grp2") ///
|
||||
option("group2")
|
||||
|
||||
CHECKBOX cb_boxy 255 145 95 ., ///
|
||||
label("Box yscale:") ///
|
||||
onclickon(graph.ed_boxy.enable) ///
|
||||
onclickoff(graph.ed_boxy.disable)
|
||||
EDIT ed_boxy 355 @ 40 ., ///
|
||||
label("Box yscale") numonly default(1) ///
|
||||
option("boxsca")
|
||||
|
||||
CHECKBOX cb_boxs 255 165 95 ., ///
|
||||
label("Box shade:") ///
|
||||
onclickon(graph.ed_boxs.enable) ///
|
||||
onclickoff(graph.ed_boxs.disable)
|
||||
EDIT ed_boxs 355 @ 40 ., ///
|
||||
label("Box shading") numonly default(4) ///
|
||||
option("boxsha")
|
||||
|
||||
CHECKBOX cb_texts 255 185 95 ., ///
|
||||
label("Font scale:") ///
|
||||
onclickon(graph.ed_texts.enable) ///
|
||||
onclickoff(graph.ed_texts.disable)
|
||||
EDIT ed_texts 355 @ 40 ., ///
|
||||
label("Font scale") numonly default(1) ///
|
||||
option("texts")
|
||||
|
||||
/* end sets */
|
||||
|
||||
GROUPBOX gb_gopts7 10 205 390 _ht1h, ///
|
||||
label("Allowed Graph7 Options:")
|
||||
EDIT ed_gopts7 15 225 380 ., ///
|
||||
label("Graph7 Options")
|
||||
|
||||
CHECKBOX cb_b1 15 255 390 ., ///
|
||||
label("Effect Direction Labels, option b1( ):") ///
|
||||
onclickon(script graph_b1_on) ///
|
||||
onclickoff(script graph_b1_off)
|
||||
TEXT tx_b1_l 10 275 25 ., ///
|
||||
label("Left:")
|
||||
EDIT ed_b1_l 35 275 160 ., ///
|
||||
label(" Left")
|
||||
TEXT tx_b1_r 205 275 35 ., ///
|
||||
label("Right:")
|
||||
EDIT ed_b1_r 240 275 160 ., ///
|
||||
label("Right")
|
||||
|
||||
/* end Graph7 opts */
|
||||
|
||||
END
|
||||
|
||||
INCLUDE ifin
|
||||
|
||||
SCRIPT main_binary_on
|
||||
BEGIN
|
||||
main.tx_binary.show
|
||||
main.vl_binary.show
|
||||
main.tx_binary.enable
|
||||
main.vl_binary.enable
|
||||
|
||||
main.tx_effect_ci.disable
|
||||
main.vl_effect_ci.disable
|
||||
main.tx_effect_ci.hide
|
||||
main.vl_effect_ci.hide
|
||||
|
||||
main.tx_effect_se.disable
|
||||
main.vl_effect_se.disable
|
||||
main.tx_effect_se.hide
|
||||
main.vl_effect_se.hide
|
||||
|
||||
main.tx_contin_exp.disable
|
||||
main.vl_contin_exp.disable
|
||||
main.tx_contin_exp.hide
|
||||
main.vl_contin_exp.hide
|
||||
|
||||
main.tx_contin_ctl.disable
|
||||
main.vl_contin_ctl.disable
|
||||
main.tx_contin_ctl.hide
|
||||
main.vl_contin_ctl.hide
|
||||
|
||||
graph.cb_counts.enable
|
||||
END
|
||||
|
||||
SCRIPT main_binary_off
|
||||
BEGIN
|
||||
main.tx_binary.disable
|
||||
main.vl_binary.disable
|
||||
main.tx_binary.hide
|
||||
main.vl_binary.hide
|
||||
|
||||
graph.cb_counts.disable
|
||||
END
|
||||
|
||||
SCRIPT main_continuous_on
|
||||
BEGIN
|
||||
main.tx_contin_exp.show
|
||||
main.vl_contin_exp.show
|
||||
main.tx_contin_exp.enable
|
||||
main.vl_contin_exp.enable
|
||||
|
||||
main.tx_contin_ctl.show
|
||||
main.vl_contin_ctl.show
|
||||
main.tx_contin_ctl.enable
|
||||
main.vl_contin_ctl.enable
|
||||
|
||||
main.tx_binary.disable
|
||||
main.vl_binary.disable
|
||||
main.tx_binary.hide
|
||||
main.vl_binary.hide
|
||||
|
||||
main.tx_effect_ci.disable
|
||||
main.vl_effect_ci.disable
|
||||
main.tx_effect_ci.hide
|
||||
main.vl_effect_ci.hide
|
||||
|
||||
main.tx_effect_se.disable
|
||||
main.vl_effect_se.disable
|
||||
main.tx_effect_se.hide
|
||||
main.vl_effect_se.hide
|
||||
END
|
||||
|
||||
SCRIPT main_continuous_off
|
||||
BEGIN
|
||||
main.tx_contin_exp.disable
|
||||
main.vl_contin_exp.disable
|
||||
main.tx_contin_exp.hide
|
||||
main.vl_contin_exp.hide
|
||||
|
||||
main.tx_contin_ctl.disable
|
||||
main.vl_contin_ctl.disable
|
||||
main.tx_contin_ctl.hide
|
||||
main.vl_contin_ctl.hide
|
||||
END
|
||||
|
||||
SCRIPT main_effect_ci_on
|
||||
BEGIN
|
||||
main.tx_effect_ci.show
|
||||
main.vl_effect_ci.show
|
||||
main.tx_effect_ci.enable
|
||||
main.vl_effect_ci.enable
|
||||
|
||||
main.tx_effect_se.disable
|
||||
main.vl_effect_se.disable
|
||||
main.tx_effect_se.hide
|
||||
main.vl_effect_se.hide
|
||||
|
||||
main.tx_binary.disable
|
||||
main.vl_binary.disable
|
||||
main.tx_binary.hide
|
||||
main.vl_binary.hide
|
||||
|
||||
main.tx_contin_exp.disable
|
||||
main.vl_contin_exp.disable
|
||||
main.tx_contin_exp.hide
|
||||
main.vl_contin_exp.hide
|
||||
|
||||
main.tx_contin_ctl.disable
|
||||
main.vl_contin_ctl.disable
|
||||
main.tx_contin_ctl.hide
|
||||
main.vl_contin_ctl.hide
|
||||
END
|
||||
|
||||
SCRIPT main_effect_ci_off
|
||||
BEGIN
|
||||
main.tx_effect_ci.disable
|
||||
main.vl_effect_ci.disable
|
||||
main.tx_effect_ci.hide
|
||||
main.vl_effect_ci.hide
|
||||
END
|
||||
|
||||
SCRIPT main_effect_se_on
|
||||
BEGIN
|
||||
main.tx_effect_se.show
|
||||
main.vl_effect_se.show
|
||||
main.tx_effect_se.enable
|
||||
main.vl_effect_se.enable
|
||||
|
||||
main.tx_effect_ci.disable
|
||||
main.vl_effect_ci.disable
|
||||
main.tx_effect_ci.hide
|
||||
main.vl_effect_ci.hide
|
||||
|
||||
main.tx_binary.disable
|
||||
main.vl_binary.disable
|
||||
main.tx_binary.hide
|
||||
main.vl_binary.hide
|
||||
|
||||
main.tx_contin_exp.disable
|
||||
main.vl_contin_exp.disable
|
||||
main.tx_contin_exp.hide
|
||||
main.vl_contin_exp.hide
|
||||
|
||||
main.tx_contin_ctl.disable
|
||||
main.vl_contin_ctl.disable
|
||||
main.tx_contin_ctl.hide
|
||||
main.vl_contin_ctl.hide
|
||||
END
|
||||
|
||||
SCRIPT main_effect_se_off
|
||||
BEGIN
|
||||
main.tx_effect_se.disable
|
||||
main.vl_effect_se.disable
|
||||
main.tx_effect_se.hide
|
||||
main.vl_effect_se.hide
|
||||
END
|
||||
|
||||
SCRIPT main_by_on
|
||||
BEGIN
|
||||
main.vl_by.enable
|
||||
main.gb_by_opts.enable
|
||||
main.cb_nosubgroup.enable
|
||||
main.cb_sgweight.enable
|
||||
END
|
||||
|
||||
SCRIPT main_by_off
|
||||
BEGIN
|
||||
main.vl_by.disable
|
||||
main.gb_by_opts.disable
|
||||
main.cb_nosubgroup.disable
|
||||
main.cb_sgweight.disable
|
||||
END
|
||||
|
||||
SCRIPT metan7_b_random_on
|
||||
BEGIN
|
||||
metan7_b.cb_breslow.disable
|
||||
metan7_b.cb_chi2.disable
|
||||
END
|
||||
|
||||
SCRIPT metan7_b_peto_on
|
||||
BEGIN
|
||||
metan7_b.cb_breslow.disable
|
||||
metan7_b.cb_cornfield.disable
|
||||
END
|
||||
|
||||
PROGRAM metan7_b_bd
|
||||
BEGIN
|
||||
if metan7_b.r_or {
|
||||
call metan7_b.cb_breslow.enable
|
||||
}
|
||||
END
|
||||
|
||||
PROGRAM metan7_b_chi2
|
||||
BEGIN
|
||||
if metan7_b.r_or & !(metan7_b.r_random | metan7_b.r_randomi) {
|
||||
call metan7_b.cb_chi2.enable
|
||||
}
|
||||
END
|
||||
|
||||
PROGRAM metan7_b_cornfield
|
||||
BEGIN
|
||||
if metan7_b.r_or {
|
||||
call metan7_b.cb_cornfield.enable
|
||||
}
|
||||
END
|
||||
|
||||
SCRIPT metan7_b_rr_on
|
||||
BEGIN
|
||||
metan7_b.cb_log.enable
|
||||
metan7_b.cb_eform.enable
|
||||
END
|
||||
|
||||
PROGRAM metan7_b_or_on
|
||||
BEGIN
|
||||
call metan7_b.cb_log.enable
|
||||
call metan7_b.cb_eform.enable
|
||||
call metan7_b.r_peto.enable
|
||||
if !metan7_b.r_peto {
|
||||
call metan7_b.cb_cornfield.enable
|
||||
}
|
||||
if !(metan7_b.r_random | metan7_b.r_randomi) {
|
||||
call metan7_b.cb_chi2.enable
|
||||
}
|
||||
call metan7_b.cb_breslow.enable
|
||||
END
|
||||
|
||||
PROGRAM metan7_b_or_off
|
||||
BEGIN
|
||||
if !metan7_b.r_rr {
|
||||
call metan7_b.cb_log.disable
|
||||
call metan7_b.cb_eform.disable
|
||||
}
|
||||
call metan7_b.r_peto.disable
|
||||
call metan7_b.cb_cornfield.disable
|
||||
call metan7_b.cb_chi2.disable
|
||||
call metan7_b.cb_breslow.disable
|
||||
END
|
||||
|
||||
PROGRAM metan7_b_rr_off
|
||||
BEGIN
|
||||
if !metan7_b.r_or {
|
||||
call metan7_b.cb_log.disable
|
||||
call metan7_b.cb_eform.disable
|
||||
}
|
||||
END
|
||||
|
||||
SCRIPT graph_xlabel_on
|
||||
BEGIN
|
||||
graph.ed_xlabel.enable
|
||||
graph.cb_force.enable
|
||||
END
|
||||
|
||||
SCRIPT graph_xlabel_off
|
||||
BEGIN
|
||||
graph.ed_xlabel.disable
|
||||
graph.cb_force.disable
|
||||
END
|
||||
|
||||
SCRIPT graph_counts_on
|
||||
BEGIN
|
||||
graph.cb_grp1.enable
|
||||
graph.cb_grp2.enable
|
||||
END
|
||||
|
||||
SCRIPT graph_counts_off
|
||||
BEGIN
|
||||
graph.cb_grp1.disable
|
||||
graph.cb_grp2.disable
|
||||
graph.cb_grp1.setoff
|
||||
graph.cb_grp2.setoff
|
||||
graph.ed_grp1.disable
|
||||
graph.ed_grp2.disable
|
||||
END
|
||||
|
||||
SCRIPT graph_b1_on
|
||||
BEGIN
|
||||
graph.tx_b1_l.enable
|
||||
graph.ed_b1_l.enable
|
||||
graph.tx_b1_r.enable
|
||||
graph.ed_b1_r.enable
|
||||
END
|
||||
|
||||
SCRIPT graph_b1_off
|
||||
BEGIN
|
||||
graph.tx_b1_l.disable
|
||||
graph.ed_b1_l.disable
|
||||
graph.tx_b1_r.disable
|
||||
graph.ed_b1_r.disable
|
||||
END
|
||||
|
||||
|
||||
PROGRAM command
|
||||
BEGIN
|
||||
put " metan7 "
|
||||
if main.r_binary {
|
||||
varlist main.vl_binary
|
||||
}
|
||||
if main.r_continuous {
|
||||
varlist main.vl_contin_exp main.vl_contin_ctl
|
||||
}
|
||||
if main.r_effect_ci {
|
||||
varlist main.vl_effect_ci
|
||||
}
|
||||
if main.r_effect_se {
|
||||
varlist main.vl_effect_se
|
||||
}
|
||||
INCLUDE _ifin_pr
|
||||
beginoptions
|
||||
if main.cb_name | main.cb_year {
|
||||
put "label("
|
||||
if main.cb_name {
|
||||
put "namevar=" main.vn_name
|
||||
}
|
||||
if main.cb_name & main.cb_year {
|
||||
put ", "
|
||||
}
|
||||
if main.cb_year {
|
||||
put "yearvar=" main.vn_year
|
||||
}
|
||||
put ") "
|
||||
}
|
||||
optionarg main.vl_sortby
|
||||
optionarg main.vl_by
|
||||
optionarg main.ed_ilevel
|
||||
optionarg main.ed_olevel
|
||||
optionarg main.vn_wgt
|
||||
option main.cb_nokeep
|
||||
option main.cb_nosubgroup
|
||||
option main.cb_sgweight
|
||||
if main.r_binary {
|
||||
if !main.vn_wgt {
|
||||
option radio(metan7_b r_fixed r_fixedi r_random r_randomi r_peto)
|
||||
}
|
||||
option radio(metan7_b r_rr r_or r_rd)
|
||||
option metan7_b.cb_cornfield
|
||||
option metan7_b.cb_chi2
|
||||
option metan7_b.cb_breslow
|
||||
option metan7_b.cb_log
|
||||
option metan7_b.cb_eform
|
||||
option metan7_b.cb_nograph
|
||||
option metan7_b.cb_notable
|
||||
optionarg metan7_b.ed_cc
|
||||
option metan7_b.cb_nointeger
|
||||
}
|
||||
if main.r_continuous {
|
||||
if !main.vn_wgt {
|
||||
option radio(metan7_c r_fixed r_random)
|
||||
}
|
||||
option radio(metan7_c r_cohen r_hedges r_glass r_nostandard)
|
||||
option metan7_c.cb_nograph
|
||||
option metan7_c.cb_notable
|
||||
option metan7_c.cb_nointeger
|
||||
}
|
||||
if main.r_effect_se | main.r_effect_ci {
|
||||
if !main.vn_wgt {
|
||||
option radio(metan7_e r_fixed r_random)
|
||||
}
|
||||
optionarg metan7_e.ed_effect
|
||||
option metan7_e.cb_nograph
|
||||
option metan7_e.cb_notable
|
||||
}
|
||||
optionarg graph.fi_saving
|
||||
optionarg graph.ed_xlabel
|
||||
option graph.cb_force
|
||||
option graph.cb_counts
|
||||
option graph.cb_nowt
|
||||
option graph.cb_nostats
|
||||
option graph.cb_nooverall
|
||||
option graph.cb_nobox
|
||||
optionarg graph.ed_grp1
|
||||
optionarg graph.ed_grp2
|
||||
optionarg graph.ed_texts
|
||||
optionarg graph.ed_legend
|
||||
optionarg graph.ed_boxy
|
||||
optionarg graph.ed_boxs
|
||||
put graph.ed_gopts7 " "
|
||||
if graph.cb_b1 {
|
||||
put "b1(*I:" graph.ed_b1_l "*" graph.ed_b1_r ") "
|
||||
}
|
||||
endoptions
|
||||
END
|
369
Modules/ado/plus/m/metan7.hlp
Normal file
369
Modules/ado/plus/m/metan7.hlp
Normal file
@ -0,0 +1,369 @@
|
||||
.-
|
||||
help for ^metan7^, ^labbe^, ^funnel^
|
||||
.-
|
||||
|
||||
Fixed and random effects meta-analysis
|
||||
--------------------------------------
|
||||
|
||||
|
||||
^metan7^ varlist [^if^ exp] [^in^ range]
|
||||
[, ^rr or rd cohen hedges glass nosta^ndard
|
||||
^fixed random fixedi randomi peto wgt(^weightvar^) nooverall^
|
||||
^cornfield chi2 breslow log eform noint^eger^ cc(^#^)^
|
||||
^by(^byvar^) nosubgroup sgweight ilevel(^#^) olevel(^#^)^
|
||||
^label(namevar=^name^, yearvar=^year^) legend(^text^)^
|
||||
^sortby(^sort_vars^) nokeep notable nograph^
|
||||
^xt^ick^(^#,..,#^) xla^bel^(^#,..,#^) force^
|
||||
^t1title(^#,..,#^) t2title(^#,..,#^) b1title(^#,..,#^) b2title(^#,..,#^)^
|
||||
^boxsha(^#^) boxsca(^#^) nobox texts(^#^) nowt nostats counts^
|
||||
^group1(^text^) group2(^text^) effect(^text^) saving(^filename^)^ ]
|
||||
|
||||
|
||||
^labbe^ varlist [^if^ exp] [^in^ range] [^weight^]
|
||||
[ , ^nowt per^cent ^or(^#^) rr(^#^) rd(^#^) rrn(^#^) null logit^
|
||||
graph_options ]
|
||||
|
||||
^funnel^ [varlist] [^if^ exp] [^in^ range] [^weight^]
|
||||
[, ^ysq^rt ^sa^mple ^ov^erall(#) graph_options ]
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
These routines provide methods for the meta-analysis of aggregate level
|
||||
data. Either binary (event) or continuous data from two groups may be
|
||||
combined using the ^metan7^ command. Additionally, pre-calculated effect
|
||||
sizes may be pooled. Several meta-analytic methods are available, and
|
||||
the results may be displayed graphically in a Forest plot. A test for
|
||||
the statistical significance of the overall effect size is also provided,
|
||||
along with a test for excess between-trial variation (heterogeneity)
|
||||
and the I-squared measure which is an alternative summary of this
|
||||
(Higgins & Thompson 2002). Note that this command has been updated-
|
||||
see ^metan^
|
||||
|
||||
^labbe^ draws a L'Abbe plot for event data (proportion of successes in the
|
||||
two groups). This is an alternative to the graph produced by ^metan7^
|
||||
|
||||
^funnel^ may be used for producing a "funnel plot", a graph of either the
|
||||
study sample size, standard error or precision (inverse of s.e.) against
|
||||
the effect size.
|
||||
|
||||
|
||||
Options for ^metan7^
|
||||
-----------------
|
||||
|
||||
The main meta-analysis routine ^metan7^ requires either two, three, four
|
||||
or six variables to be declared.
|
||||
|
||||
When four variables are specified, analysis of binary data is performed
|
||||
on the 2x2 table with cell counts denoted by the variable list.
|
||||
|
||||
With six variables, the data are assumed continuous and to be the sample
|
||||
size, mean and standard deviation of the experimental group followed by
|
||||
those of the control group.
|
||||
|
||||
For two or three variables, a variance-weighted analysis is performed in
|
||||
a similar fashion to the @meta@ command;
|
||||
the two variable syntax is <theta> and <SE(theta)>.
|
||||
the 3 variable syntax is <theta>, <lower ci (theta)>, <upper ci (theta)>
|
||||
Note that in this situation "theta" is taken to be the logarithm of the
|
||||
effect size if the odds ratio or risk ratio is used. ^This differs from^
|
||||
^the equivalent in the meta command^. This program does not assume the
|
||||
three variables need log transformation: if odds ratios or risk ratios
|
||||
are combines, it is up to the user to log-transform them first. The
|
||||
^eform^ option can be used to change back to the original scale if needed.
|
||||
By default the confidence intervals are assumed symmetric, and the studies
|
||||
are pooled by taking the variance to be equal to (CI width)/2z.
|
||||
|
||||
|
||||
Specifying the measure and model with which to pool the data
|
||||
------------------------------------------------------------
|
||||
|
||||
|
||||
Options for binary data (4 variables)
|
||||
|
||||
^rr^ pools risk ratios [default]
|
||||
^or^ pools odds ratios
|
||||
^rd^ pools risk differences
|
||||
|
||||
|
||||
^fixed^ specifies a fixed effect model using the method of
|
||||
Mantel and Haenszel [default]
|
||||
^fixedi^ specifies a fixed effect model using the inverse variance method
|
||||
^peto^ specifies that Peto's method is used to pool odds ratios
|
||||
^random^ specifies a random effects model using the method of
|
||||
DerSimonian & Laird, with the estimate of heterogeneity being taken
|
||||
from the Mantel-Haenszel model
|
||||
^randomi^ specifies a random effects model using the method of
|
||||
DerSimonian & Laird, with the estimate of heterogeneity being taken
|
||||
from the inverse variance fixed effect model
|
||||
|
||||
^cornfield^ computes confidence intervals for odds ratios by method of
|
||||
Cornfield, rather than the (default) Woolf method
|
||||
^chi2^ displays chi-squared statistic (instead of z) for the test
|
||||
of significance of the pooled effect size. This is available only for
|
||||
odds ratios pooled using Peto or Mantel-Haenszel methods
|
||||
^breslow^ produces Breslow-Day test for homogeneity of ORs
|
||||
|
||||
^cc(^#^)^ defines a fixed continuity correction to add in the case where
|
||||
a study contains a zero cell. By default, metan7 adds 0.5 to each cell of
|
||||
a trial where a zero is encountered when using Inverse-Variance,
|
||||
Der-Simonian & Laird or Mantel-Haenszel weighting to enable finite
|
||||
variance estimators to be derived. However, the cc option allows the use
|
||||
of other constants (including none). See also the ^nointeger^ option below.
|
||||
|
||||
^nointeger^ allows the cell counts to be non-integers. This may be useful
|
||||
when a variable continuity correction is sought for studies containing
|
||||
zero cells, but also may be used in other circumstances, such as where a
|
||||
cluster-randomised trial is to be incorporated and the "effective sample
|
||||
size" is less than the total number of observations.
|
||||
|
||||
|
||||
Options for continuous data
|
||||
|
||||
^cohen^ pools standardised mean differences by the method of Cohen
|
||||
[default]
|
||||
^hedges^ pools standardised mean differences by the method of Hedges
|
||||
^glass^ pools standardised mean differences by the method of Glass
|
||||
^nostandard^ pools unstandardised mean differences
|
||||
|
||||
^fixed^ specifies a fixed effect model using the inverse variance method
|
||||
[default]
|
||||
^random^ specifies a random effects model using the DerSimonian & Laird
|
||||
method
|
||||
|
||||
^nointeger^ denotes that the number of observations in each arm does not
|
||||
need to be an integer. By default, the first and fourth variables specified
|
||||
(containing N_intervention and N_control respectively) may occasionally be
|
||||
non-integer (see above entry under binary data)
|
||||
|
||||
|
||||
|
||||
Alternative weighting (for all data types)
|
||||
|
||||
^wgt(^wgtvar^)^ denotes that the effect size is to be computed by assigning
|
||||
a weight of wgtvar to the studies. When RRs or ORs are declared, their
|
||||
logarithms are weighted. You should only use this option if you are
|
||||
satisfied that the weights are meaningful.
|
||||
|
||||
|
||||
Output
|
||||
------
|
||||
|
||||
General
|
||||
|
||||
^by^ specifies that the meta-analysis is to be stratified
|
||||
according to the variable declared.
|
||||
|
||||
^sgweight^ specifies that the display is to present the percentage
|
||||
weights within each subgroup separately. By default metan7 presents
|
||||
weights as a percentage of the overall total.
|
||||
^nosubgroup^ indicates that no within-group results are to be
|
||||
presented. By default metan7 pools trials both within and across
|
||||
all studies
|
||||
|
||||
^log^ reports the results on the log scale
|
||||
(valid for OR and RR analyses only)
|
||||
^eform^ exponentiates all effect sizes and confidence intervals
|
||||
(valid only for analyses of odds ratios or risk ratios)
|
||||
^ilevel()^ specifies the significance level (eg 90,95,99) for the
|
||||
individual trial confidence intervals
|
||||
^olevel()^ specifies the significance level (eg 90,95,99) for the
|
||||
overall (pooled) confidence intervals
|
||||
^ilevel^ and ^olevel^ need not be the same, and by default are equal
|
||||
to the significance level specified using the ^set level^ command
|
||||
|
||||
^sortby(^varlist^)^ sorts by one or more variables ^varlist^
|
||||
^label(^ [^namevar^=namevar] [^,yearvar^=yearvar] ^)^
|
||||
labels the data by its name, year or both. Either or both option/s
|
||||
may be left blank. For the table display the overall length of the
|
||||
label is restricted to 20 characters
|
||||
^nokeep^ prevents the retention of study parameters in permanent
|
||||
variables (see saved results below)
|
||||
^notable^ prevents display of table of results
|
||||
^nograph^ prevents display of graph
|
||||
|
||||
|
||||
|
||||
Graph display options for forest plot
|
||||
|
||||
^legend()^ specifies a label to be used for the study identifiers at
|
||||
the top of the graph. This is a rename of the ^stext()^ option that
|
||||
appeared in some previous versions of metan7.
|
||||
^effect()^ may be used when the effect size and its standard error
|
||||
are declared. This allows the graph to name the summary statistic used
|
||||
|
||||
^nooverall^ prevents display of overall effect size on graph
|
||||
(automatically enforces the ^nowt^ option)
|
||||
^nowt^ prevents display of study weight on graph
|
||||
^nostats^ prevents display of study statistics on graph
|
||||
^counts^ displays data counts (n/N) for each group when using
|
||||
binary data
|
||||
|
||||
^group1()^, ^group2()^ can be used with the counts option: the text should
|
||||
contain the names of the two groups.
|
||||
|
||||
^xlabel()^ defines x-axis labels
|
||||
^xtick()^ adds tick marks to the x-axis
|
||||
|
||||
^force()^ forces the x-axis scale to be in the range specified
|
||||
by ^xlabel()^
|
||||
|
||||
^t1title(..)^, ^t2title(..)^, ^b1title(..)^, ^b2title(..)^
|
||||
adds titles to graph in the usual manner, but ^b1title(..)^ has an added
|
||||
feature. If the text starts with "*I:" and contains an asterisk, metan7
|
||||
interprets this as meaning the label declares something about the effect
|
||||
sizes. For example,
|
||||
|
||||
. ^metan7^ [varlist] ^, b1title(*I:^Favours treatment ^*^ Favours control^)^
|
||||
|
||||
displays a legend under the graph denoting that studies with effect sizes
|
||||
to the left of the graph (eg below odds ratios of less than 1) denote a
|
||||
beneficial treatment, whilst those finding effects to the right indicate
|
||||
a negative treatment effect.
|
||||
|
||||
^boxsha()^ controls box shading intensity, between 0 and 4. The default
|
||||
is 4, which produces a filled box
|
||||
^boxsca()^ controls box scaling, which by default is 1
|
||||
^nobox^ prevents a "weighted box" being drawn for each study, instead
|
||||
displaying effect sizes as identically sized circles
|
||||
^texts()^ specifies font size for text display on graph. The default
|
||||
size is 1
|
||||
|
||||
^saving(^filename^)^ saves the forest plot to the specified file
|
||||
|
||||
Note that for graphs on the log scale (that is, ORs or RRs), values
|
||||
outside the range [10e-8,10e8] are not displayed. A confidence interval
|
||||
which extends beyond this will have an arrow added at the end of the range;
|
||||
should the effect size and confidence interval be completely off this
|
||||
scale, they will be represented as a single (triangle-shaped) arrow.
|
||||
|
||||
By default, ^metan7^ adds the following new variables to the data set:
|
||||
|
||||
^_ES^ Effect size (ES)
|
||||
^_seES^ Standard error of ES
|
||||
or, when OR or RR are specfied:
|
||||
^_selogES^ the standard error of its logarithm
|
||||
^_LCI^ Lower confidence limit for ES
|
||||
^_UCI^ Upper confidence limit for ES
|
||||
^_WT^ Study percentage weight
|
||||
^_SS^ Study sample size
|
||||
|
||||
|
||||
Options for ^funnel^
|
||||
------------------
|
||||
|
||||
If the ^funnel^ command is invoked following ^metan7^ with no parameters
|
||||
specified it will produce a standard funnel plot of precision (1/SE)
|
||||
against treatment effect. Addition of the ^noinvert^ option will produce
|
||||
a plot of standard error against treatment effect. The alternative
|
||||
sample size version of the funnel plot can be obtained by using the
|
||||
^sample^ option (this automatically selects the ^noinvert^ option).
|
||||
Alternative plots can be created by specifying ^precision_var^ and
|
||||
^effect_size^. If the effect size is a relative risk or odds ratio,
|
||||
the ^xlog^ option should be used to create a symmetrical plot.
|
||||
|
||||
|
||||
All options for graph are valid. Additionally,
|
||||
|
||||
^sample^ denotes that the y-axis is the sample size and not a
|
||||
standard error
|
||||
^noinvert^ prevents the values of the precision variable from being
|
||||
inverted
|
||||
^ysqrt^ represent y-axis on square root scale
|
||||
^overall(^x^)^ draws a dashed vertical line at overall effect size given by x
|
||||
|
||||
|
||||
Options for ^labbe^
|
||||
-----------------
|
||||
|
||||
By default the size of the plotting symbol is proportional to the sample
|
||||
size of the study. If weight is specified the plotting size will be
|
||||
proportional to the weight variable.
|
||||
All options for graph are valid. Additionally, the following options may
|
||||
be used
|
||||
|
||||
^nowt^ declares that the plotted data points are to be the same size
|
||||
^percent^ display the event rates as percentages rather than proportions
|
||||
|
||||
^null^ draws a line corresponding to a null effect (ie p1=p2)
|
||||
^or(^x1^)^ draws a line corresponding to a fixed odds ratio of x1
|
||||
^rd(^x2^)^ draws a line corresponding to a fixed risk difference of x2
|
||||
^rr(^x3^)^ draws a line corresponding to a fixed risk ratio
|
||||
(for the event) of x3
|
||||
^rrn(^x4^)^ draws a line corresponding to a fixed risk ratio
|
||||
(for the non-event) of x4
|
||||
|
||||
The latter two may require explanation: whereas the OR and RD are
|
||||
invariant to the definition of which of the binary outcomes is the "event"
|
||||
and which is the "non-event", the RR is not. That is, whilst the command
|
||||
^metan7 a b c d , or^ gives the same result as ^metan7 b a d c , or^
|
||||
(with direction changed), an RR analysis does not. The L'Abbe plot allows
|
||||
the display of either or both be superimposed
|
||||
|
||||
^logit^ is for use when the ^or()^ option has been used; it displays the
|
||||
probabilities on the logit scale ie log(p/1-p). On the logit scale the
|
||||
odds ratio is a linear effect, and so this makes it easier to assess the
|
||||
"fit" of the line.
|
||||
|
||||
One note of caution: depending on the size of the studies, you may need to
|
||||
rescale the graph (by means of the ^psize()^ option)
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
. ^metan7 tdeath tnodeath cdeath cnodeath, or chi2 label(namevar=trialid)^
|
||||
. ^metan7 tdeath tnodeath cdeath cnodeath, rd random^
|
||||
. ^metan7 tdeath tnodeath cdeath cnodeath, olevel(99) ilevel(95)^ /*
|
||||
/* ^sortby(year) label(namevar=trialid, yearid=year) nostats nowt^
|
||||
|
||||
. ^metan7 n1 mean1 sd1 n2 mean2 sd2, by(trialtype)^ /*
|
||||
*/ ^b1(*I:Treatment reduces blood pressure * Treatment increases blood pressure)^
|
||||
|
||||
. ^gen logor = (a*d)/(b*c)^
|
||||
. ^gen selogor = sqrt( (1/a) + (1/b) + (1/c) + (1/d) )^
|
||||
. ^metan7 logor selogor , eform effect(Odds ratio) ^
|
||||
|
||||
. ^metan7 percentlowerci upperci , wgt(n_positives) b1(Sensitivity)^ /*
|
||||
*/ ^xlabel(0,20,40,60,80,100) nooverall^
|
||||
|
||||
|
||||
. ^local ovratio=r(ES)^
|
||||
. ^funnel , sample ysqrt xlabel(0.1,0.5,1,5,10) ylabel(0,500,1000)^ /*
|
||||
*/ ^overall(`ovratio')^
|
||||
. ^funnel or selogor, xlabel(0.1,0.5,1,5,10) ylabel(0,0.05,0.1) xlog^
|
||||
|
||||
. ^labbe tdeath tnodeath cdeath cnodeath, xlabel(0,0.25,0.5,0.75,1)^ /*
|
||||
*/ ^ylabel(0,0.25,0.5,0.75,1) rr(0.91) rd(-0.021) ^
|
||||
|
||||
. ^metan7 n1 m1 sd1 n2 m2 sd2, nostandard^
|
||||
. ^metan7 n1 m1 sd1 n2 m2 sd2, random xla(-2,-1,0,1,2) force saving(metagrph)^
|
||||
|
||||
|
||||
|
||||
|
||||
Authors
|
||||
-------
|
||||
|
||||
Michael J Bradburn, Jonathan J Deeks, Douglas G Altman.
|
||||
Centre for Statistics in Medicine, University of Oxford,
|
||||
Old Road Campus, Headington, Oxford OX3 7LF, UK.
|
||||
|
||||
email mike.bradburn@@cancer.org.uk
|
||||
|
||||
|
||||
References
|
||||
----------
|
||||
|
||||
Higgins JPT, Thompson SG (2002) Quantifying heterogeneity in a meta-analysis.
|
||||
Statistics in Medicine 21:1539-1558
|
||||
|
||||
|
||||
Also see
|
||||
--------
|
||||
|
||||
STB: STB-44 sbe24
|
||||
On-line: help for @meta@ (if installed), @metacum@ (if installed),
|
||||
@metareg@ (if installed), @metabias@ (if installed),
|
||||
@metatrim@ (if installed), @metainf@ (if installed),
|
||||
@galbr@ (if installed)
|
||||
|
191
Modules/ado/plus/m/metan_examples.ado
Normal file
191
Modules/ado/plus/m/metan_examples.ado
Normal file
@ -0,0 +1,191 @@
|
||||
program metan_examples
|
||||
version 9.0
|
||||
`1'
|
||||
end
|
||||
|
||||
program define metan_example_basic
|
||||
preserve
|
||||
di ""
|
||||
use http://fmwww.bc.edu/repec/bocode/m/metan_example_data.dta, clear
|
||||
di in wh ""
|
||||
di ". metan tdeath tnodeath cdeath cnodeath, rd random"
|
||||
di "> label(namevar=id, yearid=year) counts"
|
||||
|
||||
metan tdeath tnodeath cdeath cnodeath, rd random ///
|
||||
label(namevar=id, yearid=year) counts
|
||||
restore
|
||||
end
|
||||
|
||||
program define metan_example_cols
|
||||
preserve
|
||||
di ""
|
||||
use http://fmwww.bc.edu/repec/bocode/m/metan_example_data.dta, clear
|
||||
di in wh ""
|
||||
di ". metan tdeath tnodeath cdeath cnodeath,"
|
||||
di "> sortby(year) lcols(id year country) rcols(population)"
|
||||
di "> textsize(110) astext(60) double nostats nowt nohet notable"
|
||||
|
||||
metan tdeath tnodeath cdeath cnodeath, ///
|
||||
sortby(year) lcols(id year country) rcols(population) ///
|
||||
textsize(110) astext(60) double nostats nowt nohet notable
|
||||
restore
|
||||
end
|
||||
|
||||
program define metan_example_by
|
||||
preserve
|
||||
di ""
|
||||
use http://fmwww.bc.edu/repec/bocode/m/metan_example_data.dta, clear
|
||||
di in whi ""
|
||||
di ". metan tsample tmean tsd csample cmean csd,"
|
||||
di "> by(type_study) sgweight fixed second(random)"
|
||||
di "> rfdist counts label(namevar = id)"
|
||||
di "> favours(Treatment reduces blood pressure # Treatment increases blood pressure)"
|
||||
|
||||
metan tsample tmean tsd csample cmean csd, ///
|
||||
by(type_study) sgweight fixed second(random) ///
|
||||
rfdist counts label(namevar = id) ///
|
||||
favours(Treatment reduces blood pressure # Treatment increases blood pressure)
|
||||
restore
|
||||
end
|
||||
|
||||
program metan_example_2param
|
||||
preserve
|
||||
di ""
|
||||
use http://fmwww.bc.edu/repec/bocode/m/metan_example_data.dta, clear
|
||||
di in whi ""
|
||||
di ""
|
||||
di ". gen logor = ln( (tdeath*cnodeath)/(tnodeath*cdeath) ) )"
|
||||
di ""
|
||||
di ". gen selogor = sqrt( (1/tdeath) + (1/tnodeath) + (1/cdeath) + (1/cnodeath) )"
|
||||
di ""
|
||||
di ". metan logor selogor, eform xlabel(0.5, 1, 1.5, 2, 2.5)"
|
||||
di "> force xtick(0.75, 1.25, 1.75, 2.25) effect(Odds ratio)"
|
||||
|
||||
gen logor = ln( (tdeath*cnodeath)/(tnodeath*cdeath) )
|
||||
gen selogor = sqrt( (1/tdeath) + (1/tnodeath) + (1/cdeath) + (1/cnodeath) )
|
||||
metan logor selogor, eform xlabel(0.5, 1, 1.5, 2, 2.5) ///
|
||||
force xtick(0.75, 1.25, 1.75, 2.25) effect(Odds ratio)
|
||||
restore
|
||||
end
|
||||
|
||||
program define metan_example_diag
|
||||
preserve
|
||||
di ""
|
||||
use http://fmwww.bc.edu/repec/bocode/m/metan_example_data.dta, clear
|
||||
di in whi ""
|
||||
di ". metan percent lowerci upperci, wgt(n_positives)"
|
||||
di "> xlabel(0,10,20,30,40,50,60,70,80,90,100) force"
|
||||
di "> null(50) label(namevar=id) nooverall notable"
|
||||
di "> title(Sensitivity, position(6))"
|
||||
di in gr ""
|
||||
|
||||
metan percent lowerci upperci, wgt(n_positives) ///
|
||||
xlabel(0,10,20,30,40,50,60,70,80,90,100) force ///
|
||||
null(50) label(namevar=id) nooverall notable ///
|
||||
title(Sensitivity, position(6))
|
||||
restore
|
||||
end
|
||||
|
||||
program define metan_example_user
|
||||
preserve
|
||||
di ""
|
||||
use http://fmwww.bc.edu/repec/bocode/m/metan_example_data.dta, clear
|
||||
di in whi ""
|
||||
di ". metan OR ORlci ORuci, wgt(bweight)"
|
||||
di "> first(0.924 0.753 1.095 Bayesian)"
|
||||
di "> firststats(param V=3.86, p=0.012)"
|
||||
di "> label(namevar=id)"
|
||||
di "> xlabel(0.25, 0.5, 1, 2, 4) force"
|
||||
di "> null(1) aspect(1.2) scheme(economist)"
|
||||
|
||||
metan OR ORlci ORuci, wgt(bweight) ///
|
||||
first(0.924 0.753 1.095 Bayesian) ///
|
||||
firststats(param V=3.86, p=0.012) ///
|
||||
label(namevar=id) ///
|
||||
xlabel(0.25, 0.5, 1, 2, 4) force ///
|
||||
null(1) aspect(1.2) scheme(economist)
|
||||
restore
|
||||
end
|
||||
|
||||
program define metan_example_custom
|
||||
preserve
|
||||
di ""
|
||||
use http://fmwww.bc.edu/repec/bocode/m/metan_example_data.dta, clear
|
||||
di in whi ""
|
||||
di ""
|
||||
di `". gen counts = ". " + string(tdeath) + "/" + string(tdeath+tnodeath)"'
|
||||
di `"> + ", " + string(cdeath) + "/" + string(cdeath+cnodeath)"'
|
||||
di ""
|
||||
di ". metan tdeath tnodeath cdeath cnodeath,"
|
||||
di "> lcols(id year) notable"
|
||||
di "> boxopt( mcolor(forest_green) msymbol(triangle) )"
|
||||
di "> pointopt( msymbol(triangle) mcolor(gold) msize(tiny)"
|
||||
di "> mlabel(counts) mlabsize(vsmall) mlabcolor(forest_green) mlabposition(1) )"
|
||||
di "> ciopt( lcolor(sienna) lwidth(medium) )"
|
||||
|
||||
gen counts = ". " + string(tdeath) + "/" + string(tdeath+tnodeath) ///
|
||||
+ ", " + string(cdeath) + "/" + string(cdeath+cnodeath)
|
||||
metan tdeath tnodeath cdeath cnodeath, ///
|
||||
lcols(id year) notable ///
|
||||
boxopt( mcolor(forest_green) msymbol(triangle) ) ///
|
||||
pointopt( msymbol(triangle) mcolor(gold) msize(tiny) ///
|
||||
mlabel(counts) mlabsize(vsmall) mlabcolor(forest_green) mlabposition(1) ) ///
|
||||
ciopt( lcolor(sienna) lwidth(medium) )
|
||||
restore
|
||||
end
|
||||
|
||||
program define funnel_example_immed
|
||||
preserve
|
||||
di ""
|
||||
use http://fmwww.bc.edu/repec/bocode/m/metan_example_data.dta, clear
|
||||
di in whi ""
|
||||
di ". metan tdeath tnodeath cdeath cnodeath, nograph notable"
|
||||
di ""
|
||||
di ". local ovratio=r(ES)"
|
||||
di ""
|
||||
di ". funnel, sample ysqrt xlabel(0.1,0.5,1,5,10)"
|
||||
di "> ylabel(0,500,1000) overall(`ovratio')"
|
||||
|
||||
metan tdeath tnodeath cdeath cnodeath, nograph notable
|
||||
local ovratio=r(ES)
|
||||
funnel, sample ysqrt xlabel(0.1,0.5,1,5,10) ///
|
||||
ylabel(0,500,1000) overall(`ovratio')
|
||||
restore
|
||||
end
|
||||
|
||||
program define funnel_example_param
|
||||
preserve
|
||||
di ""
|
||||
use http://fmwww.bc.edu/repec/bocode/m/metan_example_data.dta, clear
|
||||
di in whi ""
|
||||
di ". gen logor = ln( (tdeath*cnodeath)/(tnodeath*cdeath) ) )"
|
||||
di ""
|
||||
di ". gen selogor = sqrt( (1/tdeath) + (1/tnodeath) + (1/cdeath) + (1/cnodeath) )"
|
||||
di ""
|
||||
di ". funnel OR selogor, xlabel(0.1,0.5,1,5,10)"
|
||||
di "> ylabel(0,1,2,3,4,5) xlog"
|
||||
|
||||
gen logor = ln( (tdeath*cnodeath)/(tnodeath*cdeath) )
|
||||
gen selogor = sqrt( (1/tdeath) + (1/tnodeath) + (1/cdeath) + (1/cnodeath) )
|
||||
funnel OR selogor, xlabel(0.1,0.5,1,5,10) ///
|
||||
ylabel(0,1,2,3,4,5) xlog
|
||||
restore
|
||||
end
|
||||
|
||||
program define labbe_example
|
||||
preserve
|
||||
di ""
|
||||
use http://fmwww.bc.edu/repec/bocode/m/metan_example_data.dta, clear
|
||||
di in whi ""
|
||||
di ". labbe tdeath tnodeath cdeath cnodeath,"
|
||||
di "> xlabel(0,0.25,0.5,0.75,1) ylabel(0,0.25,0.5,0.75,1)"
|
||||
di "> rr(1.029) rd(0.014) null"
|
||||
|
||||
labbe tdeath tnodeath cdeath cnodeath, ///
|
||||
xlabel(0,0.25,0.5,0.75,1) ylabel(0,0.25,0.5,0.75,1) ///
|
||||
rr(1.029) rd(0.014) null
|
||||
restore
|
||||
end
|
||||
|
||||
|
||||
|
166
Modules/ado/plus/m/metaninf.ado
Normal file
166
Modules/ado/plus/m/metaninf.ado
Normal file
@ -0,0 +1,166 @@
|
||||
*! 1.0.2 TJS 29 Feb 2004 Saves jackknived estimates
|
||||
* 1.0.1 TJS 20 Jul 2001
|
||||
* 1.0.0 TJS 22 May 2001
|
||||
*! based on: metainf 3.0.0 AT Mar 2000 (STB-56: sbe26.1)
|
||||
|
||||
program define metaninf
|
||||
version 6.0
|
||||
syntax varlist(min=2 max=6 numeric) [if] [in] [, id(varname) noGRAPH /*
|
||||
*/ LABEL(string) SAVe(string) t1(str) t2(str) Format(str) noTABLE `options' *]
|
||||
tokenize `varlist'
|
||||
|
||||
* preserve
|
||||
|
||||
local est = "`1'"
|
||||
|
||||
if "`label'" != "" {
|
||||
parse "`label'", parse("=,")
|
||||
while "`1'" != "" {
|
||||
cap confirm var `3'
|
||||
if _rc != 0 {
|
||||
di in re "Variable `3' not defined"
|
||||
exit _rc
|
||||
}
|
||||
local `1' "`3'"
|
||||
mac shift 4
|
||||
}
|
||||
}
|
||||
tempvar code
|
||||
qui {
|
||||
if "`namevar'" != "" {
|
||||
local lbnvl : value label `namevar'
|
||||
if "`lbnvl'" != "" { quietly decode `namevar', gen(`code') }
|
||||
else {
|
||||
gen str10 `code' = ""
|
||||
cap confirm string variable `namevar'
|
||||
if _rc == 0 { replace `code' = `namevar' }
|
||||
else if _rc == 7 { replace `code' = string(`namevar') }
|
||||
}
|
||||
}
|
||||
else { gen str3 `code' = string(_n) }
|
||||
if "`yearvar'" != "" {
|
||||
local yearvar "`yearvar'"
|
||||
cap confirm string variable `yearvar'
|
||||
if _rc == 7 { local str "string" }
|
||||
if "`namevar'" == "" { replace `code' = `str'(`yearvar') }
|
||||
else { replace `code' = `code' + " (" + `str'(`yearvar') + ")" }
|
||||
}
|
||||
}
|
||||
local id "`code'"
|
||||
|
||||
preserve
|
||||
|
||||
|
||||
* Dealing with if and in options
|
||||
if ("`if'" != "") { qui keep `if' }
|
||||
if ("`in'" != "") { qui keep `in' }
|
||||
if _N <= 1 { error 2001 }
|
||||
|
||||
* Overall estimates
|
||||
tempvar so
|
||||
qui gen `so' = _n
|
||||
qui metan `varlist', nograph `options'
|
||||
local ove = $S_1
|
||||
local ll = $S_3
|
||||
local ul = $S_4
|
||||
sort `so'
|
||||
|
||||
* Meta-analysis estimate omiting one study each step
|
||||
tempvar theta setheta ulth llth
|
||||
qui sum `1', detail
|
||||
local n = _result(1)
|
||||
qui {
|
||||
gen `theta' = .
|
||||
gen `setheta' = .
|
||||
gen `ulth' = .
|
||||
gen `llth' = .
|
||||
label var `theta' "Estimate"
|
||||
label var `llth' "Lower CI Limit"
|
||||
label var `ulth' "Upper CI Limit"
|
||||
}
|
||||
|
||||
local i = 1
|
||||
tempvar s
|
||||
qui gen `s' = _n
|
||||
while (`i' <= `n') {
|
||||
qui {
|
||||
metan `varlist' if `s' != `i', `options' nograph
|
||||
sort `so'
|
||||
replace `theta' = $S_1 in `i'
|
||||
replace `llth' = $S_3 in `i'
|
||||
replace `ulth' = $S_4 in `i'
|
||||
}
|
||||
local i = `i' + 1
|
||||
}
|
||||
|
||||
* Maximum and minimum CI values
|
||||
qui sum `llth', detail
|
||||
local mnx = r(min)
|
||||
qui sum `ulth', detail
|
||||
local mxx = r(max)
|
||||
|
||||
* Labeling plot
|
||||
if "`t2'" == "" { local t2 `""' }
|
||||
if "`t1'" == "" { local t1 "Meta-analysis estimates, given named study is omitted" }
|
||||
|
||||
* Numeric format
|
||||
if "`format'" == "" { local format "%5.2f" }
|
||||
|
||||
* Print option
|
||||
if "`table'" != "notable" {
|
||||
di
|
||||
di in gr "------------------------------------------------------------------------------"
|
||||
di in gr _col(2) "Study omitted" _col(20) "|" _col(24) "Estimate" _col(39) "[95% Conf. Interval]"
|
||||
di in gr "-------------------+----------------------------------------------------------"
|
||||
local i = 1
|
||||
while `i' <= `n' {
|
||||
if "`id'" == "" { local a = `s' in `i' }
|
||||
else { local a = `id' in `i' }
|
||||
local b = `theta' in `i'
|
||||
local c = `llth' in `i'
|
||||
local d = `ulth' in `i'
|
||||
di _col(2) "`a'" _col(20) in gr "|" in ye _col(24) `b' _col(39) `c' _col(52) `d'
|
||||
local i=`i'+1
|
||||
}
|
||||
di in gr "-------------------+----------------------------------------------------------"
|
||||
di _col(2) "Combined" _col(20) in gr "|" in ye _col(24) `ove' _col(39) `ll' _col(52) `ul'
|
||||
di in gr "------------------------------------------------------------------------------"
|
||||
}
|
||||
|
||||
* Display plot
|
||||
if "`graph'" != "nograph" {
|
||||
mhplot `llth' `theta' `ulth', r sy(|o|) l("`id'") t1(`t1') t2(`t2') /*
|
||||
*/ f(`format') xline(`ove',`ll',`ul') xlab(`mnx',`ove',`ll',`ul',`mxx') /*
|
||||
*/ xti(`ove',`ll',`ul') xscale(`mnx',`mxx')
|
||||
}
|
||||
|
||||
if "`save'" != "" {
|
||||
local c = index("`save'",",")
|
||||
if `c' != 0 {
|
||||
local save = substr("`save'",1,`c'-1) + " " + substr("`save'",`c'+1, .)
|
||||
}
|
||||
local save1 : word 1 of `save'
|
||||
local replace : word 2 of `save'
|
||||
if "`replace'" == "replace" {
|
||||
capture drop `save1'
|
||||
}
|
||||
capture confirm new var `save1'
|
||||
if _rc {
|
||||
local rc = _rc
|
||||
di in re "`save1' exists. Use 'replace' option: save(save_var, replace)."
|
||||
exit `rc'
|
||||
}
|
||||
qui {
|
||||
gen `save1' = `theta'
|
||||
sort `id'
|
||||
tempfile saved
|
||||
save `saved'
|
||||
restore
|
||||
sort `id'
|
||||
merge `id' using `saved', keep(`save1') update replace nokeep
|
||||
drop if _merge==2
|
||||
drop _merge
|
||||
}
|
||||
label var `save1' "jackknifed `est' (metaninf)"
|
||||
|
||||
end
|
377
Modules/ado/plus/m/metaninf.dlg
Normal file
377
Modules/ado/plus/m/metaninf.dlg
Normal file
@ -0,0 +1,377 @@
|
||||
/*
|
||||
|
||||
*! metaninf dialog version 1.0.2, 29 Feb 2004, T. J. Steichen, steichen@triad.rr.com
|
||||
*! for metaninf version 1.0.2, 29 Feb 2004, T. J. Steichen, steichen@triad.rr.com
|
||||
|
||||
Influence of a single study in meta-analysis estimation
|
||||
-------------------------------------------------------
|
||||
|
||||
Syntax: metaninf varlist [if exp] [in range] [, fixed fixedi random randomi
|
||||
rr or rd peto cornfield hedges cohen glass nostandard
|
||||
label(namevar=namevar[, yearvar=yearvar])
|
||||
ilevel(#) olevel(#) notable nograph save(varname [, replace]) ]
|
||||
|
||||
Install in User Statistics menu via Stata commands:
|
||||
. window menu append item "stUserStatistics" "metan&inf (Metan-based Influence Analysis)" "db metaninf"
|
||||
. window menu refresh
|
||||
To permanently install, place the commands in your -profile.do- file.
|
||||
*/
|
||||
|
||||
VERSION 8.0
|
||||
|
||||
INCLUDE _std_small
|
||||
INCLUDE _ht240
|
||||
INCLUDE header
|
||||
|
||||
HELP hlp1, view("help metaninf")
|
||||
RESET res1, label("Reset")
|
||||
|
||||
DIALOG main, label("metaninf 1.0.2 - Metan-based Influence Analysis") tabtitle("Main")
|
||||
BEGIN
|
||||
GROUPBOX gb_data 10 5 330 _ht1h, ///
|
||||
label("Type of Data:")
|
||||
RADIO r_binary 15 25 100 ., ///
|
||||
label("Binary Count") first ///
|
||||
onclickon(script main_binary_on) ///
|
||||
onclickoff(script main_binary_off)
|
||||
RADIO r_continuous 125 25 100 ., ///
|
||||
label("Continuous") middle ///
|
||||
onclickon(script main_continuous_on) ///
|
||||
onclickoff(script main_continuous_off)
|
||||
RADIO r_effect 235 25 100 ., ///
|
||||
label("Effect Size") last ///
|
||||
onclickon(script main_effect_on) ///
|
||||
onclickoff(script main_effect_off)
|
||||
|
||||
TEXT tx_binary 10 50 _iwd ., ///
|
||||
label("Vars for Counts a, b, c, d, in that order")
|
||||
VARLIST vl_binary @ _ss @ ., ///
|
||||
label("Vars for a, b, c, d")
|
||||
|
||||
TEXT tx_contin_exp @ 50 _iwd ., ///
|
||||
label("Vars for Experimental Group: n, mean, sd, in that order")
|
||||
VARLIST vl_contin_exp @ _ss @ ., ///
|
||||
label("Experimental Group: n, mean, sd")
|
||||
TEXT tx_contin_ctl @ _ss _iwd ., ///
|
||||
label("Vars for Control Group: n, mean, sd, in that order")
|
||||
VARLIST vl_contin_ctl @ _ss @ ., ///
|
||||
label("Control Group: n, mean, sd")
|
||||
|
||||
TEXT tx_effect @ 50 _iwd ., ///
|
||||
label("Vars for Effect Sizes: theta, se(theta), in that order")
|
||||
VARLIST vl_effect @ _ss @ ., ///
|
||||
label("Effect Sizes: theta, se(theta)")
|
||||
|
||||
GROUPBOX gb_labels 10 130 330 _ht3h, ///
|
||||
label("Labels for Data:")
|
||||
CHECKBOX cb_name 20 150 70 ., ///
|
||||
label("Name:") ///
|
||||
onclickon(main.vn_name.enable) ///
|
||||
onclickoff(main.vn_name.disable) ///
|
||||
option("id")
|
||||
VARNAME vn_name 100 150 230 ., ///
|
||||
label("Name Variable")
|
||||
CHECKBOX cb_year 20 170 70 ., ///
|
||||
label("Year:") ///
|
||||
onclickon(main.vn_year.enable) ///
|
||||
onclickoff(main.vn_year.disable) ///
|
||||
option("id")
|
||||
VARNAME vn_year 100 170 230 ., ///
|
||||
label("Year Variable")
|
||||
|
||||
CHECKBOX cb_save_jk 10 200 330 ., ///
|
||||
label("Save jack-knived estimates: varname [, replace]") ///
|
||||
onclickon(main.vn_save_jk.enable) ///
|
||||
onclickoff(main.vn_save_jk.disable)
|
||||
VARNAME vn_save_jk 10 220 330 ., ///
|
||||
label("Save estimates Variable") ///
|
||||
option("save")
|
||||
|
||||
END
|
||||
|
||||
DIALOG metan_b, tabtitle("Binary Opts")
|
||||
BEGIN
|
||||
GROUPBOX gb_pool 0 10 210 _ht9h, ///
|
||||
label("Pooling Model")
|
||||
RADIO r_fixed 10 30 190 ., ///
|
||||
label("Fixed, Mantel Haenzel") first ///
|
||||
option("fixed")
|
||||
RADIO r_fixedi @ _ss @ ., ///
|
||||
label("Fixed, Inverse Variance") middle ///
|
||||
option("fixedi")
|
||||
RADIO r_random @ _ss @ ., ///
|
||||
label("Random, Mantel Haenzel") middle ///
|
||||
option("random")
|
||||
RADIO r_randomi @ _ss @ ., ///
|
||||
label("Random, Inverse Variance") middle ///
|
||||
option("randomi")
|
||||
RADIO r_peto @ _ss @ ., ///
|
||||
label("Peto") last ///
|
||||
option("peto")
|
||||
|
||||
GROUPBOX gb_stat 220 10 120 _ht5h, ///
|
||||
label("Statistic")
|
||||
RADIO r_rr 230 30 80 ., ///
|
||||
label("RR") first ///
|
||||
option("rr")
|
||||
RADIO r_or @ _ss @ ., ///
|
||||
label("OR") middle ///
|
||||
onclickon(script metan_b_or_on) ///
|
||||
onclickoff(script metan_b_or_off) ///
|
||||
option("or")
|
||||
RADIO r_rd @ _ss @ ., ///
|
||||
label("RD") last ///
|
||||
option("rd")
|
||||
|
||||
CHECKBOX cb_cornfield 10 140 200 ., ///
|
||||
label("Use Cornfield CI's") ///
|
||||
option("cornfield")
|
||||
CHECKBOX cb_chi2 10 160 200 ., ///
|
||||
label("Use Chi-2 Statistic") ///
|
||||
option("chi2")
|
||||
CHECKBOX cb_breslow 10 180 200 ., ///
|
||||
label("Use Breslow-Day test") ///
|
||||
option("breslow")
|
||||
|
||||
CHECKBOX cb_notable 230 140 200 ., ///
|
||||
label("noTable") ///
|
||||
option("notable")
|
||||
CHECKBOX cb_nograph 230 160 200 ., ///
|
||||
label("noGraph") ///
|
||||
option("nograph")
|
||||
END
|
||||
|
||||
DIALOG metan_c, tabtitle("Contin. Opts")
|
||||
BEGIN
|
||||
GROUPBOX gb_pool 0 10 210 _ht3h, ///
|
||||
label("Pooling Model")
|
||||
RADIO r_fixed 10 30 190 ., ///
|
||||
label("Fixed, Inverse Variance") first ///
|
||||
option("fixed")
|
||||
RADIO r_random @ _ss @ ., ///
|
||||
label("Random, Inverse Variance") last ///
|
||||
option("random")
|
||||
|
||||
GROUPBOX gb_stat 220 10 120 _ht7h, ///
|
||||
label("Statistic")
|
||||
RADIO r_cohen 230 30 100 ., ///
|
||||
label("Cohen") first ///
|
||||
option("cohen")
|
||||
RADIO r_hedges @ _ss @ ., ///
|
||||
label("Hedges") middle ///
|
||||
option("hedges")
|
||||
RADIO r_glass @ _ss @ ., ///
|
||||
label("Glass") middle ///
|
||||
option("glass")
|
||||
RADIO r_nostandard @ _ss @ ., ///
|
||||
label("noStandard") last ///
|
||||
option("nostandard")
|
||||
|
||||
CHECKBOX cb_notable 230 140 200 ., ///
|
||||
label("noTable") ///
|
||||
option("notable")
|
||||
CHECKBOX cb_nograph 230 160 200 ., ///
|
||||
label("noGraph") ///
|
||||
option("nograph")
|
||||
END
|
||||
|
||||
DIALOG metan_e, tabtitle("Effect Opts")
|
||||
BEGIN
|
||||
GROUPBOX gb_pool 0 10 210 _ht3h, ///
|
||||
label("Pooling Model")
|
||||
RADIO r_fixed 10 30 190 ., ///
|
||||
label("Fixed, Inverse Variance") first ///
|
||||
option("fixed")
|
||||
RADIO r_random @ _ss @ ., ///
|
||||
label("Random, Inverse Variance") last ///
|
||||
option("random")
|
||||
/*
|
||||
GROUPBOX gb_stat 220 10 120 _ht5h, ///
|
||||
label("Statistic")
|
||||
RADIO r_rr 230 30 80 ., ///
|
||||
label("RR") first ///
|
||||
option("rr")
|
||||
RADIO r_or @ _ss @ ., ///
|
||||
label("OR") middle ///
|
||||
option("or")
|
||||
RADIO r_rd @ _ss @ ., ///
|
||||
label("RD") last ///
|
||||
option("rd")
|
||||
*/
|
||||
|
||||
CHECKBOX cb_notable 230 140 200 ., ///
|
||||
label("noTable") ///
|
||||
option("notable")
|
||||
CHECKBOX cb_nograph 230 160 200 ., ///
|
||||
label("noGraph") ///
|
||||
option("nograph")
|
||||
END
|
||||
|
||||
INCLUDE ifin
|
||||
|
||||
SCRIPT main_binary_on
|
||||
BEGIN
|
||||
main.tx_binary.show
|
||||
main.vl_binary.show
|
||||
main.tx_binary.enable
|
||||
main.vl_binary.enable
|
||||
|
||||
main.tx_effect.disable
|
||||
main.vl_effect.disable
|
||||
main.tx_effect.hide
|
||||
main.vl_effect.hide
|
||||
|
||||
main.tx_contin_exp.disable
|
||||
main.vl_contin_exp.disable
|
||||
main.tx_contin_exp.hide
|
||||
main.vl_contin_exp.hide
|
||||
|
||||
main.tx_contin_ctl.disable
|
||||
main.vl_contin_ctl.disable
|
||||
main.tx_contin_ctl.hide
|
||||
main.vl_contin_ctl.hide
|
||||
|
||||
END
|
||||
|
||||
SCRIPT main_binary_off
|
||||
BEGIN
|
||||
main.tx_binary.disable
|
||||
main.vl_binary.disable
|
||||
main.tx_binary.hide
|
||||
main.vl_binary.hide
|
||||
END
|
||||
|
||||
SCRIPT main_continuous_on
|
||||
BEGIN
|
||||
main.tx_contin_exp.show
|
||||
main.vl_contin_exp.show
|
||||
main.tx_contin_exp.enable
|
||||
main.vl_contin_exp.enable
|
||||
|
||||
main.tx_contin_ctl.show
|
||||
main.vl_contin_ctl.show
|
||||
main.tx_contin_ctl.enable
|
||||
main.vl_contin_ctl.enable
|
||||
|
||||
main.tx_binary.disable
|
||||
main.vl_binary.disable
|
||||
main.tx_binary.hide
|
||||
main.vl_binary.hide
|
||||
|
||||
main.tx_effect.disable
|
||||
main.vl_effect.disable
|
||||
main.tx_effect.hide
|
||||
main.vl_effect.hide
|
||||
END
|
||||
|
||||
SCRIPT main_continuous_off
|
||||
BEGIN
|
||||
main.tx_contin_exp.disable
|
||||
main.vl_contin_exp.disable
|
||||
main.tx_contin_exp.hide
|
||||
main.vl_contin_exp.hide
|
||||
|
||||
main.tx_contin_ctl.disable
|
||||
main.vl_contin_ctl.disable
|
||||
main.tx_contin_ctl.hide
|
||||
main.vl_contin_ctl.hide
|
||||
END
|
||||
|
||||
SCRIPT main_effect_on
|
||||
BEGIN
|
||||
main.tx_effect.show
|
||||
main.vl_effect.show
|
||||
main.tx_effect.enable
|
||||
main.vl_effect.enable
|
||||
|
||||
main.tx_binary.disable
|
||||
main.vl_binary.disable
|
||||
main.tx_binary.hide
|
||||
main.vl_binary.hide
|
||||
|
||||
main.tx_contin_exp.disable
|
||||
main.vl_contin_exp.disable
|
||||
main.tx_contin_exp.hide
|
||||
main.vl_contin_exp.hide
|
||||
|
||||
main.tx_contin_ctl.disable
|
||||
main.vl_contin_ctl.disable
|
||||
main.tx_contin_ctl.hide
|
||||
main.vl_contin_ctl.hide
|
||||
END
|
||||
|
||||
SCRIPT main_effect_off
|
||||
BEGIN
|
||||
main.tx_effect.disable
|
||||
main.vl_effect.disable
|
||||
main.tx_effect.hide
|
||||
main.vl_effect.hide
|
||||
END
|
||||
|
||||
SCRIPT metan_b_or_on
|
||||
BEGIN
|
||||
metan_b.r_peto.enable
|
||||
metan_b.cb_cornfield.enable
|
||||
metan_b.cb_chi2.enable
|
||||
metan_b.cb_breslow.enable
|
||||
END
|
||||
|
||||
SCRIPT metan_b_or_off
|
||||
BEGIN
|
||||
metan_b.r_peto.disable
|
||||
metan_b.cb_cornfield.disable
|
||||
metan_b.cb_chi2.disable
|
||||
metan_b.cb_breslow.disable
|
||||
END
|
||||
|
||||
PROGRAM command
|
||||
BEGIN
|
||||
put "metaninf "
|
||||
if main.r_binary {
|
||||
varlist main.vl_binary
|
||||
}
|
||||
if main.r_continuous {
|
||||
varlist main.vl_contin_exp main.vl_contin_ctl
|
||||
}
|
||||
if main.r_effect {
|
||||
varlist main.vl_effect
|
||||
}
|
||||
INCLUDE _ifin_pr
|
||||
beginoptions
|
||||
if main.cb_name | main.cb_year {
|
||||
put "label("
|
||||
if main.cb_name {
|
||||
put "namevar=" main.vn_name
|
||||
}
|
||||
if main.cb_name & main.cb_year {
|
||||
put ", "
|
||||
}
|
||||
if main.cb_year {
|
||||
put "yearvar=" main.vn_year
|
||||
}
|
||||
put ") "
|
||||
}
|
||||
if main.r_binary {
|
||||
option radio(metan_b r_fixed r_fixedi r_random r_randomi)
|
||||
option radio(metan_b r_rr r_or r_rd)
|
||||
option metan_b.cb_cornfield
|
||||
option metan_b.cb_chi2
|
||||
option metan_b.cb_breslow
|
||||
option metan_b.cb_nograph
|
||||
option metan_b.cb_notable
|
||||
}
|
||||
if main.r_continuous {
|
||||
option radio(metan_c r_fixed r_random)
|
||||
option radio(metan_c r_cohen r_hedges r_glass r_nostandard)
|
||||
option metan_c.cb_nograph
|
||||
option metan_c.cb_notable
|
||||
}
|
||||
if main.r_effect {
|
||||
option radio(metan_e r_fixed r_random)
|
||||
/* option radio(metan_e r_rr r_or r_rd) */
|
||||
option metan_e.cb_nograph
|
||||
option metan_e.cb_notable
|
||||
}
|
||||
optionarg main.vn_save_jk
|
||||
endoptions
|
||||
END
|
174
Modules/ado/plus/m/metaninf.hlp
Normal file
174
Modules/ado/plus/m/metaninf.hlp
Normal file
@ -0,0 +1,174 @@
|
||||
.-
|
||||
help for ^metaninf^ version 1.0.2
|
||||
.-
|
||||
|
||||
Influence of a single study in meta-analysis estimation
|
||||
-------------------------------------------------------
|
||||
|
||||
^metaninf^ varlist [^if^ exp] [^in^ range] [, ^fixed fixedi random randomi^
|
||||
^rr or rd peto cornfield hedges cohen glass nosta^ndard
|
||||
^label(^label_vars^) il^evel^(^#^) ol^evel^(^#^) notable nograph^
|
||||
^sav^e^(^varname [^, replace^]^)^ ]
|
||||
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
^metaninf^ investigates the influence of each individual study on the overall
|
||||
meta-analysis summary estimate. The command presents a table and a graph of
|
||||
the results of an influence analysis in which the meta-analysis is reestimated
|
||||
omitting each study in turn.
|
||||
|
||||
The table numerically provides the results, with the rows of the table being
|
||||
the meta-analysis of all studies except the "omitted" study named in that row,
|
||||
and the usual, full meta-analysis (omitting none of the studies) being given
|
||||
as the "combined" results at the bottom of the table.
|
||||
|
||||
The graph visually provides the same results in a plot, naming the omitted
|
||||
study on the left margin and presenting the resulting "omitted" meta-analytic
|
||||
summary statistics as a horizontal confidence interval. The full, "combined"
|
||||
results are shown as the solid vertical lines.
|
||||
|
||||
No formal test of influence is given; rather, the program provides and displays
|
||||
results to which some general guidelines can be applied to assess influence.
|
||||
One such guideline is that an individual study is suspected of excessive
|
||||
influence if the point estimate of its "omitted" analysis lies outside the
|
||||
confidence interval of the "combined" analysis. Another quideline is that a
|
||||
study is excessively influential if its "omitted" meta-analytic estimate
|
||||
differs in significance relative to the "combined" analysis. Neither of these
|
||||
quidelines provides definitive proof that such a study should, or should not,
|
||||
be removed from the analysis; they merely provide a suggestion that some
|
||||
attention be paid to potential reasons for its influence.
|
||||
|
||||
^metaninf^ uses program ^metan^ as its meta-analysis engine and its options are
|
||||
a direct subset of ^metan^'s. It is expected that users will merely edit a ^metan^
|
||||
command line by adding the "inf" suffix to the program name to run ^metaninf^.
|
||||
|
||||
Like ^metan^, ^metaninf^ requires either four or six variables to be declared.
|
||||
When four variables are specified, analysis of binary data is performed.
|
||||
When six variables are specified, the data are assumed continuous.
|
||||
|
||||
Binary data is presented as the 4 cell counts (a b c d) of a 2x2 table where
|
||||
a and b are the number of event & no-event subjects in the intervention group
|
||||
and c and d are similar numbers for the control group.
|
||||
|
||||
. ^metaninf a b c d^
|
||||
|
||||
Continuous data is presented as 6 values: the n, mean and sd for the treatment
|
||||
(or intervention) group followed by similar values for the control group.
|
||||
|
||||
. ^metaninf nt mt sdt nc mc sdc^
|
||||
|
||||
|
||||
Options
|
||||
-------
|
||||
|
||||
Scaling and pooling options
|
||||
---------------------------
|
||||
|
||||
Options for binary data
|
||||
|
||||
^rr^ pools risk ratios (the default).
|
||||
|
||||
^or^ pools odds ratios.
|
||||
|
||||
^rd^ pools risk differences.
|
||||
|
||||
^fixed^ specifies a fixed effect model using the method of Mantel & Haenszel
|
||||
(the default).
|
||||
|
||||
^fixedi^ specifies a fixed effect model using the inverse variance method.
|
||||
|
||||
^peto^ specifies that Peto's assumption free method is used to pool odds
|
||||
ratios.
|
||||
|
||||
^random^ specifies a random effects model using the method of DerSimonian &
|
||||
Laird, with the estimate of heterogeneity being taken from the
|
||||
Mantel-Haenszel model.
|
||||
|
||||
^randomi^ specifies a random effects model using the method of DerSimonian &
|
||||
Laird, with the estimate of heterogeneity being taken from the inverse
|
||||
variance fixed effect model.
|
||||
|
||||
^cornfield^ computes confidence intervals for odds ratios by the method of
|
||||
Cornfield, rather than the (default) Woolf method.
|
||||
|
||||
|
||||
Options for continuous data
|
||||
|
||||
^cohen^ pools standardized mean differences by the method of Cohen
|
||||
(the default).
|
||||
|
||||
^hedges^ pools standardized mean differences by the method of Hedges.
|
||||
|
||||
^glass^ pools standardized mean differences by the method of Glass.
|
||||
|
||||
^nostandard^ pools unstandardized mean differences.
|
||||
|
||||
^fixed^ specifies a fixed effect model using the inverse variance method
|
||||
(the default).
|
||||
|
||||
^random^ specifies a random effects model using the DerSimonian & Laird
|
||||
method.
|
||||
|
||||
|
||||
General output options
|
||||
----------------------
|
||||
|
||||
^label(^[^namevar^=namevar] [^, yearvar^=yearvar]^)^
|
||||
labels the data by its name, year or both. However, neither option
|
||||
is required. For the table display the overall length of the label is
|
||||
restricted to 16 characters.
|
||||
|
||||
^ilevel()^ specifies the significance level (eg 90,95,99) for the
|
||||
individual trial confidence intervals.
|
||||
|
||||
^olevel()^ specifies the significance level (eg 90,95,99) for the
|
||||
overall (pooled) confidence intervals.
|
||||
|
||||
^ilevel^ and ^olevel^ need not be the same, and by default are equal
|
||||
to the significance level specified using the ^set level^ command.
|
||||
|
||||
^notable^ prevents display of the table of results.
|
||||
|
||||
^nograph^ prevents display of the graph.
|
||||
|
||||
^save(^varname [^, replace^]^)^ saves the jackknifed estimates.
|
||||
|
||||
|
||||
Note
|
||||
----
|
||||
|
||||
To run ^metaninf^, the ^metan^ command [STB-44: sbe24] must be installed.
|
||||
|
||||
|
||||
Acknowledgements
|
||||
----------------
|
||||
|
||||
^metaninf^ is a direct rip-off of ^metainf^ (by Aurelio Tobias; see STB-47: sbe26;
|
||||
STB-56: sbe26.1). It blatently uses ^metan^ (by Michael J Bradburn, Jonathan J
|
||||
Deeks and Douglas G Altman; see STB-44: sbe24) as its meta-analysis calculation
|
||||
engine and ^mhplot^, a slight variation of ^hplot^ (by Nicolas Cox), as its
|
||||
graphic engine. The current author is indebted to the above authors for all
|
||||
their hard work, thus allowing this program to be written with no apparent
|
||||
personal intellectual input. Thanks guys!
|
||||
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
. ^metaninf a b c d, fixedi or label(namevar=studyid, yearvar=year)^
|
||||
. ^metaninf nt mt sdt nc mc sdc, cohen notable^
|
||||
|
||||
|
||||
Author
|
||||
------
|
||||
|
||||
Thomas J Steichen, steichen@triad.rr.com
|
||||
|
||||
|
||||
Also see
|
||||
--------
|
||||
|
||||
On-line: help for @metan@, and if installed: @metainf@, @meta@, @metareg@, @metacum@,
|
||||
@metabias@, @metatrim@, @metap@, @galbr@, @funnel@, @labbe@, and @hplot@.
|
160
Modules/ado/plus/m/metannt.ado
Normal file
160
Modules/ado/plus/m/metannt.ado
Normal file
@ -0,0 +1,160 @@
|
||||
*!version 1.0 MJB 9 May 2003
|
||||
|
||||
cap program drop metannt
|
||||
program define metannt , rclass
|
||||
version 7.0
|
||||
syntax [, measure(string) size(string) confint(string) baseline(string)]
|
||||
*If measure size & confint left unspecified, assume that these are as stored
|
||||
*from previous metan/meta-analysis in r(ES) etc
|
||||
|
||||
if "`measure'`size'`confint'"=="" {
|
||||
*Get effect size, conf intervals and type of summary measure from metan
|
||||
local measure = r(measure)
|
||||
local size = r(ES)
|
||||
local conf_l= r(ci_low)
|
||||
local conf_u= r(ci_upp)
|
||||
}
|
||||
else {
|
||||
*otherwise, user is assumed to have specified them: conf interval needs parsing (and is optional)
|
||||
local measure=upper("`measure'")
|
||||
if "`confint'"!="" {
|
||||
tokenize "`confint'", parse(",")
|
||||
local conf_l=`1'
|
||||
local conf_u=`3'
|
||||
}
|
||||
}
|
||||
|
||||
cap {
|
||||
if ("`measure'"=="SMD" | "`measure'"=="WMD" | "`measure'"=="ES")
|
||||
di in re "metannt valid only after binary data meta-analysis"
|
||||
exit
|
||||
}
|
||||
cap {
|
||||
assert ("`measure'"=="OR" | "`measure'"=="RR" | "`measure'"=="RD")
|
||||
assert `size'>-1
|
||||
assert `size'>0 if ("`measure'"=="OR" |"`measure'"=="RR")
|
||||
assert `size'<1 if "`measure'"=="RD"
|
||||
assert `size'!=.
|
||||
}
|
||||
if _rc!=0 {
|
||||
di in re "Specify a valid measure AND effect size using measure( ) and size( ) options,"
|
||||
di in re " or use last estimates from metan"
|
||||
exit
|
||||
}
|
||||
|
||||
if "`conf_l'"!="" {
|
||||
cap {
|
||||
assert `conf_l'>=-1
|
||||
assert `conf_l'>0 if "`measure'"!="RD"
|
||||
assert `conf_u'<=1 if "`measure'"=="RD"
|
||||
assert `size'>`conf_l'
|
||||
assert `size'<`conf_u'
|
||||
}
|
||||
if _rc!=0 {
|
||||
di in re "Invalid confidence interval"
|
||||
exit
|
||||
}
|
||||
}
|
||||
if "`baseline'"=="" {
|
||||
local baseline =r(cger)
|
||||
local note2 "**" /* to reinforce estimation of CGER from data */
|
||||
}
|
||||
|
||||
if ( (`size'>0 & "`measure'"=="RD") | (`size'>1 & "`measure'"!="RD") ) {
|
||||
local directn "excess"
|
||||
local nntstub "H"
|
||||
}
|
||||
else {
|
||||
local directn "avoided"
|
||||
local nntstub "B"
|
||||
}
|
||||
if "`conf_l'"!="" {
|
||||
local ci "(CI)"
|
||||
local cont "_cont"
|
||||
}
|
||||
di _n in gr " Control group | Treatment group |" _col(43) "| No. of `directn' "
|
||||
di in gr " event rate | event rate *" _col(34) "| NNT`nntstub'* | events per 1000 `ci'*"
|
||||
di in gr _dup(15) "-" "+" _dup(17) "-" "+" _dup(8) "-" "+" _dup(26) "-"
|
||||
|
||||
|
||||
*error check
|
||||
local flag=0
|
||||
|
||||
|
||||
parse "`baseline'", parse(",")
|
||||
while "`1'"!="" {
|
||||
local cger=`1'
|
||||
*calculate tger then NNT / events from d-a
|
||||
if "`measure'"=="RD" {
|
||||
local tger=`cger'+`size'
|
||||
if "`ci'"!="" {
|
||||
local tger_ll = `cger'+`conf_l'
|
||||
local tger_ul = `cger'+`conf_u'
|
||||
}
|
||||
}
|
||||
|
||||
if "`measure'"=="RR" {
|
||||
local tger=(`cger'*`size')
|
||||
if "`ci'"!="" {
|
||||
local tger_ll =(`cger'*`conf_l')
|
||||
local tger_ul =(`cger'*`conf_u')
|
||||
}
|
||||
}
|
||||
|
||||
if "`measure'"=="OR" {
|
||||
local tger=(`size'*`cger')/(1-`cger'+`cger'*`size')
|
||||
if "`ci'"!="" {
|
||||
local tger_ll =(`conf_l'*`cger')/(1-`cger'+`cger'*`conf_l')
|
||||
local tger_ul =(`conf_u'*`cger')/(1-`cger'+`cger'*`conf_u')
|
||||
}
|
||||
}
|
||||
if (`tger'>=0 & `tger'<=1 & `cger'>=0 & `cger'<=1) {
|
||||
|
||||
local nnt = abs(1/(`cger'-`tger'))
|
||||
local np1000=abs(1000*(`cger'-`tger'))
|
||||
if "`ci'"!="" {
|
||||
*direction is important for CI
|
||||
if `cger'>`tger' {
|
||||
*events avoided: CI goes from (cg-max_tg to cg-min_tg)
|
||||
local np1k_ll =(1000*(`cger'-`tger_ul'))
|
||||
local np1k_ul =(1000*(`cger'-`tger_ll'))
|
||||
}
|
||||
else {
|
||||
*events excess: CI goes from (tg_min-cg to tg_max-cg)
|
||||
local np1k_ll =(1000*(`tger_ll'-`cger'))
|
||||
local np1k_ul =(1000*(`tger_ul'-`cger'))
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
local flag=10
|
||||
local nnt =.
|
||||
local np1000 =.
|
||||
}
|
||||
|
||||
di in ye _col(5) %6.3f `cger' " `note2'" _col(23) %6.3f `tger' _col(35) %6.1f `nnt' /*
|
||||
*/ _col(48) %5.1f `np1000' `cont'
|
||||
|
||||
if "`ci'"!="" {
|
||||
di in ye " (" %5.1f `np1k_ll' " , " %5.1f `np1k_ul' ")
|
||||
local tger_ll = `cger'+`conf_u'
|
||||
}
|
||||
|
||||
|
||||
|
||||
mac shift 2
|
||||
}
|
||||
|
||||
if `flag'>1 { di in bl "Note some baseline/event rate combinations are invalid"}
|
||||
di _n in bl "* based on `measure'=" %5.3f `size' " applied to the control group event rate(s)"
|
||||
if "`note2'"=="**" {
|
||||
di in bl "** based on an assumed average control group event rate of `cger'"
|
||||
|
||||
return scalar cger= `cger'
|
||||
return scalar tger= `tger'
|
||||
return scalar nnt= `nnt'
|
||||
return scalar ep1000= `np1000'
|
||||
|
||||
end
|
||||
|
123
Modules/ado/plus/m/metannt.dlg
Normal file
123
Modules/ado/plus/m/metannt.dlg
Normal file
@ -0,0 +1,123 @@
|
||||
/*
|
||||
|
||||
*! metannt dialog version 1.0.1, 13 May 2003, T. J. Steichen, steichen@triad.rr.com
|
||||
*! for metannt version 1.0, 9 May 2003, M. J. Bradburn, mike.bradburn@cancer.org.uk
|
||||
|
||||
Metan-based estimates of absolute benefit or risk
|
||||
-------------------------------------------------
|
||||
|
||||
Syntax: metannt , baseline(#[,#...#]) [ measure(or|rr|rd) size(#) confint(#,#) ]
|
||||
|
||||
To install in User Statistics menu via Stata commands:
|
||||
. window menu append item "stUserStatistics" "Metan-based NNT (metann&t)" "db metannt"
|
||||
. window menu refresh
|
||||
To permanently install, place the commands in your -profile.do- file.
|
||||
|
||||
*/
|
||||
|
||||
VERSION 8.0
|
||||
|
||||
INCLUDE _std_small
|
||||
INCLUDE header
|
||||
|
||||
HELP hlp1, view("help metannt")
|
||||
RESET res1, label("Reset")
|
||||
|
||||
DIALOG main, label("metannt 1.0 - Metan-based NNT") tabtitle("Main")
|
||||
BEGIN
|
||||
TEXT tx_base 10 10 150 ., ///
|
||||
label("Baseline(s): # , # , ...")
|
||||
EDIT ed_base 10 30 330 ., ///
|
||||
label("Baseline value(s)") ///
|
||||
option("baseline")
|
||||
|
||||
CHECKBOX cb_effect 10 65 310 ., ///
|
||||
label("Enter Values (default: use metan values)") ///
|
||||
onclickon(script main_opts_on) ///
|
||||
onclickoff(script main_opts_off)
|
||||
|
||||
FRAME fr_enter 10 90 330 100
|
||||
|
||||
GROUPBOX gb_stat 20 95 70 _ht5h, ///
|
||||
label("Measure")
|
||||
RADIO r_rr 25 115 50 ., ///
|
||||
label("RR") first ///
|
||||
onclickon(script main_rr_on) ///
|
||||
option("measure(rr)")
|
||||
RADIO r_or @ _ss @ ., ///
|
||||
label("OR") middle ///
|
||||
onclickon(script main_or_on) ///
|
||||
option("measure(or)")
|
||||
RADIO r_rd @ _ss @ ., ///
|
||||
label("RD") last ///
|
||||
onclickon(script main_rd_on) ///
|
||||
option("measure(rd)")
|
||||
|
||||
TEXT tx_size 180 115 150 ., ///
|
||||
label("Effect Size: #")
|
||||
EDIT ed_size 100 @ 40 ., ///
|
||||
label("Effect Size") ///
|
||||
numonly ///
|
||||
option("size")
|
||||
|
||||
TEXT tx_ci 180 140 150 ., ///
|
||||
label("Effect Size CI: # , #")
|
||||
EDIT ed_ci 100 @ 70 ., ///
|
||||
label("Effect Size CI") ///
|
||||
option("confint")
|
||||
END
|
||||
|
||||
SCRIPT main_opts_on
|
||||
BEGIN
|
||||
main.gb_stat.enable
|
||||
main.r_rr.enable
|
||||
main.r_or.enable
|
||||
main.r_rd.enable
|
||||
main.tx_ci.enable
|
||||
main.ed_ci.enable
|
||||
main.tx_size.enable
|
||||
main.ed_size.enable
|
||||
END
|
||||
|
||||
SCRIPT main_opts_off
|
||||
BEGIN
|
||||
main.gb_stat.disable
|
||||
main.r_rr.disable
|
||||
main.r_or.disable
|
||||
main.r_rd.disable
|
||||
main.tx_ci.disable
|
||||
main.ed_ci.disable
|
||||
main.tx_size.disable
|
||||
main.ed_size.disable
|
||||
END
|
||||
|
||||
SCRIPT main_rr_on
|
||||
BEGIN
|
||||
main.tx_size.setlabel "Effect Size: # > 0"
|
||||
main.tx_ci.setlabel "Effect Size CI: 0 < # , #"
|
||||
END
|
||||
|
||||
SCRIPT main_or_on
|
||||
BEGIN
|
||||
main.tx_size.setlabel "Effect Size: # > 0"
|
||||
main.tx_ci.setlabel "Effect Size CI: 0 < # , #"
|
||||
END
|
||||
|
||||
SCRIPT main_rd_on
|
||||
BEGIN
|
||||
main.tx_size.setlabel "Effect Size: -1 < # < 1"
|
||||
main.tx_ci.setlabel "Effect Size CI: -1 < # < 1"
|
||||
END
|
||||
|
||||
PROGRAM command
|
||||
BEGIN
|
||||
require main.ed_base
|
||||
require main.ed_size
|
||||
put "metannt "
|
||||
beginoptions
|
||||
option radio(main r_rr r_or r_rd)
|
||||
optionarg main.ed_base
|
||||
optionarg main.ed_size
|
||||
optionarg main.ed_ci
|
||||
endoptions
|
||||
END
|
86
Modules/ado/plus/m/metannt.hlp
Normal file
86
Modules/ado/plus/m/metannt.hlp
Normal file
@ -0,0 +1,86 @@
|
||||
.-
|
||||
help for ^metannt^
|
||||
.-
|
||||
|
||||
Estimates of absolute benefit or risk from meta-analysis
|
||||
--------------------------------------------------------
|
||||
|
||||
|
||||
^metannt , measure(^or|rr|rd^) size(^#^) confint(^#,#^) baseline(^#[,#...#]^)^
|
||||
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
This program is intended to aid interpretation of meta-analyses of binary
|
||||
data by presenting the effect sizes in absolute terms. Both the number
|
||||
needed to treat (NNT) and the number of events avoided (or added) per
|
||||
1000 are presented.
|
||||
|
||||
The ^Number Needed to Treat (NNT)^ is the number of individuals required
|
||||
to experience the intervention in order to expect there to be one
|
||||
additional event to be observed. Assuming the event is undesireable, this
|
||||
is termed the "number needed to treat to benefit" (NNTB). If the
|
||||
intervention arm experiences more events, this is commonly refered to as
|
||||
the "number needed to treat to harm" (NNTH).
|
||||
|
||||
^metannt^ calculates this by deriving an effect size (e.g. a risk ratio),
|
||||
applying it to a population with a given event prevalance, and from this
|
||||
deriving a projected event rate if the population were to receive the
|
||||
intervention. The NNT is equal to
|
||||
1/(control group event rate - treatment group event rate).
|
||||
|
||||
The ^number of avoided or excess events (respectively) per 1000 population^
|
||||
is the difference between the two event rates multiplied by 1000. The
|
||||
intervention group event rate is calculated in the same manner as with
|
||||
the NNT. Optionally a confidence interval is also presented, using the
|
||||
confidence limits of the effect size applied to the control group event
|
||||
rate.
|
||||
|
||||
Options for ^metannt^
|
||||
-------------------
|
||||
|
||||
^baseline()^ specifies the baseline (ie. control group) event rates, from
|
||||
which the NNT and number of events avoided are computed from. More than
|
||||
one baseline event rate may be specified.
|
||||
|
||||
^measure(^rr|or|rd^)^ specifies whether the estimated effect size pooled is
|
||||
a risk ratio, odds ratio or (absolute) risk difference.
|
||||
|
||||
^size(^#^)^ denotes the size of the effect
|
||||
|
||||
^confint(^#,#^)^ denotes the confidence interval around the effect size.
|
||||
|
||||
By default the saved results from the r() macros within @metan@ are used to
|
||||
derive the control group event rate, the effect measure, the effect size and
|
||||
its confidence interval. However, unless a recent version of metan (1.71
|
||||
onwards) was used immediately beforehand, the first three options must be
|
||||
specified. The confidence interval is optional.
|
||||
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
. ^metannt , measure(rr) size(0.2) baseline(0.1,0.2,0.3)^
|
||||
|
||||
. ^metan tdeath tnodeath cdeath cnodeath, or^
|
||||
. ^metannt , baseline(0.15)^
|
||||
|
||||
|
||||
|
||||
|
||||
Authors
|
||||
-------
|
||||
|
||||
Michael J Bradburn, Jonathan J Deeks, Douglas G Altman.
|
||||
Centre for Statistics in Medicine, Institute of Health Sciences,
|
||||
Old Road, Headington, Oxford OX3 7LF, UK.
|
||||
|
||||
email mike.bradburn@@cancer.org.uk
|
||||
|
||||
Also see
|
||||
--------
|
||||
|
||||
On-line: help for @metan@ (if installed), @meta@ (if installed)
|
||||
|
||||
|
55
Modules/ado/plus/m/metap.dlg
Normal file
55
Modules/ado/plus/m/metap.dlg
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
|
||||
*! metap dialog version 1.0.0, 13 May 2003, T. J. Steichen, steichen@triad.rr.com
|
||||
*! for metap version 2.0.0, Mar 2000, Aurelio Tobias, atobias@isciii.es
|
||||
|
||||
Meta-analysis of p-values
|
||||
-------------------------
|
||||
|
||||
Syntax: metap pvar [if exp] [in range] [ , method(#) ]
|
||||
|
||||
To install in User Statistics menu via Stata commands:
|
||||
. window menu append item "stUserStatistics" "Meta-analysis of p-values (meta&p)" "db metap"
|
||||
. window menu refresh
|
||||
To permanently install, place the commands in your -profile.do- file.
|
||||
*/
|
||||
|
||||
VERSION 8.0
|
||||
|
||||
INCLUDE _std_small
|
||||
INCLUDE header
|
||||
|
||||
HELP hlp1, view("help metap")
|
||||
RESET res1, label("Reset")
|
||||
|
||||
DIALOG main, label("metap 2.0.0 - Meta-analysis of p-values") tabtitle("Main")
|
||||
BEGIN
|
||||
TEXT tx_p 10 10 145 ., ///
|
||||
label("Variable for p-values:")
|
||||
VARNAME vn_p 150 @ 190 ., ///
|
||||
label("Variable for p-values")
|
||||
|
||||
GROUPBOX gb_method 10 40 330 _ht5h, ///
|
||||
label("Method:")
|
||||
RADIO r_f 15 55 200 ., ///
|
||||
label("Fisher's") first ///
|
||||
option(NONE)
|
||||
RADIO r_ea 15 75 200 ., ///
|
||||
label("Edgington's additive") middle ///
|
||||
option("method(ea)")
|
||||
RADIO r_en 15 95 200 ., ///
|
||||
label("Edgington's normal curve") last ///
|
||||
option("method(en)")
|
||||
END
|
||||
|
||||
INCLUDE ifin
|
||||
|
||||
PROGRAM command
|
||||
BEGIN
|
||||
put "metap "
|
||||
varlist main.vn_p
|
||||
INCLUDE _ifin_pr
|
||||
beginoptions
|
||||
option radio(main r_f r_ea r_en)
|
||||
endoptions
|
||||
END
|
916
Modules/ado/plus/m/metareg.ado
Normal file
916
Modules/ado/plus/m/metareg.ado
Normal file
@ -0,0 +1,916 @@
|
||||
*! v2.6.1 Roger Harbord 4 Nov 2008
|
||||
|
||||
program define metareg, eclass byable(recall)
|
||||
version 7
|
||||
if replay() {
|
||||
if "`e(cmd)'" !="metareg" {
|
||||
error 301 /* last estimates not found */
|
||||
}
|
||||
if _by() {
|
||||
error 190 /* request may not be combined with by */
|
||||
}
|
||||
Display `0'
|
||||
exit
|
||||
}
|
||||
|
||||
syntax varlist(min=1 numeric) [if] [in] , [ /*
|
||||
*/ wsse(varname numeric) /*
|
||||
*/ EForm /*
|
||||
*/ NOCONStant /*
|
||||
*/ MM /*
|
||||
*/ REML /*
|
||||
*/ EB /*
|
||||
*/ Knapphartung /*
|
||||
*/ z /* standard normal w/o K-H modification to variance
|
||||
*/ Level(passthru) /*
|
||||
*/ PERMute(string) /*
|
||||
*/ Graph /* produce a bubble plot
|
||||
*/ RAndomsize /* marker size according to random-effects weights
|
||||
*/ TAU2test /* tests for tau2=0 residual het test
|
||||
*/ LOg /* maximize_option
|
||||
*/ TOLerance(real 1e-6) /* maximize_option also used by eb method
|
||||
*/ ITERate(integer 100) /* maximize_option - default 16000 is too large!
|
||||
*/ wsvar(varname numeric)/* undoc'd, for compat with v1 ( wsvar = wsse^2 )
|
||||
*/ bsest(string) /* undoc'd, for compat with v1
|
||||
*/ tdist /* undoc'd, use t-distib w/o K-H variance mod'n
|
||||
*/ ORIGinal /* undoc'd, use version 1 (metareg_orig)
|
||||
*/ LRtau2 /* undoc'd, for compat with v.2.2 on SSC
|
||||
*/ NOITer /* passed through to metareg_orig
|
||||
*/ NOTAUComp /* no comparison of tau2 with constant-only model;
|
||||
for use by permute() option
|
||||
*/ * /* other `options', parsed by -mlopts-
|
||||
*/ ]
|
||||
|
||||
marksample touse
|
||||
tokenize `varlist'
|
||||
local y `1' /* study estimate */
|
||||
qui count if `touse'
|
||||
local nobs = r(N)
|
||||
if r(N) == 0 {
|
||||
error 2000 /* no observations */
|
||||
}
|
||||
if r(N) <= `: word count `*'' {
|
||||
error 2001 /* insufficient observations */
|
||||
}
|
||||
macro shift 1
|
||||
_rmcoll `*' if `touse', `noconstant'
|
||||
local xvars `r(varlist)'
|
||||
|
||||
mlopts mlopts, `options' iterate(`iterate') /* Parse maximize_options */
|
||||
|
||||
if "`wsse'"=="" & "`wsvar'"=="" {
|
||||
di as error "wsse() option required"
|
||||
exit 100
|
||||
}
|
||||
|
||||
if "`wsse'"!="" & "`wsvar'"!="" {
|
||||
di as error "options wsse() and wsvar() cannot both be specified"
|
||||
exit 198
|
||||
}
|
||||
|
||||
if "`wsse'"!="" {
|
||||
capture assert `wsse' > 0 if `touse'
|
||||
if _rc {
|
||||
di as error "zero or negative wsse() not allowed"
|
||||
exit 499
|
||||
}
|
||||
tempvar wsvar
|
||||
qui gen `wsvar' = `wsse'^2 if `touse'
|
||||
}
|
||||
|
||||
if "`wsvar'"!="" {
|
||||
capture assert `wsvar' > 0 if `touse'
|
||||
if _rc {
|
||||
di as error "zero or negative wsvar() not allowed"
|
||||
exit 499
|
||||
}
|
||||
}
|
||||
|
||||
if "`noconstant'"!="" {
|
||||
/* local nvar : word count `varlist' */
|
||||
if `: word count `varlist'' == 1 {
|
||||
di as error "independent variables required with " /*
|
||||
*/ "noconstant option"
|
||||
exit 102
|
||||
}
|
||||
}
|
||||
|
||||
local wc : word count "`mm' `reml' `eb'"
|
||||
if `wc' > 1 {
|
||||
di as error "Only one of options mm, reml and eb can be specified"
|
||||
exit 198
|
||||
}
|
||||
|
||||
local wc : word count "`mm' `reml' `eb' `bsest'"
|
||||
if `wc' > 1 {
|
||||
di as error "Option bsest() cannot be used with options mm, reml or eb"
|
||||
exit 198
|
||||
}
|
||||
|
||||
if "`bsest'"!="reml" & "`bsest'"!="ml" & "`bsest'"!="eb" /*
|
||||
*/ & "`bsest'"!="mm" & "`bsest'"!="" {
|
||||
di as error "Between study variance estimation method invalid:"
|
||||
di as error "should be either reml, ml, eb or mm"
|
||||
exit 198
|
||||
}
|
||||
|
||||
if "`bsest'" == "" {
|
||||
if "`mm'" != "" | "`permute'" != "" { /* MM is default with permute */
|
||||
local bsest "mm"
|
||||
}
|
||||
else if "`eb'" != "" {
|
||||
local bsest "eb"
|
||||
}
|
||||
else { /* REML is default otherwise */
|
||||
local bsest "reml"
|
||||
}
|
||||
}
|
||||
|
||||
if "`bsest'" =="ml" {
|
||||
di as text /*
|
||||
*/ "Option bsest(ml) not supported by version 2 of metareg."
|
||||
di as text "Calling version 1.06 (sbe23):" _n(1)
|
||||
metareg_orig `0'
|
||||
exit
|
||||
}
|
||||
|
||||
if "`knapphartung'" !="" & "`z'" != "" {
|
||||
di as error "Options knapphartung and z cannot both be specified"
|
||||
exit 198
|
||||
}
|
||||
|
||||
if "`tdist'" != "" & ( "`z'" != "" | "`knapphartung'" !="" ) {
|
||||
di as error "Option t cannot be specified with options knapphartung or z"
|
||||
exit 198
|
||||
}
|
||||
|
||||
if "`original'" =="original" {
|
||||
di as text "Calling metareg version 1.06 (sbe23):" _n(1)
|
||||
metareg_orig `0'
|
||||
exit
|
||||
}
|
||||
|
||||
if "`log'"=="" {
|
||||
local log "nolog"
|
||||
}
|
||||
|
||||
if "`lrtau2'" != "" {
|
||||
local tau2test tau2test
|
||||
}
|
||||
|
||||
if "`permute'" != "" {
|
||||
if "`xvars'" == "" {
|
||||
di as error "Option permute() requires at least one covariate"
|
||||
exit 198
|
||||
}
|
||||
Permute, y(`y') xvars(`xvars') wsvar(`wsvar') permute(`permute') ///
|
||||
nobs(`nobs') `noconstant' ///
|
||||
bsest(`bsest') `knapphartung' `z' ///
|
||||
level(`level') touse(`touse')
|
||||
exit
|
||||
}
|
||||
|
||||
|
||||
/*** begin main code ***/
|
||||
tempvar w hat v resid
|
||||
tempname remll_c remll sumw tau2 tau2mm b V Q df_Q tau2_0
|
||||
|
||||
quietly {
|
||||
|
||||
/** (get starting values using) method-of-moments **/
|
||||
gen `w'=1/`wsvar' if `touse'
|
||||
summ `w' if `touse', meanonly
|
||||
scalar `sumw'=r(sum)
|
||||
/* use regress not vwls so can predict hat */
|
||||
regress `y' `xvars' [iw=`w'] if `touse', `noconstant'
|
||||
predict `hat' if `touse', hat
|
||||
/* H_ii where H = X(X'WX)^{-1}X', W=diag(w) */
|
||||
replace `hat'=`hat'*`w'^2 if `touse' /* Tr( WX(X'WX)^{-1}X'W ) */
|
||||
/* iweights mess up residual df so compute it : */
|
||||
scalar `df_Q' = `nobs' - e(df_m) - ("`noconstant'" == "")
|
||||
scalar `Q' = e(rss)
|
||||
summ `hat' if `touse', meanonly
|
||||
scalar `tau2' = (`Q' - `df_Q') / ( `sumw' - r(sum))
|
||||
/* truncate at zero */
|
||||
scalar `tau2' = max(`tau2', 0)
|
||||
|
||||
/* Fit constant-only model to compare tau2
|
||||
NB can't compare different fixed-effect models using REML log-L */
|
||||
if "`noconstant'" == "" & "`notaucomp'"=="" & "`xvars'" != "" {
|
||||
metareg `y' if `touse', wsvar(`wsvar') bsest(`bsest') notaucomp
|
||||
scalar `tau2_0' = e(tau2)
|
||||
}
|
||||
} /* end quietly */
|
||||
|
||||
if "`bsest'" == "reml" { /* *** REML start *** */
|
||||
|
||||
global REML_x `xvars' /* betas not estimated by ml so pass X as global*/
|
||||
global REML_nocons `noconstant' /* have to pass as global too */
|
||||
|
||||
/* fit comparison fixed-effect (tau2=0) model*/
|
||||
ml model d0 metareg_ll (`y' `wsvar' = ) /*
|
||||
*/ if `touse', maximize init(_cons=0) /*
|
||||
*/ search(off) iterate(0) nowarning nolog
|
||||
scalar `remll_c' = e(ll) /* log-L, comparison model */
|
||||
|
||||
/* estimate tau2 using ml */
|
||||
local tau2mm = max(`tau2', 1e-4) /* init doesn't work with scalar */
|
||||
ml model d0 metareg_ll (`y' `wsvar' = ) if `touse',/*
|
||||
*/ maximize init(_cons=`tau2mm') search(off) nopreserve noscvars /*
|
||||
*/ `log' tolerance(`tolerance') `mlopts'
|
||||
|
||||
if "`e(converged)'" != "1" {
|
||||
di as error "WARNING: REML estimation of tau2 failed to converge."
|
||||
di as error "Estimates may be wrong."
|
||||
di as error "Try adding mm option to use method-of-moments".
|
||||
}
|
||||
|
||||
macro drop REML_x
|
||||
macro drop REML_nocons
|
||||
|
||||
scalar `tau2' = max( _b[_cons], 0)
|
||||
if `tau2' > 0 {
|
||||
scalar `remll' = e(ll)
|
||||
}
|
||||
else {
|
||||
scalar `remll' = `remll_c'
|
||||
}
|
||||
|
||||
} /* REML end */
|
||||
|
||||
if "`bsest'" == "eb" { /* *** EB start *** */
|
||||
local oldtau2=-1
|
||||
local j=0
|
||||
|
||||
while abs((`tau2'-`oldtau2')/(`oldtau2'+1e-8)) >= `tolerance' {
|
||||
local j = `j'+1
|
||||
tempvar wt ypred wtsq numi
|
||||
local oldtau2=`tau2'
|
||||
qui {
|
||||
gen `wt'=(`wsvar'+`tau2')^-1 if `touse'
|
||||
regress `y' `xvars' [aw=`wt'] if `touse'
|
||||
predict `ypred' if `touse'
|
||||
gen `wtsq'=`wt'^2 if `touse'
|
||||
gen `numi'=(`wt')*(((e(N)/e(df_r))*((`y'-`ypred')^2))-`wsvar') if `touse'
|
||||
summ `numi' if `touse', meanonly
|
||||
local num=r(sum)
|
||||
summ `wt', meanonly
|
||||
local tau2=`num'/r(sum)
|
||||
}
|
||||
if "`log'" == "log" {
|
||||
di as txt "Iteration " `j' ": tau^2 = " as res `tau2'
|
||||
}
|
||||
}
|
||||
local tau2 = max(`tau2',0)
|
||||
} /* EB end*/
|
||||
|
||||
/** estimate final model by weighted LS **/
|
||||
quietly {
|
||||
gen `v' = `wsvar' + `tau2'
|
||||
regress `y' `xvars' [iw=1/`v'] if `touse', mse1 `noconstant'
|
||||
matrix `b' = e(b)
|
||||
matrix `V' = e(V)
|
||||
local df_m = e(df_m)
|
||||
|
||||
/** knapp and hartung variance adjustment **/
|
||||
if "`z'" == "" & "`tdist'" == "" {
|
||||
tempname vkh
|
||||
predict `resid' if `touse', resid
|
||||
replace `resid' = `resid'*`resid' / `v' if `touse'
|
||||
summarize `resid' if `touse', meanonly
|
||||
local qkh = r(sum) / `df_Q'
|
||||
matrix `V' = `V' * max(1, `qkh')
|
||||
}
|
||||
|
||||
} /* end quietly */
|
||||
|
||||
|
||||
estimates post `b' `V', depname(`y') obs(`nobs') esample(`touse')
|
||||
estimates scalar tau2 = `tau2'
|
||||
estimates scalar df_m = `df_m'
|
||||
estimates scalar Q = `Q'
|
||||
estimates scalar df_Q = `df_Q'
|
||||
estimates scalar I2 = max( ( `Q' - `df_Q' ) / `Q', 0 )
|
||||
if "`z'" == "" { /* post df_r so get t & F tests not z and chi2 */
|
||||
estimates scalar df_r = `df_Q'
|
||||
}
|
||||
if "`tdist'" =="" & "`z'" == "" {
|
||||
estimates scalar q_KH = `qkh'
|
||||
}
|
||||
if "`wsse'" == "" {
|
||||
estimates local wsvar "`wsvar'"
|
||||
}
|
||||
else {
|
||||
estimates local wsse "`wsse'"
|
||||
}
|
||||
|
||||
if "`bsest'" == "mm" {
|
||||
estimates local method "Method of moments"
|
||||
}
|
||||
if "`bsest'" == "eb" {
|
||||
estimates local method "Empirical Bayes"
|
||||
}
|
||||
if "`bsest'" == "reml" {
|
||||
estimates local method "REML"
|
||||
/* return reml log-l in e(remll) NOT e(ll)
|
||||
to ensure can't do inappropriate lrtest of fixed effects */
|
||||
estimates scalar remll = `remll'
|
||||
if "`remll_c'" != "" {
|
||||
estimates scalar remll_c = `remll_c'
|
||||
if (e(remll) < e(remll_c)) | (`tau2' <= 0) {
|
||||
estimates scalar chi2_c = 0
|
||||
}
|
||||
else {
|
||||
estimates scalar chi2_c = 2*(e(remll)-e(remll_c))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if "`noconstant'" == "" & "`notaucomp'"=="" & "`xvars'" != "" {
|
||||
estimates scalar tau2_0 = `tau2_0'
|
||||
}
|
||||
|
||||
/* overall F (or chi2) test */
|
||||
if "`xvars'" != "" {
|
||||
qui test `xvars'
|
||||
if "`r(chi2)'" != "" {
|
||||
estimates scalar chi2 = r(chi2)
|
||||
}
|
||||
else {
|
||||
estimates scalar F = r(F)
|
||||
}
|
||||
}
|
||||
|
||||
estimates local predict "metareg_p"
|
||||
estimates local depvar "`y'"
|
||||
estimates local cmd "metareg"
|
||||
|
||||
Display, `level' `eform' `tau2test'
|
||||
|
||||
|
||||
if "`graph'" != "" {
|
||||
if `: word count `xvars'' != 1 {
|
||||
di as error in smcl ///
|
||||
"graph option works only with a single {it:indepvar}"
|
||||
}
|
||||
else Graph `y' `xvars' `v' `w' `randomsize'
|
||||
}
|
||||
|
||||
end
|
||||
|
||||
program define Graph
|
||||
version 8.2
|
||||
args y xvars v w randomsize
|
||||
|
||||
tempvar fit
|
||||
qui predict `fit'
|
||||
if "`randomsize'" == "" {
|
||||
local size `w'
|
||||
}
|
||||
else {
|
||||
local size 1/`v'
|
||||
}
|
||||
local yti : variable label `y'
|
||||
if "`yti'" == "" {
|
||||
local yti `y'
|
||||
}
|
||||
scatter `y' `xvars' [aw=`size'], msymbol(oh) ///
|
||||
|| line `fit' `xvars', sort ///
|
||||
||, legend(off) ytitle( `yti')
|
||||
|
||||
end
|
||||
|
||||
|
||||
program define Display
|
||||
version 7
|
||||
syntax [, Level(int $S_level) EForm Tau2test q]
|
||||
tempname pval i2
|
||||
if "`eform'" == "eform" {
|
||||
local eform eform(exp(b))
|
||||
}
|
||||
scalar `pval' = chi2tail(e(df_Q), e(Q))
|
||||
|
||||
di as txt _n "Meta-regression" /*
|
||||
*/ _col(55) "Number of obs" _col(70) "= " as res %7.0f e(N)
|
||||
di as res "`e(method)'" /*
|
||||
*/ as txt " estimate of between-study variance" /*
|
||||
*/ _col(55) "tau2" _col(70) "=" as res %8.4g e(tau2)
|
||||
di as txt "% residual variation due to heterogeneity" /*
|
||||
*/ _col(55) "I-squared_res" _col(70) "= " as res %6.2f 100 * e(I2) "%"
|
||||
|
||||
|
||||
if "`e(tau2_0)'" != "" {
|
||||
di as txt "Proportion of between-study variance explained" /*
|
||||
*/ _col(55) "Adj R-squared " _col(70) "= " _c
|
||||
di as res %6.2f 100 * ( 1 - e(tau2) / e(tau2_0) ) "%"
|
||||
}
|
||||
|
||||
/* Overall model fit */
|
||||
if e(df_m) > 1 {
|
||||
di as txt "Joint test for all covariates" _c
|
||||
if "`e(df_r)'" == "" {
|
||||
di as txt _col(55) "Model chi2(" as res e(df_m) as txt ")" /*
|
||||
*/ _col(70) "= " as res %7.2f e(chi2)
|
||||
}
|
||||
else {
|
||||
di as txt _col(55) "Model F(" as res e(df_m) as txt "," /*
|
||||
*/ as res e(df_r) as txt ")" _col(70) "= " /*
|
||||
*/ as res %7.2f e(F)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
di as res "With" _c
|
||||
if "`e(q_KH)'" == "" {
|
||||
di as res "out" _c
|
||||
}
|
||||
di as txt " Knapp-Hartung modification" _c
|
||||
|
||||
if e(df_m) > 1 {
|
||||
if "`e(df_r)'" == "" {
|
||||
di as txt _col(55) "Prob > chi2" _col(70) "= " /*
|
||||
*/ as res %7.4f chi2tail( e(df_m), e(chi2) )
|
||||
}
|
||||
else {
|
||||
di as txt _col(55) "Prob > F" _col(70) "= " /*
|
||||
*/ as res %7.4f Ftail( e(df_m), e(df_r), e(F) )
|
||||
}
|
||||
}
|
||||
else {
|
||||
di /* end line */
|
||||
}
|
||||
|
||||
|
||||
estimates display, level(`level') `eform'
|
||||
|
||||
if "`tau2test'" != "" {
|
||||
di as txt "Test for residual between-study variance (of tau2=0)" /*
|
||||
*/ _col(55) "Q_res (" as res %1.0f e(df_Q) as txt " df)" /*
|
||||
*/ _col(70) "= " as res %7.2f e(Q)
|
||||
di as txt _col(55) "Prob > Q_res" _col(70) "= " as res %7.4f `pval'
|
||||
|
||||
if "`e(method)'" == "REML" {
|
||||
scalar `pval' = chi2tail(1, e(chi2_c))*0.5
|
||||
if e(chi2_c) <=0 {
|
||||
scalar `pval'= 1
|
||||
}
|
||||
di in smcl as txt "Likelihood-ratio test of tau2=0: " /*
|
||||
*/ as txt "{help j_chibar:chibar2(01) =}" as res %6.2f e(chi2_c) /*
|
||||
*/ as txt " Prob > chibar2 = " as res %7.4f `pval'
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
end
|
||||
|
||||
|
||||
program define Permute, rclass
|
||||
version 7
|
||||
syntax, y(varname numeric) xvars(varlist numeric) wsvar(varname numeric) ///
|
||||
permute(string) nobs(integer) [noconstant bsest(string) knapphartung z ///
|
||||
level(passthru) touse(varname numeric)]
|
||||
|
||||
gettoken reps 0 : permute, parse(",")
|
||||
confirm integer number `reps'
|
||||
if `reps' < 1 {
|
||||
di as err "permute() must be a positive integer"
|
||||
exit 198
|
||||
}
|
||||
|
||||
syntax [, Univariable Detail Verbose NOISily Joint(string) * ]
|
||||
|
||||
if "`verbose'" != "" { /* verbose is undoc'd synonym for detail */
|
||||
local detail detail
|
||||
}
|
||||
|
||||
if "`xvars'" == "" {
|
||||
di as error "permute() option not allowed when no covariates"
|
||||
exit 198
|
||||
}
|
||||
|
||||
if "`joint'" != "" & "`univariable'" != "" {
|
||||
di as error "options univariable and joint() cannot both be specified"
|
||||
exit 198
|
||||
}
|
||||
|
||||
if `:word count `xvars'' == 1 {
|
||||
local univariable /* ensure unset if only one xvar */
|
||||
}
|
||||
|
||||
if "`univariable'" == "" {
|
||||
di as txt _n(1) "Monte Carlo permutation test for meta-regression"
|
||||
}
|
||||
else {
|
||||
di as txt _n(1) in smcl /*
|
||||
*/ "Monte Carlo permutation test for {it:single covariate} meta-regressions"
|
||||
}
|
||||
|
||||
if "`bsest'" == "" {
|
||||
local bsest "mm" /* mm is default for permutation test */
|
||||
}
|
||||
if "`bsest'" == "mm" {
|
||||
di as res _n "Moment-based " _c
|
||||
}
|
||||
else {
|
||||
di as res _n "REML " _c
|
||||
}
|
||||
di as txt "estimate of between-study variance"
|
||||
|
||||
if "`knapphartung'" == "" {
|
||||
local z "z" /* z is default for for permutation test */
|
||||
di as res "Without " _c
|
||||
}
|
||||
else {
|
||||
di as res "With " _c
|
||||
}
|
||||
di as txt "Knapp & Hartung modification to standard errors"
|
||||
|
||||
|
||||
if "`noconstant'" != "" {
|
||||
di as error "Permutation test inappropriate with no constant"
|
||||
exit 198
|
||||
}
|
||||
|
||||
local permopts `univariable' `noconstant' `bsest' `knapphartung' `z'
|
||||
|
||||
preserve
|
||||
qui keep if `touse'
|
||||
|
||||
foreach x of varlist `xvars' {
|
||||
local explist "`explist' `x'=r(z_`x')"
|
||||
local xlist "`xlist' `x'"
|
||||
}
|
||||
|
||||
/* parse varlists in joint() option separated by \ / or | */
|
||||
local jt `joint'
|
||||
local nj 0
|
||||
while "`jt'" != "" {
|
||||
gettoken tmp jt : jt, parse("\/|")
|
||||
if strpos("\/|", "`tmp'") {
|
||||
continue
|
||||
}
|
||||
local 0 `tmp'
|
||||
syntax varlist
|
||||
local nj = `nj' + 1
|
||||
local joint`nj' `varlist'
|
||||
di as txt "joint`nj' : " as res "`joint`nj''"
|
||||
local explistj "`explistj' joint`nj'=r(chi2`nj')"
|
||||
local jlist "`jlist' joint`nj'"
|
||||
}
|
||||
|
||||
tempvar n
|
||||
qui gen `n' = _n if `touse'
|
||||
|
||||
tempfile pm pmadj
|
||||
if "`noisily'" =="" {
|
||||
local quietly quietly
|
||||
/* quietly permute then replay (if detail specified)
|
||||
to suppress full -permute- header */
|
||||
}
|
||||
`quietly' permute `n' /*
|
||||
*/ "metareg_pm `y' `wsvar' `n', xvars(`xvars') joint(`joint') `permopts'" /*
|
||||
*/ `explist' `explistj', /*
|
||||
*/ reps(`reps') saving(`pm') replace `options'
|
||||
|
||||
|
||||
tempname R C P B
|
||||
matrix `R' = r(reps)
|
||||
matrix `C' = r(c)
|
||||
matrix `P' = `C' * inv(diag(`R'))
|
||||
|
||||
local nx : word count `xvars'
|
||||
forvalues i = 1/`nx' {
|
||||
local minreps = min(`reps',`R'[1,`i'])
|
||||
}
|
||||
if `minreps' != `reps' {
|
||||
di as txt "WARNING: some permutations returned missing values" _c
|
||||
di as txt "See detail below:"
|
||||
local detail detail
|
||||
}
|
||||
|
||||
/* to get adjusted p-values from -permute-,
|
||||
replace z-statistics by their largest absolute values
|
||||
for each permutation */
|
||||
quietly {
|
||||
use `pm', clear
|
||||
tempvar max
|
||||
gen `max' = 0
|
||||
foreach v of varlist `xlist' {
|
||||
replace `max' = abs(`v') if abs(`v') > `max'
|
||||
}
|
||||
foreach v of varlist `xlist' {
|
||||
replace `v' = `max'
|
||||
}
|
||||
drop `max'
|
||||
save `pmadj', replace
|
||||
permute `xlist' `jlist' using `pmadj', `level'
|
||||
} // end quietly
|
||||
|
||||
matrix `B' = r(b)
|
||||
matrix `R' = `R' \ r(reps)
|
||||
matrix `C' = `C' \ r(c)
|
||||
matrix `P' = `P' \ r(c) * inv(diag(r(reps)))
|
||||
foreach M in `R' `C' `P' {
|
||||
matrix rownames `M' = unadj multadj
|
||||
if "`joint'" != "" {
|
||||
/* set matrix entries for adjusted joint tests (N/A) to missing */
|
||||
matrix `M'[2, colnumb(`M',"joint1")] = J(1,`nj',.)
|
||||
}
|
||||
}
|
||||
|
||||
/* clear results from last permutation so not available to user */
|
||||
estimates clear
|
||||
restore
|
||||
|
||||
/*** Display results of permutation test ****/
|
||||
|
||||
if `nx' == 1 { /* only one xvar */
|
||||
local sep = sqrt(`P'[1,1]*(1-`P'[1,1])/`reps')
|
||||
if `sep' == 0 {
|
||||
local sep .
|
||||
}
|
||||
di as txt _n _col(9) "Number of obs =" as res %8.0f _N
|
||||
di as txt _col(9) "Permutations =" as res %8.0f `reps'
|
||||
di in smcl as txt "{hline 13}{c TT}{hline 17}"
|
||||
di in smcl as txt /*
|
||||
*/ %12s "`y'" " {c |}" _s(1) /*
|
||||
*/ %6s "p" _s(4) /*
|
||||
*/ %6s "SE(p)"
|
||||
|
||||
di in smcl as txt "{hline 13}{c +}{hline 17}"
|
||||
di in smcl as txt /*
|
||||
*/ %12s abbrev(`"`xvars'"',10) /*
|
||||
*/ " {c |}" _s(2) /*
|
||||
*/ as result %7.3f `P'[1,1] _s(1) /*
|
||||
*/ as result %7.4f `sep'
|
||||
di in smcl as txt "{hline 13}{c BT}{hline 17}"
|
||||
}
|
||||
|
||||
else { /* more than one xvar */
|
||||
|
||||
/* Table Head */
|
||||
di as txt _n "P-values unadjusted and adjusted for multiple testing"
|
||||
di as txt _n _col(14) "Number of obs =" as res %8.0f `nobs'
|
||||
di as txt _col(14) "Permutations =" as res %8.0f `reps'
|
||||
di in smcl as txt "{hline 13}{c TT}{hline 22}"
|
||||
di in smcl as txt _s(13) "{c |}" _s(12) "P"
|
||||
di in smcl as txt /*
|
||||
*/ %12s abbrev("`y'",10) " {c |}" /*
|
||||
*/ %11s "Unadjusted" %11s "Adjusted"
|
||||
di in smcl as txt "{hline 13}{c +}{hline 22}"
|
||||
|
||||
foreach x of local xvars {
|
||||
local i = `i' + 1
|
||||
di in smcl as txt /*
|
||||
*/ %12s abbrev(`"`x'"',10) /*
|
||||
*/ " {c |}" _s(4) /*
|
||||
*/ as result %7.3f `P'[1,`i'] _s(4) /*
|
||||
*/ %7.3f `P'[2,`i']
|
||||
}
|
||||
|
||||
if "`joint'" != "" {
|
||||
di in smcl as txt "{hline 13}{c +}{hline 22}"
|
||||
forvalues j = 1/`nj' {
|
||||
di in smcl as txt /*
|
||||
*/ %12s "joint`j'" /*
|
||||
*/ " {c |}" _s(4) /*
|
||||
*/ as result %7.3f `P'[1,`nx'+`j']
|
||||
}
|
||||
}
|
||||
|
||||
/* Table Foot */
|
||||
di in smcl as txt "{hline 13}{c BT}{hline 22}"
|
||||
/* largest SE(p) = sqrt( max( p(1-p)/n ) ) */
|
||||
local maxvarp 0
|
||||
forvalues i = 1/2 {
|
||||
forvalues j = 1/`=colsof(`P')'{
|
||||
local maxvarp = max( `maxvarp', ///
|
||||
`P'[`i',`j'] * (1 - `P'[`i',`j']) / `R'[`i',`j'] )
|
||||
}
|
||||
}
|
||||
if `maxvarp' == 0 {
|
||||
local maxvarp .
|
||||
}
|
||||
di as txt "largest Monte Carlo SE(P) =" /*
|
||||
*/ as res %7.4f sqrt(`maxvarp')
|
||||
}
|
||||
|
||||
/* Detailed results if requested, as displayed by -permute- */
|
||||
if "`detail'" != "" {
|
||||
di as txt in smcl _n(2) "{title:Unadjusted}"
|
||||
permute `xlist' `jlist' using `pm', `level'
|
||||
|
||||
if `nx' > 1 {
|
||||
di as txt in smcl _n(2) "{title:Adjusted for multiple testing}"
|
||||
permute `xlist' using `pmadj', `level'
|
||||
}
|
||||
}
|
||||
|
||||
di as txt _n "WARNING:"
|
||||
di as txt "Monte Carlo methods use random numbers, so results may differ between runs."
|
||||
di as txt "Ensure you specify enough permutations to obtain the desired precision."
|
||||
|
||||
return scalar N = `nobs'
|
||||
return matrix reps = `R'
|
||||
return matrix c = `C'
|
||||
return matrix p = `P'
|
||||
return matrix b = `B'
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
program define metareg_orig
|
||||
*! v1.06 copyright Stephen Sharp January 1998 STB-42 sbe23
|
||||
version 5.0
|
||||
local varlist "req ex min(1)"
|
||||
local if "opt"
|
||||
local in "opt"
|
||||
local options "WSSe(string) WSVar(string) BSest(string) TOLeran(integer 4) Level(integer $S_level)"
|
||||
local options "`options' NOITer ORIGinal" /* original added by RMH */
|
||||
|
||||
parse "`*'"
|
||||
if "`wsse'"=="" & "`wsvar'"=="" {
|
||||
di in re "Must specify a variable containing estimate of precision"
|
||||
di in re "within each trial, using either wsse() or wsvar() option"
|
||||
exit 198
|
||||
}
|
||||
if "`wsse'"~="" & "`wsvar'"~=""{
|
||||
confirm variable `wsse'
|
||||
confirm variable `wsvar'
|
||||
local i=1
|
||||
while `i'<=_N {
|
||||
if abs(`wsse[`i']'^2-`wsvar[`i']')>0.00001 {
|
||||
di in re "Within study variance should be square of within study standard error"
|
||||
exit 198
|
||||
}
|
||||
local i=`i'+1
|
||||
}
|
||||
}
|
||||
if "`wsvar'"~="" {
|
||||
confirm variable `wsvar'
|
||||
}
|
||||
if "`wsse'"~="" {
|
||||
confirm variable `wsse'
|
||||
tempvar wsvar
|
||||
qui gen `wsvar'=`wsse'^2
|
||||
}
|
||||
if "`bsest'"=="" {
|
||||
local bsest "reml"
|
||||
}
|
||||
if "`bsest'"~="reml" & "`bsest'"~="ml" & "`bsest'"~="eb" & "`bsest'"~="mm" & "`bsest'"~="" {
|
||||
di in re "Between study variance estimation method invalid:"
|
||||
di in re "should be either reml, ml, eb or mm"
|
||||
exit 198
|
||||
}
|
||||
if "`noiter'"~="" & "`bsest'"=="mm" {
|
||||
di in bl "Warning: mm is a non-iterative method, noiter option ignored"
|
||||
}
|
||||
parse "`varlist'", parse(" ")
|
||||
|
||||
local y "`1'"
|
||||
mac shift
|
||||
local xvars "`*'"
|
||||
|
||||
tempvar touse
|
||||
preserve
|
||||
qui {
|
||||
mark `touse' `if' `in'
|
||||
markout `touse' `y' `xvars'
|
||||
keep if `touse'
|
||||
}
|
||||
|
||||
qui regress `y' `xvars'
|
||||
local p=_result(3)
|
||||
local N=_result(1)
|
||||
|
||||
if "`bsest'"=="mm" {
|
||||
tempvar wt ypred numi one
|
||||
qui {
|
||||
gen `wt'=`wsvar'^-1
|
||||
regress `y' `xvars' [aw=`wt']
|
||||
predict `ypred'
|
||||
gen `one'=1
|
||||
tempname X C Xt C1 XtC1 A A1 A1XtC1 C1X B
|
||||
mkmat `one' `xvars', matrix(`X')
|
||||
matrix `C'=J(`N',`N',0)
|
||||
local i=1
|
||||
while `i'<=_N {
|
||||
matrix `C'[`i',`i']=`wsvar'[`i']
|
||||
local i=`i'+1
|
||||
}
|
||||
mat `Xt'=`X''
|
||||
mat `C1'=inv(`C')
|
||||
mat `XtC1'=`Xt'*`C1'
|
||||
mat `A'=`XtC1'*`X'
|
||||
mat `A1'=inv(`A')
|
||||
mat `A1XtC1'=`A1'*`XtC1'
|
||||
mat `C1X'=`C1'*`X'
|
||||
mat `B'=`C1X'*`A1XtC1'
|
||||
local trB=trace(`B')
|
||||
summ `wt'
|
||||
local denom=_result(18)-`trB'
|
||||
gen `numi'=`wt'*((`y'-`ypred')^2)
|
||||
summ `numi'
|
||||
local num=max(_result(18)-(`N'-(`p'+1)),0)
|
||||
local newtsq=`num'/`denom'
|
||||
}
|
||||
}
|
||||
|
||||
if "`bsest'"~="mm" {
|
||||
|
||||
local tsq=0.1
|
||||
local newtsq=0
|
||||
local j=1
|
||||
|
||||
while abs(`tsq'-`newtsq')>=10^(-`toleran') {
|
||||
tempvar wt ypred wtsq numi
|
||||
local tsq=`newtsq'
|
||||
if "`noiter'"=="" {
|
||||
di in gr "Iteration " `j' ": tau^2 = " in ye `tsq'
|
||||
}
|
||||
qui {
|
||||
gen `wt'=(`wsvar'+`tsq')^-1
|
||||
regress `y' `xvars' [aw=`wt']
|
||||
predict `ypred'
|
||||
gen `wtsq'=`wt'^2
|
||||
}
|
||||
if "`bsest'"=="reml" {
|
||||
qui {
|
||||
gen `numi'=(`wtsq')*(((`N'/(`N'-(`p'+1)))*((`y'-`ypred')^2))-`wsvar')
|
||||
summ `numi'
|
||||
local num=max(_result(18),0)
|
||||
summ `wtsq'
|
||||
local denom=_result(18)
|
||||
local newtsq=`num'/`denom'
|
||||
}
|
||||
}
|
||||
|
||||
if "`bsest'"=="ml" {
|
||||
qui {
|
||||
gen `numi'=(`wtsq')*(((`y'-`ypred')^2)-`wsvar')
|
||||
summ `numi'
|
||||
local num=max(_result(18),0)
|
||||
summ `wtsq'
|
||||
local denom=_result(18)
|
||||
local newtsq=`num'/`denom'
|
||||
}
|
||||
}
|
||||
|
||||
if "`bsest'"=="eb" {
|
||||
qui {
|
||||
gen `numi'=(`wt')*(((`N'/(`N'-(`p'+1)))*((`y'-`ypred')^2))-`wsvar')
|
||||
summ `numi'
|
||||
local num=max(_result(18),0)
|
||||
summ `wt'
|
||||
local denom=_result(18)
|
||||
local newtsq=`num'/`denom'
|
||||
}
|
||||
}
|
||||
|
||||
local j=`j'+1
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
tempvar wt
|
||||
qui {
|
||||
gen `wt'=(`wsvar'+`newtsq')^-1
|
||||
summ `wt'
|
||||
}
|
||||
local sumwt=_result(18)
|
||||
|
||||
#delimit ;
|
||||
di _n
|
||||
in gr "Meta-analysis regression"
|
||||
_col(56) "No of studies = " in ye `N' _n
|
||||
in gr _col(56) "tau^2 method " in ye "`bsest'" _n
|
||||
in gr _col(56) "tau^2 estimate = " in ye %6.5g `newtsq' _n ;
|
||||
#delimit cr
|
||||
if "`bsest'"=="ml" | "`bsest'"=="reml" | "`bsest'"=="eb" {
|
||||
di in bl "Successive values of tau^2 differ by less than 10^-"`toleran' " :convergence achieved"
|
||||
}
|
||||
|
||||
qui regress `y' `xvars' [aw=`wt']
|
||||
|
||||
local scpar=(`sumwt'*(_result(9)^2))/_result(1)
|
||||
local scpar1=(1/`scpar')
|
||||
|
||||
matrix V=get(VCE)
|
||||
matrix b=get(_b)
|
||||
|
||||
matrix v=`scpar1'*V
|
||||
|
||||
|
||||
mat post b v
|
||||
mat mlout, level(`level')
|
||||
|
||||
global S_1 = `N'
|
||||
global S_2 = `newtsq'
|
||||
|
||||
restore
|
||||
|
||||
end
|
||||
|
||||
|
||||
exit
|
113
Modules/ado/plus/m/metareg.dlg
Normal file
113
Modules/ado/plus/m/metareg.dlg
Normal file
@ -0,0 +1,113 @@
|
||||
/*
|
||||
|
||||
*! metareg dialog version 1.0.1, 13 May 2003, T. J. Steichen, steichen@triad.rr.com
|
||||
*! for metareg version 1.06, Jan 1998, Stephen Sharp, stephen.j.sharp@gsk.com
|
||||
|
||||
Meta-analysis regression
|
||||
------------------------
|
||||
|
||||
Syntax: metareg y varlist [if exp] [in range] , { wsse(varname)| wsvar(varname) }
|
||||
[ bsest(string) toleran(#) level(#) noiter ]
|
||||
|
||||
To install in User Statistics menu via Stata commands:
|
||||
. window menu append item "stUserStatistics" "Meta-analysis Regression (meta®)" "db metareg"
|
||||
. window menu refresh
|
||||
To permanently install, place the commands in your -profile.do- file.
|
||||
*/
|
||||
|
||||
VERSION 8.0
|
||||
|
||||
INCLUDE _std_small
|
||||
INCLUDE header
|
||||
|
||||
HELP hlp1, view("help metareg")
|
||||
RESET res1, label("Reset")
|
||||
|
||||
DIALOG main, label("metareg 1.06 - Meta-analysis Regression") tabtitle("Main")
|
||||
BEGIN
|
||||
TEXT tx_theta 10 5 110 ., ///
|
||||
label("Dependent (y):")
|
||||
VARNAME vn_theta 110 5 230 ., ///
|
||||
label("Var for theta")
|
||||
|
||||
CHECKBOX cb_id 10 35 100 ., ///
|
||||
label("Covariates:") ///
|
||||
onclickon(main.vl_covar.enable) ///
|
||||
onclickoff(main.vl_covar.disable)
|
||||
VARLIST vl_covar 110 35 230 ., ///
|
||||
label("Vars for covariates")
|
||||
|
||||
GROUPBOX gb_ws 5 60 340 _ht3h, ///
|
||||
label("Within-study Varibility:")
|
||||
RADIO r_se 15 80 85 ., ///
|
||||
label("Std. Error") first ///
|
||||
option("wsse")
|
||||
RADIO r_var 155 80 75 ., ///
|
||||
label("Variance") last ///
|
||||
option("wsvar")
|
||||
TEXT tx_ws 10 100 110 ., ///
|
||||
label("Variable name:")
|
||||
VARNAME vn_ws 110 100 230 ., ///
|
||||
label("WS Variable")
|
||||
|
||||
|
||||
GROUPBOX gb_bsest 5 130 175 _ht3h, ///
|
||||
label("BS Method")
|
||||
RADIO r_reml 15 150 55 ., ///
|
||||
label("ReML") first ///
|
||||
option("bsest(reml)")
|
||||
RADIO r_ml 15 170 55 ., ///
|
||||
label("ML") middle ///
|
||||
option("bsest(ml)")
|
||||
RADIO r_eb 85 150 85 ., ///
|
||||
label("EmBayes") middle ///
|
||||
option("bsest(eb)")
|
||||
RADIO r_mm 85 170 85 ., ///
|
||||
label("Moments") last ///
|
||||
option("bsest(mm)")
|
||||
|
||||
CHECKBOX cb_noiter 210 135 95 ., ///
|
||||
label("No Iteration") ///
|
||||
option("noiter")
|
||||
|
||||
CHECKBOX cb_level 210 155 85 ., ///
|
||||
label("CI Level:") ///
|
||||
onclickon(main.ed_level.enable) ///
|
||||
onclickoff(main.ed_level.disable)
|
||||
EDIT ed_level 300 @ 40 ., ///
|
||||
label("Level") ///
|
||||
numonly default(95) ///
|
||||
option("level")
|
||||
|
||||
CHECKBOX cb_tol 210 175 85 ., ///
|
||||
label("Tolerance:") ///
|
||||
onclickon(main.ed_tol.enable) ///
|
||||
onclickoff(main.ed_tol.disable)
|
||||
EDIT ed_tol 300 @ 40 ., ///
|
||||
label("Tolerance") ///
|
||||
numonly default(4) ///
|
||||
option("toleran")
|
||||
END
|
||||
|
||||
INCLUDE ifin
|
||||
|
||||
PROGRAM command
|
||||
BEGIN
|
||||
put "metareg "
|
||||
varlist main.vn_theta [main.vl_covar]
|
||||
INCLUDE _ifin_pr
|
||||
beginoptions
|
||||
if main.r_se {
|
||||
put "wsse("
|
||||
}
|
||||
if main.r_var {
|
||||
put "wsvar("
|
||||
}
|
||||
put main.vn_ws
|
||||
put ")"
|
||||
option radio(main r_reml r_ml r_eb r_mm)
|
||||
option main.cb_noiter
|
||||
optionarg main.ed_level
|
||||
optionarg main.ed_tol
|
||||
endoptions
|
||||
END
|
368
Modules/ado/plus/m/metareg.hlp
Normal file
368
Modules/ado/plus/m/metareg.hlp
Normal file
@ -0,0 +1,368 @@
|
||||
{smcl}
|
||||
{* 31oct2008}{...}
|
||||
{cmd:help metareg}{right: ({browse "http://www.stata-journal.com/article.html?article=up0023":SJ8-4: sbe23_1})}
|
||||
{hline}
|
||||
|
||||
{title:Title}
|
||||
|
||||
{p2colset 5 16 18 2}{...}
|
||||
{p2col :{hi:metareg} {hline 2}}Meta-analysis regression (revised){p_end}
|
||||
{p2colreset}{...}
|
||||
|
||||
|
||||
{title:Syntax}
|
||||
|
||||
{p 8 15 2}
|
||||
{cmd: metareg}
|
||||
{it:{help varname:depvar}} [{it:{help varlist:indepvars}}]
|
||||
{ifin} {cmd:wsse(}{it:varname}{cmd:)}
|
||||
[, {cmdab:ef:orm}
|
||||
{cmdab:g:raph}
|
||||
{cmdab:ra:ndomsize}
|
||||
{cmdab:nocons:tant}
|
||||
{cmd:mm} {cmd:reml} {cmd:eb}
|
||||
{cmdab:k:napphartung} {cmd:z}
|
||||
{cmdab:tau:2test}
|
||||
{cmdab:l:evel(}{it:#}{cmd:)}
|
||||
{cmdab:perm:ute(}{it:#} [{cmd:,} {cmdab:u:nivariable} {cmdab:d:etail}
|
||||
{cmdab:j:oint(}{it:varlist1} [{cmd:|} {it:varlist2} ...]{cmd:)}]{cmd:)}
|
||||
{cmd:log}
|
||||
{it:maximize_options}]
|
||||
|
||||
{pstd}
|
||||
{cmd:by} can be used with {cmd:metareg}; see {manhelp by D}.
|
||||
|
||||
|
||||
{title:Description}
|
||||
|
||||
{pstd}
|
||||
{cmd:metareg} performs random-effects meta-regression
|
||||
using aggregate-level data.
|
||||
|
||||
{pstd}
|
||||
From a more abstract perspective, it extends {helpb vwls}
|
||||
by estimating an extra additive component of variance tau2:
|
||||
|
||||
{p 8 17 2}
|
||||
y_i = a + B*x_i + u_i + e_i
|
||||
|
||||
{pstd} where a is a constant, u_i is a normal error term with known standard deviations
|
||||
wsse_i that may vary across units, and e_i is a normal error with variance
|
||||
tau2 to be estimated, assumed equal across units. This is a similar model to
|
||||
those fit by the {helpb xt} commands, except that the within-unit data have
|
||||
been summarized by an effect estimate and its standard error for each unit i.
|
||||
|
||||
|
||||
{title:Options}
|
||||
|
||||
{phang}{cmd:wsse(}{it:varname}{cmd:)} specifies the variable
|
||||
containing the standard error of {it:depvar} within each study
|
||||
({ul:w}ithin-{ul:s}tudy {ul:s}tandard {ul:e}rror). All values of {it:varname}
|
||||
must be greater than zero. {cmd:wsse()} is required.
|
||||
|
||||
{phang}{cmd:eform} indicates to output the exponentiated form of the
|
||||
coefficients and to suppress reporting of the constant. This option may
|
||||
be useful when {it:depvar} is the logarithm of a ratio measure, such as a log
|
||||
odds-ratio or a log risk-ratio.
|
||||
|
||||
{phang}{cmd:graph} requests a line graph of fitted values
|
||||
plotted against the first covariate in {it:indepvars},
|
||||
together with the estimates from each study represented by circles.
|
||||
By default, the circle sizes depend on the precision of each estimate
|
||||
(the inverse of its within-study variance),
|
||||
which is the weight given to each study in the fixed-effects model.
|
||||
|
||||
{phang}{cmd:randomsize} is for use with the {cmd:graph} option. It
|
||||
specifies that the size of the circles will depend on the weights in the
|
||||
random-effects model rather than the precision of each estimate. These
|
||||
random-effects weights depend on the estimate of tau2.
|
||||
|
||||
{pstd} The remaining options will mainly be of interest to more advanced users:
|
||||
|
||||
{phang}{cmd:noconstant} suppresses the constant term (intercept).
|
||||
This is rarely appropriate in meta-regression.
|
||||
|
||||
{pstd} The {cmd:mm}, {cmd:reml}, and {cmd:eb} options are alternatives
|
||||
that specify the method of estimation
|
||||
of the additive (between-study) component of variance tau2.
|
||||
|
||||
{phang}{cmd:mm} specifies the use of method of moments to estimate the
|
||||
additive (between-study) component of variance tau2; this is a generalization
|
||||
of the DerSimonian and Laird (1986) method commonly used for random-effects
|
||||
meta-analysis. For speed, this is the default when the {cmd:permute()} option
|
||||
is specified, because it is the only noniterative method.
|
||||
|
||||
{phang}{cmd:reml} specifies the use of residual maximum likelihood (REML) to estimate the additive
|
||||
(between-study) component of variance tau2. This is the default unless the
|
||||
{cmd:permute()} option is specified. This revised version uses
|
||||
Stata's maximum likelihood facilities to maximize the REML
|
||||
log likelihood. It will therefore not give identical results to the previous
|
||||
version of {cmd:metareg}, which used an approximate iterative method.
|
||||
|
||||
{phang}{cmd:eb} specifies the use of the "empirical Bayes" method
|
||||
to estimate tau2 (Morris 1983).
|
||||
|
||||
{phang}{cmd:knapphartung} makes a modification to the variance of the
|
||||
estimated coefficients suggested by Knapp and Hartung (2003), accompanied by
|
||||
the use of a t distribution in place of the standard normal distribution when
|
||||
calculating p-values and confidence intervals. This is the default unless the
|
||||
{cmd:permute()} option is specified.
|
||||
|
||||
{phang}{cmd:z} requests that the {cmd:knapphartung} modification not be
|
||||
applied and that the standard normal distribution be used to calculate
|
||||
p-values and confidence intervals. This is the default when the
|
||||
{cmd:permute()} option is specified with a fixed-effects model.
|
||||
|
||||
{phang}{cmd:tau2test} adds to the output two tests of tau2 = 0. The first is
|
||||
based on the residual heterogeneity statistic, Q_res. The second (not
|
||||
available if the {cmd:mm} option is also
|
||||
specified) is a likelihood-ratio test based on the REML log likelihood. These
|
||||
are two tests of the same null hypothesis (the fixed-effects model with tau2
|
||||
= 0), but the alternative hypotheses are different, as are the distributions of
|
||||
the test statistics under the null, so close agreement of the two tests is not
|
||||
guaranteed. Both tests are typically of little interest because it is more
|
||||
helpful to quantify heterogeneity than to test for it.
|
||||
|
||||
{phang} {opt level(#)} specifies the confidence level, as a percentage, for
|
||||
confidence intervals. The default is {cmd:level(95)} or as set by
|
||||
{helpb set level}.
|
||||
|
||||
{phang} {cmd:permute(}...{cmd:)} calculates p-values by using a Monte Carlo permutation
|
||||
test. See {help metareg##permute:Option for permutation test} for more information about the option.
|
||||
|
||||
{phang}{cmd:log} requests the display of the iteration log during estimation of
|
||||
tau2. This is ignored if the {cmd:mm} option is specified, because this uses a
|
||||
noniterative method.
|
||||
|
||||
{phang}{it:maximize_options} are ignored unless estimation of tau2 is by REML.
|
||||
These options control the maximization process; see {helpb maximize}. You
|
||||
should never need to specify them; they are supported only in case problems in
|
||||
the REML estimation of tau2 are ever reported or suspected.
|
||||
|
||||
|
||||
{marker permute}{...}
|
||||
{title:Option for permutation test}
|
||||
|
||||
{pstd} The {cmd:permute()} option calculates p-values by using a Monte
|
||||
Carlo permutation test, as recommended by Higgins and
|
||||
Thompson (2004). To address multiple testing, {cmd:permute()} also calculates
|
||||
p-values for the most- to least-significant covariates, as the same
|
||||
authors also recommend.
|
||||
|
||||
{pstd}
|
||||
The syntax of {cmd:permute()} is
|
||||
|
||||
{p 8 15 2}{cmd:permute(}{it:#}
|
||||
[{cmd:,}
|
||||
{cmd:univariable}
|
||||
{cmd:detail}
|
||||
{cmd:joint(}{it:varlist1} [{cmd:|} {it:varlist2} ...]{cmd:)}]{cmd:)}
|
||||
|
||||
{pstd}
|
||||
where {it:#} is required and specifies the number of random permutations to
|
||||
perform. Larger values give more precise p-values but take longer.
|
||||
|
||||
{pstd}
|
||||
There are three suboptions:
|
||||
|
||||
{phang}{cmd:univariable} indicates that p-values should be calculated for a
|
||||
series of single covariate meta-regressions of each covariate in {it:varlist}
|
||||
separately, instead of a multiple meta-regression of all covariates in
|
||||
{it:varlist} simultaneously.
|
||||
|
||||
{phang}{cmd:detail} requests more detailed output in the style given by
|
||||
{helpb permute}.
|
||||
|
||||
{phang}{cmd:joint(}{it:varlist1} [{cmd:|} {it:varlist2} ...]{cmd:)}
|
||||
specifies that a permutation p-value should also be computed for a joint
|
||||
test of the variables in each {help varlist}.
|
||||
|
||||
{pstd}The {cmd:eform}, {cmd:level()}, and {cmd:z} options have
|
||||
no effect when the {cmd:permute()} option is specified.
|
||||
|
||||
|
||||
{title:Syntax of predict}
|
||||
|
||||
{p 4 4}
|
||||
The syntax of {helpb predict} following {cmd:metareg} is
|
||||
|
||||
{p 8 15 2}{cmd:predict} [{it:type}] {it:newvar} {ifin} [{cmd:,} {it:statistic}]
|
||||
|
||||
{pstd}
|
||||
where {it:statistic} is
|
||||
|
||||
{p 8 25}{cmd:xb}{space 11}fitted values; the default{p_end}
|
||||
{p 8 25}{cmd:stdp}{space 9}standard error of the prediction{p_end}
|
||||
{p 8 25}{cmd:stdf}{space 9}standard error of the forecast{p_end}
|
||||
{p 8 25}{cmd:u}{space 12}predicted random effects{p_end}
|
||||
{p 8 25}{cmdab:usta:ndard}{space 4}standardized predicted random effects{p_end}
|
||||
{p 8 25}{cmd:xbu}{space 10}prediction including random effects{p_end}
|
||||
{p 8 25}{cmd:stdxbu}{space 7}standard error of xbu{p_end}
|
||||
{p 8 25}{cmdab:h:at}{space 10}leverage (diagonal elements of hat matrix)
|
||||
|
||||
{pstd}
|
||||
These statistics are available both in and out of sample;
|
||||
type {cmd:predict ... if e(sample) ...} if wanted only for the estimation sample.
|
||||
|
||||
|
||||
{title:Options for predict}
|
||||
|
||||
{phang}{cmd:xb}, the default, calculates the linear prediction, x_i*b, that is, the fitted values excluding the random effects.
|
||||
|
||||
{phang}{cmd:stdp} calculates the standard error of the prediction
|
||||
(the standard error of the fitted values excluding the random effects).
|
||||
|
||||
{phang}{cmd:stdf} calculates the standard error of the forecast.
|
||||
This gives the standard deviation of the predicted distribution
|
||||
of the true value of {it:depvar} in a future study,
|
||||
with the covariates given by {it:varlist}.
|
||||
{break}stdf^2 = stdp^2 + tau2.
|
||||
|
||||
{phang}{cmd:u} calculates the predicted random effects, u_i. These are the
|
||||
best linear unbiased predictions of the random effects, also known as
|
||||
the empirical Bayes (or posterior mean) estimates of the random effects,
|
||||
or as shrunken residuals.
|
||||
|
||||
{phang}{cmd:ustandard} calculates the standardized predicted random effects,
|
||||
i.e., the predicted random effects, u_i,
|
||||
divided by their (unconditional) standard errors.
|
||||
These may be useful for diagnostics and model checking.
|
||||
|
||||
{phang}{cmd:xbu} calculates the prediction including random effects, a +
|
||||
B*x_i + u_i, also known as the empirical Bayes estimates of the effects for
|
||||
each study.
|
||||
|
||||
{phang}{cmd:stdxbu} calculates the standard error of the prediction including
|
||||
random effects.
|
||||
|
||||
{phang}{cmd:hat} calculates the leverages (the diagonal elements of the
|
||||
projection hat matrix).
|
||||
|
||||
|
||||
{title:Saved results}
|
||||
|
||||
{pstd}When the {cmd:permute()} option is not specified, {cmd:metareg} saves
|
||||
the following in {cmd:e()}:
|
||||
|
||||
{synoptset 20 tabbed}{...}
|
||||
{p2col 5 20 24 2: Scalars}{p_end}
|
||||
{synopt:{cmd:e(N)}}number of observations{p_end}
|
||||
{synopt:{cmd:e(df_m)}}model degrees of freedom{p_end}
|
||||
{synopt:{cmd:e(df_Q)}}degrees of freedom for test of Q=0{p_end}
|
||||
{synopt:{cmd:e(df_r)}}residual degrees of freedom (if t tests used){p_end}
|
||||
{synopt:{cmd:e(remll)}}REML log likelihood{p_end}
|
||||
{synopt:{cmd:e(chi2_c)}}chi^2 for comparison test{p_end}
|
||||
{synopt:{cmd:e(F)}}model F statistic{p_end}
|
||||
{synopt:{cmd:e(tau2)}}estimate of tau2{p_end}
|
||||
{synopt:{cmd:e(Q)}}Cochran's Q{p_end}
|
||||
{synopt:{cmd:e(I2)}}I-squared{p_end}
|
||||
{synopt:{cmd:e(q_KH)}}Knapp-Hartung variance modification factor{p_end}
|
||||
{synopt:{cmd:e(remll_c)}}REML log likelihood, comparison model{p_end}
|
||||
{synopt:{cmd:e(tau2_0)}}tau2, constant-only model{p_end}
|
||||
{synopt:{cmd:e(chi2)}}model chi^2{p_end}
|
||||
|
||||
{synoptset 20 tabbed}{...}
|
||||
{p2col 5 20 24 2: Macros}{p_end}
|
||||
{synopt:{cmd:e(cmd)}}{cmd:metareg}{p_end}
|
||||
{synopt:{cmd:e(predict)}}program used to implement {cmd:predict}{p_end}
|
||||
{synopt:{cmd:e(wsse)}}name of {cmd:wsse()} variable{p_end}
|
||||
{synopt:{cmd:e(depvar)}}name of dependent variable{p_end}
|
||||
{synopt:{cmd:e(method)}}{cmd:REML}, {cmd:Method of moments}, or
|
||||
{cmd:Empirical Bayes}{p_end}
|
||||
{synopt:{cmd:e(properties)}}{cmd:b V}{p_end}
|
||||
|
||||
{synoptset 20 tabbed}{...}
|
||||
{p2col 5 20 24 2: Matrices}{p_end}
|
||||
{synopt:{cmd:e(b)}}coefficient vector{p_end}
|
||||
{synopt:{cmd:e(V)}}variance-covariance matrix of estimators{p_end}
|
||||
|
||||
{synoptset 20 tabbed}{...}
|
||||
{p2col 5 20 24 2: Functions}{p_end}
|
||||
{synopt:{cmd:e(sample)}}marks estimation sample{p_end}
|
||||
{p2colreset}{...}
|
||||
|
||||
|
||||
{title:Examples}
|
||||
|
||||
{phang}{cmd:. metareg logrr latitude, wsse(selogrr) eform}
|
||||
|
||||
{phang}{cmd:. metareg logrr latitude, wsse(selogrr) graph}
|
||||
|
||||
{phang}{cmd:. metareg smd abstract duration itt, wsse(sesmd) permute(10000)}
|
||||
|
||||
{phang}{cmd:. metareg smd abstract duration itt, wsse(sesmd) permute(1000,}
|
||||
{cmd: univariable)}
|
||||
|
||||
{phang}{cmd:. xi: metareg logor i.group, wsse(selogor) permute(1000, joint(i.group))}
|
||||
|
||||
|
||||
{title:Note}
|
||||
|
||||
{pstd} {cmd:metareg} is programmed as a Stata estimation command and so
|
||||
supports many of the commands listed under {helpb estcom} and
|
||||
{helpb postest} (except when the {cmd:permute()} option is used). One
|
||||
deliberate exception is {helpb lrtest}, which is not appropriate after
|
||||
{cmd:metareg} (because the REML log likelihood cannot be used to compare models
|
||||
with different fixed effects, while the method of moments is not based on a
|
||||
likelihood). For this reason, when the REML method is used, the iteration log
|
||||
showing the log likelihood is suppressed by default; specify
|
||||
the {cmd:log} option if you wish to see it.
|
||||
|
||||
|
||||
{title:References}
|
||||
|
||||
{phang}DerSimonian, R., and N. Laird. 1986. Meta analysis in clinical trials.
|
||||
{it:Controlled Clinical Trials} 7: 177-188.
|
||||
|
||||
{phang} Higgins, J. P. T, and S. G. Thompson. 2004. Controlling the risk of
|
||||
spurious findings from meta-regression. {it:Statistics in Medicine} 23:
|
||||
1663-1682.
|
||||
|
||||
{phang} Knapp, G., and J. Hartung. 2003. Improved tests for a random effects
|
||||
meta-regression with a single covariate. {it:Statistics in Medicine} 22:
|
||||
2693-2710.
|
||||
|
||||
{phang} Morris, C. N. 1983. Parametric empirical Bayes inference: Theory and
|
||||
applications. {it:Journal of the American Statistical Association} 78: 47-55.
|
||||
|
||||
{phang} Sharp, S. 1998. sbe23: Meta-analysis regression. {it:Stata Technical Bulletin} 42: 16-22. Reprinted in {it:Stata Technical Bulletin Reprints}, vol. 7, pp. 148-155. College Station, TX: Stata Press.
|
||||
|
||||
|
||||
{title:Author}
|
||||
|
||||
{pstd}Roger M. Harbord{p_end}
|
||||
{pstd}Department of Social Medicine{p_end}
|
||||
{pstd}University of Bristol, UK{p_end}
|
||||
{pstd}{browse "mailto:roger.harbord@bristol.ac.uk":roger.harbord@bristol.ac.uk}{p_end}
|
||||
|
||||
|
||||
{title:Acknowledgments}
|
||||
|
||||
{pstd}
|
||||
This is a substantial revision of the original version of {cmd:metareg}
|
||||
written by Stephen Sharp (1998), who gave his permission to release this
|
||||
version under the same name and to incorporate his code. Julian Higgins gave
|
||||
advice on the permutation test. Aijing Shang tested early versions and made
|
||||
helpful suggestions. Portions of the new code borrow ideas from official
|
||||
Stata commands such as {cmd:nbreg}, and I thank StataCorp for making such code
|
||||
visible to the user.
|
||||
|
||||
{pstd}
|
||||
A dialog box, written by Thomas J. Steichen, is available for the original
|
||||
version of the {cmd:metareg} command.
|
||||
|
||||
|
||||
{title:Also see}
|
||||
|
||||
{psee}
|
||||
Article: {it:Stata Journal}, volume 8, number 4: {browse "http://www.stata-journal.com/article.html?article=up0023":sbe23_1},{break}
|
||||
{it:Stata Technical Bulletin} 42: {browse "http://www.stata.com/products/stb/journals/stb42.pdf":sbe23}
|
||||
|
||||
{psee}
|
||||
Manual: {hi:[R] meta},{break}
|
||||
{hi:[R] permute}
|
||||
|
||||
{psee}
|
||||
Online: {manhelp vwls R}, {manhelp permute R}, {helpb meta} (if installed),
|
||||
{helpb metan} (if installed), {help meta_dialog} (if installed)
|
||||
{p_end}
|
35
Modules/ado/plus/m/metareg_ll.ado
Normal file
35
Modules/ado/plus/m/metareg_ll.ado
Normal file
@ -0,0 +1,35 @@
|
||||
*! v 1.1 26Oct2004
|
||||
*! Roger Harbord
|
||||
/*
|
||||
log-likelihood evaluator (method d0) for metareg v2.
|
||||
Estimates tau2 by REML.
|
||||
Variables :
|
||||
$ML_y1 holds the y-vector of study estimates,
|
||||
$ML_y2 holds the within-study variances
|
||||
$REML_x holds the covariates
|
||||
$REML_nocons is flag "" or "noconstant"
|
||||
*/
|
||||
|
||||
program define metareg_ll
|
||||
version 7
|
||||
args todo b lnf
|
||||
tempvar lnfj v r
|
||||
tempname R tau2
|
||||
mleval `tau2' = `b', scalar
|
||||
quietly {
|
||||
gen double `v' = $ML_y2 +`tau2' /* v_i = sigma_i^2 + tau^2 */
|
||||
capture regress $ML_y1 $REML_x [iw=1/`v'] if $ML_samp, $REML_nocons
|
||||
if _rc == 0 {
|
||||
predict double `r' if $ML_samp, resid
|
||||
gen double `lnfj' = `r'^2/`v' +log(`v')
|
||||
mlsum `lnf' = `lnfj'
|
||||
matrix accum R = $REML_x [iw=1/`v'] if $ML_samp, $REML_nocons
|
||||
/* R = X'V^-1X is reml correction to -2logL */
|
||||
scalar `lnf' = -0.5 * ( `lnf' +log( det(R) ) )
|
||||
}
|
||||
else {
|
||||
scalar `lnf' = .
|
||||
}
|
||||
}
|
||||
|
||||
end
|
101
Modules/ado/plus/m/metareg_p.ado
Normal file
101
Modules/ado/plus/m/metareg_p.ado
Normal file
@ -0,0 +1,101 @@
|
||||
*! version 1.21 March 23, 2007 @ 17:05:47
|
||||
*! Roger Harbord
|
||||
/*
|
||||
code based on example in _pred_se.hlp
|
||||
v1.21 fixed stdxbu
|
||||
*/
|
||||
|
||||
program define metareg_p
|
||||
version 7
|
||||
local myopts "STDF U USTAndard XBU STDXBU Hat"
|
||||
_pred_se "`myopts'" `0' /* handles xp and stdp */
|
||||
if `s(done)' {
|
||||
exit
|
||||
}
|
||||
local typ `s(typ)'
|
||||
local varn `s(varn)'
|
||||
local 0 `"`s(rest)'"'
|
||||
syntax [if] [in] [, `myopts' noOFFset]
|
||||
|
||||
/* concatenate switch options together */
|
||||
local type "`stdf'`u'`ustandard'`xbu'`stdxbu'`hat'"
|
||||
|
||||
/* quickly process default case */
|
||||
if "`type'"=="" {
|
||||
di as txt "(option xb assumed; fitted values)"
|
||||
_predict `typ' `varn' `if' `in', xb `offset'
|
||||
exit
|
||||
}
|
||||
|
||||
/* mark sample */
|
||||
marksample touse
|
||||
|
||||
if "`type'"=="u" | "`type'"=="xbu" | "`type'" == "ustandard" {
|
||||
tempvar xb
|
||||
qui _predict double `xb' if `touse', xb `offset'
|
||||
}
|
||||
|
||||
if "`type'" == "stdf" | "`type'" == "stdxbu" | "`type'" == "ustandard" /*
|
||||
*/ | "`type'" == "hat" {
|
||||
tempvar stdp
|
||||
qui _predict double `stdp' if `touse', stdp `offset'
|
||||
}
|
||||
|
||||
if "`type'" == "u" | "`type'" == "xbu" | "`type'" == "stdxbu" /*
|
||||
*/ | "`type'" =="ustandard" | "`type'" =="hat" {
|
||||
tempvar wsvar
|
||||
if "`e(wsvar)'" !="" {
|
||||
qui gen `wsvar' = `e(wsvar)' if `touse'
|
||||
}
|
||||
else {
|
||||
qui gen `wsvar' = `e(wsse)'^2 if `touse'
|
||||
}
|
||||
}
|
||||
|
||||
if "`type'" == "u" | "`type'" == "xbu" | "`type'" == "stdxbu" {
|
||||
tempvar B /* Bayes shrinkage factor */
|
||||
qui gen double `B' = e(tau2) / ( e(tau2) + `wsvar' ) if `touse'
|
||||
}
|
||||
|
||||
|
||||
if "`type'" == "u" {
|
||||
gen `typ' `varn' = `B' * ( `e(depvar)' - `xb' ) if `touse'
|
||||
label var `varn' "Predicted random effects"
|
||||
exit
|
||||
}
|
||||
|
||||
if "`type'" == "xbu" {
|
||||
gen `typ' `varn' = `B' * `e(depvar)' + (1-`B') * `xb' if `touse'
|
||||
label var `varn' "Prediction including random effects"
|
||||
exit
|
||||
}
|
||||
|
||||
if "`type'" == "stdf" {
|
||||
gen `typ' `varn' = sqrt( `stdp'^2 + e(tau2) ) if `touse'
|
||||
label var `varn' "S.E. of the forecast"
|
||||
exit
|
||||
}
|
||||
|
||||
if "`type'" == "stdxbu" {
|
||||
gen `typ' `varn' = sqrt( `B'^2 * ( `wsvar' + e(tau2) ) ///
|
||||
+ (1-`B'^2) * `stdp'^2 ) if `touse'
|
||||
label var `varn' "S.E. of prediction incl. random effects"
|
||||
exit
|
||||
}
|
||||
|
||||
if "`type'" == "ustandard" {
|
||||
gen `typ' `varn' = ( `e(depvar)' - `xb' ) / /*
|
||||
*/ sqrt( `wsvar' + e(tau2) - `stdp'^2 ) if `touse'
|
||||
label var `varn' "Standardized predicted random effects"
|
||||
exit
|
||||
}
|
||||
|
||||
if "`type'" == "hat" {
|
||||
gen `typ' `varn' = `stdp'^2 / ( `wsvar' + e(tau2) ) if `touse'
|
||||
label var `varn' "Leverage"
|
||||
exit
|
||||
}
|
||||
|
||||
|
||||
error 198
|
||||
end
|
58
Modules/ado/plus/m/metareg_pm.ado
Normal file
58
Modules/ado/plus/m/metareg_pm.ado
Normal file
@ -0,0 +1,58 @@
|
||||
*! v1.3.0 8Sep2005
|
||||
/* added "joint" option to go with metareg.ado v2.3.1 */
|
||||
program define metareg_pm, rclass
|
||||
version 7
|
||||
syntax varlist [if], xvars(varlist numeric) [ univariable joint(string) ] *
|
||||
tokenize `varlist'
|
||||
args y wsvar n
|
||||
marksample touse
|
||||
tempvar xp z zabs
|
||||
tempname zi
|
||||
|
||||
foreach x of varlist `xvars' {
|
||||
gen `: type `x'' `xp' = `x'[`n'] if `touse'
|
||||
drop `x'
|
||||
rename `xp' `x'
|
||||
}
|
||||
|
||||
if "`univariable'" == "" { /* single multiple meta-regression */
|
||||
metareg `y' `xvars' if `touse', wsvar(`wsvar') notaucomp `options'
|
||||
|
||||
foreach x of varlist `xvars' {
|
||||
scalar `zi' = _b[`x'] / _se[`x']
|
||||
return scalar z_`x' = `zi'
|
||||
}
|
||||
}
|
||||
|
||||
else { /* separate univariable meta-regressions */
|
||||
foreach x of varlist `xvars' {
|
||||
metareg `y' `x' if `touse', wsvar(`wsvar') notaucomp `options'
|
||||
scalar `zi' = _b[`x'] / _se[`x']
|
||||
return scalar z_`x' = `zi'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
while "`joint'" != "" {
|
||||
gettoken tmp joint : joint, parse("\/|")
|
||||
if strpos("\/|", "`tmp'") {
|
||||
continue
|
||||
}
|
||||
local 0 `tmp'
|
||||
syntax varlist
|
||||
local j = `j' + 1
|
||||
qui test `varlist'
|
||||
if "`r(chi2)'" != "" {
|
||||
return scalar chi2`j' = r(chi2)
|
||||
}
|
||||
else {
|
||||
return scalar chi2`j' = r(F) * r(df)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
255
Modules/ado/plus/m/metatrim.dlg
Normal file
255
Modules/ado/plus/m/metatrim.dlg
Normal file
@ -0,0 +1,255 @@
|
||||
/*
|
||||
|
||||
*! metatrim dialog version 1.0.2, 22 Jul 2003, T. J. Steichen, steichen@triad.rr.com
|
||||
*! for metatrim version 1.0.5, 18 Oct 2002, T. J. Steichen, steichen@triad.rr.com
|
||||
|
||||
Nonparametric "trim and fill" analysis of publication bias in meta-analysis
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
syntax: metatrim varlist [if] [in]
|
||||
[ , Vari CI REffect PRint Funnel EForm LEvel(real 95) ESTimat(R|L|Q)
|
||||
GRaph IDvar(varname) FLIP MIXED SAve(filename [, REPLACE]) * ]
|
||||
|
||||
Install in User Statistics menu via Stata commands:
|
||||
. window menu append item "stUserStatistics" "meta&trim ("Trim and Fill" Analysis)" "db metatrim"
|
||||
. window menu refresh
|
||||
To permanently install, place the commands in your -profile.do- file.
|
||||
*/
|
||||
|
||||
VERSION 8.0
|
||||
|
||||
INCLUDE _std_small
|
||||
DEFINE _dlght 230
|
||||
INCLUDE header
|
||||
|
||||
HELP hlp1, view("help metatrim")
|
||||
RESET res1, label("Reset")
|
||||
|
||||
DIALOG main, label(`"metatrim 1.0.5 - "Trim and Fill" Analysis"') tabtitle("Main")
|
||||
BEGIN
|
||||
GROUPBOX gb_data 10 5 330 85, ///
|
||||
label("Type of Data")
|
||||
RADIO r_se 15 20 100 ., ///
|
||||
label("Theta, SE") first ///
|
||||
onclickon(script main_se_on) ///
|
||||
option(NONE)
|
||||
RADIO r_var 115 @ 100 ., ///
|
||||
label("Theta, Var") middle ///
|
||||
onclickon(script main_var_on) ///
|
||||
option("var")
|
||||
RADIO r_ci 215 @ 110 ., ///
|
||||
label("exp(Theta), CI") last ///
|
||||
onclickon(script main_ci_on) ///
|
||||
option("ci")
|
||||
|
||||
TEXT tx_se 15 40 320 ., ///
|
||||
label("Vars for theta, se(theta), in that order")
|
||||
VARLIST vl_se @ _ss @ ., ///
|
||||
label("Vars for theta, se(theta)")
|
||||
TEXT tx_var @ 40 320 ., ///
|
||||
label("Vars for theta, var(theta), in that order")
|
||||
VARLIST vl_var @ _ss @ ., ///
|
||||
label("Vars for theta, var(theta)")
|
||||
TEXT tx_ci @ 40 320 ., ///
|
||||
label("Vars for exp(theta), CI_LL, CI_UL, in that order")
|
||||
VARLIST vl_ci @ _ss @ ., ///
|
||||
label("Vars for exp(theta), CI_LL, CI_UL")
|
||||
|
||||
GROUPBOX gb_estimat 10 95 90 80, ///
|
||||
label("Estimate")
|
||||
RADIO r_linear 15 110 80 ., ///
|
||||
label("Linear") first ///
|
||||
option(NONE)
|
||||
RADIO r_run @ 130 @ ., ///
|
||||
label("Run") middle ///
|
||||
option("est(run)")
|
||||
RADIO r_quadratic @ 150 @ ., ///
|
||||
label("Quadratic") last ///
|
||||
option("est(quadratic)")
|
||||
|
||||
GROUPBOX gb_pool 105 95 90 60, ///
|
||||
label("Pooling")
|
||||
RADIO r_fixed 110 110 80 ., ///
|
||||
label("Fixed") first ///
|
||||
option(NONE)
|
||||
RADIO r_random @ 130 @ ., ///
|
||||
label("Random") last ///
|
||||
option("reffect")
|
||||
|
||||
CHECKBOX cb_eform 205 100 70 ., ///
|
||||
label("Eform") ///
|
||||
option("eform")
|
||||
|
||||
CHECKBOX cb_flip 205 120 70 ., ///
|
||||
label("Flip") ///
|
||||
option("flip")
|
||||
|
||||
CHECKBOX cb_mixed 205 140 70 ., ///
|
||||
label("Mixed") ///
|
||||
option("mixed")
|
||||
|
||||
CHECKBOX cb_graph 275 100 70 ., ///
|
||||
label("Graph") ///
|
||||
onclickon(program main_cb_graph_on) ///
|
||||
onclickoff(program main_cb_graph_off) ///
|
||||
option("graph")
|
||||
|
||||
CHECKBOX cb_funnel 275 120 70 ., ///
|
||||
label("Funnel") ///
|
||||
option("funnel")
|
||||
|
||||
CHECKBOX cb_print 275 140 70 ., ///
|
||||
label("Print") ///
|
||||
option("print") ///
|
||||
onclickon(program main_cb_print_on) ///
|
||||
onclickoff(program main_cb_print_off)
|
||||
|
||||
CHECKBOX cb_id 110 157 100 ., ///
|
||||
label("ID Variable:") ///
|
||||
onclickon(main.vn_id.enable) ///
|
||||
onclickoff(main.vn_id.disable)
|
||||
VARNAME vn_id 210 160 130 ., ///
|
||||
label("ID Variable") ///
|
||||
option("id")
|
||||
|
||||
CHECKBOX cb_fill_save 10 185 90 ., ///
|
||||
label("Save filled:") ///
|
||||
onclickon(main.fi_fill_save.enable) ///
|
||||
onclickoff(main.fi_fill_save.disable)
|
||||
FILE fi_fill_save 110 185 230 ., ///
|
||||
save ///
|
||||
label("File Name") ///
|
||||
error("Save File Name") ///
|
||||
dialogtitle("Save file") ///
|
||||
filter("Stata Data|*.dta") ///
|
||||
option("save")
|
||||
|
||||
CHECKBOX cb_gph_save 10 210 90 ., ///
|
||||
label("Save gph:") ///
|
||||
onclickon(main.fi_gph_save.enable) ///
|
||||
onclickoff(main.fi_gph_save.disable)
|
||||
FILE fi_gph_save 110 210 230 ., ///
|
||||
save ///
|
||||
label("File Name") ///
|
||||
error("Saving File Name") ///
|
||||
dialogtitle("Saving file") ///
|
||||
filter("Stata Graphs|*.gph") ///
|
||||
option("saving")
|
||||
END
|
||||
|
||||
INCLUDE ifin
|
||||
|
||||
PROGRAM main_cb_graph_on
|
||||
BEGIN
|
||||
call main.cb_id.enable
|
||||
if main.cb_id {
|
||||
call main.vn_id.enable
|
||||
}
|
||||
END
|
||||
|
||||
PROGRAM main_cb_graph_off
|
||||
BEGIN
|
||||
if !main.cb_print {
|
||||
call main.cb_id.disable
|
||||
call main.vn_id.disable
|
||||
}
|
||||
END
|
||||
|
||||
PROGRAM main_cb_print_on
|
||||
BEGIN
|
||||
call main.cb_id.enable
|
||||
if main.cb_id {
|
||||
call main.vn_id.enable
|
||||
}
|
||||
END
|
||||
|
||||
PROGRAM main_cb_print_off
|
||||
BEGIN
|
||||
if !main.cb_graph {
|
||||
call main.cb_id.disable
|
||||
call main.vn_id.disable
|
||||
}
|
||||
END
|
||||
|
||||
SCRIPT main_se_on
|
||||
BEGIN
|
||||
main.tx_se.show
|
||||
main.vl_se.show
|
||||
main.tx_se.enable
|
||||
main.vl_se.enable
|
||||
|
||||
main.tx_var.disable
|
||||
main.vl_var.disable
|
||||
main.tx_var.hide
|
||||
main.vl_var.hide
|
||||
|
||||
main.tx_ci.disable
|
||||
main.vl_ci.disable
|
||||
main.tx_ci.hide
|
||||
main.vl_ci.hide
|
||||
END
|
||||
|
||||
SCRIPT main_var_on
|
||||
BEGIN
|
||||
main.tx_var.show
|
||||
main.vl_var.show
|
||||
main.tx_var.enable
|
||||
main.vl_var.enable
|
||||
|
||||
main.tx_se.disable
|
||||
main.vl_se.disable
|
||||
main.tx_se.hide
|
||||
main.vl_se.hide
|
||||
|
||||
main.tx_ci.disable
|
||||
main.vl_ci.disable
|
||||
main.tx_ci.hide
|
||||
main.vl_ci.hide
|
||||
END
|
||||
|
||||
SCRIPT main_ci_on
|
||||
BEGIN
|
||||
main.tx_ci.show
|
||||
main.vl_ci.show
|
||||
main.tx_ci.enable
|
||||
main.vl_ci.enable
|
||||
|
||||
main.tx_se.disable
|
||||
main.vl_se.disable
|
||||
main.tx_se.hide
|
||||
main.vl_se.hide
|
||||
|
||||
main.tx_var.disable
|
||||
main.vl_var.disable
|
||||
main.tx_var.hide
|
||||
main.vl_var.hide
|
||||
END
|
||||
|
||||
PROGRAM command
|
||||
BEGIN
|
||||
put "metatrim "
|
||||
if main.r_se {
|
||||
varlist main.vl_se
|
||||
}
|
||||
if main.r_var {
|
||||
varlist main.vl_var
|
||||
}
|
||||
if main.r_ci {
|
||||
varlist main.vl_ci
|
||||
}
|
||||
INCLUDE _ifin_pr
|
||||
beginoptions
|
||||
option radio(main r_se r_var r_ci)
|
||||
option radio(main r_linear r_run r_quadratic)
|
||||
option radio(main r_fixed r_random)
|
||||
option main.cb_eform
|
||||
option main.cb_flip
|
||||
option main.cb_mixed
|
||||
option main.cb_print
|
||||
option main.cb_graph
|
||||
option main.cb_funnel
|
||||
optionarg main.vn_id
|
||||
optionarg main.fi_fill_save
|
||||
optionarg main.fi_gph_save
|
||||
endoptions
|
||||
END
|
628
Modules/ado/plus/m/mhplot.ado
Normal file
628
Modules/ado/plus/m/mhplot.ado
Normal file
@ -0,0 +1,628 @@
|
||||
*! 1.4.5 TJS 24 May 2001
|
||||
* based on hplot 1.4.4 NJC 23 May 2001
|
||||
program define mhplot
|
||||
version 6.0
|
||||
|
||||
#delimit ;
|
||||
syntax varlist(numeric) [if] [in]
|
||||
[, BOrder SOrt(string) noXaxis noYaxis PEn(string) Symbol(string)
|
||||
T1title(string) T2title(string asis) TItle(str asis) TTIck VALLBL(varname)
|
||||
XLAbel(numlist) XLIne(numlist) XSCale(str) XTIck(numlist) Axtol(int 600)
|
||||
Blank flipt Format(string) FONTC(int 290) FONTR(int 570) FONTCB(int 444)
|
||||
FONTRB(int 923) GAPMag(real 1) GAPs(numlist int) GLegend(string)
|
||||
GLLJ GLPOS(int -1) t2m(int 0) Grid LAP Legend(string) LIne NIT2
|
||||
t1m(int 0) PTSize(int 275) Range RLegend(varname) rllj RLPos(int 31500)
|
||||
TIM(int 0) Vat VATFmt(string) VATPos(int 31500) Cstart(int -1)
|
||||
SAving(string) PENText(int 1) ] ;
|
||||
#delimit cr
|
||||
|
||||
qui {
|
||||
tempvar touse order gleg gap dmin dmax dneg dpos z
|
||||
mark `touse' `if' `in'
|
||||
Markout2 `touse' `varlist'
|
||||
gen `order' = _n
|
||||
gsort - `touse' `sort' `order'
|
||||
count if `touse'
|
||||
local nuse = r(N)
|
||||
|
||||
* legend on left
|
||||
if "`legend'" == "" {
|
||||
tempvar legend
|
||||
gen str1 `legend' = " "
|
||||
if "`blank'" == "" { replace `legend' = string(_n) if `touse' }
|
||||
}
|
||||
else {
|
||||
confirm variable `legend'
|
||||
capture confirm string variable `legend'
|
||||
if _rc == 7 {
|
||||
tempvar legend2
|
||||
capture decode `legend', gen(`legend2')
|
||||
if _rc {
|
||||
gen str1 `legend2' = ""
|
||||
replace `legend2' = string(`legend')
|
||||
}
|
||||
else { replace `legend2' = string(`legend') if missing(`legend2') }
|
||||
local legend "`legend2'"
|
||||
}
|
||||
}
|
||||
local leglen : type `legend'
|
||||
local leglen = substr("`leglen'", 4, .)
|
||||
if `cstart' == -1 {
|
||||
local cstart = 2000 + int(9000 * `leglen' / 25)
|
||||
}
|
||||
|
||||
* legend on right
|
||||
if "`rlegend'" != "" {
|
||||
capture confirm string variable `rlegend'
|
||||
if _rc == 7 {
|
||||
tempvar rleg2
|
||||
capture decode `rlegend', gen(`rleg2')
|
||||
if _rc == 0 {
|
||||
replace `rleg2' = string(`rlegend') if missing(`rleg2')
|
||||
local rlegend "`rleg2'"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
* axis scale
|
||||
if "`xscale'" != "" {
|
||||
tokenize "`xscale'", parse(",")
|
||||
if "`4'" != "" | "`2'" != "," {
|
||||
di in r "invalid xscale( ) option"
|
||||
exit 198
|
||||
}
|
||||
local xscmin `1'
|
||||
local xscmax `3'
|
||||
}
|
||||
|
||||
if "`xscmin'" == "" { local min 0 }
|
||||
else local min `xscmin'
|
||||
if "`xscmax'" == "" { local max 0 }
|
||||
else local max `xscmax'
|
||||
|
||||
* xlabel xtick xline might extend graph range beyond data range
|
||||
if "`xlabel'`xtick'`xline'" != "" {
|
||||
numlist "`xlabel' `xtick' `xline'", sort
|
||||
local nn : word count `r(numlist)'
|
||||
local xmin : word 1 of `r(numlist)'
|
||||
local xmax : word `nn' of `r(numlist)'
|
||||
local min = min(`min', `xmin')
|
||||
local max = max(`max', `xmax')
|
||||
}
|
||||
|
||||
* gap legend?
|
||||
gen str1 `gleg' = " "
|
||||
local glj = cond("`gllj'" != "", -1, 1)
|
||||
if "`glegend'" != "" {
|
||||
tokenize "`glegend'", parse("!")
|
||||
local j 1
|
||||
while "`1'" != "" {
|
||||
if "`1'" != "!" {
|
||||
if "`1'" == "." { local 1 " " }
|
||||
local gleg`j' "`1'"
|
||||
local j = `j' + 1
|
||||
}
|
||||
mac shift
|
||||
}
|
||||
}
|
||||
|
||||
* gaps between lines?
|
||||
gen byte `gap' = 0
|
||||
if "`gaps'" != "" {
|
||||
local j 1
|
||||
numlist "`gaps'", int range(>=0)
|
||||
tokenize `r(numlist)'
|
||||
while "`1'" != "" {
|
||||
if "`1'" == "0" {
|
||||
local gleg0 "`gleg`j''"
|
||||
if "`gleg0'" == "" { local gleg0 " " }
|
||||
}
|
||||
else {
|
||||
replace `gap' = 1 in `1' if `1' <= `nuse'
|
||||
replace `gleg' = "`gleg`j''" in `1' if `1' <= `nuse'
|
||||
}
|
||||
local j = `j' + 1
|
||||
mac shift
|
||||
}
|
||||
}
|
||||
count if `gap'
|
||||
local ngaps = r(N) + ("`gleg0'" != "")
|
||||
|
||||
* data range
|
||||
tokenize `varlist'
|
||||
local nvars : word count `varlist'
|
||||
gen `dmin' = `1'
|
||||
gen `dmax' = `1'
|
||||
if `nvars' >= 2 {
|
||||
local i 2
|
||||
while `i' <= `nvars' {
|
||||
replace `dmin' = min(`dmin', ``i'')
|
||||
replace `dmax' = max(`dmax', ``i'')
|
||||
local i = `i' + 1
|
||||
}
|
||||
}
|
||||
su `dmin' if `touse', meanonly
|
||||
local min = min(`min', r(min))
|
||||
su `dmax' if `touse', meanonly
|
||||
local max = max(`max', r(max))
|
||||
local drange = `max' - `min'
|
||||
local zero = cond(`min' >= 0, max(0, `min'), min(0, `max'))
|
||||
gen `z' = `zero'
|
||||
gen `dneg' = min(`dmin', `z')
|
||||
gen `dpos' = max(`dmax', `z')
|
||||
}
|
||||
|
||||
* start of parameter block
|
||||
|
||||
local t1start 1000 /* row for t1title */
|
||||
local t2start 1900 /* row for t2title */
|
||||
local ybeg 2400 /* start of y-axis */
|
||||
local ylength 17600
|
||||
|
||||
* `axtol' is space at ends of y-axis
|
||||
* axtol too large => ystep negative FW
|
||||
if `axtol' > `ylength' / 2 {
|
||||
di in bl "axtol too large: reset to default 600"
|
||||
local axtol 600
|
||||
}
|
||||
|
||||
* row where first line starts
|
||||
local ystart = `ybeg' + `axtol'
|
||||
|
||||
* step between lines: one gap defaults to one line
|
||||
local ystep = (`ylength' - 2 * `axtol') / (`nuse' - 1 + `ngaps' *`gapmag')
|
||||
|
||||
local yend = `ybeg' + `ylength'
|
||||
local ynudge = 200 * (`fontr' / 570)^2
|
||||
/* text displaced downwards from lines */
|
||||
local ytick 400 /* tick length */
|
||||
local yleg 1000 /* labels down from axis */
|
||||
local yleg = `yend' + `yleg'
|
||||
local ytitle 1400 /* title down from labels */
|
||||
local ytitlef 900 /* title down from labels, flip titles */
|
||||
local xstart `cstart' /* col where first line begins */
|
||||
local xgap 400 /* gap between left legend and body of plot */
|
||||
local xbeg = `xstart' - `xgap'
|
||||
if `glpos' == -1 { local glpos `xbeg' }
|
||||
local xlength = 30000 - `xstart'
|
||||
/* horizontal extent of data region */
|
||||
local xend = `xbeg' + `xgap' + `xlength'
|
||||
local xz = `xbeg' + `xgap' + `xlength' * (`zero' - `min') / `drange'
|
||||
local mcent = (`cstart' + 30000) / 2 + `tim'
|
||||
/* col where main title centred */
|
||||
local dotsp 150 /* spacing between dots */
|
||||
|
||||
if "`format'" == "" { local format "%1.0f" }
|
||||
if "`vatfmt'" == "" { local vatfmt "%1.0f" }
|
||||
local ahl = 500 * `ptsize' / 275 /* arrowhead length */
|
||||
local aha = _pi / 6 /* arrowhead angle, between head and stem */
|
||||
local barht `ahl' /* bar height */
|
||||
|
||||
if "`symbol'" == "" {
|
||||
if `nvars' < 6 { local symbol "46253" }
|
||||
else local symbol : di _dup(`nvars') "4"
|
||||
}
|
||||
else if length("`symbol'") == 1 & `nvars' > 1 {
|
||||
local symbol : di _dup(`nvars') "`symbol'"
|
||||
}
|
||||
Gphtrans `symbol'
|
||||
local symbol "`r(symbol)'"
|
||||
|
||||
if "`pen'" == "" { local pen : di _dup(`nvars') "2" }
|
||||
else if length("`pen'") == 1 & `nvars' > 1 {
|
||||
local pen : di _dup(`nvars') "`pen'"
|
||||
}
|
||||
|
||||
* end of parameter block
|
||||
|
||||
* start gph
|
||||
if "`saving'" != "" { local saving ", saving(`saving')" }
|
||||
gph open `saving' /* FW */
|
||||
gph pen `pentext'
|
||||
gph font `fontr' `fontc'
|
||||
|
||||
* y-axis
|
||||
if "`yaxis'" == "" { gph line `ybeg' `xstart' `yend' `xstart' }
|
||||
|
||||
* ttick => top ticks
|
||||
local ttick = "`ttick'" == "ttick"
|
||||
* ttick should => border FW
|
||||
if `ttick' { local border "border" }
|
||||
|
||||
* x-axis and labels
|
||||
if "`xaxis'" == "" {
|
||||
gph line `yend' `xstart' `yend' `xend'
|
||||
local ytick2 = `ybeg' - `ytick' / 2
|
||||
local ytick = `yend' + `ytick'
|
||||
if "`xlabel'" == "" {
|
||||
gph line `yend' `xstart' `ytick' `xstart'
|
||||
gph line `yend' `xend' `ytick' `xend'
|
||||
if `ttick' {
|
||||
gph line `ybeg' `xstart' `ytick2' `xstart'
|
||||
gph line `ybeg' `xend' `ytick2' `xend' /* FW */
|
||||
}
|
||||
local text = cond("`lap'" == "lap", abs(`min'), `min')
|
||||
local text : di `format' `text'
|
||||
gph text `yleg' `xstart' 0 0 `text'
|
||||
local text = cond("`lap'" == "lap", abs(`max'), `max')
|
||||
local text : di `format' `text'
|
||||
gph text `yleg' `xend' 0 0 `text'
|
||||
}
|
||||
else {
|
||||
numlist "`xlabel'"
|
||||
tokenize `r(numlist)'
|
||||
if "`vallbl'" != "" { local vallbl : value label `vallbl' }
|
||||
while "`1'" != "" {
|
||||
local xtickp = `xbeg' + `xgap' + `xlength' * (`1' - `min') / `drange'
|
||||
gph line `yend' `xtickp' `ytick' `xtickp'
|
||||
if `ttick' { gph line `ybeg' `xtickp' `ytick2' `xtickp' }
|
||||
local text = cond("`lap'" == "lap", abs(`1'), `1')
|
||||
if "`vallbl'" != "" {
|
||||
local label : label `vallbl' `text'
|
||||
if "`label'" != "" { local text "`label'" }
|
||||
}
|
||||
else local text : di `format' `text'
|
||||
gph text `yleg' `xtickp' 0 0 `text'
|
||||
mac shift
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
* x-ticks
|
||||
if "`xtick'" != "" {
|
||||
numlist "`xtick'"
|
||||
tokenize `r(numlist)'
|
||||
while "`1'" != "" {
|
||||
local xtickp = `xbeg' + `xgap' + `xlength' * (`1' - `min') / `drange'
|
||||
gph line `yend' `xtickp' `ytick' `xtickp'
|
||||
if `ttick' { gph line `ybeg' `xtickp' `ytick2' `xtickp' }
|
||||
mac shift
|
||||
}
|
||||
}
|
||||
|
||||
* x-lines
|
||||
if "`xline'" != "" {
|
||||
numlist "`xline'"
|
||||
tokenize `r(numlist)'
|
||||
while "`1'" != "" {
|
||||
local xli = `xbeg' + `xgap' + `xlength' * (`1' - `min') / `drange'
|
||||
gph line `yend' `xli' `ybeg' `xli'
|
||||
mac shift
|
||||
}
|
||||
}
|
||||
|
||||
* border
|
||||
if "`border'" != "" {
|
||||
gph line `ybeg' `xstart' `ybeg' `xend'
|
||||
gph line `ybeg' `xend' `yend' `xend'
|
||||
if "`xaxis'" != "" { gph line `yend' `xstart' `yend' `xend' }
|
||||
}
|
||||
|
||||
* gap legend above first data point
|
||||
if "`gleg0'" != "" {
|
||||
local y2 = `ystart' + (`gapmag' - 1) * `ystep' + `ynudge'
|
||||
gph text `y2' `glpos' 0 `glj' `gleg0'
|
||||
}
|
||||
|
||||
* for each variable
|
||||
tokenize `varlist'
|
||||
local j 1
|
||||
while "`1'" != "" {
|
||||
|
||||
local data "`1'"
|
||||
local sy = substr("`symbol'", `j', 1)
|
||||
local pe = substr("`pen'", `j', 1)
|
||||
local y `ystart'
|
||||
if "`gleg0'" != "" { local y = `y' + `ystep' * `gapmag' }
|
||||
|
||||
* for each observation
|
||||
local i 1
|
||||
while `i' <= `nuse' {
|
||||
|
||||
/* tjs code */
|
||||
* dots and/or lines
|
||||
if `j' == 1 {
|
||||
|
||||
local xmax = `xbeg' + `xgap' + /*
|
||||
*/ `xlength' * (`dmax'[`i'] - `min') / `drange'
|
||||
local xmin = `xbeg' + `xgap' + /*
|
||||
*/ `xlength' * (`dmin'[`i'] - `min') / `drange'
|
||||
|
||||
if "`line'" == "line" { gph line `y' `xmin' `y' `xmax' }
|
||||
|
||||
if "`line'`grid'" == "" {
|
||||
if "`range'" == "range" {
|
||||
local ndots = int(abs(`xmax' - `xmin') / `dotsp')
|
||||
tempvar ys xs
|
||||
if `ndots' > _N { qui set obs `ndots' }
|
||||
qui gen `ys' = `y'
|
||||
qui gen `xs' = _n
|
||||
qui replace `xs' = `xmin' + (`xs' - 1) * `dotsp'
|
||||
qui replace `xs' = . if `xs' < `xmin' | `xs' > `xmax'
|
||||
gph vpoint `ys' `xs', size(`ptsize') symbol(0)
|
||||
}
|
||||
else {
|
||||
local ndots = int(abs(`xmax' - `xz') / `dotsp')
|
||||
tempvar ys xs
|
||||
if `ndots' > _N { qui set obs `ndots' }
|
||||
qui gen `ys' = `y'
|
||||
qui gen `xs' = _n
|
||||
qui replace `xs' = `xz' + (`xs' - 1) * `dotsp' * sign(`dpos'[`i'])
|
||||
qui replace `xs' = . if `xs' < `xmin' | `xs' > `xmax'
|
||||
gph vpoint `ys' `xs', size(`ptsize') symbol(0)
|
||||
|
||||
local ndots = int(abs(`xmin' - `xz') / `dotsp')
|
||||
tempvar ys xs
|
||||
if `ndots' > _N { qui set obs `ndots' }
|
||||
qui gen `ys' = `y'
|
||||
qui gen `xs' = _n
|
||||
qui replace `xs' = `xz' + (`xs' - 1) * `dotsp' * sign(`dneg'[`i'])
|
||||
qui replace `xs' = . if `xs' < `xmin' | `xs' > `xmax'
|
||||
gph vpoint `ys' `xs', size(`ptsize') symbol(0)
|
||||
}
|
||||
}
|
||||
|
||||
if "`grid'" != "" {
|
||||
tempvar ys xs
|
||||
local ndots = int(abs(`xstart' - `xend') / `dotsp')
|
||||
if `ndots' > _N { qui set obs `ndots' }
|
||||
qui gen `ys' = `y'
|
||||
qui gen `xs' = _n
|
||||
qui replace `xs' = `xstart' + (`xs' - 1) * `dotsp'
|
||||
qui replace `xs' = . if `xs' > `xend'
|
||||
gph vpoint `ys' `xs', size(`ptsize') symbol(0)
|
||||
}
|
||||
}
|
||||
/* tjs code end */
|
||||
|
||||
* data point
|
||||
gph pen `pe'
|
||||
local x = `xbeg' + `xgap' + `xlength' * (`data'[`i'] - `min') / `drange'
|
||||
if `data'[`i'] < . & "`sy'" != "i" {
|
||||
if "`sy'" == "a" {
|
||||
if `j' == 1 { local sign 1 }
|
||||
else local sign = sign(`data'[`i'] - `prev'[`i'])
|
||||
Gphhah `y' `x' `sign' `ahl' `aha'
|
||||
}
|
||||
else if "`sy'" == ">" { Gphhah `y' `x' 1 `ahl' `aha' }
|
||||
else if "`sy'" == "<" { Gphhah `y' `x' -1 `ahl' `aha' }
|
||||
else Gphpt `sy' `y' `x' `barht' `ptsize'
|
||||
}
|
||||
|
||||
* text
|
||||
gph pen `pentext'
|
||||
local y2 = `y' + `ynudge'
|
||||
if "`vat'" != "" & `nvars' == 1 {
|
||||
local text : di `vatfmt' `data'[`i']
|
||||
gph text `y2' `vatpos' 0 1 `text'
|
||||
}
|
||||
if `j' == 1 {
|
||||
local text = `legend'[`i']
|
||||
gph text `y2' `xbeg' 0 1 `text'
|
||||
}
|
||||
if `j' == 1 & "`rlegend'" != "" {
|
||||
local text = `rlegend'[`i']
|
||||
local rlj = cond("`rllj'" != "", -1, 1)
|
||||
gph text `y2' `rlpos' 0 `rlj' `text'
|
||||
}
|
||||
|
||||
* gap
|
||||
if `gap'[`i'] {
|
||||
local y = `y' + `ystep' * `gapmag'
|
||||
if `j' == 1 {
|
||||
local text = `gleg'[`i']
|
||||
local y2 = `y' + `ynudge'
|
||||
gph text `y2' `glpos' 0 `glj' `text'
|
||||
}
|
||||
}
|
||||
|
||||
local y = `y' + `ystep'
|
||||
local i = `i' + 1
|
||||
}
|
||||
* next observation
|
||||
|
||||
local prev `1'
|
||||
local j = `j' + 1
|
||||
mac shift
|
||||
}
|
||||
* next variable
|
||||
|
||||
* t2title, left justified (defaults to key for 2 or more variables)
|
||||
if "`t2title'" != "" & trim("`t2title'") == "" { local t2title }
|
||||
else if "`t2title'" != "" { gph text `t2start' `xstart' 0 -1 `t2title' }
|
||||
else if `nvars' >= 2 {
|
||||
local t2 = `t2start' - `ynudge'
|
||||
local xjump = `xlength' / `nvars'
|
||||
local xjump2 = `xjump' / 50
|
||||
local x = `xstart' + `xjump2' + `t2m'
|
||||
local j 1
|
||||
while `j' <= `nvars' {
|
||||
local sy = substr("`symbol'", `j', 1)
|
||||
local pe = substr("`pen'", `j', 1)
|
||||
gph pen `pe'
|
||||
if "`sy'" == "a" {
|
||||
local ahv = index("`symbol'", "a")
|
||||
if `ahv' > 1 {
|
||||
local this : word `ahv' of `varlist'
|
||||
local ahvm1 = `ahv' - 1
|
||||
local prev : word `ahvm1' of `varlist'
|
||||
count if `this' >= `prev' & `touse'
|
||||
local majsign = cond(r(N) > `nuse' / 2, 1, -1)
|
||||
}
|
||||
else local majsign 1
|
||||
local x3 = `x' + 0.6 * `ptsize' * `majsign'
|
||||
Gphhah `t2' `x3' `majsign' `ahl' `aha'
|
||||
}
|
||||
else if "`sy'" == ">" {
|
||||
local x3 = `x' + 0.6 * `ptsize'
|
||||
Gphhah `t2' `x3' 1 `ahl' `aha'
|
||||
}
|
||||
else if "`sy'" == "<" {
|
||||
local x3 = `x' - 0.6 * `ptsize'
|
||||
Gphhah `t2' `x3' -1 `ahl' `aha'
|
||||
}
|
||||
else if "`sy'" != "i" {
|
||||
Gphpt `sy' `t2' `x' `barht' `ptsize'
|
||||
}
|
||||
local x2 = `x' + `xjump2'
|
||||
local var : word `j' of `varlist'
|
||||
if "`nit2'" == "" {
|
||||
local text : variable label `var'
|
||||
if "`text'" == "" { local text "`var'" }
|
||||
}
|
||||
else local text "`var'"
|
||||
gph pen `pentext'
|
||||
gph text `t2start' `x2' 0 -1 `text'
|
||||
local x = `x' + `xjump'
|
||||
local j = `j' + 1
|
||||
}
|
||||
}
|
||||
|
||||
* title and t1title
|
||||
if `"`title'"' == `""' & `nvars' == 1 {
|
||||
local title : variable label `data'
|
||||
if "`title'" == "" { local title "`data'" }
|
||||
}
|
||||
else if `"`title'"' != `""' { local title `title' }
|
||||
|
||||
local xL = `xstart' + `t1m'
|
||||
if "`flipt'" == "" { /* default */
|
||||
* t1title, left justified
|
||||
gph text `t1start' `xL' 0 -1 `t1title'
|
||||
|
||||
* main title at bottom, centred
|
||||
gph font `fontrb' `fontcb'
|
||||
local ytitle = `yleg' + `ytitle'
|
||||
gph text `ytitle' `mcent' 0 0 `title'
|
||||
}
|
||||
else { /* flip titles from default */
|
||||
* bottom title, centred (and closer to axis than default)
|
||||
local ytitle = `yleg' + `ytitlef'
|
||||
gph text `ytitle' `mcent' 0 0 `t1title'
|
||||
|
||||
* main title at top, left justified
|
||||
gph font `fontrb' `fontcb'
|
||||
gph text `t1start' `xL' 0 -1 `title'
|
||||
}
|
||||
|
||||
gph close
|
||||
end
|
||||
|
||||
program define Gphhah /* horizontal arrow head */
|
||||
* `1' y position of tip
|
||||
* `2' x position of tip
|
||||
* `3' sign determines direction: 1 = >, -1 = <
|
||||
* `4' arrowhead length
|
||||
* `5' arrowhead interior angle (between shaft and head)
|
||||
* 1.0.1 NJC 18 February 1999
|
||||
* 1.0.0 NJC 27 May 1997
|
||||
version 6.0
|
||||
local ah1y = `1' - `3' * `4' * sin(`5')
|
||||
local ah1x = `2' - `3' * `4' * cos(`5')
|
||||
local ah2y = `1' + `3' * `4' * sin(`5')
|
||||
local ah2x = `2' - `3' * `4' * cos(`5')
|
||||
gph line `ah1y' `ah1x' `1' `2'
|
||||
gph line `ah2y' `ah2x' `1' `2'
|
||||
end
|
||||
|
||||
program define Gphbar /* vertical bar */
|
||||
* Gphbar yposition xposition bar_height
|
||||
* 1.0.1 NJC 18 February 1999
|
||||
* 1.0.0 NJC 27 May 1997
|
||||
version 6.0
|
||||
local by1 = `1' - 0.5 * `3'
|
||||
local by2 = `1' + 0.5 * `3'
|
||||
gph line `by1' `2' `by2' `2'
|
||||
end
|
||||
|
||||
program define Gphcross /* cross X */ /* FW */
|
||||
* Gphcross yposition xposition bar_height
|
||||
* 1.0.1 NJC 18 February 1999
|
||||
* 1.0.0 NJC 6 October 1997
|
||||
version 6.0
|
||||
local Xy1 = `1' - 0.5 * `3'
|
||||
local Xy2 = `1' + 0.5 * `3'
|
||||
local Xx1 = `2' - 0.5 * `3'
|
||||
local Xx2 = `2' + 0.5 * `3'
|
||||
gph line `Xy1' `Xx1' `Xy2' `Xx2'
|
||||
gph line `Xy2' `Xx1' `Xy1' `Xx2'
|
||||
end
|
||||
|
||||
program def Markout2 /* marks out obs with all missing values */
|
||||
* 1.0.2 NJC 16 February 1999
|
||||
* 1.0.1 NJC 25 March 1998
|
||||
version 6.0
|
||||
syntax varlist(min=1) [, Strok ]
|
||||
tokenize `varlist'
|
||||
local nvars : word count `varlist'
|
||||
if `nvars' == 1 { exit 0 }
|
||||
local nvars = `nvars' - 1
|
||||
local markvar `1'
|
||||
mac shift
|
||||
tempvar nmiss
|
||||
gen `nmiss' = 0
|
||||
qui {
|
||||
while "`1'" != "" {
|
||||
local type : type `1'
|
||||
if substr("`type'", 1, 3) == "str" {
|
||||
if "`strok'" != "" { replace `nmiss' = `nmiss' + (`1' == "") }
|
||||
else replace `nmiss' = `nmiss' + 1
|
||||
}
|
||||
else replace `nmiss' = `nmiss' + (`1' == .)
|
||||
mac shift
|
||||
}
|
||||
replace `nmiss' = `nmiss' == `nvars'
|
||||
replace `markvar' = 0 if `nmiss'
|
||||
}
|
||||
end
|
||||
|
||||
program def Gphtrans, rclass /* transliterate ".OSTodp" -> "0123456" */
|
||||
* 1.0.2 NJC 1 March 1999
|
||||
* 1.0.0 NJC 31 March 1998
|
||||
version 6.0
|
||||
args argin
|
||||
local length = length("`argin'")
|
||||
|
||||
local i 1
|
||||
while `i' <= `length' {
|
||||
local s = substr("`argin'", `i', 1)
|
||||
if "`s'" == "." { local s 0 }
|
||||
else if "`s'" == "O" { local s 1 }
|
||||
else if "`s'" == "S" { local s 2 }
|
||||
else if "`s'" == "T" { local s 3 }
|
||||
else if "`s'" == "o" { local s 4 }
|
||||
else if "`s'" == "d" { local s 5 }
|
||||
else if "`s'" == "p" { local s 6 }
|
||||
local argout "`argout'`s'"
|
||||
local i = `i' + 1
|
||||
}
|
||||
|
||||
return local symbol `argout'
|
||||
end
|
||||
|
||||
program def Gphpt
|
||||
* 1.2.2 NJC 24 February 1999 smaller big cross, bigger ,
|
||||
* 1.2.1 NJC 18 February 1999
|
||||
* 1.2.0 NJC 12 Jan 1999
|
||||
* 1.1.0 NJC 24 Sept 1998
|
||||
* 1.0.0 NJC 6 April 1998
|
||||
version 6.0
|
||||
args sy y x barht ptsize
|
||||
|
||||
if "`sy'" == "|" { Gphbar `y' `x' `barht' }
|
||||
else if "`sy'" == "," { Gphbar `y' `x' 0.6*`barht' }
|
||||
else if "`sy'" == "X" { Gphcross `y' `x' 0.707*`barht' }
|
||||
else if "`sy'" == "x" { Gphcross `y' `x' 0.5*`barht' }
|
||||
else if "`sy'" == "-" { Gphhbar `y' `x' 0.5*`barht' }
|
||||
else gph point `y' `x' `ptsize' `sy'
|
||||
end
|
||||
|
||||
program define Gphhbar /* horizontal bar */
|
||||
* Gphhbar yposition xposition bar_length
|
||||
* 1.0.1 NJC 18 February 1999
|
||||
* 1.0.0 NJC 24 Sept 1998
|
||||
version 6.0
|
||||
local bx1 = `2' - 0.5 * `3'
|
||||
local bx2 = `2' + 0.5 * `3'
|
||||
gph line `1' `bx1' `1' `bx2'
|
||||
end
|
437
Modules/ado/plus/m/micombine.ado
Normal file
437
Modules/ado/plus/m/micombine.ado
Normal file
@ -0,0 +1,437 @@
|
||||
*! version 1.1.1 PR 28nov2005
|
||||
/*
|
||||
History
|
||||
|
||||
1.1.1 28nov2005 eform and eform() option styles now allowed.
|
||||
nowarning option to suppress warning message about supported regression cmds.
|
||||
1.1.0 30sep2005 Generalization of supported commands (cmdchk.ado also modified).
|
||||
Version <=7 no longer supported.
|
||||
1.0.9 18apr2005 Default rowid variable becomes _i.
|
||||
If not found, take from char _dta[MI_obsid] then char _dta[mi_id].
|
||||
Default impid variable is _j. If not found, take from _dta[MI_impid].
|
||||
These changes are for future compatibility with MItools.
|
||||
1.0.8 04mar2005 Fixed problem with eform on redisplay
|
||||
1.0.7 28jan2005 Fixed problem with null model estimation
|
||||
Fixed bug with noconstant option
|
||||
1.0.6 25jan2005 e(sample) now correct for all imputations, via ereturn post.
|
||||
Add d.f. quantities from Barnard & Rubin (1999) Biometrika 86:948-955 eq (3)-(5).
|
||||
Minor additions to ereturn quantities for compatibility with misw.
|
||||
Allow null model and model only with constant for benefit of misw.
|
||||
1.0.5 16nov2004 Update calculations of quantities stored for Li et al (1991) F test.
|
||||
1.0.4 13oct2004 Change e(cmd) to `cmd', make e(cmd2)="micombine" (for use after mfx).
|
||||
Implementation of mean log likelihood and chisquare statistic saved
|
||||
(note undocumented -noclear- but v. useful option to ereturn post/estimates post).
|
||||
*/
|
||||
program define micombine, eclass
|
||||
|
||||
if _caller()<=7 {
|
||||
di as error "version 7 and earlier not supported"
|
||||
exit 9
|
||||
}
|
||||
|
||||
if replay() {
|
||||
if `"`e(cmd2)'"'!="micombine" {
|
||||
error 301
|
||||
}
|
||||
syntax[, EForm EForm2(string)]
|
||||
if "`eform2'"!="" {
|
||||
if "`eform'"!="" di as err "[eform ignored]"
|
||||
local eform eform(`eform2')
|
||||
}
|
||||
else if "`eform'"!="" local eform eform("exp(b)")
|
||||
di as text _n "Multiple imputation parameter estimates (" as res e(m) as text " imputations)"
|
||||
capture ereturn display, `eform'
|
||||
local rc=_rc
|
||||
if `rc'>0 {
|
||||
* Null model, or model with cc() only
|
||||
if `"`e(cmd)'"'!="stcox" {
|
||||
`e(cmd)' `0'
|
||||
}
|
||||
else di as text "[Null model - no estimates]"
|
||||
}
|
||||
else ereturn display, `eform'
|
||||
di as result e(N) as text " observations."
|
||||
exit
|
||||
}
|
||||
|
||||
gettoken cmd 0 : 0
|
||||
if "`cmd'"=="stpm" {
|
||||
local dist 7
|
||||
local bad 0
|
||||
}
|
||||
else {
|
||||
cmdchk `cmd'
|
||||
local cmdnotknown `s(bad)'
|
||||
/*
|
||||
dist=0 (normal), 1 (binomial), 2 (poisson), 3 (cox), 4 (glm),
|
||||
5 (xtgee), 6(ereg/weibull).
|
||||
*/
|
||||
local dist `s(dist)'
|
||||
}
|
||||
syntax [anything] [if] [in] [aw fw pw iw] , [ IMPid(string) BR CC(varlist) noCONStant ///
|
||||
DEAD(varname) DETail EForm EForm2(string) GENxb(string) LRR noWARning OBSid(string) * ]
|
||||
|
||||
if `cmdnotknown' & "`warning'"!="nowarning" {
|
||||
di as err _n "Warning: " as inp "`cmd'" as err " is not a certified regression command for micombine."
|
||||
di as err "micombine will continue mechanically, but correct results are not guaranteed."
|
||||
di as err "You must take responsibility that Rubin's rules are appropriate here." _n
|
||||
}
|
||||
|
||||
if "`eform2'"!="" {
|
||||
if "`eform'"!="" di as err "[eform ignored]"
|
||||
local eform eform(`eform2')
|
||||
}
|
||||
else if "`eform'"!="" local eform eform("exp(b)")
|
||||
|
||||
* Check for possible impid characteristic. If it does not exist use default _j
|
||||
if "`impid'"=="" {
|
||||
local impid: char _dta[MI_impid]
|
||||
if "`impid'"=="" local impid _j
|
||||
}
|
||||
cap confirm var `impid'
|
||||
if _rc {
|
||||
di as err "imputation identifier `impid' not found"
|
||||
exit 601
|
||||
}
|
||||
|
||||
* Check for possible obsid chars. If none exist use default _i
|
||||
if "`obsid'"=="" {
|
||||
local I: char _dta[MI_obsid]
|
||||
if "`I'"=="" local I: char _dta[mi_id]
|
||||
if "`I'"=="" local I _i
|
||||
}
|
||||
else local I `obsid'
|
||||
cap confirm var `I'
|
||||
if _rc {
|
||||
di as err "observation identifier `I' not found"
|
||||
exit 601
|
||||
}
|
||||
|
||||
if "`detail'"!="" {
|
||||
local detail noisily
|
||||
}
|
||||
else local detail
|
||||
|
||||
*Change here 11/15/05, commenting out the line below !! PR DELETED XIAO CHEN'S EDIT, NOV 05
|
||||
frac_cox "`dead'" `dist'
|
||||
|
||||
if "`constant'"=="noconstant" {
|
||||
if "`cmd'"=="fit" | "`cmd'"=="stcox" | "`cmd'"=="cox" {
|
||||
di as error "noconstant invalid with `cmd'"
|
||||
exit 198
|
||||
}
|
||||
}
|
||||
|
||||
*Change here 11/15/05, `dist' could be null.... !! PR DELETED XIAO CHEN'S EDIT, NOV 05
|
||||
*if "`dist'" =="7" { /* stcox, streg, stpm */
|
||||
if `dist'==7 {
|
||||
local y
|
||||
local yname _t
|
||||
local xvars `anything'
|
||||
}
|
||||
else {
|
||||
gettoken y xvars : anything
|
||||
gettoken xvars left: xvars, parse("(")
|
||||
local yname `y'
|
||||
}
|
||||
|
||||
tempvar touse
|
||||
quietly {
|
||||
marksample touse
|
||||
markout `touse' `varlist' `dead' `cc'
|
||||
if "`dead'"!="" {
|
||||
local dead "dead(`dead')"
|
||||
}
|
||||
|
||||
* Deal with weights.
|
||||
frac_wgt `"`exp'"' `touse' `"`weight'"'
|
||||
local wgt `r(wgt)'
|
||||
|
||||
tempvar J
|
||||
* Important (compatibility with mitools): ignore rows for which impid=0
|
||||
egen int `J'=group(`impid') if `touse'==1 & `impid'>0 & !missing(`impid')
|
||||
sum `J', meanonly
|
||||
local m=r(max)
|
||||
if `m'<2 {
|
||||
di as error "there must be at least 2 imputations"
|
||||
exit 198
|
||||
}
|
||||
|
||||
local nxvar: word count `xvars'
|
||||
/*
|
||||
if `nxvar'<1 {
|
||||
di as err "there must be at least one covariate"
|
||||
exit 198
|
||||
}
|
||||
*/
|
||||
local ncc: word count `cc' /* could legitimately be zero */
|
||||
local nvar=`nxvar'+`ncc' /* number of covariates in model */
|
||||
|
||||
count if `touse'==1 & `J'==1
|
||||
local nobs=r(N)
|
||||
|
||||
* Null Cox model (or model with only ccvars): fit on final imputation only, and quit
|
||||
if "`xvars'"=="" & ("`cmd'"=="cox" | "`cmd'"=="stcox") {
|
||||
if "`cmd'"=="stcox" & "`cc'"=="" {
|
||||
local options `options' estimate
|
||||
}
|
||||
`detail' `cmd' `y' `cc' if `touse'==1 & `J'==`m' `wgt', `options' `dead' `constant'
|
||||
noi `cmd'
|
||||
di as result `nobs' as text " observations."
|
||||
ereturn scalar m=`m'
|
||||
ereturn local impid `impid'
|
||||
ereturn local cmd `cmd'
|
||||
ereturn local cmd2 micombine
|
||||
exit
|
||||
}
|
||||
|
||||
* Compute model over m imputations
|
||||
tempname W Q B T QQ
|
||||
if "`genxb'"!="" {
|
||||
tempvar xb xbtmp
|
||||
gen `xb'=.
|
||||
}
|
||||
* Estimate mean LR chisquare statistic (where possible)
|
||||
tempname chi2 ell ell0 nucom
|
||||
scalar `chi2'=0
|
||||
scalar `ell'=0
|
||||
scalar `ell0'=0
|
||||
forvalues i=1/`m' {
|
||||
tempname Q`i'
|
||||
`detail' `cmd' `y' `xvars' `cc' `left' if `touse'==1 & `J'==`i' `wgt', ///
|
||||
`options' `dead' `constant'
|
||||
scalar `nucom'=e(df_r) // complete-data residual degrees of freedom
|
||||
if `nucom'==. {
|
||||
scalar `nucom'=100000
|
||||
}
|
||||
scalar `ell'=`ell'+e(ll)
|
||||
scalar `ell0'=`ell0'+e(ll_0)
|
||||
scalar `chi2'=`chi2'-2*(e(ll_0)-e(ll))
|
||||
if "`genxb'"!="" {
|
||||
predict `xbtmp' if `touse'==1 & `J'==`i', xb
|
||||
replace `xb'=`xbtmp' if `touse'==1 & `J'==`i'
|
||||
drop `xbtmp'
|
||||
}
|
||||
matrix `Q`i''=e(b)
|
||||
if `i'==1 {
|
||||
matrix `Q'=e(b)
|
||||
matrix `W'=e(V)
|
||||
}
|
||||
else {
|
||||
matrix `Q'=`Q'+e(b)
|
||||
matrix `W'=`W'+e(V)
|
||||
}
|
||||
|
||||
}
|
||||
if "`genxb'"!="" {
|
||||
sort `touse' `I' `J'
|
||||
by `touse' `I': gen `genxb'=sum(`xb')/`m' if `touse'==1
|
||||
by `touse' `I': replace `genxb'=`genxb'[_N] if _n<_N
|
||||
lab var `genxb' "Mean Linear Predictor (`m' imputations)"
|
||||
}
|
||||
matrix `Q'=`Q'/`m' /* MI param estimates */
|
||||
matrix `W'=`W'/`m'
|
||||
scalar `chi2'=`chi2'/`m'
|
||||
scalar `ell'=`ell'/`m'
|
||||
scalar `ell0'=`ell0'/`m'
|
||||
local k=colsof(`Q')
|
||||
matrix `B'=J(`k',`k',0)
|
||||
forvalues i=1/`m' {
|
||||
matrix `QQ'=`Q`i''-`Q'
|
||||
if `i'==1 {
|
||||
matrix `B'=`QQ''*`QQ'
|
||||
}
|
||||
else matrix `B'=`B'+`QQ''*`QQ'
|
||||
}
|
||||
matrix `B'=`B'/(`m'-1)
|
||||
matrix `T'=`W'+(1+1/`m')*`B' /* estimated VCE matrix */
|
||||
/*
|
||||
Relative increase in variance due to missing information (r) for
|
||||
each variable, and df and lambda, the fraction of missing information.
|
||||
All measures are unstable for low m. See Schafer (1997) p. 110.
|
||||
|
||||
Note that BIF = sqrt(T/W) = sqrt(1 + (B/W)*(1+1/m)) = sqrt(1+r)
|
||||
is the between-imputation imprecision factor, i.e. the ratio
|
||||
of the SE derived from T to the SE derived from W,
|
||||
ignoring between-imputation variation in parameter estimates.
|
||||
*/
|
||||
tempname r t lambda nu BIF
|
||||
matrix `r'=J(1,`k',0)
|
||||
matrix `lambda'=J(1,`k',0)
|
||||
matrix `nu'=J(1,`k',0)
|
||||
matrix `BIF'=J(1,`k',0)
|
||||
scalar `t'=`m'-1
|
||||
* Next few lines assign quantities for tests of individual (1 df) components of Q (=beta)
|
||||
forvalues j=1/`k' {
|
||||
matrix `r'[1,`j']=(1+1/`m')*`B'[`j',`j']/`W'[`j',`j']
|
||||
matrix `nu'[1,`j']=cond(`t'>4, 4+(`t'-4)*(1+(1-2/`t')/`r'[1,`j'])^2, `t'*(1+1/`r'[1,`j'])^2)
|
||||
matrix `lambda'[1,`j']=(`r'[1,`j']+2/(`nu'[1,`j']+3))/(`r'[1,`j']+1)
|
||||
matrix `BIF'[1,`j']=sqrt(1+`r'[1,`j']) /* = sqrt(`T'[`j',`j']/`W'[`j',`j']) */
|
||||
}
|
||||
* Next few lines assign quantities for d.f. from Barnard & Rubin 1999 B'ka 86(4): 948-955.
|
||||
tempname nutilde num nuobs gamma
|
||||
matrix `nutilde'=J(1,`k',0)
|
||||
matrix `num'=J(1,`k',0)
|
||||
matrix `nuobs'=J(1,`k',0)
|
||||
matrix `gamma'=J(1,`k',0)
|
||||
forvalues j=1/`k' {
|
||||
matrix `gamma'[1,`j']=(1+1/`m')*`B'[`j',`j']/`T'[`j',`j']
|
||||
matrix `nuobs'[1,`j']=((`nucom'+1)/(`nucom'+3))*`nucom'*(1-`gamma'[1,`j'])
|
||||
matrix `num'[1,`j']=(`m'-1)*`gamma'[1,`j']^-2
|
||||
matrix `nutilde'[1,`j']=1/((1/`num'[1,`j']+1/`nuobs'[1,`j']))
|
||||
}
|
||||
* use all varnames
|
||||
local names: colnames(`Q1')
|
||||
matrix colnames `r'=`names'
|
||||
matrix colnames `nu'=`names'
|
||||
matrix colnames `lambda'=`names'
|
||||
matrix colnames `BIF'=`names'
|
||||
|
||||
matrix colnames `gamma'=`names'
|
||||
matrix colnames `nuobs'=`names'
|
||||
matrix colnames `num'=`names'
|
||||
matrix colnames `nutilde'=`names'
|
||||
|
||||
* Li, Raghunathan & Rubin (1991) estimates of T and nu1
|
||||
* for F test of Q=0 on k,nu1 degrees of freedom
|
||||
tempname r1 t1 BW TLRR
|
||||
matrix `BW'=`B'*syminv(`W')
|
||||
scalar `r1'=trace(`BW')*(1+1/`m')/`k'
|
||||
matrix `TLRR'=`W'*(1+`r1')
|
||||
scalar `t1'=`k'*(`m'-1)
|
||||
matrix colnames `Q'=`names'
|
||||
matrix rownames `T'=`names'
|
||||
matrix colnames `T'=`names'
|
||||
matrix rownames `B'=`names'
|
||||
matrix colnames `B'=`names'
|
||||
matrix rownames `TLRR'=`names'
|
||||
matrix colnames `TLRR'=`names'
|
||||
|
||||
}
|
||||
di as text _n "Multiple imputation parameter estimates (`m' imputations)"
|
||||
if "`lrr'"!="" {
|
||||
di as text "[Using Li-Raghunathan-Rubin (LRR) estimate of VCE matrix]"
|
||||
ereturn post `Q' `TLRR', depname(`yname') obs(`nobs') esample(`touse') noclear
|
||||
ereturn matrix T `T'
|
||||
}
|
||||
else {
|
||||
ereturn post `Q' `T', depname(`yname') obs(`nobs') esample(`touse') noclear
|
||||
ereturn matrix TLRR `TLRR'
|
||||
}
|
||||
if "`br'"=="" {
|
||||
ereturn display, `eform'
|
||||
di as result `nobs' as text " observations."
|
||||
}
|
||||
ereturn matrix B `B'
|
||||
ereturn matrix W `W'
|
||||
ereturn matrix r `r'
|
||||
ereturn matrix nu `nu'
|
||||
ereturn matrix lambda `lambda'
|
||||
ereturn matrix BIF `BIF'
|
||||
|
||||
* Quantities for calculating df `nutilde' according to Barnard & Rubin (1999)
|
||||
ereturn matrix gamma `gamma'
|
||||
ereturn matrix nuobs `nuobs'
|
||||
ereturn matrix num `num'
|
||||
ereturn matrix nutilde `nutilde'
|
||||
|
||||
ereturn scalar r1=`r1'
|
||||
ereturn scalar nu1=cond(`t1'>4, 4+(`t1'-4)*(1+(1-2/`t1')/`r1')^2, 0.5*`t1'*(1+1/`k')*(1+1/`r1')^2)
|
||||
ereturn scalar m=`m'
|
||||
ereturn scalar chi2=`chi2'
|
||||
ereturn scalar ll=`ell'
|
||||
ereturn scalar ll_0=`ell0'
|
||||
ereturn local eform `eform'
|
||||
ereturn local impid `impid'
|
||||
ereturn local cmd `cmd'
|
||||
ereturn local cmd2 micombine
|
||||
if "`br'"!="" {
|
||||
display_t
|
||||
di as result `nobs' as text " observations."
|
||||
}
|
||||
end
|
||||
|
||||
program define display_t
|
||||
* Display results with t-statistics estimated according to Barnard & Rubin (1999)
|
||||
tempname V Q nu
|
||||
matrix `V'=e(V)
|
||||
matrix `Q'=e(b)
|
||||
matrix `nu'=e(nutilde)
|
||||
local yname `e(depvar)'
|
||||
local xs: colnames `Q'
|
||||
local k=colsof(`Q')
|
||||
di as text _n "Intervals and inference based on d.f. from Barnard & Rubin (1999)"
|
||||
di as txt "{hline 13}{c TT}{hline 64}"
|
||||
local t0 = abbrev("`yname'",12)
|
||||
if `"`e(eform)'"'!="" {
|
||||
local tt "Odds Ratio"
|
||||
}
|
||||
else {
|
||||
local tt " Coef."
|
||||
}
|
||||
|
||||
#delimit ;
|
||||
di as text
|
||||
%12s "`t0'" _col(14)"{c |}`tt' Std. Err. t P>|t| [$S_level% Conf. Intvl] MI.df"
|
||||
_n "{hline 13}{c +}{hline 64}" ;
|
||||
#delimit cr
|
||||
tempname df mn se t p invt l u
|
||||
forvalues i=1/`k' {
|
||||
local x: word `i' of `xs'
|
||||
if "`x'"!="_cons" {
|
||||
local fmt : format `x'
|
||||
if substr("`fmt'",-1,1)=="f" {
|
||||
local fmt="%8."+substr("`fmt'",-2,2)
|
||||
}
|
||||
else if substr("`fmt'",-2,2)=="fc" {
|
||||
local fmt="%8."+substr("`fmt'",-3,3)
|
||||
}
|
||||
else local fmt "%8.0g"
|
||||
local fmt`i' `fmt'
|
||||
}
|
||||
else local fmt "%8.0g"
|
||||
scalar `df' =`nu'[1,`i']
|
||||
scalar `mn' = `Q'[1,`i']
|
||||
scalar `se' = sqrt(`V'[`i',`i'])
|
||||
scalar `t' = `mn'/`se'
|
||||
scalar `p' = 2* ttail(`df', abs(`t'))
|
||||
scalar `invt' = invttail(`df', (1-$S_level/100)/2)
|
||||
scalar `l' = `mn' - `invt'*`se'
|
||||
scalar `u' = `mn' + `invt'*`se'
|
||||
if `"`e(eform)'"'!="" {
|
||||
scalar `mn' = exp(`mn')
|
||||
scalar `se' = `mn'*`se'
|
||||
scalar `l' = exp(`l')
|
||||
scalar `u' = exp(`u')
|
||||
}
|
||||
if `df'>99999 {
|
||||
local fmtdf %9.2e
|
||||
}
|
||||
else local fmtdf %9.2f
|
||||
di as text /*
|
||||
*/ %12s abbrev("`x'",12) _col(14) "{c |}" /*
|
||||
*/ _col(17) as res `fmt' `mn' /*
|
||||
*/ _col(27) `fmt' `se' /*
|
||||
*/ _col(36) %7.2f `t' /*
|
||||
*/ _col(42) %7.3f `p' /*
|
||||
*/ _col(52) `fmt' `l' /*
|
||||
*/ _col(61) `fmt' `u' /*
|
||||
*/ _col(70) `fmtdf' `df'
|
||||
}
|
||||
di as text "{hline 13}{c BT}{hline 64}"
|
||||
end
|
||||
|
||||
program define chkrowid, sclass
|
||||
local I: char _dta[mi_id]
|
||||
if "`I'"=="" {
|
||||
di as error "no row-identifier variable found - data may have incorrect format"
|
||||
exit 198
|
||||
}
|
||||
cap confirm var `I'
|
||||
local rc=_rc
|
||||
if `rc' {
|
||||
di as error "row-identifier variable `I' not found"
|
||||
exit `rc'
|
||||
}
|
||||
sret local I `I'
|
||||
end
|
284
Modules/ado/plus/m/micombine.hlp
Normal file
284
Modules/ado/plus/m/micombine.hlp
Normal file
@ -0,0 +1,284 @@
|
||||
{smcl}
|
||||
{* 28nov2005}{...}
|
||||
{hline}
|
||||
help for {hi:micombine}{right:(SJ5-4: st0067_2; SJ5-2: st0067_1; SJ4-3: st0067)}
|
||||
{hline}
|
||||
|
||||
{title:Estimation of regression models with multiply imputed samples}
|
||||
|
||||
|
||||
{p 8 18 2}
|
||||
{cmd:micombine}
|
||||
{{it:supported_regression_cmd} | {it:other_regression_cmd}}
|
||||
[{it:yvar}]
|
||||
[{it:covarlist}]
|
||||
[{it:other_stuff]}
|
||||
{ifin}
|
||||
{weight}
|
||||
[{cmd:,}
|
||||
{cmd:br}
|
||||
{cmdab:nocons:tant}
|
||||
{cmdab:det:ail}
|
||||
{cmdab:ef:orm}[{cmd:(}{it:string}{cmd:)}]
|
||||
{cmdab:g:enxb(}{it:newvarname}{cmd:)}
|
||||
{cmdab:imp:id(}{it:varname}{cmd:)}
|
||||
{cmd:lrr}
|
||||
{cmdab:nowar:ning}
|
||||
{cmdab:obs:id(}{it:varname}{cmd:)}
|
||||
{it:regression_cmd_options}]
|
||||
|
||||
{p 4 4 2}
|
||||
where
|
||||
|
||||
{p 8 8 2}
|
||||
{it:supported_regression_cmd}s are
|
||||
{helpb clogit},
|
||||
{helpb cnreg},
|
||||
{helpb glm},
|
||||
{helpb logistic},
|
||||
{helpb logit},
|
||||
{helpb mlogit},
|
||||
{helpb ologit},
|
||||
{helpb oprobit},
|
||||
{helpb poisson},
|
||||
{helpb probit},
|
||||
{helpb qreg},
|
||||
{helpb regress},
|
||||
{helpb rreg},
|
||||
{helpb stcox},
|
||||
{helpb streg},
|
||||
or
|
||||
{helpb xtgee}, and {it:other_regression_cmd} is any other Stata regression command
|
||||
(see Remarks).
|
||||
|
||||
{p 4 4 2}
|
||||
{cmd:micombine} shares a subset of the features of all {help estcom:estimation commands};
|
||||
see {it:Remarks}.
|
||||
|
||||
{p 4 4 2}
|
||||
All weight types supported by {it:regression_cmd} are allowed; see
|
||||
{help weight}.
|
||||
|
||||
|
||||
{title:Description}
|
||||
|
||||
{p 4 4 2}
|
||||
{cmd:micombine} estimates the parameters of a regression model whose
|
||||
type is determined by {it:supported_regression_cmd} or {it:other_regression_cmd}.
|
||||
Parameter estimates are combined
|
||||
across several replicates obtained previously by multiple imputation,
|
||||
e.g. by using {helpb ice} to create a file of imputed data.
|
||||
See {it:Remarks} for a brief account of how {cmd:micombine} combines
|
||||
the estimates and obtains standard errors.
|
||||
|
||||
|
||||
{title:Options}
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:br} calculates degrees of freedom and tests of significance for each predictor
|
||||
according to the formulae (3)-(5) of Barnard & Rubin (1999).
|
||||
After estimation, the required degrees of freedom are stored in a matrix
|
||||
(column vector) {cmd:e(nutilde)}. Note that if {cmd:test}
|
||||
is used after {cmd:micombine} for significance testing of regression
|
||||
coefficients, such tests assume that the degrees of freedom are
|
||||
equal to the number of observations minus the number of parameters
|
||||
estimated, not those given in {cmd:e(nutilde)}.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:noconstant} suppresses the regression constant in all regressions.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:detail} gives details of the regression model for each imputation.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:eform}[{cmd:(}{it:string}{cmd:)}] specifies that the exponentiated form
|
||||
of the coefficients be output and that the constant not be reported.
|
||||
The exponentiated coefficients are labeled {cmd:exp(b)}, unless
|
||||
the optional {it:string} is used.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:genxb(}{it:newvarname}{cmd:)} creates {it:newvarname} to hold the
|
||||
linear predictor from each regression model, averaged over all the
|
||||
imputations.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:impid(}{it:varname}{cmd:)} specifies that {it:varname} is the variable
|
||||
identifying the imputations. The number of imputations is determined as
|
||||
the number of unique values of {it:varname}. All observations for which
|
||||
{it:varname} takes the value zero are ignored in the analysis.
|
||||
The default {it:varname} is {cmd:_j}.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:lrr} specifies that the Li-Raghunathan-Rubin (LRR) robust estimate of the
|
||||
variance-covariance matrix of the regression coefficients be used.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:nowarning} suppresses the warning message about the use
|
||||
of {it:other_regression_cmd}s (see {it:Remarks}).
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:obsid(}{it:varname}{cmd:)} is provided to allow {cmd:micombine} to analyze
|
||||
datasets created by programs other than {cmd:ice}. {it:varname} specifies the name
|
||||
of a variable holding the "observation ID", i.e. the sequence number of each
|
||||
observation in a given imputation. The number of observations should
|
||||
be identical between imputations, as should the order of the observations.
|
||||
{it:varname} should run 1,...,N for imputation 1, 1,...,N for imputation 2, and
|
||||
so on. {cmd:ice} automatically stores the information with the data, so this
|
||||
option is not required. The default {it:varname} is {cmd:_i}.
|
||||
|
||||
{p 4 8 2}
|
||||
{it:regression_cmd_options} may be any of the options appropriate to
|
||||
{it:regression_cmd}.
|
||||
|
||||
|
||||
{title:Remarks}
|
||||
|
||||
{p 4 4 2}
|
||||
Details of statistical inference from multiple imputed datasets are nicely
|
||||
described in a recent Stata Journal article by John Carlin and colleagues
|
||||
(Carlin et al. 2003). Here, with due acknowledgment to John, I give an edited
|
||||
version of section 2 of his article.
|
||||
|
||||
{p 4 4 2}
|
||||
A simple method of combining estimates from several models was derived by
|
||||
Rubin (1987). Suppose initially that primary interest lies in estimating a
|
||||
scalar quantity, Q. Here, Q is a regression coefficient, for example, the log
|
||||
hazard ratio in a proportional hazards model. Suppose that we have imputed m
|
||||
complete datasets using an appropriate model. In each dataset, standard
|
||||
complete-data methods are used to obtain an estimate of Q with an associated
|
||||
standard error. Let Q(k) and U(k) denote the point estimate and variance
|
||||
respectively from the kth (k = 1, 2, ... , m) dataset. The point estimate Q^
|
||||
of Q from multiple imputation is simply the arithmetic mean of Q(1),...,Q(k).
|
||||
|
||||
{p 4 4 2}
|
||||
Obtaining a valid standard error for this estimate of Q^ requires combining
|
||||
information on within-imputation and between-imputation variation. The latter
|
||||
is important in reflecting uncertainty due to variability between imputation
|
||||
samples. First, a within-imputation variance component, W, is obtained as the
|
||||
mean of the complete-data variance estimates, Q(1),....,Q(k). Second, a
|
||||
between-imputation variance component, B, is calculated as the sum of squares
|
||||
of Q(1),....,Q(k) about Q^, divided by m-1. The (total) variance T of Q^ is
|
||||
given by
|
||||
|
||||
{p 8 12 2}
|
||||
T = W + B * (1 + 1/m)
|
||||
|
||||
{p 4 4 2}
|
||||
Rubin (1987) showed that (Q - Q^)/sqrt(T) is distributed approximately
|
||||
as Student's t on nu degrees of freedom, where
|
||||
|
||||
{p 8 12 2}
|
||||
nu = (m - 1) * (1 + W /(B * (1 + 1/m)))^2
|
||||
|
||||
{p 4 4 2}
|
||||
The (1 + 1/m) term in these expressions indicates that it is not necessary to
|
||||
a create large number of imputed datasets, particularly when B is much smaller
|
||||
than W. The condition will be satisfied unless there is much missing data and
|
||||
the parameter estimates within each dataset are very precise.
|
||||
|
||||
{title:Available regression commands}
|
||||
|
||||
{p 4 4 2}
|
||||
{cmd:micombine} has been tested with the commands listed under
|
||||
{it:supported_regression_cmd} at the beginning of this help file.
|
||||
{cmd:micombine} {it:may} work satisfactorily with {it:other_regression_cmd}s,
|
||||
but this cannot be guaranteed. This facility is provided so that the
|
||||
researcher familiar with a particular Stata command has a fighting chance of
|
||||
obtaining correct MI estimates and standard errors. HOWEVER, THE AUTHOR
|
||||
DISCLAIMS ALL RESPONSIBILITY FOR THE CORRECTNESS OF RESULTS ARISING FROM USE
|
||||
OF AN {it:other_regression_cmd}. Note that {it:other_stuff} in the syntax
|
||||
diagram is code that may be required by some {it:other_regression_cmd}s, for
|
||||
example {cmd:ivreg} wants {cmd:(}{it:varlist2}{cmd: = }{it:varlist_iv}{cmd:)}.
|
||||
{cmd:micombine} parses for the occurrence of an opening parenthesis. There may
|
||||
be other syntaxes that are not accommodated by this approach; if so, please
|
||||
contact the author with details.
|
||||
|
||||
{title:Postestimation prediction}
|
||||
|
||||
{p 4 4 2}
|
||||
The {cmd:predict} command {it:may} work as you expect after {cmd:micombine},
|
||||
but this feature should be regarded as under development and should be
|
||||
treated with caution. {cmd:micombine} stores the quantities needed by
|
||||
{cmd:predict} at the last execution of the regression command, that is at the
|
||||
final imputation, but prediction following some regression commands has
|
||||
non-standard features that are hard to emulate accurately.
|
||||
Known issues are as follows:
|
||||
|
||||
{p 8 12 2}
|
||||
1. After {cmd:micombine mlogit}: {cmd:predict} may require that the outcome
|
||||
levels are known as 0, 1, 2, ... , so it may be necessary to drop the
|
||||
score label for the outcome variable, if such a label is defined.
|
||||
This is KNOWN to be a problem using {cmd:mfx} following {cmd:micombine mlogit}.
|
||||
For example, {cmd:mfx compute, predict(outcome(0))} will work only if
|
||||
the lowest level of the outcome is 0, and is not labeled.
|
||||
|
||||
{p 8 12 2}
|
||||
2. After {cmd:micombine} with a restricted sample (i.e. using {cmd:if},
|
||||
{cmd:in} or zero weights for some observations, or some members
|
||||
of {it:covarlist} still have missing values), the system variable
|
||||
{cmd:e(sample)} is defined as you would expect it to be
|
||||
only for the final imputation. In all earlier imputations it
|
||||
is zero. Although not necessarily convenient for use of
|
||||
{cmd:e(sample)} in data analysis, the behavior is correct for the
|
||||
purposes of {cmd:predict}, since the relevant sample size and
|
||||
estimation sample are properties of (any) one imputation,
|
||||
but not of the complete assembly of imputations.
|
||||
|
||||
|
||||
{title:Examples}
|
||||
|
||||
{p 4 8 2}{cmd:. ice y x1 x2 x3 using imp, m(10) genmiss(m_)}{p_end}
|
||||
{p 4 8 2}{cmd:. use imp, clear}{p_end}
|
||||
{p 4 8 2}{cmd:. micombine regress y x1 x2 x3}{p_end}
|
||||
{p 4 8 2}{cmd:. stset time, failure(cens)}{p_end}
|
||||
{p 4 8 2}{cmd:. micombine stcox x1 x2 x3, genxb(index)}{p_end}
|
||||
{p 4 8 2}{cmd:. test x2==1}{p_end}
|
||||
{p 4 8 2}{cmd:. testparm x1 x2}{p_end}
|
||||
|
||||
|
||||
{title:Author}
|
||||
|
||||
{p 4 4 2}
|
||||
Patrick Royston, MRC Clinical Trials Unit, London.
|
||||
patrick.royston@ctu.mrc.ac.uk
|
||||
|
||||
|
||||
{title:References}
|
||||
|
||||
{p 4 8 2}
|
||||
Barnard, J. and D. B. Rubin. 1999. Small-sample degrees of freedom with
|
||||
multiple imputation. {it:Biometrika} 86: 948-955.
|
||||
|
||||
{p 4 8 2}
|
||||
Carlin, J. B., N. Li, P. Greenwood, and C. Coffey. 2003.
|
||||
Tools for analyzing multiple imputed datasets. {it:Stata Journal} 3(3): 226-244.
|
||||
|
||||
{p 4 8 2}
|
||||
Carlin, J. B., N. Li, P. Greenwood, and C. Coffey. 2003.
|
||||
Tools for analyzing multiple imputed datasets. {it:Stata Journal} 3(3): 226-244.
|
||||
|
||||
{p 4 8 2}
|
||||
Li, K., T. Raghunathan, and D. Rubin. 1991. Large sample significance levels
|
||||
from multiply-imputed data using moment-based statistics and an F reference
|
||||
distribution. {it:Journal of the American Statistical Association} 86: 1065-1073.
|
||||
|
||||
{p 4 8 2}
|
||||
Rubin, D. 1987. {it:Multiple Imputation for Nonresponse in Surveys}. New York:
|
||||
Wiley.
|
||||
|
||||
{p 4 8 2}
|
||||
Schafer, J. 1997. {it:Analysis of Incomplete Multivariate Data}. London:
|
||||
Chapman & Hall.
|
||||
|
||||
{p 4 8 2}
|
||||
van Buuren, S., H. C. Boshuizen and D. L. Knook. 1999. Multiple imputation of
|
||||
missing blood pressure covariates in survival analysis.
|
||||
{it:Statistics in Medicine} 18: 681-694.
|
||||
(Also see http://www.multiple-imputation.com.)
|
||||
|
||||
|
||||
{title:Also see}
|
||||
|
||||
{psee}
|
||||
Online: {helpb ice}
|
||||
{p_end}
|
73
Modules/ado/plus/m/mijoin.ado
Normal file
73
Modules/ado/plus/m/mijoin.ado
Normal file
@ -0,0 +1,73 @@
|
||||
*! version 1.0.3 PR 16oct2004.
|
||||
* History
|
||||
* 1.0.3 16oct2004 Saving, using etc of file safest with compound quotes, fixed.
|
||||
|
||||
program define mijoin, rclass
|
||||
version 7
|
||||
|
||||
syntax [anything(name=filestub)], CLEAR [ IMPid(string) m(int 0) ]
|
||||
|
||||
if "`filestub'"=="" {
|
||||
capture assert "$mimps"!="" & "$mi_sf"!=""
|
||||
if _rc {
|
||||
di as error "please set up your data with -{help miset}-, or specify a filename stub"
|
||||
exit 198
|
||||
}
|
||||
local filestub $mi_sf
|
||||
if `m'>$mimps {
|
||||
di as err "m cannot exceed its -miset- value of $mimps"
|
||||
exit 198
|
||||
}
|
||||
if `m'==0 {
|
||||
local m $mimps
|
||||
}
|
||||
}
|
||||
|
||||
if `m'<=0 {
|
||||
di as err "number of imputations m(), if specified, must be a positive integer"
|
||||
exit 198
|
||||
}
|
||||
|
||||
if "`impid'"=="" {
|
||||
local J _j
|
||||
}
|
||||
else local J `impid'
|
||||
preserve
|
||||
quietly {
|
||||
forvalues j=1/`m' {
|
||||
use `"`filestub'`j'"', clear
|
||||
chkrowid
|
||||
local I `s(I)'
|
||||
if "`I'"=="" {
|
||||
* create row number
|
||||
local I _i
|
||||
cap drop `I'
|
||||
gen long `I'=_n
|
||||
lab var `I' "obs. number"
|
||||
}
|
||||
cap drop `J'
|
||||
gen int `J'=`j'
|
||||
lab var `J' "imputation number"
|
||||
tempfile tmp`j'
|
||||
save `"`tmp`j''"'
|
||||
}
|
||||
use `"`tmp1'"', clear
|
||||
forvalues j=2/`m' {
|
||||
append using `"`tmp`j''"'
|
||||
}
|
||||
char _dta[mi_id] `I'
|
||||
}
|
||||
restore, not
|
||||
end
|
||||
|
||||
program define chkrowid, sclass
|
||||
local I: char _dta[mi_id]
|
||||
if "`I'"=="" {
|
||||
exit
|
||||
}
|
||||
cap confirm var `I'
|
||||
if _rc {
|
||||
exit
|
||||
}
|
||||
sret local I `I'
|
||||
end
|
102
Modules/ado/plus/m/mijoin.hlp
Normal file
102
Modules/ado/plus/m/mijoin.hlp
Normal file
@ -0,0 +1,102 @@
|
||||
{smcl}
|
||||
{* 11jun2004}{...}
|
||||
{hline}
|
||||
help for {cmd:mijoin}, {cmd:misplit}{right:(SJ5-4: st0067_2; SJ5-2: st0067_1; SJ4-3: st0067)}
|
||||
{hline}
|
||||
|
||||
{title:Join or split multiple imputed datasets}
|
||||
|
||||
|
||||
{p 8 17 2}
|
||||
{c -(}{cmd:mijoin} [{it:filestubname}] | {cmd:misplit}{c )-}{cmd:,}
|
||||
{cmd:clear}
|
||||
[{cmd:m(}{it:#}{cmd:)}
|
||||
{cmdab:imp:id(}{it:varname}{cmd:)}]
|
||||
|
||||
|
||||
{title:Description}
|
||||
|
||||
{p 4 4 2}
|
||||
{cmd:mijoin} converts datasets prepared by Carlin's {helpb miset} routine
|
||||
to {helpb mvis} format, for analysis by {helpb micombine}. The component
|
||||
datasets are stacked (joined vertically). If {it:filestubname} is
|
||||
specified then the program will look for files called
|
||||
{it:filestubname}{cmd:1.dta}, {it:filestubname}{cmd:2.dta},...,
|
||||
{it:filestubname}{cmd:m.dta} where {cmd:m} is determined by
|
||||
the {cmd:m()} option.
|
||||
|
||||
{p 4 4 2}
|
||||
{cmd:misplit} converts a dataset prepared by {helpb mvis}
|
||||
to {helpb miset} format, for analysis
|
||||
by {helpb mifit} and other utilities. You should {cmd:use}
|
||||
the dataset first.
|
||||
|
||||
{p 4 4 2}
|
||||
The operations performed by {cmd:mijoin} and {cmd:misplit}
|
||||
are reciprocal.
|
||||
|
||||
|
||||
{title:Options}
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:clear} is not optional and confirms that you are willing to replace the
|
||||
data in memory.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:m(}{it:#}{cmd:)} sets the number of imputed datasets to {it:#}.
|
||||
|
||||
{p 4 8 2}
|
||||
{cmd:impid(}{it:varname}{cmd:)} sets the name of the variable identifying the
|
||||
imputations to {it:varname} (default is {cmd:_j}). {cmd:mijoin} creates
|
||||
{it:varname} whereas {cmd:misplit} expects it to exist already.
|
||||
|
||||
|
||||
{title:Remarks}
|
||||
|
||||
{p 4 4 2}
|
||||
After {cmd:mijoin} has been executed, the data are ready for immediate use by
|
||||
{cmd:micombine}. However, to save the data permanently you would
|
||||
need to issue a {helpb save} command.
|
||||
|
||||
{p 4 4 2}
|
||||
After {cmd:misplit} has been executed, the data are ready for immediate use by
|
||||
Carlin's routines. However, to save the data permanently you would
|
||||
need to issue a {helpb misave} command followed by {helpb miset} on the next use.
|
||||
|
||||
|
||||
{title:Examples}
|
||||
|
||||
{p 4 8 2}{cmd:. mvis y x1 x2 x3 using imp, m(3)}{p_end}
|
||||
{p 4 8 2}{cmd:. use imp, clear}{p_end}
|
||||
{p 4 8 2}{cmd:. misplit, clear}{p_end}
|
||||
{p 4 8 2}{cmd:. mifit regress y x1 x2 x3}
|
||||
|
||||
{p 4 8 2}{cmd:. miset using imp, clear mimps(5)}{p_end}
|
||||
{p 4 8 2}{cmd:. mijoin, clear}{p_end}
|
||||
{p 4 8 2}{cmd:. micombine regress y x1 x2 x3}
|
||||
|
||||
{p 4 8 2}{cmd:. mijoin imp, clear m(5)}{p_end}
|
||||
{p 4 8 2}{cmd:. save imp_mvis}{p_end}
|
||||
{p 4 8 2}{cmd:. micombine regress y x1 x2 x3}
|
||||
|
||||
|
||||
{title:Author}
|
||||
|
||||
{p 4 4 2}
|
||||
Patrick Royston, MRC Clinical Trials Unit, London.
|
||||
patrick.royston@ctu.mrc.ac.uk
|
||||
|
||||
|
||||
{title:References}
|
||||
|
||||
{p 4 8 2}
|
||||
Carlin, J. B., N. Li, P. Greenwood, and C. Coffey. 2003.
|
||||
Tools for analyzing multiple imputed datasets. {it:Stata Journal} 3(3):
|
||||
226-244.
|
||||
|
||||
|
||||
{title:Also see}
|
||||
|
||||
{p 4 13 2}
|
||||
Online: {helpb mvis}, {helpb micombine}, {helpb miset} (if installed)
|
||||
{p_end}
|
53
Modules/ado/plus/m/misplit.ado
Normal file
53
Modules/ado/plus/m/misplit.ado
Normal file
@ -0,0 +1,53 @@
|
||||
*! version 1.0.1 PR 01oct2004.
|
||||
program define misplit, rclass
|
||||
version 7
|
||||
syntax, CLEAR [ IMPid(string) m(int 5) ]
|
||||
cap assert `m'>1
|
||||
if _rc {
|
||||
di "{err}more than one imputation is required"
|
||||
exit 198
|
||||
}
|
||||
if "`impid'"=="" {
|
||||
local impid _j
|
||||
}
|
||||
cap confirm var `impid'
|
||||
if _rc {
|
||||
di as err "imputation identifier `impid' not found in file `using'"
|
||||
exit 601
|
||||
}
|
||||
tempvar J
|
||||
egen int `J'=group(`impid')
|
||||
sum `J', meanonly
|
||||
local m=r(max)
|
||||
if r(max)<2 {
|
||||
di as error "more than one imputation is required"
|
||||
exit 198
|
||||
}
|
||||
if r(max)<`m' {
|
||||
local m=r(max)
|
||||
di as text "[note: data for only `m' imputations found in file]"
|
||||
}
|
||||
preserve
|
||||
quietly {
|
||||
forvalues j=1/`m' {
|
||||
keep if `J'==`j'
|
||||
drop `J'
|
||||
cap erase "_mitemp`j'.dta"
|
||||
save "_mitemp`j'.dta"
|
||||
restore, preserve
|
||||
*egen int `J'=group(`impid')
|
||||
}
|
||||
global mi_uf `using'
|
||||
global mi_sf _mitemp
|
||||
global mimps `m'
|
||||
|
||||
use _mitemp1.dta, clear
|
||||
}
|
||||
if $mimps==2 {
|
||||
di "{p}{txt}data for $mimps imputations have been copied to _mitemp1.dta and _mitemp$mimps.dta"
|
||||
}
|
||||
else {
|
||||
di _n "{p}{txt}Data for $mimps imputations have been copied to ${mi_sf}1.dta to $mi_sf$mimps.dta"
|
||||
}
|
||||
restore, not
|
||||
end
|
1
Modules/ado/plus/m/misplit.hlp
Normal file
1
Modules/ado/plus/m/misplit.hlp
Normal file
@ -0,0 +1 @@
|
||||
.h mijoin
|
211
Modules/ado/plus/m/misschk.ado
Normal file
211
Modules/ado/plus/m/misschk.ado
Normal file
@ -0,0 +1,211 @@
|
||||
*! version 1.1.0 2009-12-22
|
||||
* - add extended missing values - s. rohrman
|
||||
|
||||
capture program drop misschk
|
||||
program define misschk
|
||||
version 9.0 // 2009-12-22
|
||||
syntax [varlist] [if] [in] ///
|
||||
, [GENerate(string)] /// stub for indicator variables
|
||||
[dummy] /// dummy indicator variables
|
||||
[replace] /// replace variables if they exist
|
||||
[NONUMber] /// . in table for missing, not #
|
||||
[NOSort] /// Don't sort pattern list
|
||||
[help] /// explain what is going on
|
||||
[SPace] /// blank rather than _ if not missing
|
||||
[EXTmiss] // show extended missing // 1.1.0
|
||||
|
||||
tempvar ifin
|
||||
mark `ifin' `if' `in'
|
||||
|
||||
local notmissstr "_"
|
||||
if ("`space'"=="space") {
|
||||
local notmissstr " "
|
||||
}
|
||||
else if "`nonumber'"=="nonumber" | "`extmiss'"=="extmiss" { // 1.1.0
|
||||
local notmissstr "-"
|
||||
}
|
||||
local sort "sort"
|
||||
if "`nosort'"=="nosort" {
|
||||
local sort ""
|
||||
}
|
||||
|
||||
// using extmiss and nonumber options together = error // 1.1.0
|
||||
|
||||
if "`nonumber'"=="nonumber" & "`extmiss'"=="extmiss" {
|
||||
di in red "Error: cannot use nonumber and extmiss options together."
|
||||
exit
|
||||
}
|
||||
|
||||
// if dummy variable option
|
||||
|
||||
if "`dummy'"~="" {
|
||||
if "`generate'"=="" {
|
||||
di in red "Error: dummy options requires use of generate option."
|
||||
exit
|
||||
}
|
||||
capture label def lmisschk 0 NotMissing 1 Missing
|
||||
}
|
||||
local gennm = "`generate'"
|
||||
|
||||
// information on individual variables
|
||||
|
||||
di _n in g "Variables examined for missing values"
|
||||
if "`if'" ~="" | "`in'"~="" {
|
||||
di in g "For sample defined by: " in y "`if' `in'"
|
||||
}
|
||||
|
||||
// strip off string variables
|
||||
|
||||
parse "`varlist'", parse(" ")
|
||||
local vars
|
||||
while "`1'" != "" { // loop through variables
|
||||
capture confirm numeric variable `1'
|
||||
if _rc==0 {
|
||||
local vars "`vars' `1'"
|
||||
}
|
||||
mac shift
|
||||
}
|
||||
|
||||
local varlist "`vars'"
|
||||
parse "`varlist'", parse(" ")
|
||||
|
||||
local nvar = 0
|
||||
|
||||
di _n in g " # Variable # Missing % Missing"
|
||||
di in g "--------------------------------------------"
|
||||
|
||||
quietly tab `ifin'
|
||||
local total = r(N)
|
||||
|
||||
while "`1'" != "" { // loop through variables
|
||||
local ++nvar
|
||||
qui count if `1'>=. & `ifin' // count missing; changed == 1.1.0
|
||||
* create binary variables indicating if observation is missing
|
||||
if "`dummy'"~="" {
|
||||
if "`replace'"=="replace" {
|
||||
capture drop `gennm'`1'
|
||||
}
|
||||
quietly gen `gennm'`1' = (`1'>=.) if `ifin' // changed == 1.1.0
|
||||
label var `gennm'`1' "Missing value for `1'?"
|
||||
label val `gennm'`1' lmisschk
|
||||
}
|
||||
* list # and percent missing
|
||||
di in y %3.0f " `nvar' " _col(7) "`1'" ///
|
||||
_col(23) %7.0f r(N) _col(36) %6.1f 100*r(N)/`total'
|
||||
mac shift
|
||||
|
||||
} // loop through list of variables
|
||||
|
||||
parse "`varlist'", parse(" ")
|
||||
|
||||
// loop through all variables and count missing
|
||||
|
||||
tempvar ismissn ismissw missw missn
|
||||
quietly gen `missn' = 0 if `ifin'
|
||||
label var `missn' "Missing for how many variables?"
|
||||
quietly gen str1 `missw' = "" if `ifin'
|
||||
label var `missw' "Missing for which variables?"
|
||||
|
||||
local nvar = 0
|
||||
local i = 0
|
||||
local ext "a b c d e f g h i j k l m n o p q r s t u v w x y z" // 1.1.0
|
||||
while "`1'" != "" {
|
||||
local ++nvar
|
||||
* ones has only one's digit of variable number
|
||||
local ones = mod(`nvar',10)
|
||||
|
||||
* drop tempvars from last loop
|
||||
capture drop `ismissn' `ismissw'
|
||||
|
||||
* 1 if mssing, else 0; . if not in if in
|
||||
capture quietly gen `ismissn' = (`1'>=.) if `ifin' // changed == 1.1.0
|
||||
|
||||
* string with indicator of missing status. Space if no missing;
|
||||
* then if missing, either . or digit number.
|
||||
capture quietly gen str1 `ismissw' = "`notmissstr'"
|
||||
if "`nonumber'"=="nonumber" & "`extmiss'"=="" { // 1.1.0
|
||||
quietly replace `ismissw' = "." if `1'>=. & `ifin' // changed == 1.1.0
|
||||
}
|
||||
else if "`extmiss'"=="extmiss" & "`nonumber'"=="" { // changed == 1.1.0
|
||||
quietly replace `ismissw' = "." if `1'==. & `ifin'
|
||||
foreach ltr in `ext' {
|
||||
quietly replace `ismissw' = "`ltr'" if `1'==.`ltr' & `ifin'
|
||||
}
|
||||
}
|
||||
else if "`nonumber'"=="" & "`extmiss'"=="" {
|
||||
quietly replace `ismissw' = "`ones'" if `1'>=. & `ifin' // changed == 1.1.0
|
||||
}
|
||||
|
||||
* add blank every 5th variable
|
||||
if mod(`nvar'-1,5) == 0 {
|
||||
quietly replace `missw' = `missw' + " "
|
||||
}
|
||||
|
||||
* build string with pattern of missing data
|
||||
quietly replace `missw' = `missw' + `ismissw'
|
||||
* count total number of missing for given case
|
||||
quietly replace `missn' = `missn' + `ismissn'
|
||||
mac shift
|
||||
}
|
||||
capture drop `ismissn' `ismissw'
|
||||
|
||||
// List results
|
||||
|
||||
* patterns of missing data
|
||||
if "`extmiss'"=="" { // 1.1.0
|
||||
di _n in y "Warning: " in g ///
|
||||
"this output does not differentiate among extended missing."
|
||||
di in g ///
|
||||
"To generate patterns for extended missing, use extmiss option."
|
||||
}
|
||||
if "`help'"=="help" {
|
||||
di in g _n ///
|
||||
"The columns in the table below correspond to the # in the table above."
|
||||
di in g ///
|
||||
"If a column is blank, there were no missing cases for that variable."
|
||||
}
|
||||
if "`help'"=="help" & "`extmiss'"=="extmiss" { //1.1.0
|
||||
di _n
|
||||
di _n in g ///
|
||||
"Letters in each column refer to the extended missing for the"
|
||||
di in g ///
|
||||
"corresponding variable"
|
||||
}
|
||||
tab `missw' if `ifin', `nosort'
|
||||
|
||||
* number missing for given observations
|
||||
if "`help'"=="help" {
|
||||
di _n in g ///
|
||||
"Table indicates the number of variables for which an observation"
|
||||
di in g ///
|
||||
"has missing data."
|
||||
}
|
||||
tab `missn' if `ifin'
|
||||
|
||||
// create variables with pattern and number of missing cases
|
||||
|
||||
if "`generate'" != "" {
|
||||
|
||||
if "`replace'"=="replace" {
|
||||
capture drop `gennm'pattern
|
||||
capture drop `gennm'number
|
||||
}
|
||||
|
||||
clonevar `gennm'pattern = `missw'
|
||||
clonevar `gennm'number = `missn'
|
||||
if "`help'"=="help" {
|
||||
di _n in g "Variables created:" // added end quote 1.1.0
|
||||
di in y " `gennm'pattern" in g ///
|
||||
" is a string variable showing the pattern of missing data."
|
||||
di in y " `gennm'number" in g ///
|
||||
" is the number of variables for which a case has missing data."
|
||||
di in y " `gennm'<varnm>" in g ///
|
||||
" is a binary variable indicating missing data for <varnm>."
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
end
|
||||
exit
|
||||
* version 1.0.1 06Jul2005
|
||||
* version 1.0.0 13Apr2005
|
87
Modules/ado/plus/m/misschk.sthlp
Normal file
87
Modules/ado/plus/m/misschk.sthlp
Normal file
@ -0,0 +1,87 @@
|
||||
{smcl}
|
||||
{* 22Dec2009}{...}
|
||||
{cmd:help misschk}: Help for misschk - 2009-12-22
|
||||
{hline}
|
||||
{p2colset 4 14 14 2}{...}
|
||||
|
||||
{title:Overview}
|
||||
|
||||
{p 4 4 2 75}
|
||||
The command {cmd:misschk} examines patterns of missing data for a set of variables.
|
||||
pattern of missing data.
|
||||
|
||||
{title:Syntax}
|
||||
|
||||
{p 8 13 2}
|
||||
{cmdab:misschk} [{varlist}]
|
||||
{ifin}
|
||||
{weight}
|
||||
[{cmd:,}
|
||||
{it:options}]
|
||||
, [GENerate(string)] /// stub for indicator variables
|
||||
[dummy] /// dummy indicator variables
|
||||
[replace] /// replace variables if they exist
|
||||
[NONUMber] /// . in table for missing, not #
|
||||
[NOSort] /// Don't sort pattern list
|
||||
[help] /// explain what is going on
|
||||
[SPace] /// blank rather than _ if not missing
|
||||
[EXTmiss] // show extended missing // 1.1.0
|
||||
|
||||
{synoptset 15 tabbed}{...}
|
||||
{synopthdr}
|
||||
{synoptline}
|
||||
|
||||
{synopt:{opt ext:miss}}Each type of extended missing values is indicated
|
||||
with the letter for that missing value (e.g., {bf:c} for {bf:.c}). By
|
||||
default all missing values are treated simply as missing and
|
||||
indicated by a {bf:.}.{p_end}
|
||||
|
||||
{synopt:{opt gen:erate(rootname)}}is the root for the variables created with
|
||||
information about missing data. If this option is not used,
|
||||
temporary variables are created that are deleted when the program is
|
||||
finsihed. The variables created are:
|
||||
|
||||
{it:rootname}{bf:n} is the number of variables from the variable-list for which
|
||||
a given observation has missing data. For example, a value of 5 would
|
||||
mean that that observation had missing data for five of the variables
|
||||
in the list.
|
||||
|
||||
{it:rootname}{bf:which} indicates the pattern of missing values. This is a
|
||||
string variable with a {bf:_} indicating valid data for a variable
|
||||
and a number indicating missing data for that variable. For
|
||||
example, {bf:_____ __8__ _} is the pattern in which there is no
|
||||
missing data for the first seven variables in the variablae
|
||||
list, missing data for the eighth, and no missing data for the
|
||||
ninth through eleventh variable.{p_end}
|
||||
|
||||
{synopt:{opt dummy}}requests that dummy variables be created for each
|
||||
variable in the variable list. The dummy variable begins with the
|
||||
stem specified with the {bf:gen()} options, then adds the name of the
|
||||
variable. A value of 1 indicates missing data for that case, 0 indicates
|
||||
data is not missing. For example, with the options {bf:gen(M_) dummy},
|
||||
variables such as M_female M_income would be generated.{p_end}
|
||||
|
||||
{synopt:{opt nonumber}}specifies that a variable that has missing cases will be
|
||||
indicated by a {bf:.} rather than by a single digit number corresponding
|
||||
to the sequence number of that variable. For example, without the
|
||||
{bf:nonumber} option, a missing data pattern might look like
|
||||
{bf:_2_4_ 6___} to indicate missing data in the 2nd, 4th and 6th
|
||||
variables. With the {bf:nonumber} option, the pattern
|
||||
would be {bf:_._._ .___} .{p_end}
|
||||
|
||||
{synopt:{opt nosort}}specifies that the list of patterns of missing data
|
||||
should not be sorted with the most common pattern listed first. With
|
||||
{bf:nosort}, the patterns are listed according to the pattern, not the
|
||||
frequency of missing data.{p_end}
|
||||
|
||||
{synopt:{opt replace}}replaces existing variables {it:rootname}{bf:n}
|
||||
and {it:rootname}{bf:which} if they already exist.{p_end}
|
||||
|
||||
{synopt:{opt space}}indicates that in the summary table a space rather than
|
||||
a {bf:_} will be used to indicate when a variable does not have missing data.{p_end}
|
||||
|
||||
|
||||
{synopt:{opt help}}requests a description of each part of the output.{p_end}
|
||||
|
||||
{synoptline}
|
||||
INCLUDE help spost_footer
|
958
Modules/ado/plus/m/mlogplot.ado
Normal file
958
Modules/ado/plus/m/mlogplot.ado
Normal file
@ -0,0 +1,958 @@
|
||||
*! version 2.5.0 2009-10-28 jsl
|
||||
* - stata 11 update for returns from -mlogit-
|
||||
|
||||
capture program drop mlogplot
|
||||
capture program drop lp_plt
|
||||
capture program drop getprob
|
||||
|
||||
program define mlogplot
|
||||
version 6.0
|
||||
tempname tmp b sd bstd sdrhs 01rhs sdi ch0 chu chs _lpstdt _lpplt isdum
|
||||
* if 1, then auto exit of mlogview
|
||||
global PE_mlerr = 0
|
||||
|
||||
/* 06Apr2006 - trap 0 category
|
||||
mat `tmp' = e(cat)
|
||||
local ncat = e(k_cat)
|
||||
local i = 1
|
||||
while `i' <= `ncat' {
|
||||
local v = `tmp'[`i',1]
|
||||
if `v' <= 0 {
|
||||
di in r "outcome categories cannot be 0 or negative."
|
||||
di in r "recode outcome variable to begin at 1."
|
||||
exit
|
||||
}
|
||||
local i = `i' + 1
|
||||
}
|
||||
*/
|
||||
* 18Nov2005
|
||||
local maxvar = 7
|
||||
syntax [varlist(default=none)], [/*
|
||||
*/ ORatio DChange Prob(real 1) packed labels /*
|
||||
*/ min(real -99999) max(real 99999) /*
|
||||
*/ matrix Std(string) Vars(string) /*
|
||||
*/ dcadd(real 0) dcbase(real .1) NTics(real 7) /*
|
||||
*/ Basecategory(real -1) Note(string) VALues] /*
|
||||
*/ [saving(string)] [sign]
|
||||
|
||||
* create saving option
|
||||
local gphopen "gph open"
|
||||
if "`saving'"~="" { local gphopen "gph open, saving(`saving')" }
|
||||
|
||||
local varis `varlist'
|
||||
if "`varis'"=="" & "`matrix'"~="matrix" {
|
||||
_perhs
|
||||
local varis "`r(rhsnms)'"
|
||||
}
|
||||
if `min'>=`max' {
|
||||
di in r "the minimum is larger than the maximum"
|
||||
exit
|
||||
}
|
||||
* dcplot=1 if dc plot
|
||||
local dcplot = 0
|
||||
if "`dchange'"=="dchange" & "`oratio'"~="oratio" {
|
||||
local dcplot = 1
|
||||
local packed packed
|
||||
}
|
||||
* mavar depends on whether there is packing
|
||||
if "`packed'" == "packed" {
|
||||
local maxvar = 11 /* max # to plot in packed graph */
|
||||
}
|
||||
|
||||
*=> matrix input
|
||||
|
||||
if "`matrix'" == "matrix" {
|
||||
if `prob'~=1 {
|
||||
di in r "with matrix input the prob " /*
|
||||
*/ "option does not work."
|
||||
local prob = 1
|
||||
}
|
||||
if "`dchange'" == "dchange" {
|
||||
if "`oratio'" ~= "oratio" {
|
||||
di in r "dchange plots are not " /*
|
||||
*/ "possible with matrix input."
|
||||
exit
|
||||
}
|
||||
di in r "dchange option does not work " /*
|
||||
*/ "with matrix output. option was ignored."
|
||||
local dchange ""
|
||||
}
|
||||
|
||||
local depvar "$mnldepnm"
|
||||
* names of variables to plot
|
||||
local varis `vars'
|
||||
* in b, cols are variables, rows are contrasts
|
||||
mat `b' = mnlbeta
|
||||
mat `sdrhs' = mnlsd
|
||||
local nvarp1 = colsof(`b') + 1 /* with constant */
|
||||
*todo: check if # of bvarnm is same as cols of b
|
||||
* variables associated with rows of betas
|
||||
local bvarnm "$mnlname"
|
||||
*todo: if doesn't exist, make it all 1's
|
||||
* columns correspond to columns in betas
|
||||
mat `sd' = mnlsd
|
||||
* check size of beta and sd's
|
||||
local n1 = colsof(`b')
|
||||
local n2 = colsof(`sd')
|
||||
if `n1'~=`n2' {
|
||||
di in r "# of columns in mnlbeta and mnlsd must be equal"
|
||||
exit
|
||||
}
|
||||
} /* if matrix */
|
||||
|
||||
*=> get information from mlogit
|
||||
|
||||
else {
|
||||
if "`e(cmd)'"!="mlogit" {
|
||||
di in r "mlogplot must be run after mlogit or with matrix input"
|
||||
exit
|
||||
}
|
||||
local depvar = e(depvar)
|
||||
version 5
|
||||
mat `b' = get(_b)
|
||||
version 6
|
||||
* 2009-10-28
|
||||
tempname eV
|
||||
_get_mlogit_bv `b' `eV'
|
||||
*mat list `b'
|
||||
*mat list `eV'
|
||||
local bvarnm : colnames(`b')
|
||||
parse "`bvarnm'", parse (" ")
|
||||
quietly _pesum, dummy
|
||||
mat `sdrhs' = r(Ssd)
|
||||
mat `sdrhs' = `sdrhs'[1,2...]
|
||||
mat `01rhs' = r(Sdummy)
|
||||
mat `01rhs' = `01rhs'[1,2...]
|
||||
|
||||
* 16Nov2005 1.6.8 - get range
|
||||
tempname rngrhs
|
||||
mat `rngrhs' = r(Smax) - r(Smin)
|
||||
mat `rngrhs' = `rngrhs'[1,2...]
|
||||
*<
|
||||
local nvarp1 = colsof(`b') /* with constant */
|
||||
}
|
||||
local nvar = `nvarp1' - 1 /* excludes constant */
|
||||
local ncat = rowsof(`b') + 1
|
||||
local maxnvar = 3*`nvar' /* allows each var plotted 3 times */
|
||||
/* 0->1, +-1, +-sd */
|
||||
if `basecategory' > `ncat' {
|
||||
di in r "specified base category exceeds number of categories"
|
||||
exit
|
||||
}
|
||||
|
||||
*=> get discrete change coefficints
|
||||
*
|
||||
* Note: PE_dc - each variable has 5 rows
|
||||
* row 1: 0->1 (16Nov2005 1.6.8 not min->max)
|
||||
* row 2: min->max (16Nov2005 1.6.8 which can be 0->1)
|
||||
* row 3: -/+ 1
|
||||
* row 4: -/+ sd
|
||||
* row 5: not used
|
||||
* row label is void if coefficient not computed
|
||||
|
||||
* 16Nov2005 1.6.8 - discrete change over range
|
||||
tempname chr
|
||||
mat `chr' = J(`nvar',`ncat',0)
|
||||
|
||||
mat `ch0' = J(`nvar',`ncat',0)
|
||||
mat `chu' = J(`nvar',`ncat',0)
|
||||
mat `chs' = J(`nvar',`ncat',0)
|
||||
if "`dchange'" == "dchange" {
|
||||
|
||||
capture local ncol = colsof(PE_dc)
|
||||
capture local nrow = rowsof(PE_dc)
|
||||
|
||||
if "`ncol'"=="" {
|
||||
di in r "you must run prchange before " /*
|
||||
*/ "plotting discrete changes"
|
||||
global PE_mlerr = 1
|
||||
exit
|
||||
}
|
||||
local nr = `nvar'*5
|
||||
|
||||
/* TEST:
|
||||
di "nvar: `nvar'"
|
||||
di "nvarp1: `nvarp1'"
|
||||
di "ncat: `ncat'"
|
||||
di "maxnvar:`maxnvar'"
|
||||
di "ncol: `ncol'"
|
||||
di "nrow: `nrow'"
|
||||
di "nr: `nr'"
|
||||
END TEST */
|
||||
|
||||
* size of PE_dc is wrong; probably old PE_dc hanging around
|
||||
* 26Nov2006 - or prchange run on only some of the rhs variables
|
||||
if `ncol'~=`ncat' | `nrow'~=`nr' {
|
||||
di in r "There is a problem with the discrete change " ///
|
||||
"coefficients. Rerun " in w "prchange" in r "."
|
||||
di in r "Note that " in w "prchange" in r " must include " ///
|
||||
"all variables. For example, for the model "
|
||||
di in w "mlogit occ white ed exper" in r ", run " ///
|
||||
in w "prchange" in r ", not " in w "prchange white ed" ///
|
||||
in r "."
|
||||
global PE_mlerr = 1
|
||||
exit
|
||||
}
|
||||
local ivar = 1
|
||||
local r = 1
|
||||
while `ivar' <= `nvar' {
|
||||
local c = 1
|
||||
* loop over outcome categories
|
||||
while `c' <= `ncat' {
|
||||
* 16Nov2005 1.6.8 - retrieve dc over range
|
||||
scalar `tmp' = PE_dc[`r'+1,`c']
|
||||
mat `chr'[`ivar',`c'] = `tmp'
|
||||
* 16Nov2005 1.6.8 retrieve dc from 0 to 1 (same as dc over range)
|
||||
scalar `tmp' = PE_dc[`r',`c']
|
||||
*scalar `tmp' = PE_dc[`r'+1,`c']
|
||||
mat `ch0'[`ivar',`c'] = `tmp'
|
||||
* -/+ 1
|
||||
scalar `tmp' = PE_dc[`r'+2,`c']
|
||||
mat `chu'[`ivar',`c'] = `tmp'
|
||||
* -/+ sd
|
||||
scalar `tmp' = PE_dc[`r'+3,`c']
|
||||
mat `chs'[`ivar',`c'] = `tmp'
|
||||
local c = `c' + 1
|
||||
}
|
||||
local ivar = `ivar' + 1
|
||||
local r = `r' + 5
|
||||
}
|
||||
} /* if dchange */
|
||||
|
||||
*=> parse variables to plot and check if dummy variable
|
||||
mat `_lpplt' = J(`maxnvar',1,0) /* 1 if plot this coef */
|
||||
mat `isdum' = J(`maxnvar',1,0) /* 1 if dummy variable */
|
||||
parse "`varis'",parse(" ") /* varis==variables to be plot */
|
||||
local ntoplot = 0
|
||||
while "`1'"~="" {
|
||||
if `ntoplot' >= `maxvar' {
|
||||
di in r "only `maxvar' variables can be " /*
|
||||
*/ "plotted in one graph"
|
||||
exit
|
||||
}
|
||||
* check selected name is in beta matrix
|
||||
local i 1
|
||||
local okvarn = 0
|
||||
while `i' <= `nvar' {
|
||||
* bvarnm contains names from beta matrix
|
||||
local vnm : word `i' of `bvarnm'
|
||||
if "`1'"=="`vnm'" { local okvarn = `i' }
|
||||
local i = `i' + 1
|
||||
}
|
||||
if `okvarn'==0 {
|
||||
di in red "`1' was not a variable in mlogit"
|
||||
exit
|
||||
}
|
||||
local ntoplot = `ntoplot' + 1
|
||||
if "`matrix'" ~= "matrix" {
|
||||
mat `isdum'[`ntoplot',1] = `01rhs'[1,`okvarn']
|
||||
}
|
||||
* plot variables in this order
|
||||
mat `_lpplt'[`ntoplot',1] = `okvarn'
|
||||
macro shift
|
||||
}
|
||||
|
||||
*=> parse standardization type for each variable
|
||||
|
||||
mat `_lpstdt' = J(`maxnvar',1,0) /* Plot: 1=unstd; 3=std; 2=0/1 */
|
||||
local i 1
|
||||
local nstd = length("`std'")
|
||||
while `i' <= `nstd' {
|
||||
local stdi = substr("`std'",`i',1)
|
||||
|
||||
* 16Nov2005 1.6.8 - allow r as an option for how to plot variable
|
||||
if "`stdi'"~="r" & "`stdi'"~="s" & "`stdi'"~="u" & "`stdi'"~="0" {
|
||||
di in r "std() options must be s, r, u or 0"
|
||||
* if "`stdi'"~="s" & "`stdi'"~="u" & "`stdi'"~="0" {
|
||||
* di in r "std() options must be s, u or 0"
|
||||
exit
|
||||
}
|
||||
mat `_lpstdt'[`i',1] = 1 /* unstd */
|
||||
if "`stdi'" == "s" {
|
||||
mat `_lpstdt'[`i',1] = 3 /* std */
|
||||
}
|
||||
|
||||
* 16Nov2005 1.6.8 - if range, type 4 coefficients
|
||||
if "`stdi'" == "r" {
|
||||
mat `_lpstdt'[`i',1] = 4 /* min max */
|
||||
}
|
||||
|
||||
if "`stdi'" == "0" {
|
||||
mat `_lpstdt'[`i',1] = 2 /* dummy */
|
||||
if `isdum'[`i',1]~=1 {
|
||||
di in r "variable specified as std(0) " /*
|
||||
*/ "is not a binary variable"
|
||||
exit
|
||||
}
|
||||
}
|
||||
* warning if isdum and not 0
|
||||
if `isdum'[`i',1]==1 & `_lpstdt'[`i',1]~=2 {
|
||||
local tmp = `_lpplt'[`i',1]
|
||||
local vnm : word `tmp' of `bvarnm'
|
||||
di in r "warning: variable `vnm'" /*
|
||||
*/ " is binary, but std(0) was not used"
|
||||
}
|
||||
local i = `i' + 1
|
||||
}
|
||||
if `ntoplot'~=`nstd' {
|
||||
di in r "# of variables does not match # of " /*
|
||||
*/ "std() values specified"
|
||||
exit
|
||||
}
|
||||
|
||||
*=> set up matrices with plot data
|
||||
|
||||
tempname _lpbplt _lpbvar _lpbcat _lpboff _lpbtyp _lpbchk _lpbchp
|
||||
local tmp = `ntoplot' * `ncat' /* # coefs to plot */
|
||||
matrix `_lpbplt' = J(`tmp',1,0) /* coef to plot */
|
||||
matrix `_lpbchp' = `_lpbplt' /* values of discrete change */
|
||||
matrix `_lpboff' = `_lpbplt' /* vertical offset */
|
||||
matrix `_lpbvar' = `_lpbplt' /* variable number */
|
||||
matrix `_lpbcat' = `_lpbplt' /* category */
|
||||
matrix `_lpbtyp' = `_lpbplt' /* type of standardization */
|
||||
|
||||
* compute standardized betas
|
||||
mat `bstd' = `b'
|
||||
local ivar = 1
|
||||
while `ivar' < `nvarp1' {
|
||||
scalar `sdi' = `sdrhs'[1,`ivar']
|
||||
* loop over categories and fill in border
|
||||
local icat = 1
|
||||
while `icat' < `ncat' {
|
||||
mat `bstd'[`icat',`ivar'] = `b'[`icat',`ivar'] * `sdi'
|
||||
local icat = `icat' + 1
|
||||
}
|
||||
local ivar = `ivar' + 1
|
||||
}
|
||||
|
||||
* 2007-06-29
|
||||
if "`matrix'" != "matrix" {
|
||||
* 16Nov2005 1.6.8 - compute beta*range
|
||||
tempname brng
|
||||
mat `brng' = `b'
|
||||
local ivar = 1
|
||||
while `ivar' < `nvarp1' {
|
||||
scalar `sdi' = `rngrhs'[1,`ivar']
|
||||
* loop over categories and fill in border
|
||||
local icat = 1
|
||||
while `icat' < `ncat' {
|
||||
mat `brng'[`icat',`ivar'] = `b'[`icat',`ivar'] * `sdi'
|
||||
local icat = `icat' + 1
|
||||
}
|
||||
local ivar = `ivar' + 1
|
||||
}
|
||||
}
|
||||
else {
|
||||
// make range missing since it is not used
|
||||
tempname brng
|
||||
mat `brng' = `bstd' * .
|
||||
} // 2007-06-29
|
||||
|
||||
* determine basecategory
|
||||
if "`matrix'"~="matrix" {
|
||||
_pecats `e(depvar)'
|
||||
local catnm "`r(catnms)'"
|
||||
* 30Mar2005 1.6.6
|
||||
if "`values'"=="values" {
|
||||
local catnm "`r(catvals)'"
|
||||
}
|
||||
|
||||
* refnum is value of the reference category for the estiamted betas
|
||||
* 2007-06-29 stata 10
|
||||
if c(stata_version) < 10 {
|
||||
local refnum = e(basecat)
|
||||
}
|
||||
else {
|
||||
local refnum = e(baseout)
|
||||
}
|
||||
|
||||
* 1.7.0 08Apr2006 - fix when refnum is 0
|
||||
if `refnum'==0 {
|
||||
local refnum = 1
|
||||
}
|
||||
|
||||
* names of outcome categories in order of matrix
|
||||
* all but the last correspond to the rows in b
|
||||
}
|
||||
|
||||
if "`matrix'"=="matrix" {
|
||||
local catnm "$mnlcatnm"
|
||||
local refnum "`ncat'"
|
||||
}
|
||||
|
||||
*=> stack b coefficients to plot into _lpbplt vector
|
||||
|
||||
* determine offset for plot
|
||||
* baserow has the row in b with beta's for new base category
|
||||
local baserow = 0
|
||||
* `basecategory' has the # of the specified base
|
||||
if `basecategory'~=`refnum' & `basecategory'~=-1 {
|
||||
local baserow = `basecategory'
|
||||
if `basecategory' > `refnum' { local baserow = `baserow' - 1 }
|
||||
}
|
||||
* loop through variables, decide on std and unstd to plot
|
||||
local iloc = 1
|
||||
local ivar = 1
|
||||
while `ivar' <= `ntoplot' {
|
||||
local icat = 1
|
||||
local varnum = `_lpplt'[`ivar',1]
|
||||
* find b values for changing basecategory
|
||||
local bbase = 0
|
||||
local bbstd = 0
|
||||
* 16Nov2005 1.6.8
|
||||
local bbrng = 0
|
||||
|
||||
if `baserow' ~= 0 {
|
||||
local bbase = `b'[`baserow',`varnum']
|
||||
local bbstd = `bstd'[`baserow',`varnum']
|
||||
* 16Nov2005 1.6.8
|
||||
local bbrng = `brng'[`baserow',`varnum']
|
||||
}
|
||||
* compute _lpbplt
|
||||
while `icat' <= `ncat' {
|
||||
if `icat' < `ncat' {
|
||||
matrix `_lpbplt'[`iloc',1] = `b'[`icat',`varnum'] - `bbase'
|
||||
}
|
||||
else {
|
||||
matrix `_lpbplt'[`iloc',1] = 0 - `bbase'/* ref category */
|
||||
}
|
||||
matrix `_lpbtyp'[`iloc',1] = 1
|
||||
matrix `_lpbchp'[`iloc',1] = `chu'[`varnum',`icat']
|
||||
if `_lpstdt'[`ivar',1] == 2 {
|
||||
matrix `_lpbtyp'[`iloc',1] = 2
|
||||
matrix `_lpbchp'[`iloc',1] = `ch0'[`varnum',`icat']
|
||||
}
|
||||
if `_lpstdt'[`ivar',1] == 3 {
|
||||
if `icat' < `ncat' {
|
||||
matrix `_lpbplt'[`iloc',1] = /*
|
||||
*/ `bstd'[`icat',`varnum'] - `bbstd'
|
||||
}
|
||||
else {
|
||||
matrix `_lpbplt'[`iloc',1] = /*
|
||||
*/ 0 - `bbstd' /* reference category */
|
||||
}
|
||||
matrix `_lpbtyp'[`iloc',1] = 3
|
||||
matrix `_lpbchp'[`iloc',1] = `chs'[`varnum',`icat']
|
||||
}
|
||||
|
||||
* 16Nov2005 1.6.8 - coefficients when change over range
|
||||
if `_lpstdt'[`ivar',1] == 4 {
|
||||
if `icat' < `ncat' {
|
||||
matrix `_lpbplt'[`iloc',1] = /*
|
||||
*/ `brng'[`icat',`varnum'] - `bbrng'
|
||||
}
|
||||
else {
|
||||
matrix `_lpbplt'[`iloc',1] = /*
|
||||
*/ 0 - `bbrng' /* reference category */
|
||||
}
|
||||
matrix `_lpbtyp'[`iloc',1] = 4
|
||||
matrix `_lpbchp'[`iloc',1] = `chr'[`varnum',`icat']
|
||||
}
|
||||
|
||||
* _lpbplt now has coefficients to be plotted
|
||||
matrix `_lpbvar'[`iloc',1] = `ivar' /* var# for given coef */
|
||||
matrix `_lpbcat'[`iloc',1] = `icat' /* cat# for tiven coef */
|
||||
local iloc = `iloc' + 1
|
||||
local icat = `icat' + 1
|
||||
}
|
||||
local ivar = `ivar' + 1
|
||||
}
|
||||
|
||||
if `dcplot' == 1 { /* dcplot , so plot _lpbchp */
|
||||
matrix `_lpbplt' = `_lpbchp'
|
||||
}
|
||||
|
||||
*=> determine offsets for letters
|
||||
|
||||
* algorithm is use offsets of 0,1,2,0,1,2 as coefficients are ordered
|
||||
* from smallest to largerst. The code is messy, but works...
|
||||
|
||||
* if packed, use 0's already in _lpboff
|
||||
if "`packed'" ~= "packed" {
|
||||
local iloc = 1
|
||||
local ivar = 1
|
||||
while `ivar' <= `ntoplot' {
|
||||
local varnum = `_lpplt'[`ivar',1]
|
||||
* grab coefficients for given variable in _lpbplt
|
||||
local istrt = ((`ivar'-1)*`ncat') + 1
|
||||
local iend = `istrt' + `ncat' - 1
|
||||
matrix `_lpbchk' = `_lpbplt'[`istrt'..`iend',1]
|
||||
local icat = 1
|
||||
while `icat' <= `ncat' {
|
||||
local icat2 = 1
|
||||
local minn = 99999999
|
||||
* find smallest coef that hasn't been used
|
||||
while `icat2' <= `ncat' {
|
||||
if `_lpbchk'[`icat2',1] < `minn' {
|
||||
local minn = `_lpbchk'[`icat2',1]
|
||||
local minloc = `icat2'
|
||||
}
|
||||
local icat2 = `icat2' + 1
|
||||
}
|
||||
* this is current smallest
|
||||
local updown = mod(`icat'+2,3)
|
||||
* change to big values so won't select again
|
||||
mat `_lpbchk'[`minloc',1] = 99999999
|
||||
local minn = 99999999
|
||||
* this is the location in the stored variables
|
||||
local ichng = `istrt' + `minloc' - 1
|
||||
mat `_lpboff'[`ichng',1] = `updown'
|
||||
local iloc = `iloc' + 1
|
||||
local icat = `icat' + 1
|
||||
}
|
||||
local ivar = `ivar' + 1
|
||||
}
|
||||
}
|
||||
|
||||
*=> create variables from the matrices
|
||||
|
||||
mat colnames `_lpbplt' = _lpbplt
|
||||
mat colnames `_lpbvar' = _lpbvar
|
||||
mat colnames `_lpbcat' = _lpbcat
|
||||
mat colnames `_lpboff' = _lpboff
|
||||
mat colnames `_lpbtyp' = _lpbtyp
|
||||
mat colnames `_lpbchp' = _lpbchp
|
||||
mat colnames `_lpplt' = _lpplt
|
||||
mat colnames `_lpstdt' = _lpstdt
|
||||
|
||||
svmat `_lpbplt', names(col)
|
||||
svmat `_lpbvar', names(col)
|
||||
svmat `_lpbcat', names(col)
|
||||
svmat `_lpboff', names(col)
|
||||
svmat `_lpbtyp', names(col)
|
||||
svmat `_lpbchp', names(col)
|
||||
svmat `_lpplt', names(col)
|
||||
svmat `_lpstdt', names(col)
|
||||
|
||||
*=> generate variable with first letter of category names
|
||||
|
||||
if "`matrix'"~="matrix" {
|
||||
local ltr : word `refnum' of `catnm'
|
||||
local ltr = upper(substr("`ltr'",1,1))
|
||||
quietly generate str1 _lpbltr = "`ltr'"
|
||||
local icat = 1
|
||||
while `icat' <= `ncat' {
|
||||
if `icat'==`refnum' {
|
||||
local refnm: word `ncat' of `catnm'
|
||||
if `baserow'~=0 {
|
||||
local refnm: word `baserow' of `catnm'
|
||||
}
|
||||
}
|
||||
if `icat'!=`refnum' {
|
||||
local nm: word `icat' of `catnm'
|
||||
local ltr = upper(substr("`nm'",1,1))
|
||||
quietly replace _lpbltr = "`ltr'" if _lpbcat == `icat'
|
||||
}
|
||||
local icat = `icat' + 1
|
||||
}
|
||||
}
|
||||
|
||||
if "`matrix'"=="matrix" {
|
||||
* this is the reference category in the betas
|
||||
local ltr : word `ncat' of `catnm'
|
||||
local ltr = upper(substr("`ltr'",1,1))
|
||||
quietly generate str1 _lpbltr = "`ltr'"
|
||||
* get letter for reference category
|
||||
local baserow = `basecategory'
|
||||
if `baserow' == -1 { local baserow = `ncat' }
|
||||
local refnm : word `baserow' of `catnm'
|
||||
* place correct letters to plot
|
||||
local icat = 1
|
||||
while `icat' <= `ncat' {
|
||||
if `icat'!=`refnum' {
|
||||
local nm: word `icat' of `catnm'
|
||||
local ltr = upper(substr("`nm'",1,1))
|
||||
quietly replace _lpbltr = "`ltr'" if _lpbcat == `icat'
|
||||
}
|
||||
local icat = `icat' + 1
|
||||
}
|
||||
}
|
||||
|
||||
*=> data to pass to plot program
|
||||
|
||||
global S_1 = `dcplot'
|
||||
global S_2 = `min'
|
||||
global S_3 = `max'
|
||||
global S_4 "`packed'"
|
||||
global S_5 = `ntoplot'
|
||||
global S_6 = `dcadd'
|
||||
global S_7 = `dcbase'
|
||||
global S_8 = `ncat'
|
||||
global S_9 "`labels'"
|
||||
global S_10 "`dchange'"
|
||||
global S_11 "`bvarnm'"
|
||||
global S_12 = `prob'
|
||||
global S_13 "`refnm'"
|
||||
global S_14 = `ntics'
|
||||
global S_15 "`note'"
|
||||
global S_16 "`depvar'"
|
||||
global S_17 "`gphopen'"
|
||||
* 16Nov2005 sign
|
||||
global S_18 = 0
|
||||
if "`sign'"=="sign" {
|
||||
global S_18 = 1
|
||||
}
|
||||
lp_plt
|
||||
capture drop _lpbplt-_lprowb
|
||||
end
|
||||
|
||||
program define lp_plt
|
||||
* decode information from calling program
|
||||
local dcplot = $S_1
|
||||
local min = $S_2
|
||||
local max = $S_3
|
||||
local packed "$S_4"
|
||||
local ntoplot = $S_5
|
||||
local dcadd = $S_6
|
||||
local dcbase = $S_7
|
||||
local ncat = $S_8
|
||||
local labels "$S_9"
|
||||
local dchange "$S_10"
|
||||
local bvarnm "$S_11"
|
||||
local prob = $S_12
|
||||
local refnm "$S_13"
|
||||
local ntics = $S_14
|
||||
local note "$S_15"
|
||||
local depvar "$S_16"
|
||||
local gphopen "$S_17"
|
||||
* 16Nov2005 sign
|
||||
local addsign = $S_18
|
||||
|
||||
* coordinate used:
|
||||
*
|
||||
* (0,0) (0,cstrt) (0,cend)
|
||||
*
|
||||
* (rhead,cstrt) data (rhead,cend)
|
||||
*
|
||||
* (rhead+rvar,cstrt) (rhead+rvar,cend)
|
||||
*
|
||||
local cstrt = 10000 /* first column in plot space */
|
||||
local cborder = 1000 /* border at ends of plot space */
|
||||
local cend = 31500 /* right most column of plot space */
|
||||
local crange = `cend' - `cstrt' - (2*`cborder')
|
||||
local cname = `cstrt' - 700 /* name of variable ends here */
|
||||
*local rhead = 2000 /* header space for factor change scale */
|
||||
local rhead = 1800 /* header space for factor change scale */
|
||||
if `dcplot'==1 { local rhead = 1000 }
|
||||
if "`note'"~="" {
|
||||
local rhead = `rhead' + 1000
|
||||
}
|
||||
|
||||
* rows per variable in plot space
|
||||
* local rvar = 3600 /* maxvar = 5 */
|
||||
* local rvar = 3200 /* maxvar = 6 */
|
||||
local rvar = 2800 /* maxvar = 7 */
|
||||
|
||||
if "`packed'" == "packed" { local rvar = 1700 }
|
||||
|
||||
local rnmoff = 1000 - `rvar' /* vert offset for listing name */
|
||||
|
||||
* vert offset within horizontal lines (larger adds vertical compression
|
||||
local rltoff = 800
|
||||
|
||||
* rescale to metric used in columns of plot and find 0 location
|
||||
quietly sum _lpbplt /* get min and max of coefficients being plotted */
|
||||
local minb = _result(5)
|
||||
if `min'~=-99999 & `min'<`minb' { local minb = `min' }
|
||||
local maxb = _result(6)
|
||||
if `max'~=99999 & `max'>`maxb' { local maxb = `max' }
|
||||
local rng = `maxb' - `minb'
|
||||
* change range to [0-1]
|
||||
quietly generate _lpcolb = (_lpbplt - `minb')/`rng'
|
||||
local c0 = (0 - `minb')/`rng'
|
||||
* min and max column for plotting area
|
||||
local minn = `cstrt' + `cborder'
|
||||
local maxx = `cend' - `cborder'
|
||||
local rng = `maxx' - `minn'
|
||||
quietly replace _lpcolb = (_lpcolb * `rng') + `minn'
|
||||
local c0 = (`c0' * `rng') + `minn'
|
||||
|
||||
* rescale metric for rows in plot
|
||||
* # of rows to contain letters
|
||||
local rltr = `rvar' - `rltoff' - `rltoff'
|
||||
if "`packed'" ~= "packed" {
|
||||
quietly sum _lpboff
|
||||
local minn = _result(5)
|
||||
local maxx = _result(6)
|
||||
local rng = `maxx' - `minn'
|
||||
* change to range of 0--1
|
||||
quietly generate _lprowb = (_lpboff - `minn')/`rng'
|
||||
* expand to range of rltr
|
||||
quietly replace _lprowb = _lprowb * `rltr' /* offsets as # of rows */
|
||||
* determine row position
|
||||
#delimit ;
|
||||
quietly replace _lprowb = _lprowb
|
||||
+ `rhead' /* skip over header */
|
||||
+ ((_lpbvar-1)*`rvar') /* space over prior variables */
|
||||
+ `rltoff' /* space before letters begin */
|
||||
;
|
||||
#delimit cr
|
||||
quietly sum _lprowb
|
||||
}
|
||||
else if "`packed'" == "packed" {
|
||||
local rltoff = 925 /* vert offset top & bot for letters */
|
||||
* determine row position
|
||||
#delimit ;
|
||||
quietly generate _lprowb = `rhead' /* skip over header */
|
||||
+ ((_lpbvar-1)*`rvar') /* space over prior variables */
|
||||
+ `rltoff' /* space before letters begin */
|
||||
;
|
||||
#delimit cr
|
||||
}
|
||||
|
||||
`gphopen'
|
||||
gph font 600 300
|
||||
if "`note'"~="" {
|
||||
local tmp = `cstrt' - 400
|
||||
gph text 480 `tmp' 0 -1 `note'
|
||||
}
|
||||
local rloc = `rhead' - 200
|
||||
* axis at top of graph
|
||||
gph line `rloc' `cstrt' `rloc' `cend'
|
||||
* add labels at top and bottom
|
||||
gph font 500 250
|
||||
local rloc = `rhead' - 1400
|
||||
if `dcplot' == 0 {
|
||||
local ltr "`refnm'"
|
||||
* move top label down a smidge
|
||||
local rloctmp = `rloc' + 250
|
||||
gph text `rloctmp' `cstrt' 0 -1 /*
|
||||
*/ Factor Change Scale Relative to Category `ltr'
|
||||
local rloc = `rhead' + (`ntoplot'*`rvar') + 1200
|
||||
local tmp ""
|
||||
* if "`depvar'" ~= "" { local tmp " of `depvar'" }
|
||||
local ltr "`refnm' `tmp'"
|
||||
gph text `rloc' `cstrt' 0 -1 /*
|
||||
*/ Logit Coefficient Scale Relative to Category `ltr'
|
||||
}
|
||||
if `dcplot' == 1 {
|
||||
local rloc = `rhead' + (`ntoplot'*`rvar') + 1200
|
||||
*! version 1.6.5 2/24/2003 - correct typo in graph
|
||||
local tmp "Change in Predicted Probability for $S_16"
|
||||
gph text `rloc' `cstrt' 0 -1 `tmp'
|
||||
}
|
||||
* add tic marks
|
||||
local nper = (`maxb' - `minb')/(`ntics' - 1)
|
||||
local itic = 1
|
||||
local minn = `cstrt' + `cborder'
|
||||
local maxx = `cend' - `cborder'
|
||||
local cper = (`maxx' - `minn')/(`ntics' - 1)
|
||||
while `itic' <= `ntics' {
|
||||
local ticval : display round(exp(`minb' + ((`itic'-1)*`nper')),.01)
|
||||
local cval = `minn' + ((`itic'-1)*`cper')
|
||||
local rloc = `rhead' - 600
|
||||
* write tic value at top
|
||||
local rloctmp = `rloc' + 200 /* move it down a smidge */
|
||||
if `dcplot' ==0 { gph text `rloctmp' `cval' 0 0 `ticval' }
|
||||
* add tic marks
|
||||
local rlst = `rhead' - 200
|
||||
local rlend = `rlst' + 150
|
||||
gph line `rlst' `cval' `rlend' `cval'
|
||||
local rlst = `rhead' + (`ntoplot'*`rvar') - 200
|
||||
local rlend = `rlst' - 150
|
||||
gph line `rlst' `cval' `rlend' `cval'
|
||||
local ticval : display round(`minb' + ((`itic'-1)*`nper'),.01)
|
||||
local itic = `itic' + 1
|
||||
local rloc = `rhead' + (`ntoplot'*`rvar') + 400
|
||||
gph text `rloc' `cval' 0 0 `ticval'
|
||||
}
|
||||
local rloc = `rhead' + (`ntoplot'*`rvar') - 200
|
||||
gph line `rloc' `cstrt' `rloc' `cend'
|
||||
if `dcplot' == 1 {
|
||||
local rt = `rhead' - 200
|
||||
gph line `rt' `c0' `rloc' `c0'
|
||||
}
|
||||
|
||||
* plot letters
|
||||
local i 0
|
||||
local ivar 1
|
||||
local dcbase = sqrt(`dcbase')
|
||||
while `ivar' <= `ntoplot' { /* loop over variables */
|
||||
local icat 1
|
||||
while `icat' <= `ncat' { /* loop over categories within vars */
|
||||
local i = `i' + 1
|
||||
* get point to plot
|
||||
local r = _lprowb[`i']
|
||||
local c = _lpcolb[`i']
|
||||
local l = _lpbltr[`i']
|
||||
local siz 1
|
||||
if "`dchange'" == "dchange" & `dcplot' == 0 {
|
||||
local siz = sqrt(`dcadd'+abs(_lpbchp[`i']))/`dcbase'
|
||||
}
|
||||
local fr = `siz'*700
|
||||
local fc = `siz'*350
|
||||
gph font `fr' `fc'
|
||||
|
||||
* 16Nov2005 option sign
|
||||
if _lpbchp[`i']<0 & `addsign'==1 {
|
||||
gph text `r' `c' 0 0 _
|
||||
* local l "-`l'"
|
||||
}
|
||||
|
||||
gph text `r' `c' 0 0 `l'
|
||||
local icat = `icat' + 1
|
||||
}
|
||||
local ivar = `ivar' + 1
|
||||
}
|
||||
|
||||
* add names and dividing lines
|
||||
local ivar = 1
|
||||
while `ivar' <= `ntoplot' {
|
||||
* name of variable
|
||||
local varnum = _lpplt[`ivar']
|
||||
if `dcplot' == 0 & `prob'~= 1 {
|
||||
* get prob values
|
||||
global S_1 = `varnum' /* variable number */
|
||||
global S_2 = `ncat'
|
||||
getprob
|
||||
local cat1 2
|
||||
while `cat1' <= `ncat' {
|
||||
* location in data set of coordinates for this coef
|
||||
local loc1 = ((`ivar'-1)*`ncat')+`cat1'
|
||||
local r1 = _lprowb[`loc1']
|
||||
local c1 = _lpcolb[`loc1']
|
||||
local cat2 1
|
||||
while `cat2' < `cat1' {
|
||||
local loc2 = ((`ivar'-1)*`ncat')+`cat2'
|
||||
local r2 = _lprowb[`loc2']
|
||||
local c2 = _lpcolb[`loc2']
|
||||
local p = mlplt_p[`cat1',`cat2']
|
||||
if `p' > `prob' { gph line `r1' `c1' `r2' `c2' }
|
||||
local cat2 = `cat2' + 1
|
||||
} /* `cat2' < `cat1' */
|
||||
local cat1 = `cat1' + 1
|
||||
} /* `cat1' < `ncat' */
|
||||
} /* if get prob */
|
||||
local vname: word `varnum' of `bvarnm'
|
||||
if "`labels'" == "labels" & "`matrix'"~="matrix" {
|
||||
local vname2 : variable label `vname'
|
||||
if "`vname2'"!="" { local vname "`vname2'"}
|
||||
}
|
||||
local rloc = `rhead' + `rnmoff' + (`ivar'*`rvar')
|
||||
gph font 700 350
|
||||
local _lpstdt = _lpstdt[`ivar']
|
||||
if "`packed'" == "packed" {
|
||||
if `_lpstdt' == 3 {
|
||||
gph text `rloc' `cname' 0 1 `vname'-std
|
||||
}
|
||||
else if `_lpstdt' == 2 {
|
||||
gph text `rloc' `cname' 0 1 `vname'-0/1
|
||||
}
|
||||
else if `_lpstdt' == 1 {
|
||||
gph text `rloc' `cname' 0 1 `vname'
|
||||
}
|
||||
* 16Nov2005 1.6.8 - label for dc over range
|
||||
else if `_lpstdt' == 4 {
|
||||
gph text `rloc' `cname' 0 1 `vname'-range
|
||||
}
|
||||
}
|
||||
if "`packed'" ~= "packed" {
|
||||
gph text `rloc' `cname' 0 1 `vname'
|
||||
gph font 400 200
|
||||
local rloc = `rhead' + `rnmoff' + (`ivar'*`rvar') + 900
|
||||
if `_lpstdt' == 1 {
|
||||
gph text `rloc' `cname' 0 1 UnStd Coef
|
||||
}
|
||||
if `_lpstdt' == 2 {
|
||||
gph text `rloc' `cname' 0 1 0/1
|
||||
}
|
||||
if `_lpstdt' == 3 {
|
||||
gph text `rloc' `cname' 0 1 Std Coef
|
||||
}
|
||||
* 16Nov2005 1.6.8 - label for or over range
|
||||
else if `_lpstdt' == 4 {
|
||||
gph text `rloc' `cname' 0 1 Range Coef
|
||||
}
|
||||
}
|
||||
* dividing line
|
||||
if `ivar' != 1 {
|
||||
local rloc = `rhead' + ((`ivar'-1)*`rvar') - 200
|
||||
gph line `rloc' `cstrt' `rloc' `cend'
|
||||
}
|
||||
local ivar = `ivar' + 1
|
||||
}
|
||||
gph close
|
||||
end
|
||||
|
||||
program define getprob
|
||||
* get the prob values for all contrasts
|
||||
version 5.0
|
||||
tempname b v b1 b2 b12 se z p
|
||||
local ivar = $S_1
|
||||
local ncat = $S_2
|
||||
matrix `b' = get(_b)
|
||||
local nvars = colsof(`b')
|
||||
mat `v' = get(VCE)
|
||||
* 2009-10-28 - fix for stata 11 returns
|
||||
nobreak {
|
||||
_get_mlogit_bv `b' `v'
|
||||
local nvars = colsof(`b')
|
||||
}
|
||||
/* TEST
|
||||
di "nvars: `nvars'"
|
||||
di "ncat: `ncat'"
|
||||
di "v with fix"
|
||||
mat list `v'
|
||||
di "b with fix"
|
||||
mat list `b'
|
||||
END TEST */
|
||||
matrix mlplt_p = J(`ncat',`ncat',1)
|
||||
* loop through all pairs of categories
|
||||
local cat1 1
|
||||
local cat2 1
|
||||
while `cat1' <= `ncat' {
|
||||
while `cat2' <= `cat1' {
|
||||
if `cat1'!=`cat2' {
|
||||
* 1st element of contrast is not ref cat
|
||||
if `cat1'!=`ncat' {
|
||||
if `cat2'==`ncat' { scalar `b2' = 0 }
|
||||
else { scalar `b2' = `b'[`cat2',`ivar'] }
|
||||
scalar `b1' = `b'[`cat1',`ivar']
|
||||
scalar `b12' = `b1'-`b2'
|
||||
local loc2 = ((`cat2'-1)*`nvars')+`ivar'
|
||||
if `cat2'==`ncat' {
|
||||
scalar `se' = sqrt(`v'[`loc1',`loc1'])
|
||||
}
|
||||
else {
|
||||
local loc1 = ((`cat1'-1)*`nvars')+`ivar'
|
||||
scalar `se' = sqrt(`v'[`loc1',`loc1'] + /*
|
||||
*/ `v'[`loc2',`loc2'] - 2*`v'[`loc1',`loc2'])
|
||||
}
|
||||
} /* `cat1'!=`ncat' */
|
||||
* first element of contrast is reference category
|
||||
if `cat1'==`ncat' {
|
||||
if `cat2'==`ncat' { scalar `b2' = 0 }
|
||||
else { scalar `b2' = `b'[`cat2',`ivar'] }
|
||||
scalar `b1' = 0 /*`b'[`cat1',`ivar']*/
|
||||
scalar `b12' = `b1'-`b2'
|
||||
local loc2 = ((`cat2'-1)*`nvars')+`ivar'
|
||||
scalar `se' = sqrt(`v'[`loc2',`loc2'])
|
||||
}
|
||||
scalar `se' = 1/`se'
|
||||
scalar `z' = `se'*`b12'
|
||||
scalar `p' = 2*normprob(-abs(`z'))
|
||||
matrix mlplt_p[`cat1',`cat2'] = `p'
|
||||
matrix mlplt_p[`cat2',`cat1'] = `p'
|
||||
} /* if `cat1'!=`cat2' */
|
||||
local cat2 = `cat2' + 1
|
||||
} /* while `cat2' <= `ncat' */
|
||||
local cat2 1
|
||||
local cat1 = `cat1' + 1
|
||||
} /* cat1 */
|
||||
|
||||
end
|
||||
exit
|
||||
|
||||
* version 1.6.4 3/22/2001
|
||||
* version 1.6.5 2/24/2003 - correct typo in graph
|
||||
* version 1.6.6 30Mar2005 - add values option
|
||||
* version 1.6.7 13Apr2005
|
||||
* version 1.6.8 allow plots for change over range 16Nov2005
|
||||
* add: option sign: underline negative discrete change
|
||||
* option r : for range
|
||||
* version 1.6.9 error if outcome cat <= 0
|
||||
* version 1.7.0 08Apr2006 fixed when basecategory is 0!
|
||||
* version 1.7.1 26Nov2006
|
||||
* improve error message when prchange is a problem.
|
||||
* version 1.7.2 29Jun2007 // fix range problem if data is a matrix
|
||||
* version 1.7.3 29Jun2007 // stata 10 revisions
|
157
Modules/ado/plus/m/mlogplot.hlp
Normal file
157
Modules/ado/plus/m/mlogplot.hlp
Normal file
@ -0,0 +1,157 @@
|
||||
.-
|
||||
help for ^mlogplot^ - 03Nov2005
|
||||
.-
|
||||
|
||||
Odds ratio and discrete change plots for multinomial logit
|
||||
----------------------------------------------------------
|
||||
|
||||
For odds ratio plots, the results of ^mlogit^ must be in memory; for discrete
|
||||
change plots or odds ratio plots using discrete change the results of ^prchange^
|
||||
must be in memory. The syntax is:
|
||||
|
||||
^mlogplot^ [varlist] [^, or^atio ^dc^hange ^s^td^(^[^s^|^u^|^0^]...[^s^|^u^|^0^]^)^
|
||||
^min(^#^) max(^#^) packed labels p^rob^(^#^) b^asecategory^(^#^)^
|
||||
nt^ics^(^#^) n^ote^(^string^)^ ^val^ues ^dcadd(^#^) ^saving(^filename[^,replace^]^)^]
|
||||
|
||||
To create odds ratio plots with coefficients that you have placed into
|
||||
matrices (e.g.,to plot coefficients from a published paper):
|
||||
|
||||
^mlogplot,^ ^matrix v^ars^(^varlist^)^ ^s^td^(^[^s^|^u^|^0^]...[^s^|^u^|^0^]^)^
|
||||
[^min(^#^) max(^#^) packed labels b^asecategory^(^#^) nt^ics^(^#^) n^ote^(^string^)^
|
||||
^saving(^filename[^,replace^]^)^]
|
||||
|
||||
The matrices you must create are discussed below.
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
^mlogplot^ takes coefficients either from ^mlogit^ or from other programs that
|
||||
estimate the multinomial logit model. When estimates from other programs are
|
||||
used they must be passed to ^mlogplot^ as matrices. ^mlogplot^ then plots the
|
||||
odds ratios (i.e., exp(b)) and/or the discrete change coefficients. You can
|
||||
list the same variable more than once if you want both standardized and
|
||||
unstandardized coefficients to be plotted in the same graph. A variety of
|
||||
options control the way the final graph looks. The dialog box program ^mlogview^
|
||||
provides a convenient front end that allows you to use this program
|
||||
interactively.
|
||||
|
||||
^IMPORTANT^: When using coefficients from ^mlogit^, you must be sure that the
|
||||
value labels for the dependent variable begin with different letters or
|
||||
numbers. Otherwise, the plot might be misleading.
|
||||
|
||||
Options for Plotting Estimates from ^mlogit^
|
||||
---------------------------------------------
|
||||
|
||||
^oratio^ indicates that you want to plot the odds ratios (i.e., exp(b)).
|
||||
|
||||
^dchange^ requests plots involving discrete change. To use this option, you
|
||||
must have first run ^prchange^. This option does not work with the ^matrix^
|
||||
option.
|
||||
|
||||
If ^oratio^ has been specified, this options plots the size of the letters
|
||||
proportional to the size of the corresponding discrete change coefficient.
|
||||
See ^dcadd^ and ^dcbase^ for further details.
|
||||
|
||||
If ^oratio^ is not specified, ^dchange^ indicates that you want to plot the
|
||||
discrete change coefficients.
|
||||
|
||||
^basecategory^ is used for an odds ratio plot to specify which category of
|
||||
the outcome measure is to be used as the reference point.
|
||||
|
||||
^labels^ uses variable labels to label each row of the plot. You might need to
|
||||
revise your variable labels to make them fit the graph. This option does
|
||||
not work with the ^matrix^ option.
|
||||
|
||||
^min(^#^) and max(^#^)^ specify the minimum value and the maximum value on which
|
||||
the coefficients are plotted. This is useful if you want to compare
|
||||
coefficients from different logits, or produces several plots from the
|
||||
same logit.
|
||||
|
||||
^ntics^ sets the number of tic marks to show on the axes. Used along with ^min^
|
||||
and ^max^, this allows you to determine the numbering on the axes and the
|
||||
location of tic marks.
|
||||
|
||||
^packed^ removes the vertical spacing among the outcome categories. This allows
|
||||
up to 11 variables on a single graph. Otherwise, the maximum is 5.
|
||||
|
||||
^prob^ is used for an odds ratio plot to specify that if a coefficient
|
||||
contrasting two outcomes is not signficant at this level, a line is to
|
||||
be drawn connecting the letters.
|
||||
|
||||
^std(^[^s^|^u^|^0^]...[^s^|^u^|^0^]^)^ specifies the type of coefficient to plot. s specifies
|
||||
standardized coefficients; u specifies unstandardized coefficients; 0
|
||||
specifies changes from 0 to 1 in discrete change plots. For example,
|
||||
std(u0su) indicates that the first variable is unstandardized, the second
|
||||
is binary, the third standardized, and the last is unstandardized.
|
||||
|
||||
^dcadd(^#^)^ is rarely used. In odds ratio plots where
|
||||
the ^dchange^ option is specified, the size of the letter corresponds to
|
||||
the square root of the size of the discrete change coefficient. ^dcadd^ adds
|
||||
an amount to each discrete change making the size of all letters larger,
|
||||
making it easier to see the letters for small discrete changes. By
|
||||
default this quantity is 0. If your letters print too small, you might
|
||||
want to increase this by a small amount, say ^dcadd(.03)^.
|
||||
|
||||
Plotting Estimates from Matrices
|
||||
--------------------------------
|
||||
|
||||
The ^matrix^ option indicates that estimates are to be obtained from global
|
||||
matrices, which are described below. When this option is used, the options
|
||||
^prob^ and ^dchange^ are not allowed. All other options can be used.
|
||||
|
||||
^vars(varlist)^ contains the names of the variables whose coefficients you
|
||||
want to plot. The names must be in the order you want to plot them and
|
||||
must be included in the global ^mnlname^.
|
||||
|
||||
Globals for Plotting Matrices
|
||||
-----------------------------
|
||||
|
||||
^mnlbeta^ contains the betas in a matrix where element (i,j) is the j-th
|
||||
variable for comparison i relative to the reference category. That is,
|
||||
columns are for variables; rows for different contrasts. Note that
|
||||
constants are NOT included.
|
||||
|
||||
^mnlname^ contains the names of the variables corresponding to the columns of
|
||||
mnlbeta.
|
||||
|
||||
^mnlcatnm^ is a string with labels for the outcome categories. The
|
||||
1st category corresponds to the 1st column of mnlbeta, the 2nd to the
|
||||
2nd, etc. The label for the reference category should be last. Thus,
|
||||
mnlcatnm provides labels for the rows of mnlbeta. The option
|
||||
^basecategory^ references which letter in this string represents the
|
||||
base category.
|
||||
|
||||
^mnlrefn^ is the number of the category in mnlcatnm that is the reference
|
||||
category for the contrasts contained in mnlbeta.
|
||||
|
||||
^mnldepnm^ contains name of dependent variable.
|
||||
|
||||
^mnlsd^ contains the standard deviations for the variables that correspond
|
||||
to columns of mnlbeta
|
||||
|
||||
Example using mlogit
|
||||
--------------------
|
||||
|
||||
. ^mlogit occ white ed exper,basecategory(5)^
|
||||
. ^prchange^
|
||||
. ^mlogplot white ed exper, dc std(0ss) min(-2.75) max(.55)^
|
||||
|
||||
Example using matrices
|
||||
----------------------
|
||||
|
||||
. ^matrix mnlsd = (2.946427, 13.95936, 2.946427, 13.95936)^
|
||||
. ^global mnlname = "W_Educ W_Exper NW_Educ NW_Exper"^
|
||||
. ^global mnlrefn = 5^
|
||||
. ^global mnlcatnm = "Menial BlueC Craft WhiteC Prof"^
|
||||
. ^matrix mnlbeta = (-.83075, -.92255, -.68761, -.41964 \ /*^
|
||||
> ^*/ -.03380, -.03145, -.00026, .00085 \ /*^
|
||||
> ^*/ -.70126, -.56070, -.88250, -.53115 \ /*^
|
||||
> ^*/ -.11084, -.02611, -.15979, -.05209 )^
|
||||
. ^matrix mnlbeta = mnlbeta'^
|
||||
. ^mlogplot, vars(W_Educ NW_Educ W_Exper NW_Exper) matrix /*^
|
||||
> ^*/ std(ssss) note("Effects of Education")
|
||||
|
||||
.-
|
||||
Authors: J. Scott Long and Jeremy Freese
|
||||
www.indiana.edu/~jsl650/spost.htm
|
||||
spostsup@@indiana.edu
|
1067
Modules/ado/plus/m/mlogtest.ado
Normal file
1067
Modules/ado/plus/m/mlogtest.ado
Normal file
File diff suppressed because it is too large
Load Diff
120
Modules/ado/plus/m/mlogtest.sthlp
Normal file
120
Modules/ado/plus/m/mlogtest.sthlp
Normal file
@ -0,0 +1,120 @@
|
||||
{smcl}
|
||||
{* 20Oct2009 version 1.7.6 jsl}{...}
|
||||
{cmd:help mlogtest}: Help for tests for the multinomial logit model - 2009-10-20
|
||||
{hline}
|
||||
{p2colset 4 14 14 2}{...}
|
||||
|
||||
{title:Overview}
|
||||
|
||||
{p 4 4 2 78}
|
||||
The command {cmd:mlogtest} computes a variety of tests for the multinomial logit model.
|
||||
The user selects the tests they want by specifying the appropriate options. For each
|
||||
independent variable, {cmd:mlogtest} can perform either a LR or Wald test of the
|
||||
null hypothesis that the coefficients of the variable equal zero across all equations.
|
||||
{cmd:mlogtest} can also perform Wald or LR tests of whether any pair of outcome
|
||||
categories can be combined. In addition, {cmd:mlogtest} computes the Hausman and
|
||||
Small-Hsiao tests of the assumption of the independence of irrelevance alternatives (IIA)
|
||||
for each possible omitted category.
|
||||
|
||||
{title:Syntax}
|
||||
|
||||
{p 8 13 2}
|
||||
{cmd:mlogtest} [{it:varlist}]
|
||||
[{cmd:,} {it:options}]
|
||||
|
||||
{synoptset 15 tabbed}{...}
|
||||
{synopthdr}
|
||||
{synoptline}
|
||||
{syntab:{it:Tests of variables}}
|
||||
|
||||
{synopt:{opt varlist}}Selects variables to test with the wald or lr options.
|
||||
By default, all variables in the model are tested.{p_end}
|
||||
|
||||
{synopt:{opt w:ald}}Use Wald tests for each variable.{p_end}
|
||||
|
||||
{synopt:{opt lr}}Use LR test for each variable.{p_end}
|
||||
|
||||
{synopt:{opt set}{bf:(}{it:varlist} [{bf:\} {it:varlist}]{bf:)}}
|
||||
Specify a set of variables is to be tested with {cmd:lrtest} or
|
||||
{cmd:lr}. The slash {bf:\} specifies multiple sets of variables.
|
||||
This option is particularly useful when a categorical variable is
|
||||
included as a set of dummy variables, allowing that the coefficients for
|
||||
all of the dummy variables are zero across all equations.{p_end}
|
||||
|
||||
{syntab:{it:Tests for combining categories}}
|
||||
|
||||
{synopt:{opt c:ombine}}Compute Wald tests of whether two outcomes can be
|
||||
combined.{p_end}
|
||||
|
||||
{synopt:{opt lrc:ombine}}Compute LR tests of whether two outcomes can be
|
||||
combined.{p_end}
|
||||
|
||||
{syntab:{it:Tests of IIA}}
|
||||
|
||||
{synopt:{opt h:ausman}} Compute Hausman-McFadden tests using Stata's {cmd:hausman}
|
||||
command.{p_end}
|
||||
|
||||
{synopt:{opt d:etail}}Detailed results for {cmd:hausman} option are given.{p_end}
|
||||
|
||||
{synopt:{opt sm:hsiao}}Compute Small-Hsiao tests{p_end}
|
||||
|
||||
{synopt:{opt su:est}}Compute Hausman-McFadden tests using Stata's {cmd:suest}
|
||||
command.{p_end}
|
||||
|
||||
{synopt:{opt i:ia}}All of the IIA tests should be computed.{p_end}
|
||||
|
||||
{synopt:{opt b:ase}}Conduct IIA test omitting the base category of the original
|
||||
{cmd:mlogit} estimation. This is done by re-estimating the model using the largest
|
||||
remaining category as the base category. The original estimates are
|
||||
restored to memory.{p_end}
|
||||
|
||||
{syntab:{it:Other}}
|
||||
|
||||
{synopt:{opt a:ll}}All tests should be performed.{p_end}
|
||||
|
||||
{synoptline}
|
||||
|
||||
{title:Examples}
|
||||
|
||||
{bf: . mlogit whoclass income dad_educ male black hispanic asian}
|
||||
{bf: . * compute all tests}
|
||||
{bf: . mlogtest, all}
|
||||
|
||||
{bf: . mlogit whoclass income dad_educ male black hispanic asian singlpar}
|
||||
{bf: > stepmommlogit whoclass income dad_educ male black hispanic asian}
|
||||
{bf: . * teset groups of dummy variables}
|
||||
{bf: . mlogtest, lr set(black hispanic asian \ singlpar stepmom stepdad)}
|
||||
|
||||
{title:Returned matrices}
|
||||
|
||||
{p 4 4}
|
||||
{bf:r(combine)}: results of Wald tests to combine categories. Rows represent all
|
||||
contrasts among categories; columns indicates the categories contrasted, the
|
||||
chisq, df, and p of test.
|
||||
|
||||
{p 4 4}
|
||||
{bf:r(lrcomb)}: results of LR tests to combine categories. Rows represent all
|
||||
contrasts among categories; columns indicates the categories contrasted, the
|
||||
chisq, df, and p of test.
|
||||
|
||||
{p 4 4}
|
||||
{bf:r(hausman)}: results of Hausman tests of IIA assumption. Each row is one test.
|
||||
Columns indicate the omitted category of a given test, the chisq, df, and p.
|
||||
|
||||
{p 4 4}
|
||||
{bf:r(smhsiao)}: results of Small-Hsiao tests of IIA assumption.
|
||||
|
||||
{p 4 4}
|
||||
{bf:r(wald)}: results of Wald test that all coefficients of an independent variable
|
||||
equals zero
|
||||
|
||||
{p 4 4}
|
||||
{bf:r(lrtest)}: results of likelihood-ratio test that all coefficients of an
|
||||
independent variable equals zero
|
||||
|
||||
{title:Acknowledgment}
|
||||
|
||||
{p 4 4}
|
||||
The code used for the Small-Hsiao test is based on a program by Nick Winter.
|
||||
INCLUDE help spost_footer
|
||||
|
423
Modules/ado/plus/m/mlogview.ado
Normal file
423
Modules/ado/plus/m/mlogview.ado
Normal file
@ -0,0 +1,423 @@
|
||||
*! version 2.5.0 2009-10-28 jsl
|
||||
* - stata 11 update for returns from -mlogit-
|
||||
|
||||
window control clear
|
||||
|
||||
capture program drop mlogview
|
||||
capture program drop _mlgetv
|
||||
capture program drop _mlinit
|
||||
capture program drop _mlplot
|
||||
capture program drop _mlnxt7
|
||||
capture program drop _mlprnt
|
||||
capture program drop _mlhlp
|
||||
|
||||
program define mlogview
|
||||
if "`e(cmd)'"!="mlogit" {
|
||||
di in r "mlogview must be run after mlogit"
|
||||
exit
|
||||
}
|
||||
version 6.0
|
||||
|
||||
*=> Initialize
|
||||
global mlopts "`*'"
|
||||
_mlinit
|
||||
global ml_lbl ""
|
||||
|
||||
*=> List variables to plot
|
||||
local r1 = 2
|
||||
local c1 = 5
|
||||
local d1 = 12
|
||||
* c's are columns for radio buttons
|
||||
local c2 = `c1' + 55
|
||||
local c3 = `c2' + 20
|
||||
local c4 = `c3' + 28
|
||||
local c5 = `c4' + 24
|
||||
* 18Nov2005 - add button for range
|
||||
local c6 = `c5' + 36
|
||||
|
||||
* global ml_wi "Select Variables Select Amount of Change"
|
||||
* window control static ml_wi `c1' `r1' 146 9
|
||||
global ml_wi "Select Variables"
|
||||
window control static ml_wi `c1' `r1' 146 9
|
||||
global ml_wi2 "Select Amount of Change"
|
||||
local c12 = `c1' + 56
|
||||
window control static ml_wi2 `c12' `r1' 146 9
|
||||
local r1 = `r1' + `d1' - 1
|
||||
|
||||
* var#1
|
||||
local n1 = 1
|
||||
window control scombo ml_rhsnm `c1' `r1' 50 50 ml_v`n1'
|
||||
window control radbegin "+1" `c2' `r1' 20 9 ml_v`n1'r
|
||||
window control radio "+SD" `c3' `r1' 24 9 ml_v`n1'r
|
||||
window control radio "0/1" `c4' `r1' 24 9 ml_v`n1'r
|
||||
* 18Nov2005 - add Range option
|
||||
* window control radend "Don't Plot" `c5' `r1' 40 9 ml_v`n1'r
|
||||
|
||||
window control radio "Range" `c5' `r1' 32 9 ml_v`n1'r
|
||||
window control radend "Don't Plot" `c6' `r1' 40 9 ml_v`n1'r
|
||||
local r1 = `r1' + `d1'
|
||||
* var#2
|
||||
local n1 = 2
|
||||
window control scombo ml_rhsnm `c1' `r1' 50 50 ml_v`n1'
|
||||
window control radbegin "+1" `c2' `r1' 20 9 ml_v`n1'r
|
||||
window control radio "+SD" `c3' `r1' 24 9 ml_v`n1'r
|
||||
window control radio "0/1" `c4' `r1' 24 9 ml_v`n1'r
|
||||
* 18Nov2005
|
||||
* window control radend "Don't Plot" `c5' `r1' 40 9 ml_v`n1'r
|
||||
window control radio "Range" `c5' `r1' 32 9 ml_v`n1'r
|
||||
window control radend "Don't Plot" `c6' `r1' 40 9 ml_v`n1'r
|
||||
local r1 = `r1' + `d1'
|
||||
* var#3
|
||||
local n1 = 3
|
||||
window control scombo ml_rhsnm `c1' `r1' 50 50 ml_v`n1'
|
||||
window control radbegin "+1" `c2' `r1' 20 9 ml_v`n1'r
|
||||
window control radio "+SD" `c3' `r1' 24 9 ml_v`n1'r
|
||||
window control radio "0/1" `c4' `r1' 24 9 ml_v`n1'r
|
||||
* 18Nov2005
|
||||
* window control radend "Don't Plot" `c5' `r1' 40 9 ml_v`n1'r
|
||||
window control radio "Range" `c5' `r1' 32 9 ml_v`n1'r
|
||||
window control radend "Don't Plot" `c6' `r1' 40 9 ml_v`n1'r
|
||||
local r1 = `r1' + `d1'
|
||||
* var#4
|
||||
local n1 = 4
|
||||
window control scombo ml_rhsnm `c1' `r1' 50 50 ml_v`n1'
|
||||
window control radbegin "+1" `c2' `r1' 20 9 ml_v`n1'r
|
||||
window control radio "+SD" `c3' `r1' 24 9 ml_v`n1'r
|
||||
window control radio "0/1" `c4' `r1' 24 9 ml_v`n1'r
|
||||
* 18Nov2005
|
||||
* window control radend "Don't Plot" `c5' `r1' 40 9 ml_v`n1'r
|
||||
window control radio "Range" `c5' `r1' 32 9 ml_v`n1'r
|
||||
window control radend "Don't Plot" `c6' `r1' 40 9 ml_v`n1'r
|
||||
local r1 = `r1' + `d1'
|
||||
* var#5
|
||||
local n1 = 5
|
||||
window control scombo ml_rhsnm `c1' `r1' 50 50 ml_v`n1'
|
||||
window control radbegin "+1" `c2' `r1' 20 9 ml_v`n1'r
|
||||
window control radio "+SD" `c3' `r1' 24 9 ml_v`n1'r
|
||||
window control radio "0/1" `c4' `r1' 24 9 ml_v`n1'r
|
||||
* 18Nov2005
|
||||
* window control radend "Don't Plot" `c5' `r1' 40 9 ml_v`n1'r
|
||||
window control radio "Range" `c5' `r1' 32 9 ml_v`n1'r
|
||||
window control radend "Don't Plot" `c6' `r1' 40 9 ml_v`n1'r
|
||||
* var#6
|
||||
local r1 = `r1' + `d1'
|
||||
local n1 = 6
|
||||
window control scombo ml_rhsnm `c1' `r1' 50 50 ml_v`n1'
|
||||
window control radbegin "+1" `c2' `r1' 20 9 ml_v`n1'r
|
||||
window control radio "+SD" `c3' `r1' 24 9 ml_v`n1'r
|
||||
window control radio "0/1" `c4' `r1' 24 9 ml_v`n1'r
|
||||
* 18Nov2005
|
||||
* window control radend "Don't Plot" `c5' `r1' 40 9 ml_v`n1'r
|
||||
window control radio "Range" `c5' `r1' 32 9 ml_v`n1'r
|
||||
window control radend "Don't Plot" `c6' `r1' 40 9 ml_v`n1'r
|
||||
|
||||
*> 18Nov2005 - Add 7th variable
|
||||
* var#7
|
||||
local r1 = `r1' + `d1'
|
||||
local n1 = 7
|
||||
window control scombo ml_rhsnm `c1' `r1' 50 50 ml_v`n1'
|
||||
window control radbegin "+1" `c2' `r1' 20 9 ml_v`n1'r
|
||||
window control radio "+SD" `c3' `r1' 24 9 ml_v`n1'r
|
||||
window control radio "0/1" `c4' `r1' 24 9 ml_v`n1'r
|
||||
window control radio "Range" `c5' `r1' 32 9 ml_v`n1'r
|
||||
window control radend "Don't Plot" `c6' `r1' 40 9 ml_v`n1'r
|
||||
*<
|
||||
|
||||
*=> Define buttons that execute the plot program
|
||||
local r1 = `r1' + `d1'
|
||||
/* 18Nov2005 - change size
|
||||
window control button "DC Plot" 2 `r1' 40 13 ml_dc
|
||||
global ml_dc "_mlplot 1"
|
||||
window control button "OR Plot" 46 `r1' 40 13 ml_or
|
||||
global ml_or "_mlplot 2"
|
||||
window control button "OR+DC Plot" 90 `r1' 40 13 ml_od
|
||||
global ml_od "_mlplot 3"
|
||||
window control button "Next 6" 134 `r1' 40 13 ml_nxt7
|
||||
global ml_nxt7 "_mlnxt7"
|
||||
*/
|
||||
local w = 52
|
||||
local w1 = `w' + 4
|
||||
local w2 = `w' + `w' + 4
|
||||
local w3 = `w' + `w' + `w' + 4
|
||||
|
||||
window control button "DC Plot" 2 `r1' `w' 13 ml_dc
|
||||
global ml_dc "_mlplot 1"
|
||||
window control button "OR Plot" `w1' `r1' `w' 13 ml_or
|
||||
global ml_or "_mlplot 2"
|
||||
window control button "OR+DC Plot" `w2' `r1' `w' 13 ml_od
|
||||
global ml_od "_mlplot 3"
|
||||
window control button "Next 7" `w3' `r1' `w' 13 ml_nxt7
|
||||
global ml_nxt7 "_mlnxt7"
|
||||
|
||||
|
||||
*=> Add a note to graph
|
||||
local r1 = `r1' + `d1' + 7
|
||||
local r2 = `r1'
|
||||
global ml_wlbl "Note"
|
||||
window control static ml_wlbl 5 `r1' 18 9
|
||||
window control edit 25 `r2' 148 8 ml_lbl
|
||||
|
||||
*=> Plot options
|
||||
local r1 = `r1' + `d1' + 3
|
||||
global ml_opt "Plot Options"
|
||||
* window control static ml_opt 2 `r1' 173 40 blackframe
|
||||
* version 1.6.5
|
||||
* window control static ml_opt 2 `r1' 173 50 blackframe
|
||||
|
||||
* 17Nov2005
|
||||
window control static ml_opt 2 `r1' 210 60 blackframe
|
||||
|
||||
local r1 = `r1' - 3
|
||||
window control static ml_opt 5 `r1' 40 8
|
||||
local r1 = `r1' + `d1' - 3
|
||||
local r2 = `r1'
|
||||
* tics
|
||||
global ml_wtic "Number of tics"
|
||||
window control static ml_wtic 5 `r1' 47 8
|
||||
window control edit 50 `r2' 25 8 ml_tic
|
||||
* range of plot
|
||||
global ml_wmin "Plot from"
|
||||
window control static ml_wmin 90 `r1' 28 8
|
||||
window control edit 120 `r1' 17 8 ml_xmin
|
||||
global ml_wmax "to"
|
||||
window control static ml_wmax 140 `r1' 6 8
|
||||
window control edit 149 `r1' 17 8 ml_xmax
|
||||
* connect if p>
|
||||
local r1 = `r1' + `d1'
|
||||
local r2 = `r1'
|
||||
global ml_wpgt "Connect if p>="
|
||||
window control static ml_wpgt 5 `r1' 42 8
|
||||
window control edit 50 `r2' 25 8 ml_pval
|
||||
* set base category
|
||||
global ml_wb "Base category"
|
||||
window control static ml_wb 90 `r1' 45 8
|
||||
window control edit 137 `r2' 28 8 ml_bcat
|
||||
* pack odds and use variable labels
|
||||
local r1 = `r1' + `d1' - 2
|
||||
window control check "Pack odds ratio plot" 5 `r1' 80 10 ml_pack
|
||||
window control check "Use variable labels" 90 `r1' 75 10 ml_vlbl
|
||||
* pack odds and use variable labels
|
||||
local r1 = `r1' + `d1' - 2
|
||||
window control check "Use category values for plot symbols" 5 `r1' 180 10 ml_valu
|
||||
|
||||
* 17Nov2005 - add underline option for OR+DC plots
|
||||
local r1 = `r1' + `d1' - 2
|
||||
window control check "Underline indicates negative change" 5 `r1' 180 10 ml_under
|
||||
|
||||
*=> Buttons for odds and ends
|
||||
local r1 = `r1' + 15
|
||||
* 18Nov2005 - drop help button - no longer works
|
||||
* window control button "Help" 46 `r1' 40 13 ml_help
|
||||
* global ml_help "_mlhlp"
|
||||
* 18Nov2005
|
||||
* window control button "Exit" 2 `r1' 40 13 ml_ex
|
||||
* window control button "Print" 90 `r1' 83 13 ml_print
|
||||
|
||||
local w = 103
|
||||
local wx = `w' + 5
|
||||
window control button "Exit" 2 `r1' `w' 13 ml_ex
|
||||
global ml_ex "exit 3000"
|
||||
window control button "Print" `wx' `r1' `w' 13 ml_print
|
||||
global ml_print "_mlprnt"
|
||||
|
||||
* window dialog "Multinomial Logit Plots" 10 10 180 192
|
||||
* window dialog "Multinomial Logit Plots" 230 80 180 192
|
||||
* version 1.6.5
|
||||
*window dialog "Multinomial Logit Plots" 230 80 180 202
|
||||
* 17Nov2005
|
||||
*window dialog "Multinomial Logit Plots" 10 10 320 302
|
||||
* x y
|
||||
*window dialog "Multinomial Logit Plots" 10 10 220 302
|
||||
|
||||
window dialog "Multinomial Logit Plots" 10 10 220 225
|
||||
|
||||
end
|
||||
|
||||
program define _mlplot
|
||||
if "`1'" ~= "" {
|
||||
global ml_ordc = `1'
|
||||
}
|
||||
|
||||
*=> construct list of vars from the scombo boxes 1 through 6
|
||||
*=> construct list of vars from the scombo boxes 1 through 7
|
||||
* 18Nov2005
|
||||
local i = 1
|
||||
local varlst ""
|
||||
local stdlst ""
|
||||
while `i' < 8 {
|
||||
* while `i' < 7 {
|
||||
* type of plot: unstd, std, or 0 to 1
|
||||
local tmp "ml_v`i'r"
|
||||
* name of variable
|
||||
local tmpnm "ml_v`i'"
|
||||
if $`tmp'==1 {
|
||||
local varlst "`varlst' $`tmpnm'"
|
||||
local stdlst "`stdlst'u"
|
||||
}
|
||||
if $`tmp'==2 {
|
||||
local varlst "`varlst' $`tmpnm'"
|
||||
local stdlst "`stdlst's"
|
||||
}
|
||||
if $`tmp'==3 {
|
||||
local varlst "`varlst' $`tmpnm'"
|
||||
local stdlst "`stdlst'0"
|
||||
}
|
||||
* 18Nov2005
|
||||
if $`tmp'==4 {
|
||||
local varlst "`varlst' $`tmpnm'"
|
||||
local stdlst "`stdlst'r"
|
||||
}
|
||||
* 18Nov2005
|
||||
* if type is not 1, 2, 3, or 4 it is not plotted
|
||||
* if type is not 1, 2, or 3, it is not plotted
|
||||
local i = `i' + 1
|
||||
}
|
||||
|
||||
*=> build options to pass to mlogplot
|
||||
local opts "std(`stdlst')"
|
||||
if "$ml_bcat"~="" {
|
||||
local opts "`opts' b($ml_bcat)"
|
||||
}
|
||||
local opts "`opts' p($ml_pval)"
|
||||
if "$ml_xmin"~="min" {
|
||||
local opts "`opts' min($ml_xmin)"
|
||||
}
|
||||
if "$ml_xmax"~="max" {
|
||||
local opts "`opts' max($ml_xmax)"
|
||||
}
|
||||
if "$ml_lbl" ~= "" {
|
||||
local opts "`opts' note($ml_lbl)"
|
||||
}
|
||||
if $ml_ordc>=2 {
|
||||
local opts "`opts' or"
|
||||
}
|
||||
if $ml_ordc~=2 {
|
||||
local opts "`opts' dc"
|
||||
}
|
||||
if $ml_pack==1 {
|
||||
local opts "`opts' packed"
|
||||
}
|
||||
if $ml_vlbl==1 {
|
||||
local opts "`opts' labels"
|
||||
}
|
||||
* 1.6.5
|
||||
if $ml_valu==1 {
|
||||
local opts "`opts' values"
|
||||
}
|
||||
* 18Nov2005
|
||||
if $ml_under==1 {
|
||||
local opts "`opts' sign"
|
||||
}
|
||||
|
||||
local opts "`opts' ntics($ml_tic)"
|
||||
local opts "`opts' $mlopts"
|
||||
di in white ". mlogplot `varlst', `opts'"
|
||||
mlogplot `varlst',`opts'
|
||||
* if $PE_mlerr==1 {
|
||||
* exit 3000
|
||||
* }
|
||||
end
|
||||
|
||||
program define _mlinit
|
||||
|
||||
*=> set radio buttons
|
||||
local i = 1
|
||||
while `i' < 6 {
|
||||
global ml_v`i'r = 1
|
||||
local i = `i' + 1
|
||||
}
|
||||
|
||||
*=> defaults for check box
|
||||
global ml_rng = 1 /* use observed range */
|
||||
global ml_ordc = 1 /* DC plot */
|
||||
global ml_pack = 0 /* don't pack plot */
|
||||
global ml_vlbl = 0 /* don't plot value labels */
|
||||
* 17Nov2005
|
||||
global ml_under = 0 /* underline negative changes */
|
||||
|
||||
* 1.6.5
|
||||
global ml_valu = 0 /* don't plot value labels */
|
||||
global ml_pval = .1 /* connect if p> */
|
||||
global ml_tic = 9
|
||||
global ml_lbl ""
|
||||
global ml_xmin "min" /* plot from min to max */
|
||||
global ml_xmax "max"
|
||||
|
||||
*=> get b from logit
|
||||
/* 2009-10-28
|
||||
version 5.0
|
||||
mat ml_b = get(_b)
|
||||
version 6.0
|
||||
*/
|
||||
tempname v
|
||||
_get_mlogit_bv ml_b `v'
|
||||
global ml_nvars = colsof(ml_b) - 1
|
||||
|
||||
*=> get names of variables
|
||||
global ml_rhsnm : colnames(ml_b)
|
||||
global ml_nvar : word count $ml_rhsnm
|
||||
global ml_nvar = $ml_nvar - 1
|
||||
global ml_lastv = 1
|
||||
global ml_lastv = 0
|
||||
_mlgetv
|
||||
end
|
||||
|
||||
* get the names of variables to fill in the scombo boxes
|
||||
program define _mlgetv
|
||||
* get number of last variable in box; 0 if none plotted before.
|
||||
* if this is called from Next 6, this will not be 0.
|
||||
local k = $ml_lastv
|
||||
local i = 1
|
||||
* 18Nov2005
|
||||
* loop through up to 6 new variables
|
||||
* while `i' < 7 {
|
||||
* loop through up to 7 new variables
|
||||
while `i' < 8 {
|
||||
local k = `k' + 1
|
||||
* if exceed max number of vars, do fill remaining scombo boxes
|
||||
if `k' > $ml_nvar {
|
||||
* do not plot
|
||||
*18Nov2005
|
||||
* global ml_v`i'r = 4
|
||||
global ml_v`i'r = 5
|
||||
* no name
|
||||
global ml_v`i' ""
|
||||
}
|
||||
* else, get next in list of variables
|
||||
else {
|
||||
global ml_v`i' : word `k' of $ml_rhsnm
|
||||
local tmp "ml_v`i'"
|
||||
_pedum $`tmp'
|
||||
global ml_v`i'r = 1
|
||||
if r(dummy) == 1 { global ml_v`i'r = 3 }
|
||||
}
|
||||
local i = `i' + 1
|
||||
}
|
||||
* ok that this can be larger than n vars in model
|
||||
* 18Nov2005
|
||||
*global ml_lastv = $ml_lastv + 6
|
||||
global ml_lastv = $ml_lastv + 7
|
||||
end
|
||||
|
||||
program define _mlnxt7
|
||||
* if last var from _mlgetv > n vars in model, reset
|
||||
if $ml_lastv > $ml_nvar {
|
||||
global ml_lastv = 0
|
||||
}
|
||||
_mlgetv
|
||||
_mlplot
|
||||
end
|
||||
|
||||
program define _mlprnt
|
||||
gphprint,nologo
|
||||
end
|
||||
exit
|
||||
|
||||
* version 1.6.3 11Mar2001
|
||||
* version 1.6.4 19Nov2003 - for stata 8, change where box opens
|
||||
* version 1.6.5 30Mar2005 plot values not labels
|
||||
* version 1.6.6 13Apr2005 plot values not labels
|
||||
* version 1.7.0 18Nov2005 add sign and more variables - mlogview
|
||||
* version 1.7.1 01Apr2006
|
||||
* - fix dialog box
|
||||
|
52
Modules/ado/plus/m/mlogview.hlp
Normal file
52
Modules/ado/plus/m/mlogview.hlp
Normal file
@ -0,0 +1,52 @@
|
||||
.-
|
||||
help for ^mlogview^ - 1.6.1 - 2/22/01
|
||||
.-
|
||||
|
||||
Plots odds ratios and discrete change coefficients from the
|
||||
multinomial logit model.
|
||||
------------------------------------------------------------
|
||||
|
||||
^Select variables^: select independent variables to include in plot
|
||||
|
||||
^Select amount of change^: amount of discrete change to plot for each variable
|
||||
^+1^: unit change
|
||||
^+SD^: standard deviation change
|
||||
^0->1^: change from 0 to 1
|
||||
^Don't plot^: exclude variable from plot
|
||||
(Starting values for discrete change taken from output from ^prchange^, which
|
||||
must be executed prior to executing ^mlogview^ if discrete change is to be
|
||||
plotted.)
|
||||
|
||||
^DC Plot^: draw discrete change plot
|
||||
|
||||
^OR Plot^: draw odds ratio plot
|
||||
|
||||
^OR+DC Plot^: draw odds ratio plot in which the size of the letters
|
||||
indicates the discrete change
|
||||
|
||||
^Next 6^: list next 6 independent variables for packed plot
|
||||
|
||||
^Note^: title for plot
|
||||
|
||||
^Number of tics^: # of tic marks on x axis of plot
|
||||
|
||||
^Plot from^: minimum and maximum values of x axis for plot
|
||||
|
||||
^Connect if^: for odds ratio plots, connect lines if not significant at
|
||||
specified level
|
||||
|
||||
^Base category^: value of category to use as base category for odds ratio plot
|
||||
|
||||
^Pack odds ratio plot^: eliminate extra vertical space in odds ratio plot
|
||||
|
||||
^Use variable labels^: use variable labels instead of names to identify
|
||||
variables in plot
|
||||
|
||||
^Print^: send plot to printer
|
||||
|
||||
.-
|
||||
Author: J. Scott Long
|
||||
www.indiana.edu/~jslsoc/spost.htm
|
||||
spostsup@@indiana.edu
|
||||
|
||||
|
123
Modules/ado/plus/m/mnthlist.ado
Normal file
123
Modules/ado/plus/m/mnthlist.ado
Normal file
@ -0,0 +1,123 @@
|
||||
program def mnthlist, rclass
|
||||
*! NJC 1.0.0 9 January 2001
|
||||
version 6.0
|
||||
#delimit ;
|
||||
syntax , [ Global(str) Noisily Caplc Uppercase Long
|
||||
Number(int 12) Begin(str) Step(numlist int max=1 >=1)
|
||||
Year(numlist int max=1 >100 <10000) ] ;
|
||||
#delimit cr
|
||||
|
||||
if length("`global'") > 8 {
|
||||
di in r "global name must be <=8 characters"
|
||||
exit 198
|
||||
}
|
||||
|
||||
if "`caplc'" != "" & "`uppercase'" != "" {
|
||||
di in r "must choose between cap/lc and uppercase"
|
||||
exit 198
|
||||
}
|
||||
|
||||
if "`begin'" == "" {
|
||||
local begin 1
|
||||
}
|
||||
else {
|
||||
capture confirm integer number `begin'
|
||||
if _rc == 0 {
|
||||
if `begin' < 1 | `begin' > 12 {
|
||||
di in r "invalid begin( ) option"
|
||||
exit 198
|
||||
}
|
||||
}
|
||||
else { /* grind through possible abbreviations */
|
||||
local b = lower(trim("`begin'"))
|
||||
if substr("`b'",1,2) == "ja" {
|
||||
local begin 1
|
||||
}
|
||||
else if substr("`b'",1,1) == "f" {
|
||||
local begin 2
|
||||
}
|
||||
else if substr("`b'",1,3) == "mar" {
|
||||
local begin 3
|
||||
}
|
||||
else if substr("`b'",1,2) == "ap" {
|
||||
local begin 4
|
||||
}
|
||||
else if substr("`b'",1,3) == "may" {
|
||||
local begin 5
|
||||
}
|
||||
else if substr("`b'",1,3) == "jun" {
|
||||
local begin 6
|
||||
}
|
||||
else if substr("`b'",1,3) == "jul" {
|
||||
local begin 7
|
||||
}
|
||||
else if substr("`b'",1,2) == "au" {
|
||||
local begin 8
|
||||
}
|
||||
else if substr("`b'",1,1) == "s" {
|
||||
local begin 9
|
||||
}
|
||||
else if substr("`b'",1,1) == "o" {
|
||||
local begin 10
|
||||
}
|
||||
else if substr("`b'",1,1) == "n" {
|
||||
local begin 11
|
||||
}
|
||||
else if substr("`b'",1,1) == "d" {
|
||||
local begin 12
|
||||
}
|
||||
else {
|
||||
di in r "invalid begin( ) option"
|
||||
exit 198
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if "`step'" == "" { local step = 1 }
|
||||
|
||||
* upper( ) and lower( ) won't take strings >80 chars
|
||||
if "`long'" != "" {
|
||||
local m1 "January February March April May June"
|
||||
local m2 "July August September October November December"
|
||||
}
|
||||
else {
|
||||
local m1 "Jan Feb Mar Apr May Jun"
|
||||
local m2 "Jul Aug Sep Oct Nov Dec"
|
||||
}
|
||||
|
||||
if "`caplc'" == "" {
|
||||
local m1 = lower("`m1'")
|
||||
local m2 = lower("`m2'")
|
||||
}
|
||||
|
||||
if "`uppercase'" != "" {
|
||||
local m1 = upper("`m1'")
|
||||
local m2 = upper("`m2'")
|
||||
}
|
||||
|
||||
local m "`m1' `m2'"
|
||||
local i = 1
|
||||
local j = `begin'
|
||||
if "`year'" != "" {
|
||||
local y = `year' + (`begin' - 0.5) / 12
|
||||
}
|
||||
|
||||
while `i' <= `number' {
|
||||
local mnth : word `j' of `m'
|
||||
local newlist "`newlist'`mnth'`year' "
|
||||
local j = mod(`j' + `step', 12)
|
||||
local j = cond(`j' == 0, 12, `j')
|
||||
|
||||
if "`year'" != "" {
|
||||
local y = `y' + `step' / 12
|
||||
local year = int(`y')
|
||||
}
|
||||
|
||||
local i = `i' + 1
|
||||
}
|
||||
|
||||
if "`noisily'" != "" { di "`newlist'" }
|
||||
if "`global'" != "" { global `global' "`newlist'" }
|
||||
return local list `newlist'
|
||||
end
|
||||
|
2
Modules/ado/plus/m/mnthlist.hlp
Normal file
2
Modules/ado/plus/m/mnthlist.hlp
Normal file
@ -0,0 +1,2 @@
|
||||
.h listutil
|
||||
|
30
Modules/ado/plus/m/mvtab1.ado
Normal file
30
Modules/ado/plus/m/mvtab1.ado
Normal file
@ -0,0 +1,30 @@
|
||||
*! version 1.0.0 \ scott long 2007-08-05
|
||||
|
||||
// task: tabulate only missing values
|
||||
// project: workflow chapter 4
|
||||
// author: scott long \ 2007-08-05
|
||||
|
||||
// based on tab1.ado version 2.2.4 29sep2004 by StataCorp
|
||||
|
||||
program define mvtab1, byable(recall)
|
||||
version 6, missing
|
||||
syntax varlist [if] [in] [fweight] [, *]
|
||||
tokenize `varlist'
|
||||
local stop : word count `varlist'
|
||||
local i 1
|
||||
tempvar touse
|
||||
mark `touse' `if' `in' [`weight'`exp']
|
||||
|
||||
local weight "[`weight'`exp']"
|
||||
capture {
|
||||
while `i' <= `stop' {
|
||||
noisily di _n `"-> tabulation of ``i'' `if' `in'"'
|
||||
* VVVVVVVV VVVV
|
||||
cap noisily tab ``i'' if `touse' & ``i''>=. `weight' , `options' miss
|
||||
if _rc!=0 & _rc!=1001 { exit _rc }
|
||||
local i = `i' + 1
|
||||
}
|
||||
}
|
||||
error _rc
|
||||
end
|
||||
exit
|
22
Modules/ado/plus/m/mvtab1.hlp
Normal file
22
Modules/ado/plus/m/mvtab1.hlp
Normal file
@ -0,0 +1,22 @@
|
||||
.-
|
||||
help for ^mvtab1^ :: 2008-03-07
|
||||
.-
|
||||
|
||||
Tabulate missing values
|
||||
-----------------------
|
||||
|
||||
^mvtab1^ varlist^,^ (see options for ^tab1^)
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
^mvtab1^ operates just like ^tab1^ except that it only prints frequency
|
||||
distributions for missing values.
|
||||
|
||||
Options
|
||||
-------
|
||||
|
||||
See ^tab1^ for a listing of options.
|
||||
|
||||
.-
|
||||
Author: Scott Long - www.indiana.edu/~jslsoc/workflow.htm
|
Reference in New Issue
Block a user