 NCL Home > Documentation > Functions > Statistics, Bootstrap

# bootstrap_regcoef

Bootstrap estimates of linear regression coefficient. Available in version 6.4.0 and later.

## Prototype

```	function bootstrap_regcoef (
x     [*] : numeric,
y         : numeric,
nBoot  : integer,
nDim  [*] : integer,
opt    : logical
)

return_val [ variable of type 'list' containing multiple estimates]
```

## Arguments

x

A one-dimensional numeric array: x(N) where 'N' represents the sample size. This variable is referred as the 'explanatory' or 'independent' variable.

y

A numeric array of up to four dimensions: y(N), y(N,:), y(N,:,:), y(N,:,:,:) where 'N' represents the sample size.

nBoot

An integer specifying the number of bootstrap data samples to be generated.

nDim

The dimension(s) of y on which to calculate the statistic. Must be consecutive and monotonically increasing.

opt

A logical scalar to which optional attributes may be attached. If opt=False, default values are used. If opt=True and no optional attributes are present, default values will be used. If opt=True then:

• opt@sample_size: specifies the size of the resampled array to be used for the bootstrapped statistics.
• opt@sample_size=N is the default.
• opt@sample_size=n where (n.le.N). When this option is used, n=toint(f*N) where 'f' represents (say) 0.10 to 0.20.

• opt@rseed1=rseed1: allows user to set the first random seed integer value. Default is to use the system initial random seed. (See: random_setallseed)
• opt@rseed2=rseed2: allows user to set the second random seed integer value. Default is to use the system initial random seed. (See: random_setallseed)
• optrseed3="clock": tells NCL to use the 'date' clock to set the two random seeds. (See: random_setallseed)

## Return value

A variable of type 'list'. Members of a list can be accessed directly. However, it is clearer if the members are explicity extracted and given meaningful names.

```                                    ; typeof(Bootstrap) is 'list'
BootStrap  = bootstrap_regcoef(x, y, nBoot, 0, opt)
rcBoot      = BootStrap       ; Bootstrapped regression coefficients is ascending order
rcBootAvg   = BootStrap       ; Average of bootstrapped regression coefficients
rcBootStd   = BootStrap       ; Std. Deviation of bootstrapped regression coefficients
delete(BootStrap)
```

## Description

Bootstrapping is a statistical method that uses data resampling with replacement (see: generate_sample_indices) to estimate the properties of nearly any statistic. It is particularly useful when dealing with small sample sizes. A key feature is that bootstrapping makes no apriori assumption about the distribution of the sample data.

The current version resamples x and y pairs.

References:

```Computer Intensive Methods in Statistics
P. Diaconis and B. Efron
Scientific American (1983), 248:116-130
doi:10.1038/scientificamerican0583-116
http://www.nature.com/scientificamerican/journal/v248/n5/pdf/scientificamerican0583-116.pdf

An Introduction to the Bootstrap
B. Efron and R.J. Tibshirani, Chapman and Hall (1993)

Bootstrap Methods and Permutation Tests: Companion Chapter 18 to the Practice of Business Statistics
Hesterberg, T. et al (2003)
http://statweb.stanford.edu/~tibs/stat315a/Supplements/bootstrap.pdf

Climate Time Series Analysis: Classical Statistical and Bootstrap Methods
M. Mudelsee (2014) Second edition. Springer, Cham Heidelberg New York Dordrecht London
ISBN: 978-3-319-04449-1, e-ISBN: 978-3-319-04450-7
doi: 10.1007/978-3-319-04450-7
xxxii + 454 pp; Atmospheric and Oceanographic Sciences Library, Vol. 51
```

## Examples

Please see the Bootstrap and Resampling application page.

Example 1: Let x(100); y(100), N=100

```
nBoot        = 1000                ; user set
nDim         = 0
opt          = False               ; use defaults

BootStrap    = bootstrap_regcoef(x, y, nBoot, nDim, opt)
rcBoot       = BootStrap ; Bootstrapped regression coefficients in ascending order
rcBootAvg    = BootStrap ; Average of the boot strapped regression coefficients
rcBootStd    = BootStrap ; Standard deviation of bootstrapped regression coefficients
delete(BootStrap) ; no longer needed

rcBootLow    = bootstrap_estimate(rcBoot, 0.025, False)   ;  2.5% lower confidence bound
rcBootMed    = bootstrap_estimate(rcBoot, 0.500, False)   ; 50.0% median of bootstrapped estimates
rcBootHi     = bootstrap_estimate(rcBoot, 0.975, False)   ; 97.5% upper confidence bound

printVarSummary(rcBoot)        ; information only
printVarSummary(rcBootMed)     ; examine meta data

```