[R] Independent samples bootstrapped T-test : question

Jim Lemon drjimlemon at gmail.com
Sun Feb 12 08:20:28 CET 2017

Hi Tahereh,
In the code you provided, there seems to be a mistake in the calls to
"sample" in that you haven't specified the "size" argument. You should
have gotten an error there. Also, you have assigned both samples to
the same variable name, so there will be no "boot.p" when the call to
t-test is made, leading to another error message. As Bert said, have a
look at the "boot" function in the "boot" package. This is probably
what you are attempting.


On Sat, Feb 11, 2017 at 10:55 PM, Tahereh Dehdarirad <tdehdari at gmail.com> wrote:
> Dear R group,
> I have some question regarding bootstrapping in R. I wish to use
> independent samples bootstrapped T-test. I would like to know: 1 how  I can
>  calculate p and t values.2. for means and CI of each sample, should I
> report the bootstrapped mean and CI of each group? and not the ones
> obtained from t-test?
> I used the following code with regard to t-test (t value and p value), So,
> I wonder if it is correct with regard to t and p values?
> AVGMR=Names_first_last$`Avg_ Readars-Mendeley`
> B      <- 1000
> t.star = numeric(B)
>  t.vect <- vector(length=B)
> p.vect <- vector(length=B)
> for(i in 1:B){ boot.c <- sample(subset(AVGMR, Gender==1), replace=T)
> boot.c <- sample(subset(AVGMR, Gender==2), replace=T)
> ttest  <- t.test(boot.c, boot.p)
>    t.vect[i] <- ttest$statistic
>    p.vect[i] <- ttest$p.value
>  }
> I would be really grateful if you could please help me with regard to my
> both questions.
> Kind regards,
> Tahereh Dehdarirad, PhD
> Department of Library and Information Science
> University of Barcelona, Spain
>         [[alternative HTML version deleted]]
> ______________________________________________
> R-help at 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.

More information about the R-help mailing list