[R] bootstraping lm
Ernesto Jardim
ernesto at ipimar.pt
Thu Jan 16 16:16:04 CET 2003
Hi
You're correct. The problem is in "statistic" not in boot.
However it is not clear for me that the definition of t states it must
have allways the same number of dimensions. What it says is that it will
be a bootstrap replicate of statistic.
In my linear model I use factors and the number of coefficients might
change, if the bootstrap data set omits one or more levels.
My understandment is that the result of "statistic" is still a bootstrap
replicate no matter the number of dimensions.
Anyway, thanks for being helpfull.
Regards
EJ
On Thu, 2003-01-16 at 15:02, ripley at stats.ox.ac.uk wrote:
> That's not a problem in boot, but a problem in your usage of it.
>
> On 16 Jan 2003, Ernesto Jardim wrote:
>
> > Hi
> >
> > I found the problem (I hope:).
> >
> > In "boot" a data.frame with the expected results from "statistic" is
> > created, "t.star", wich has dim[[1]]=sum(R), the number of replicates,
> > and dim[[2]]=lt0, the length of the output of statistic using the
> > original data.
> >
> > t0 <- statistic(data, original, ...)
> > lt0 <- length(t0)
> > t.star <- matrix(NA, sum(R), lt0)
> >
> > However when fitting the "lm" with different sets of data, it might
> > happen that the result of "statistic" is not of the same length has with
> > the original data. That's when
> >
> > for (r in 1:sum(R)) t.star[r, ] <- statistic(data, i[r,], ...)
> >
> > fails, because its not able to replace the complete row of t.star.
> >
> > So "statistic" shall guarantee that all the outputs are of the same
> > length.
> >
> > Something you might want to had to "boot" documentation.
>
> It's already there:
>
> statistic: A function which when applied to data returns a vector
> containing the statistic(s) of interest.
>
> t: A matrix with `R' rows each of which is a bootstrap replicate
> of `statistic'.
>
> Where does it say that the statistic(s) of interest can change by
> replicate?
--
Ernesto Jardim <ernesto at ipimar.pt>
Marine Biologist
Research Institute for Agriculture and Fisheries
Lisboa, Portugal
Tel: +351 213 027 000
Fax: +351 213 015 948
More information about the R-help
mailing list