-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathREADME.Rmd
79 lines (68 loc) · 2.41 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
---
title: "Fast and Robust Bootstrap"
author: "Matias Salibian"
date: "`r format(Sys.Date())`"
output: github_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, warning=FALSE)
```
## Fast and Robust Bootstrap
This package implements the Fast and Robust Bootstrap as proposed in
[Salibian-Barrera and Zamar (2002)](http://dx.doi.org/10.1214/aos/1021379865), and
[Salibian-Barrera, M., Van Aels, S. and Willems, G. (2008)](http://dx.doi.org/10.1007/s10260-007-0048-6) for robust regression estimators (MM-estimators) computed with
`robustbase::lmrob`.
To install it use the following commands (assuming that you have
the `devtools` package from [CRAN](https://cran.r-project.org)
already installed):
```R
devtools::install_github("msalibian/FRB")
```
To use it (after installation), simply call `frb` on an `lmrob` object as computed
by `robustbase::lmrob`. Here's an example:
```{R howtouse}
library(robustbase)
library(FRB)
a <- lmrob(LNOx ~ LNOxEm + sqrtWS, data=NOxEmissions)
set.seed(123)
tmp <- frb(lmrob.object=a, nboot=1000, return.coef=FALSE)
```
If the argument `return.coef` is set to `FALSE`, then
`frb` returns the estimated covariance matrix of the
robust regression estimators. For example, the
estimated standard errors for each parameter estimate
are
```{R ses}
sqrt(diag(tmp$var))
```
We can compare them with the
estimated standard errors given by the usual
asyptotic approximation:
```{R asymp}
sqrt(diag(summary(a)$cov))
```
If the argument `return.coef` is `TRUE` then
the returned list has an element `$coef`
that contains a matrix with `nboot` rows
with a bootstrapped regression coefficient in
each of them.
The argument `return.indices` indicates whether
to return
the matrix of the indices of the bootstrap samples.
The argument `centered` indicates whether the
returned bootstrap regression coefficients
should be centered ($\hat{\beta}^* - \hat{\beta}_n$)
or not. For example:
```{r centering}
# by default the bootstrapped estimators are centered
set.seed(123)
tmp <- frb(lmrob.object=a, nboot=1000, return.coef=TRUE)
# we now add the regression estimator to each bootstrapped one
tmp2 <- scale(tmp$coef, scale=FALSE, center=-coef(a))
# use the argument centered=FALSE to return the non-centered
# bootstrapped estimators instead
set.seed(123)
tmp3 <- frb(lmrob.object=a, nboot=1000, return.coef=TRUE, centered=FALSE)
# and check that the results are the same
all.equal(tmp2, tmp3$coef)
```