[R] t.test()

ONKELINX, Thierry Thierry.ONKELINX at inbo.be
Thu Nov 23 14:32:19 CET 2006


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


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 op 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 op stat.math.ethz.ch
[mailto:r-help-bounces op stat.math.ethz.ch] Namens Robin Hankin
Verzonden: donderdag 23 november 2006 14:12
Aan: R-help op 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 op 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