Hi there,

You need a function for your statistic:

> boot(x, function(x, index) mean(x[index]), R = 1000)

ORDINARY NONPARAMETRIC BOOTSTRAP


Call:
boot(data = x, statistic = function(x, index) mean(x[index]),
    R = 1000)


Bootstrap Statistics :
     original      bias    std. error
t1* 0.4069613 0.005465687  0.07355997

See http://www.mayin.org/ajayshah/KB/R/documents/boot.html  for more
information and examples.

HTH,
Jorge.-





On Fri, Jun 7, 2013 at 6:03 PM, Rguy <r...@123mail.org> wrote:

> I am getting started with the boot package and boot command. As a first
> step I tried the following. Something is wrong, but i can't see what. Any
> advice would be much appreciated.
>
> > x = runif(10)
> > mean(x)
> [1] 0.467626212374307
> > boot(x, mean, R=100)
> Error in mean.default(data, original, ...) :
>   'trim' must be numeric of length one
>
> Enter a frame number, or 0 to exit
>
> 1: boot(x, mean, R = 100)
> 2: statistic(data, original, ...)
> 3: mean.default(data, original, ...)
> 4: stop("'trim' must be numeric of length one")
> 5: (function ()
> {
>     utils::recover()
> })()
>
> When I enter a trim parameter I get the following:
>
> > boot(x, mean, R=100, trim=0)
> [...some output omitted...]
> Warning in if (na.rm) x <- x[!is.na(x)] :
>   the condition has length > 1 and only the first element will be used
> Warning in if (na.rm) x <- x[!is.na(x)] :
>   the condition has length > 1 and only the first element will be used
> Warning in if (na.rm) x <- x[!is.na(x)] :
>   the condition has length > 1 and only the first element will be used
> Warning in if (na.rm) x <- x[!is.na(x)] :
>   the condition has length > 1 and only the first element will be used
> Warning in if (na.rm) x <- x[!is.na(x)] :
>   the condition has length > 1 and only the first element will be used
> Warning in if (na.rm) x <- x[!is.na(x)] :
>   the condition has length > 1 and only the first element will be used
> Warning in if (na.rm) x <- x[!is.na(x)] :
>   the condition has length > 1 and only the first element will be used
> Warning in if (na.rm) x <- x[!is.na(x)] :
>   the condition has length > 1 and only the first element will be used
>
> ORDINARY NONPARAMETRIC BOOTSTRAP
>
>
> Call:
> boot(data = x, statistic = mean, R = 100, trim = 0)
>
>
> Bootstrap Statistics :
>              original  bias    std. error
> t1* 0.467626212374307       0           0
> >
>
> When I enter an na.rm value as well the following is output:
>
> > boot(x, mean, R=100, trim=0, na.rm=T)
>
> ORDINARY NONPARAMETRIC BOOTSTRAP
>
>
> Call:
> boot(data = x, statistic = mean, R = 100, trim = 0, na.rm = T)
>
>
> Bootstrap Statistics :
>              original  bias    std. error
> t1* 0.467626212374307       0           0
> >
>
> Notice that the standard error is 0, indicating that no bootstrapping has
> actually taken place.
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@r-project.org mailing list
> 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.
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
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.

Reply via email to