Please read the help file!
mean is not a valid statistic to boot.
mean.boot <- function(x, i) mean(x[i])
is valid.
You can easily return as many values from boot as you like.
For example
mean.boot1 <- function(x, i)
tapply(x$StomWt[i], list(x$Age, x$Quarter)
Of course if you want to do this, you need to use a stratified
bootstrap using the strata argument to boot
strata=tapply(d2$StomWt, list(d2$Age, d2$Quarter)) should work.
Angelo Canty
On Fri, 25 Jun 2004, Louize Hill wrote:
> Hello,
>
> I am trying to carry out a bootstrap analysis (using the boot package) on a
> table and cannot work out how to get the results I need!
> I have a table ("d2") with 4 columns: "ID_code",
"Age", "Quarter" and
> "StomWt". Age (0-5) and Quarter (1-4) are my strata
> Therefore I wish to estimate the confidence intervals for the mean StomWt
> for each Age and Quarter.
>
> If I do this manually for each age / quarter I get the following:
>
> > boot (d2$StomWt[d2$Age=="0" &
d2$Quarter=="1"], mean, R=999)
>
> ORDINARY NONPARAMETRIC BOOTSTRAP
>
> Call:
> boot(data = d2$StomWt[d2$Age == "0" & d2$Quarter ==
"1"], statistic = mean,
> R = 999)
>
> Bootstrap Statistics :
> original bias std. error
> t1* 3.365 0 0
>
> Firstly - shouldn't the bias and std error be something other than 0?
> Furthermore, I would like to know if there is a way (function?) I can use
> that would automate this?
>
> Thank you for your help
> Louize Hill
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html
>
--
------------------------------------------------------------------
| Angelo J. Canty Email: cantya at mcmaster.ca |
| Mathematics and Statistics Phone: (905) 525-9140 x 27079 |
| McMaster University Fax : (905) 522-0935 |
| 1280 Main St. W. |
| Hamilton ON L8S 4K1 |