[R] t.test()

Antonio, Fabio Di Narzo antonio.fabio at gmail.com
Thu Nov 23 15:08:31 CET 2006


23 Nov 2006 14:48:31 +0100, Peter Dalgaard <p.dalgaard a biostat.ku.dk>:
> "ONKELINX, Thierry" <Thierry.ONKELINX a inbo.be> writes:
>
> > 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.
>
> NO! This is just plain wrong.

I agree.
Hoping I'm not missing anything, something like:
> t.test(x[1],x[-1], var.equal=TRUE)
should work, since pooled variance can be computed if length(x)>2.
But, surprising, this still gives "not enough 'x' observations". I've
seen that's because length of the first argument in t.test is checked
before checking 'var.equal' value in 't.test.default'.
I'm wrong, or 2 sided test should be computed as:
t.test.value <- abs(x[1]-mean(x[-1]))/var(x)
t.test.pvalue <- 2*pt(-t.test.value, length(x)-2)

?

>
>
> > 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
> >
> >
> > Cheers,
> >
> > Thierry
> >
> > ------------------------------------------------------------------------
> > ----
> >
> > ir. Thierry Onkelinx
> >
> > Instituut voor natuur- en bosonderzoek / Reseach Institute for Nature
> > and Forest
> >
> > Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
> > methodology and quality assurance
> >
> > Gaverstraat 4
> >
> > 9500 Geraardsbergen
> >
> > Belgium
> >
> > tel. + 32 54/436 185
> >
> > Thierry.Onkelinx a inbo.be
> >
> > www.inbo.be
> >
> >
> >
> > Do not put your faith in what statistics say until you have carefully
> > considered what they do not say.  ~William W. Watt
> >
> > A statistical analysis, properly conducted, is a delicate dissection of
> > uncertainties, a surgery of suppositions. ~M.J.Moroney
> >
> > -----Oorspronkelijk bericht-----
> > Van: r-help-bounces a stat.math.ethz.ch
> > [mailto:r-help-bounces a stat.math.ethz.ch] Namens Robin Hankin
> > Verzonden: donderdag 23 november 2006 14:12
> > Aan: R-help a 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 a 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 a 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.
> >
>
> --
>    O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
>   c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
>  (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
> ~~~~~~~~~~ - (p.dalgaard a biostat.ku.dk)                  FAX: (+45) 35327907
>
> ______________________________________________
> R-help a 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.
>



More information about the R-help mailing list