Hello Rui, It was perfect! Thank you so much for your kindness. It is greatly appreciated.
All the best, Janh On Sun, Oct 15, 2017 at 3:25 AM, Rui Barradas <ruipbarra...@sapo.pt> wrote: > Hello, > > Much clearer now, thanks. > It's a matter of changing the function boot calls to return the predicted > values at the point of interess, education = 50, income = 75. > > I have changed the way the function uses the indices a bit, the result is > the same, it's just the way I usually do it. > > pred.duncan.function <- function(data, indices) { > mod <- lm(prestige ~ education + income, data = data[indices, ]) > new <- data.frame(education = 50, income = 75) > predict(mod, newdata = new) > } > > set.seed(94) # make the results reproducible > > Predicted <- boot(Duncan, pred.duncan.function , 1000) > head(Predicted) > Predicted$t0 > boot.ci(Predicted, index = 1, conf = 0.95, type=c("basic", "norm", > "perc", "bca")) > > > Hope this helps, > > Rui Barradas > > Em 15-10-2017 02:22, Janh Anni escreveu: > >> 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.4...@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" <annij...@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@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]] >> >> ______________________________________________ >> R-help@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]] ______________________________________________ R-help@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/posting-guide.html and provide commented, minimal, self-contained, reproducible code.