Goals
After completing this tutorial you should understand:
- How to compute bootstrapped standard errors and confidence intervals for coefficient estimates from
quantileFit
. - How to specify the alpha level for the
quantileFit
standard errors.
Bootstrapping standard errors and confidence intervals
The computation of standard errors and confidence intervals for coefficient estimates from quantileFit
is controlled with two members of the qFitControl
structure:
- qCtl.bootstrap
- Scalar, indicating the number of bootstrap repetitions used to find bootstrap standard errors and confidence intervals. Default = 0, no bootstrap errors computed.
- qCtl.alpha
- Scalar, alpha value for computing bootstrap confidence intervals. Not valid if qCtl.bootstrap = 0.
Note that the default is that no standard errors or confidence intervals will be computed. If you wish to compute standard errors and confidence intervals the number of bootstrap repetitions must be specified using qCtl.bootstrap
.
Computing standard errors and confidence intervals
Consider our earlier example :
$$ln(wage) = \alpha + \beta_1 * age + \beta_2 * age^2 + \beta_3 * tenure$$
Note that the default GAUSS results do not report standard errors for the coefficients :
Total observations: 28101
Number of variables: 3
VAR. / tau (in %) 5% 50% 95%
--------------------------------------------------- CONSTANT -0.7630 0.5112 0.0006 age 0.1103 0.0656 0.1271 age:age -0.0017 -0.0010 -0.0016 tenure 0.0356 0.0466 0.0196
To change this, we must specify the number of bootstrap repetitions that we wish to use to compute the standard errors using qCtl.bootstrap
:
// Data file name
dataset = getGAUSSHome() $+ "examples/regsmpl.dta";
// Set up control structure
struct qFitControl qCtl;
qCtl = qFitControlCreate();
// Set rndseed
rndseed 4893;
// Turn on confidence interval
qCtl.bootstrap = 200;
// Call quantileFit
struct qFitOut qOut;
qOut = quantileFit(dataset, "ln_wage~age + age:age + tenure", qCtl);
rndseed
is used to set the random seed so the results may be replicated. It is not required to compute the standard errors and confidence intervals.GAUSS now reports standard errors, shown in parentheses, for our coefficients:
Total observations: 28101
Number of variables: 3
VAR. / tau (in %) 5% 50% 95%
-------------------------------------------------------------------------- CONSTANT -0.763 0.5112 0.000618 ( 0.16) (0.0412) (0.0905) age 0.1103 0.06559 0.1271
(0.0106) (0.00297 (0.0064) age:age -0.00172 -0.00101 -0.00157 (0.00017) (5.06e-05) (0.00011) tenure 0.03557 0.04661 0.01958
(0.00157) (0.00103) (0.00206)
These standard errors are bootstrapped using 200 repetitions, as specified by qCtl.bootstrap
.
Stored standard errors and confidence intervals
Both the bootstrapped standard errors and confidence intervals can be found in the qFitOut
output structure in the members qOut.se
and qOut.ci
, respectively.
The member qOut.se
stores the standard errors in a matrix with a separate column for each quantile level. Since we have three quantile levels and four variables (including our constant) in this regression, qOut.se
has three columns and four rows.
Conversely, the member qOut.ci
stores the confidence intervals in an array. This array stores the results for each quantile level on a separate plane. The first row on each plane stores the lower bound of the confidence interval and the second row stores the upper bound of the confidence interval. Therefore, for our model qOut.ci
is a 3 x 2 x 4 array, 3 planes because we have 3 quantile levels and four columns because we have four variables.
Changing the alpha level
In our example above, GAUSS finds a 95% percent confidence interval using the default qCtl.alpha
value of 0.05. However, suppose we wish to find a 90% confidence interval. This can be done by changing the value of qCtl.alpha
:
// Data file name
fname = __FILE_DIR $+ "regsmpl.dta";
// Set up control structure
struct qFitControl qCtl;
qCtl = qFitControlCreate();
// Set rndseed
rndseed 4893;
// Turn on confidence interval
qCtl.bootstrap = 200;
// Change alpha
qCtl.alpha = 0.10;
// Call quantileFit
struct qFitOut qOut;
qOut = quantileFit(fname, "ln_wage~age + age:age + tenure", qCtl);
The first thing to note is that qCtl.alpha
has no impact on the estimated standard errors:
Total observations: 28101
Number of variables: 3
VAR. / tau (in %) 5% 50% 95%
-------------------------------------------------------------------------- CONSTANT -0.763 0.5112 0.000618 ( 0.16) (0.0412) (0.0905) age 0.1103 0.06559 0.1271
(0.0106) (0.00297 (0.0064) age:age -0.00172 -0.00101 -0.00157 (0.00017) (5.06e-05) (0.00011) tenure 0.03557 0.04661 0.01958
(0.00157) (0.00103) (0.00206)
However, by inspect qOut.ci
we can see that our confidence intervals have changed :
Conclusion
Congratulations! After this tutorial you should know how to use the qCtl.bootstrap
and qCtl.alpha
members of the qFitControl
structure to control the computation of standard errors and confidence intervals by the quantileFit
procedure.