[R] boot function returns the same results every time - there appears to be not resampling of the original data.

John Sorkin jsorkin at grecc.umaryland.edu
Wed Dec 30 15:58:11 CET 2009


Prof Ripley,
Thank you for your advise. You recommend I consult the "book for which
this is support software." I would be happy to do so, but I don't know
what book you are referring to. 
Thank you,
John





John David Sorkin M.D., Ph.D.
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing)>>>
Prof Brian Ripley <ripley at stats.ox.ac.uk> 12/30/2009 8:55 AM >>>
On Wed, 30 Dec 2009, John Sorkin wrote:

> R 2.8.1

Rather old: have you updated package boot since?

> windows XP
>
> I am trying to learn how to use the boot function to perform a 
> bootstrap of a regression. I have written a short trial program, 
> shown below. Clearly I have done something wrong as the output of 
> each of the 100 bootstrap values for the regression are exactly the 
> same - there does not appear to be any bootstrap respampling!. What 
> have I done wrong?

First, sim="parametric" does not give 'bootstrap respampling', so I 
wonder if you have consulted the book for which this is support 
software?  You will find it hard to use boot without a clear grasp of 
the underlying concepts.

For bootstrapping a regression (and why you almost certainly do not 
want to do that) see the examples in MASS.

You clearly missed the following on the help page:

      For the parametric bootstrap it is necessary for the user to
      specify how the resampling is to be conducted.  The best way of
      accomplishing this is to specify the function ̔ran.gen̓ which
will
      return a simulated data set from the observed data set and a set
      of parameter estimates specified in ̔mle̓.

The default ran.gen() function just returns the data ....

>
>
> # Define function to be run. Function will return
> # beta coefficeint for x.
> fitter<-function(d)
> {
>  fit1<-lm(y~x,data=d)
>  print(names(fit1))
>  print(summary(fit1))
>  summary(fit1)$coefficients[2,1]
> }
>
> # Define dataframe
> x<-1:10
> y<-x+rnorm(10)
> d<-data.frame(x,y)
>
>
> #Run boot strap
> boot(d,fitter,R=100,sim="parametric")
>
>
>
> John David Sorkin M.D., Ph.D.
> Chief, Biostatistics and Informatics
> University of Maryland School of Medicine Division of Gerontology
> Baltimore VA Medical Center
> 10 North Greene Street
> GRECC (BT/18/GR)
> Baltimore, MD 21201-1524
> (Phone) 410-605-7119
> (Fax) 410-605-7913 (Please call phone number above prior to faxing)
>
> Confidentiality Statement:
> This email message, including any attachments, is for\...{{dropped:25}}




More information about the R-help mailing list