Re: [R] t.test

2007-07-06 Thread Peter Dalgaard
matthew wrote:
 Hi, how can I solve a problem without the function t.test???

 for example:
 x-(1,3,5,7)
 y-(2,4,6)
 t.test(x,y,alternative=less,paired=FALSE,var.equal=TRUE,conf.level=0.95)


   
Homework?

Hints: Take out your statistics textbook and look up the formulas for
the two-sample t.
You'll probably (there can be some variation depending on the book) find
that you need to compute

- difference of means
- sd for each group
- pooled sd
- s.e. of differences of means

all of which you can do easily in R, once you have the formulas. Then
calculate the t statistic and the corresponding p value, either using a
table or R's function for the t distibution.

-- 
   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
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

__
R-help@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.


Re: [R] t.test

2007-07-06 Thread Bartjoosen

and do read the R-manual about how to make a vector


matthew wrote:
 
 Hi, how can I solve a problem without the function t.test???
 
 for example:
 x-(1,3,5,7)
 y-(2,4,6)
 t.test(x,y,alternative=less,paired=FALSE,var.equal=TRUE,conf.level=0.95)
 
 
 

-- 
View this message in context: 
http://www.nabble.com/t.test-tf4034225.html#a11463812
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.


Re: [R] t.test()

2006-11-24 Thread Robin Hankin

On 23 Nov 2006, at 13:46, Peter Dalgaard wrote:

 Robin Hankin [EMAIL PROTECTED] writes:

 Hi

 I have a vector x of length n.   I am interested in x[1]
 being different from the other observations (ie x[-1]).

[snip]


 What arguments do I need to send to t.test() to test my null?



[snip]

 Alternatively, just write up the formula for the t statistic:

 x - c(23,25,29,27,30,30)
 (x[1]-mean(x[-1]))/sqrt(var(x[-1])*(1+1/(length(x)-1)))



The gotcha in Peter Dalgaard's formula is that the maximum  
likelihood estimate for the
variance, with a sample size of one, is zero.  This is why var[x[1]]  
doesn't appear.

[R reports var(1) as NA because it uses the unbiased formula with  
(n-1) on the denominator,
as documented]

Last night I derived the likelihood test for testing my null.  Consider

H1: x~N(mu_x,s^2);  y~N(mu_y,s^2)
H2: x,y~N(mu,s^2)


The support gained by allowing the two means to differ [ie compare H2  
to H1] is:

\[
E=
\frac{n}{2}\ln\left(
\frac{\sum(z_i-\overline{z})^2}{
\sum(x_i-\overline{x})^2+
\sum(y_i-\overline{y})^2
}\right)
\]

where z=c(x,y) is both sets of observations taken together.  This  
formula supposes one
uses the appropriate maximum likelihood estimate for the (common)  
variance.  Note that
the MLE  for the variance is different on H1 and H2.

Thus if E  2 we can reject H2 and if  !(E 2) we can accept (sic) H2.





Robin Hankin
Uncertainty Analyst
National Oceanography Centre, Southampton
European Way, Southampton SO14 3ZH, UK
  tel  023-8059-7743

__
R-help@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.


Re: [R] t.test()

2006-11-23 Thread ONKELINX, Thierry
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

[EMAIL PROTECTED]

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: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Namens Robin Hankin
Verzonden: donderdag 23 november 2006 14:12
Aan: [EMAIL PROTECTED]
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@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@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.


Re: [R] t.test()

2006-11-23 Thread Robin Hankin
Hello everybody


thanks for your advice here.

I think I'm getting tangled up.

If I use Thierry's test on iid Gaussian data,
the returned p-value should be uniform(0,1),
right?

OK,


R f - function(x){t.test(x=x[-1],mu=x[1])$p.value}
R hist(replicate(1000,f(rnorm(5


This is very skewed towards zero.  Why isn't the
histogram showing a uniform distribution?







On 23 Nov 2006, at 13:32, 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


 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

 [EMAIL PROTECTED]

 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: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] Namens Robin Hankin
 Verzonden: donderdag 23 november 2006 14:12
 Aan: [EMAIL PROTECTED]
 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@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.

--
Robin Hankin
Uncertainty Analyst
National Oceanography Centre, Southampton
European Way, Southampton SO14 3ZH, UK
  tel  023-8059-7743

__
R-help@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.


Re: [R] t.test()

2006-11-23 Thread Peter Dalgaard
ONKELINX, Thierry [EMAIL PROTECTED] 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. 

 
 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
 
 [EMAIL PROTECTED]
 
 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: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] Namens Robin Hankin
 Verzonden: donderdag 23 november 2006 14:12
 Aan: [EMAIL PROTECTED]
 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@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@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
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

__
R-help@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.


Re: [R] t.test()

2006-11-23 Thread Peter Dalgaard
Robin Hankin [EMAIL PROTECTED] writes:

 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?


You can't. Shouldn't be too much of a problem to modify t.test.default
to stop it complaining. (It's not quite enough to remove the check for
nx  2, though. You also need to deal with var(x) being NA if x has
length one.)

Alternatively, just write up the formula for the t statistic:

 x - c(23,25,29,27,30,30)
 (x[1]-mean(x[-1]))/sqrt(var(x[-1])*(1+1/(length(x)-1)))
[1] -2.189595
 2*pt(-2.1896,4)
[1] 0.09373392


-- 
   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
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

__
R-help@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.


Re: [R] t.test()

2006-11-23 Thread Prof Brian Ripley
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: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] Namens Robin Hankin
 Verzonden: donderdag 23 november 2006 14:12
 Aan: [EMAIL PROTECTED]
 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@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@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,  [EMAIL PROTECTED]
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, UKFax:  +44 1865 272595

__
R-help@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.


Re: [R] t.test()

2006-11-23 Thread Prof Brian Ripley
On Thu, 23 Nov 2006, Peter Dalgaard wrote:

 Robin Hankin [EMAIL PROTECTED] writes:

 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?


 You can't. Shouldn't be too much of a problem to modify t.test.default
 to stop it complaining. (It's not quite enough to remove the check for
 nx  2, though. You also need to deal with var(x) being NA if x has
 length one.)

And the check is correct if var.equal=FALSE, the default. I've got a 
modification for the case var.equal=TRUE running, and will patch R 
shortly.

 Alternatively, just write up the formula for the t statistic:

 x - c(23,25,29,27,30,30)
 (x[1]-mean(x[-1]))/sqrt(var(x[-1])*(1+1/(length(x)-1)))
 [1] -2.189595
 2*pt(-2.1896,4)
 [1] 0.09373392




-- 
Brian D. Ripley,  [EMAIL PROTECTED]
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, UKFax:  +44 1865 272595

__
R-help@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.


Re: [R] t.test()

2006-11-23 Thread Antonio, Fabio Di Narzo
23 Nov 2006 14:48:31 +0100, Peter Dalgaard [EMAIL PROTECTED]:
 ONKELINX, Thierry [EMAIL PROTECTED] 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
 
  [EMAIL PROTECTED]
 
  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: [EMAIL PROTECTED]
  [mailto:[EMAIL PROTECTED] Namens Robin Hankin
  Verzonden: donderdag 23 november 2006 14:12
  Aan: [EMAIL PROTECTED]
  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@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@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
 ~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

 __
 R-help@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@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.


Re: [R] t.test()

2006-11-23 Thread Thilo Kellermann
Hi,

seems as if you want to test if a single subject is a member of a population 
from which you have drawn a sample. This question has been addressed by Payne 
 Jones and Crawford and collaborators. You should have a look at their 
articles in case that I interpreted your null-hypothesis and data in the 
correct way

Good luck,
Thilo


Payne  Jones (1957, J Clin Psychol 13:115-121)

Crawford, Howell, Garthwaite (1998, J Clin Exp Neurosychol 12:482)

Crawford JR, Garthwaite PH (2005) Evaluation of Criteria for Classical 
Dissociations in Single-Case Studies by Monte Carlo Simulation. 
Neuropsychology 19(5): 664-678)


On Thursday 23 November 2006 14:48, Peter Dalgaard wrote:
 ONKELINX, Thierry [EMAIL PROTECTED] 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.

  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
 
  [EMAIL PROTECTED]
 
  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: [EMAIL PROTECTED]
  [mailto:[EMAIL PROTECTED] Namens Robin Hankin
  Verzonden: donderdag 23 november 2006 14:12
  Aan: [EMAIL PROTECTED]
  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@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@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.

-- 

Thilo Kellermann
Department of Psychiatry und Psychotherapy
RWTH Aachen University
Pauwelstr. 30
52074 Aachen
Tel.: +49 (0)241 / 8089977
Fax.: +49 (0)241 / 8082401
E-Mail: [EMAIL PROTECTED]

__
R-help@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.


Re: [R] t.test question

2006-03-06 Thread James W. MacDonald
Roth, Richard wrote:
 Hi, I have a data matrix of gene expression data from two groups that
 I would like to compare using the t-test.  The data has been
 processed using RMA and transformed using log2.  I would like to
 compare the two groups for each gene (N=10,000 genes) and have a
 result that lists the p-value for each test.  Can anyone help me with
 the t.test setup for this analysis?

Take a look at the limma package in BioConductor. You will be able to do 
what you want much faster than using e.g., t.test(). There is an 
extensive user's guide that should help you figure out what to do.

HTH,

Jim




 
 Thanks, Rich
 
 Rich Roth, PhD Senior Scientist Molecular Medicine Neurocrine
 Biosciences 858-617-7204
 
 
 
 
 
 
 
 __ 
 R-help@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


-- 
James W. MacDonald, M.S.
Biostatistician
Affymetrix and cDNA Microarray Core
University of Michigan Cancer Center
1500 E. Medical Center Drive
7410 CCGC
Ann Arbor MI 48109
734-647-5623

__
R-help@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


Re: [R] t.test using RSPerl

2005-06-14 Thread Henrik Bengtsson
This has nothing to do with RSPerl, instead it has to do what kind of 
object you obtain and how these are print():ed. Typing the name of an 
object, say, 'res', at R prompt and pressing ENTER;

  res

is equivalent as typing

  print(res)

This is for convenience to the user.  Basically, this is why you can do

  1+1
[1] 2

without having to do

  print(1+1)
[1] 2

When you transfer the object from R to Perl you will, as expect, only 
receive the value of 'res', not the output from 'print(res)'. Here is an 
example illustrating the behavior in R:

  res - t.test(1:10,y=c(7:20))
  length(res)
[1] 9
  str(res)
List of 9
  $ statistic  : Named num -5.43
   ..- attr(*, names)= chr t
  $ parameter  : Named num 22
   ..- attr(*, names)= chr df
  $ p.value: num 1.86e-05
  $ conf.int   : atomic [1:2] -11.05  -4.95
   ..- attr(*, conf.level)= num 0.95
  $ estimate   : Named num [1:2] 5.5 13.5
   ..- attr(*, names)= chr [1:2] mean of x mean of y
  $ null.value : Named num 0
   ..- attr(*, names)= chr difference in means
  $ alternative: chr two.sided
  $ method : chr Welch Two Sample t-test
  $ data.name  : chr 1:10 and c(7:20)
  - attr(*, class)= chr htest
  print(res)

 Welch Two Sample t-test

data:  1:10 and c(7:20)
t = -5.4349, df = 21.982, p-value = 1.855e-05
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
  -11.052802  -4.947198
sample estimates:
mean of x mean of y
   5.5  13.5

In your case, to capture what print(res) is outputting, you may want to 
look at ?capture.out, that is

  output - capture.output(res)
  output  # ...that is, print(output)
  [1] 
  [2] \tWelch Two Sample t-test
  [3] 
  [4] data:  1:10 and c(7:20) 
  [5] t = -5.4349, df = 21.982, p-value = 1.855e-05
  [6] alternative hypothesis: true difference in means is not equal to 0 
  [7] 95 percent confidence interval:
  [8]  -11.052802  -4.947198 
  [9] sample estimates:
[10] mean of x mean of y 
[11]   5.5  13.5 
[12] 

and transfer 'output' to Perl.

Cheers

Henrik

Wagle, Mugdha wrote:
 Hi,
  
 I've just started using R and RSPerl. I have some code as follows:
  
 R::initR(--no-save);
 R::call(t.test, ([EMAIL PROTECTED], [EMAIL PROTECTED]));
  
 where @array1 and @array2 are both 1-dimensional arrays in Perl having 54675 
 elements each. On execution the output is as follows:
  
 Calling R function name `t.test', # arguments: 3
 1) Arg type 3
 Got a reference to a value 10
 Here now!2) Arg type 3
 Got a reference to a value 10
 Here now!Calling R
 t.test(c(0, 6.24280675278087, 6.35175793656943, 5.76925805661511,
 7.0789316246711, 7.4636498661157, 8.13730810691084, 8.78203131644273,
 9.64502765609435, 9.95631242346133, 5.83129579495516, 6.8798700754926,
 7.31814159140937...(REST OF THE ARRAY ELEMENTS).
 4.91632461462501, 3.38099467434464,
 3.91800507710569, 3.23867845216438, 3.38439026334577, 4.64918707140487,
 3.23474917402449, 3.62966009445396, 3.36729582998647, 3.91999117507732
 ))
 Performed the call, result has length 9
 
 My question is : with other functions such as sum and log10, the actual 
 values of the result are displayed. Here the call seems to have worked but 
 the output is not what you get when running t.test directly on the R command 
 prompt..
  
 data:  data4[2] and data4[3] 
 t = 0.2186, df = 109.847, p-value = 0.8274
 alternative hypothesis: true difference in means is not equal to 0 
 95 percent confidence interval:
  -3722.830  4645.723 
 sample estimates:
 mean of x mean of y 
  6185.139  5723.693
  
 which is what I had expected, after seeing the outputs in the case of simpler 
 functions like sum. Could anyone please tell me how I can obtain the output I 
 expect(i.e. the same as the command line outputgiving values of t, 
 p-value and the means)?
  
 Thank you very much for the help!!
  
 Sincerely,
 Mugdha Wagle
 Hartwell Center for Bioinformatics and Biotechnology,
 St.Jude Children's Research Hospital, Memphis TN 38105
 
 __
 R-help@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
 


__
R-help@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


Re: [R] t.test formatting question

2004-04-16 Thread Tony Plate
as.numeric() (and its siblings) strip the names from vectors, e.g.:

 as.numeric(t.test(rnorm(1001))$statistic)
[1] -0.6320304

hth,

Tony Plate

At Friday 05:14 PM 4/16/2004, christopher ciotti wrote:
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
Hello all -

I'm trying to format some data where I only need one of the values 
returned from a test, say a t-test in this instance.  I have the following:

 R.version.string
[1] R version 1.9.0, 2004-04-12
 x - rnorm(1001)
 t.test(x)$statistic
   t
0.321

Any easy way (other than straight calculation) to get the t-statistic w/o 
the 't' above it?  TIA

- --
chris ciotti ([EMAIL PROTECTED])
PGP ID: 0xE94BB3B7
-BEGIN PGP SIGNATURE-
Version: PGP 8.0
iQA/AwUBQIBotlkgIqbpS7O3EQIt7ACdEhhoM3tqqmDae71Rdo/eHg2TvoQAoLSw
8QjwkHENOjjs5mzCWlXSTQXO
=LvW5
-END PGP SIGNATURE-
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] t.test formatting question

2004-04-16 Thread christopher ciotti
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
Tony Plate wrote:

 as.numeric() (and its siblings) strip the names from vectors, e.g.:

  as.numeric(t.test(rnorm(1001))$statistic)
 [1] -0.6320304
 

 hth,

 Tony Plate
Thanks for the quick response.

- --
chris ciotti ([EMAIL PROTECTED])
PGP ID: 0xE94BB3B7
-BEGIN PGP SIGNATURE-
Version: PGP 8.0
iQA/AwUBQIBqXlkgIqbpS7O3EQKNRwCfREBcPiBQDxIKcnUD6uVJyt5YP/wAnjBR
l+C3+RSz2r0juvBZ87DTyyRI
=S8Mz
-END PGP SIGNATURE-
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] t.test formatting question

2004-04-16 Thread Chuck Cleland
  How about this?

t.test(x)[[1]]

  The result of t.test(x) is a list and statistic is the first 
component of that list.

christopher ciotti wrote:
...
I'm trying to format some data where I only need one of the values 
returned from a test, say a t-test in this instance.  I have the following:

  R.version.string
[1] R version 1.9.0, 2004-04-12
  x - rnorm(1001)
  t.test(x)$statistic
   t
0.321
 
Any easy way (other than straight calculation) to get the t-statistic 
w/o the 't' above it?  TIA
... 
--
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 452-1424 (M, W, F)
fax: (917) 438-0894
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] t.test formatting question

2004-04-16 Thread Chuck Cleland
  Sorry, I should have checked that more closely.  I see that

t.test(rnorm(12))[[1]]

  retains the t.

christopher ciotti wrote:
...
I'm trying to format some data where I only need one of the values 
returned from a test, say a t-test in this instance.  I have the following:

  R.version.string
[1] R version 1.9.0, 2004-04-12
  x - rnorm(1001)
  t.test(x)$statistic
   t
0.321
 
Any easy way (other than straight calculation) to get the t-statistic 
w/o the 't' above it?  TIA
...
--
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 452-1424 (M, W, F)
fax: (917) 438-0894
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] t.test formatting question

2004-04-16 Thread Robert W. Baer, Ph.D.
How about:
as.numeric(t.test(rnorm(12))[[1]])

- Original Message - 
From: Chuck Cleland [EMAIL PROTECTED]
To: christopher ciotti [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Friday, April 16, 2004 6:25 PM
Subject: Re: [R] t.test  formatting question


Sorry, I should have checked that more closely.  I see that

 t.test(rnorm(12))[[1]]

retains the t.

 christopher ciotti wrote:
  ...
  I'm trying to format some data where I only need one of the values
  returned from a test, say a t-test in this instance.  I have the
following:
 
R.version.string
  [1] R version 1.9.0, 2004-04-12
x - rnorm(1001)
t.test(x)$statistic
 t
  0.321
   
 
  Any easy way (other than straight calculation) to get the t-statistic
  w/o the 't' above it?  TIA
  ...

 -- 
 Chuck Cleland, Ph.D.
 NDRI, Inc.
 71 West 23rd Street, 8th floor
 New York, NY 10010
 tel: (212) 845-4495 (Tu, Th)
 tel: (732) 452-1424 (M, W, F)
 fax: (917) 438-0894

 __
 [EMAIL PROTECTED] mailing list
 https://www.stat.math.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html


__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html