[R] t.test()
Prof Brian Ripley
ripley at stats.ox.ac.uk
Thu Nov 23 15:01:13 CET 2006
On Thu, 23 Nov 2006, ONKELINX, Thierry wrote:
> There is no such thing as an unpaired t-test. A t-test can be a paired,
> one sample or two sample t-test. Since you want to compare the sample
> against a given mean, you need a one sample t-test. You tried to do a
> two sample test. That didn't work because you need at least two
> observations in each group.
>
> x <- c(23,25,29,27,30,30)
> t.test(x[-1], mu = x[1])
>
> One Sample t-test
>
> data: x[-1]
> t = 5.3634, df = 4, p-value = 0.005833
> alternative hypothesis: true mean is not equal to 23
> 95 percent confidence interval:
> 25.50814 30.89186
> sample estimates:
> mean of x
> 28.2
That is not what Robin is asking for. He has an unpaired two-sample
t-test in the terminology I understand, but is also assuming
var.equal=TRUE, which is not the default in R and so needs to specified.
It should be possible to do
x <- c(23,25,29,27,30,30)
t.test(x=x[1], y=x[-1], var.equal=TRUE)
since you can make use of the pooled variance from the two groups.
In fact, R does not currently allow that case.
> -----Oorspronkelijk bericht-----
> Van: r-help-bounces at stat.math.ethz.ch
> [mailto:r-help-bounces at stat.math.ethz.ch] Namens Robin Hankin
> Verzonden: donderdag 23 november 2006 14:12
> Aan: R-help at r-project.org
> Onderwerp: [R] t.test()
>
> Hi
>
> I have a vector x of length n. I am interested in x[1]
> being different from the other observations (ie x[-1]).
>
> My null hypothesis is that x[1]
> is drawn from a Gaussian distribution of the same
> mean as observations x[-1], which are assumed
> to be iid Gaussian. The (unknown) variance
> of x[1] is assumed to be the same as the
> variance of x[-1].
>
>
> This should be an unpaired t-test.
>
> But
>
>
> > x <- c(23,25,29,27,30,30)
> > t.test(x=x[1] , y=x[-1])
> Error in t.test.default(x = x[1], y = x[-1]) :
> not enough 'x' observations
> >
>
>
>
> What arguments do I need to send to t.test() to test my null?
>
>
>
>
>
>
>
> --
> Robin Hankin
> Uncertainty Analyst
> National Oceanography Centre, Southampton
> European Way, Southampton SO14 3ZH, UK
> tel 023-8059-7743
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
>
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list