[R] Bootstrapped Regression

Janh Anni annijanh at gmail.com
Sun Oct 15 03:22:25 CEST 2017


Hello Rui,

Thanks for your helpful suggestions.  Just for illustration, let's use the
well known Duncan dataset of prestige vs education + income that is
contained in the "car" package.  Suppose I wish to use boot function to
bootstrap a linear regression of prestige ~ education + income and use the
following script:

duncan.function <- function(data, indices) {data = data[indices,]

mod <- lm(prestige ~ education + income, data=data,)

coefficients(mod)}

Results <- boot(Duncan, duncan.function , 1000)
Results

So the 1000 bootstrapped coefficients are contained in Results and I can
use the boot.ci function in the same boot package to obtain the confidence
intervals for the, say, education coefficient with something like:

boot.ci(Results, index=2, conf = 0.95, type=c("basic", "norm", "perc",
"bca"))

Then, suppose I am interested in getting a confidence interval for the
predicted  prestige at, say, education = 50 and income = 75.  The question
is how do I get boot to compute 1000 values of the predicted prestige at
education = 50 and income = 75, so that I can subsequently (hopefully) have
boot.ci compute the confidence intervals as it did for the bootstrapped
coefficients? As for prediction intervals, it wouldn't seem conceptually
feasible in this context?  Thanks again for all your help.

Janh

On Sat, Oct 14, 2017 at 11:12 AM, Bert Gunter <bgunter.4567 at gmail.com>
wrote:

> R-help is not a free coding service. We expect users to make the effort to
> learn R and *may* provide help when they get stuck. Pay a local R
> programmer if you do not wish to make such an effort.
>
> Cheers,
> Bert
>
>
> On Oct 14, 2017 7:58 AM, "Janh Anni" <annijanh at gmail.com> wrote:
>
> Greetings!
>
> We are trying to obtain confidence and prediction intervals for a predicted
> Y value from bootstrapped linear regression using the boot function. Does
> anyone know how to code it?  Greatly appreciated.
>
> Janh
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posti
> ng-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list