📄 bootstrap.hlp
字号:
{smcl}
{* 07apr2005}{...}
{cmd:help bootstrap}{right:dialog: {bf:{dialog bootstrap}}{space 15}}
{right:also see: {help bootstrap postestimation}}
{hline}
{title:Title}
{p2colset 5 22 24 2}{...}
{p2col :{hi:[R] bootstrap} {hline 2}}Bootstrap sampling and estimation{p_end}
{p2colreset}{...}
{title:Syntax}
{p 8 18 2}
{cmd:bootstrap}
{it:{help exp_list}}
[{cmd:,} {it:options} {it:{help eform_option}}]
{cmd::} {it:command}
{synoptset 24 tabbed}{...}
{synopthdr}
{synoptline}
{syntab:Main}
{synopt :{opt r:eps(#)}}perform
{it:#} bootstrap replications, default is {cmd:reps(50)}{p_end}
{syntab:Options}
{synopt :{opth str:ata(varlist)}}variables identifying strata{p_end}
{synopt :{opt si:ze(#)}}draw samples of size {it:#}; default is {help _N}{p_end}
{synopt :{opth cl:uster(varlist)}}variables
identifying resampling clusters{p_end}
{synopt :{opth id:cluster(newvar)}}create new cluster ID variable{p_end}
{p2coldent:+ {opth group(varname)}}ID variable for groups within {opt cluster()}{p_end}
{synopt :{help prefix_saving_option:{bf:{ul:sav}ing(}{it:filename}{bf:, ...)}}}save
results to {it:filename}; save statistics in double precision;
save results to {it:filename} every {it:#} replications{p_end}
{synopt :{opt bca}}compute acceleration for BCa confidence intervals{p_end}
{synopt :{opt mse}}use MSE formula for variance estimate{p_end}
{syntab:Reporting}
{synopt :{opt l:evel(#)}}set confidence level; default is {cmd:level(95)}{p_end}
{synopt :{opt notable}}suppress table of results{p_end}
{synopt :{opt noh:eader}}suppress the table header{p_end}
{synopt :{opt nol:egend}}suppress the table legend{p_end}
{synopt :{opt v:erbose}}display the full table legend{p_end}
{synopt :{opt nodots}}suppress the replication dots{p_end}
{synopt :{opt noi:sily}}display any output from {it:command}{p_end}
{synopt :{opt tr:ace}}trace the {it:command}{p_end}
{synopt :{opt ti:tle(text)}}use {it:text} as title for bootstrap results{p_end}
{syntab:Advanced}
{synopt :{opt nodrop}}do not drop observations{p_end}
{synopt :{opt nowarn}}do not warn when {cmd:e(sample)} is not set{p_end}
{synopt :{opt force}}do not check for {it:weights} or {cmd:svy} commands; seldom used{p_end}
{synopt :{opth reject(exp)}}identify invalid results{p_end}
{synopt :{opt seed(#)}}set random-number seed to {it:#}{p_end}
{synoptline}
{p2colreset}{...}
{p 4 6 2}
+ {opt group()} is not shown in the dialog box.
{p_end}
{p 4 6 2}{it:weights} are not allowed in {it:command}.{p_end}
{p 4 6 2}See {help bootstrap postestimation} for features available after estimation.
{title:Description}
{pstd}
{cmd:bootstrap} performs bootstrap estimation. Typing
{phang2}
{cmd:. bootstrap} {it:exp_list}{cmd:,} {opt reps(#)}{cmd::} {it:command}
{pstd}
executes {it:command} multiple times, bootstrapping the statistics in
{it:exp_list} by resampling observations (with replacement) from the data in
memory {it:#} times. This is commonly referred to as the nonparametric
bootstrap method.
{pstd}
{it:command} defines the statistical command to be executed. Most Stata
commands and user-written programs can be used with {cmd:bootstrap}, as long
as they follow {help language:standard Stata syntax}. If the {opt bca} option
is supplied, {it:command} must also work with {helpb jackknife}. The {cmd:by}
prefix may not be part of {it:command}.
{pstd}
{it:{help exp_list}} specifies the statistics to be collected from the
execution of {it:command}. If {it:command} changes the contents in
{cmd:e(b)}, {it:exp_list} is optional and defaults to {cmd:_b}.
{pstd}
Since bootstrapping is a random process, if you want to be able to
reproduce results, set the random-number seed by specifying
the {opt seed(#)} option or typing
{phang2}
{cmd:. set seed} {it:#}
{pstd}
where {it:#} is a seed of your choosing, before running {cmd:bootstrap}; see
{helpb generate}.
{pstd}
Many estimation commands allow the {cmd:vce(bootstrap)} option. For those
commands, we recommend using {cmd:vce(bootstrap)} over {cmd:bootstrap} since
the estimation command already handles clustering and other model-specific
details for you. The {cmd:bootstrap} prefix command is intended for use with
nonestimation commands, such as {cmd:summarize}, user-written commands, or
functions of coefficients.
{pstd}
{cmd:bs} and {cmd:bstrap} are synonyms for {cmd:bootstrap}.
{title:Options}
{dlgtab:Main}
{phang}
{opt reps(#)} specifies the number of bootstrap replications to be performed.
The default is 50. 50-200 replications are generally adequate for estimates
of standard error and thus are adequate for normal-approximation confidence
intervals. Estimates of confidence intervals using the percentile or
bias-corrected methods typically require 1,000 or more replications.
{dlgtab:Options}
{phang}
{opth strata(varlist)} specifies the variables that identify strata. If this
option is specified, bootstrap samples are taken independently within each
stratum.
{phang}
{opt size(#)} specifies the size of the samples to be drawn. The default is
{opt _N}, meaning to draw samples of the same size as the data. If specified,
{it:#} must be less than or equal to the number of observations within
{opt strata()}.
{pmore}
If {opt cluster()} is specified, the default size is the number of clusters in the
original dataset. In the case of unbalanced clusters, resulting sample sizes
will differ from replication to replication. In the case of cluster sampling,
{it:#} must be less than or equal to the number of clusters within
{opt strata()}.
{phang}
{opth cluster(varlist)} specifies the variables that identify resampling
clusters. If this option is specified, the sample drawn during each
replication is a bootstrap sample of clusters.
{phang}
{opth idcluster(newvar)} creates a new variable containing a unique
identifier for each resampled cluster. This option requires that
{opt cluster()} also be specified.
{phang}
{opth group(varname)} recreates {it:varname} containing a unique
identifier for each group across the resampled clusters. This option requires
that {opt idcluster()} also be specified.
{pmore}
This option is useful for maintaining unique group identifiers when sampling
clusters with replacement. Suppose cluster 1 contains 3 groups. If the
{cmd:idcluster(newclid)} option is specified and cluster 1 is sampled multiple
times, then {cmd:newclid} uniquiely identifes each copy of cluster 1. If
{cmd:group(newgroupid)} is also specified, then {cmd:newgroupid} uniquiely
identifies each copy of each group.
{phang}
{help prefix_saving_option:{bf:saving}({it:filename}[, {it:suboptions}])}
creates a Stata data file ({opt .dta} file) consisting of, for each statistic
in {it:exp_list}, a variable containing bootstrap replicates.
{phang2}
{opt double} specifies that the results for each replication be stored as
{opt double}s, meaning 8-byte reals. By default, they are stored as
{opt float}s, meaning 4-byte reals.
{phang2}
{opt every(#)} specifies that results be written to disk every {it:#}th
replication. {opt every()} should only be specified in conjunction with
{opt saving()} when {it:command} takes a long time for each replication. This
will allow recovery of partial results should some other software crash your
computer. See {helpb postfile}.
{phang2}
{opt replace} indicates that {it:filename} be overwritten, if it exists. This
option is not shown in the dialog box.
{phang}
{opt bca} requests that {cmd:bootstrap} estimate the acceleration of each
statistic in {it:exp_list}. This estimate is used to construct BCa
confidence intervals.
{phang}
{opt mse} indicates that {cmd:bootstrap} compute the variance using deviations
of the replicates from the observed value of the statistics based on the
entire dataset. By default, {cmd:bootstrap} computes the variance using
deviations from the average of the replicates.
{dlgtab:Reporting}
{phang}
{opt level(#)}; see {help estimation options}.
{phang}
{opt notable} suppresses the display of the table of results.
{phang}
{opt noheader} suppresses the display of the table header. This option
implies {opt nolegend}. This option may also be specified when replaying
estimation results.
{phang}
{opt nolegend} suppresses the display of the table legend. This option may
also be specified when replaying estimation results.
{phang}
{opt verbose} requests that the full table legend be displayed. By default,
coefficients and standard errors are not displayed. This option may also be
specified when replaying estimation results.
{phang}
{opt nodots} suppresses display of the replication dots. By default, a single
dot character is displayed for each successful replication. A single red 'x'
is displayed if {it:command} returns an error or if one of the values in
{it:exp_list} is missing.
{phang}
{opt noisily} requests that any output from {it:command} be displayed. This
option implies the {opt nodots} option.
{phang}
{opt trace} causes a trace of the execution of {it:command} to be displayed.
This option implies the {opt noisily} option.
{phang}
{opt title(text)} specifies a title to be displayed above the table of
bootstrap results. The default title is the title saved in {cmd:e(title)}
by an estimation command, or if {cmd:e(title)} is not filled in,
{cmd:Bootstrap results} is used. {opt title()} may also be specified when
replaying estimation results.
{dlgtab:Advanced}
{phang}
{opt nodrop} prevents observations outside {cmd:e(sample)} and the
{it:if} and {it:in} conditions from being dropped before the data is resampled.
{phang}
{opt nowarn} suppresses the display of a warning message when
{it:command} does not set {cmd:e(sample)}.
{phang}
{opt force} suppresses the restriction that {it:command} not specify
weights or be a {cmd:svy} command. This is a rarely used option. Use it only
if you know what you are doing!
{phang}
{opth reject(exp)} identifies an expression that indicates when results should
be rejected. When {it:exp} is true, the resulting values are reset to missing
values.
{phang}
{opt seed(#)} sets the random-number seed. Specifying this option is
equivalent to typing the following command prior to calling {cmd:bootstrap}:
{phang2}
{cmd:. set seed} {it:#}
{phang}
The following option is available with {cmd:bootstrap} but is not shown in
the dialog box:
{phang}
{it:eform_option} causes the coefficient table to be displayed in
exponentiated form; see {it:{help eform_option}}. {it:command} determines
which of the following are allowed ({opt eform(string)} and {opt eform} are
always allowed).
{title:Examples}
{phang}
{cmd:. bootstrap, reps(100) bca: reg mpg weight gear foreign}
{p_end}
{phang}
{cmd:. bootstrap _b, reps(1000) saving(bsauto) }
{cmd:bca: reg mpg weight gear foreign}
{p_end}
{phang}
{cmd:. bootstrap diff=(_b[weight]-_b[gear]): reg mpg weight gear foreign}
{p_end}
{phang}
{cmd:. bootstrap t=r(t), rep(1000) strata(foreign) }
{cmd:saving(bsauto): ttest mpg, by(foreign) unequal}
{p_end}
{phang}
{cmd:. bootstrap ratio=r(ratio), reps(1000) nowarn: ratio price weight}
{p_end}
{phang}
{cmd:. bootstrap ratio=r(ratio) np=r(n_price) nw=r(n_weight), }
{cmd:reps(100): ratio price weight}
{p_end}
{phang}
{cmd:. bootstrap (coef_ratio: _b[x1]/_b[x2]), }
{cmd:reps(100) cluster(clid) idcluster(newclid) }
{cmd:group(group): clogit choice x1 x2, group(group) cluster(newclid)}
{p_end}
{title:Also see}
{psee}
Manual: {bf:[R] bootstrap}
{psee}
Online: {help bootstrap postestimation};{break}
{helpb jackknife}, {helpb permute}, {helpb postfile},
{helpb sample}, {helpb simulate}, {helpb statsby}
{p_end}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -