help qenvF

Generate quantile envelopes for F quantile-quantile plot

Syntax

qenvF
varname
[if] [in]
,
generate(newvar1 newvar2)
dfnum(#)
dfdenom(#)
[
reps(#)
level(#)
overall
]

Description

qenvF generates two numeric variables for later plotting on a
quantile-quantile plot that define an envelope of low and high
expectations for each quantile given repeated sampling from a F
distribution with the same number of values, and degrees of freedom
as specified. The program is a helper program designed for use
with qplot, which must be installed separately.
Type findit qplot to get references and code sources.

When plotted, the envelopes are to be considered indicative, and not as
implying a formal decision. In particular, the envelopes underline which
quantiles are least reliable. With some experience, they should guide
later analysis.

Remarks

"Degrees of freedom" is to be understood by purists as indicating
"number of degrees of freedom".

The precise recipe is as follows.

1. Take reps samples of the same size from a F distribution
with the parameter values specified in dfnum() and
dfdenom().

2. Order each sample from smallest to largest.

3. For each rank, calculate reference intervals containing
level% of the sample quantiles. For example, with the default of
95%, the interval ranges from the 2.5% quantile to the 97.5% quantile,
the quantiles being calculated using a procedure similar to that used
for pctile.

4. The generated variables contain values defining the reference
intervals. They are not aligned with the values of varname in the
dataset, but they are assigned to the same set of observations, which is
sufficient for qplot.

This envelope approximates a separate test for each rank. The probability
that in a variable an observation falls outside this envelope is much
larger than 100 - level. When specifying the overall option an
envelope will be computed such that the overall error rate will be
approximately 100 - level using an algorithm discussed by Davison and
Hinkley (1997, Chapter 4).

1. Set L to ceil((100 - level)/200 * reps).

2. For each sample create an envelope using the remaining samples by
storing for each rank the Lth and (reps - L)th smallest value, and determine
whether the entire sample falls within this envelope. The proportion of
samples for which this is not true is an estimate of the overall error rate
of that envelope.

3. Decrease L until the overall error rate is less than 100 - level. If
the nominal level has not been reached when L = 1, then the entire range is
returned and a warning is displayed reporting the approximate overall error
rate for that envelope.

4. Compute the envelope using all samples based on this L.

Options

generate() specifies the names of two new variables to be
generated. This is a required option.

dfnum() specifies the numerator degrees of freedom of the F distribution.
This is a required option.

dfdenom() specifies the denominator degrees of freedom of the F
distribution. This is a required option.

reps() specifies the number of samples to be taken. The default is
100. This is likely to be adequate for informal exploration.

level() specifies the percent of sample values to be included
within the envelope for each rank. level(100) is allowed and
interpreted as the entire range.

overall specifies that an envelope with an approximate overall
error rate of 100 - level is to be computed instead of a pointwise
error rate of approximately 100 - level.

Examples

In the example below we check whether the sampling distibution of the Wald statistic
as returned by test does follow a F distribution if the null hypothesis
is true.

. clear all

. sysuse auto

. gen lnprice = ln(price)

. reg turn mpg i.rep78 foreign

. predict double mu1

.

. reg turn mpg i.rep78 foreign weight lnprice

. predict double mu2

. gen double ysim = turn - mu2 + mu1

.

. keep ysim mpg rep78 foreign weight lnprice

. keep if !missing(ysim, lnprice, mpg, rep78, foreign, weight)

. tempfile temp

. save `temp'

.

. program define qenv_sim_F

. use `1', clear

. bsample

. reg ysim mpg i.rep78 foreign weight lnprice

. test weight lnprice

. end

.

. simulate F=r(F), reps(1000): qenv_sim_F `temp'

.

. qenvF F, gen(lb ub) dfnum(2) dfdenom(60) overall reps(5000)

. qplot F lb ub, ms(oh none ..) c(. l l) lc(gs10 ..) legend(off) ytitle("Wald test statistics") trscale(invF(2,60,@)) xtitle(F(2,60) quantiles)

(click to run)

Authors

Maarten Buis, WZB

maarten.buis@wzb.eu

Nicholas J. Cox, Durham University

n.j.cox@durham.ac.uk

Reference

Davison, A.C. and Hinkley, D.V. 1997.
Bootstrap methods and their application.
Cambridge: Cambridge University Press.

Also see

Manual: [R] diagnostic plots