Li, Jari, and Mike,

If you *really* don't like nonparametics, try a permutation t-test.  Here's the 
code for Mike's data, as well as the output I got after running it with 9999 
permutations:

> #input the data into x, use g to determine the groups that data go into
> x<-c(13,0,10,2,0,0,1,0,0,1,5,0,0,1,0,0,0,0,0,0,0,1)
> g<-factor(c(1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2))
>
> #set up a matix a with nothing in it
> a<-c()
>
> #split x into two groups, defined by g
> x.g <- split(x,g)
> x.g
$`1`
 [1] 13  0 10  2  0  0  1  0  0  1  5

$`2`
 [1] 0 0 1 0 0 0 0 0 0 0 1

>
> # do a t-test, report the results
> z <- t.test(x.g$"1",x.g$"2", var.equal = TRUE)
> z

Two Sample t-test

data:  x.g$"1" and x.g$"2"
t = 1.9807, df = 20, p-value = 0.06154
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -0.1449011  5.5994465
sample estimates:
mean of x mean of y
2.9090909 0.1818182

>
> #permute the data, split again and report
> xperm <- sample(x,NROW(x))
> xperm
 [1]  0  1  1  0 13  1  0  0 10  0  0  0  1  0  0  0  0  5  0  0  0  2
> xperm.g <- split(xperm,g)
> xperm.g
$`1`
 [1]  0  1  1  0 13  1  0  0 10  0  0

$`2`
 [1] 0 1 0 0 0 0 5 0 0 0 2

>
> #permute the data 9999 times, and every time,
> # compute a t-value, store its absolute value in matrix a
> for(i in 1:9999) {
+   xperm <- sample(x,NROW(x))
+   xperm.g <- split(xperm,g)
+   z <- t.test(xperm.g$"1",xperm.g$"2", var.equal = TRUE)
+   a[i] <- abs(z$statistic)
+ }
>
> #recompute the absolute value of the t-value,
> # store it in the 10000 position of the array, report the matrix a
> x.g <- split(x,g)
> z <- t.test(x.g$"1",x.g$"2")
> a[10000] <- abs(z$statistic)
> #a
> #show rank of your actual t-value against
> # all the other t-values from the permutations
> rank(a)[10000]
[1] 9517.5
>
> #calculate p-value as proportion of t-values from permuations that
> # are greater than your actual t-value;
> # what is the chance that your t could be found just by chance?, or
> # "How likely is it that if the null hypothesis were true, I would
> # observe a value this extreme just due to chance?"
> # It is worth knowing that Fisher used randomization tests to test the value 
> of
> # the t-test, F-tests, etc.
> p <- (10000-rank(a)[10000])/10000
> p
[1] 0.04825

So note that the P you get from this is less than 0.05!

Like any permutation test, the P is only approximate.

Cheers, Rick

On Mar 24, 2014, at 8:45 AM, Li Wen 
<li....@environment.nsw.gov.au<mailto:li....@environment.nsw.gov.au>> wrote:

HI, Jari

The default in the Welch t test (an adaptive student's t test) doesn't assume 
equal variance; but student's t-test do assume normal distribution.

Cheers
Li

-----Original Message-----
From: 
r-sig-ecology-boun...@r-project.org<mailto:r-sig-ecology-boun...@r-project.org> 
[mailto:r-sig-ecology-boun...@r-project.org] On Behalf Of Jari Oksanen
Sent: Monday, 24 March 2014 10:43 PM
To: Richard Boyce; 
r-sig-ecology@r-project.org<mailto:r-sig-ecology@r-project.org>
Subject: Re: [R-sig-eco] report out by t.test

Except that t-test does not assume that *observations* are normally 
distributed, nor that variances are equal.

Avoid non-parametric tests: they assume too much of data properties.

For var.equal assumption in t.test, see ?t.test.

Cheers, Jari Oksanen
________________________________________
From: 
r-sig-ecology-boun...@r-project.org<mailto:r-sig-ecology-boun...@r-project.org> 
[r-sig-ecology-boun...@r-project.org<mailto:r-sig-ecology-boun...@r-project.org>]
 on behalf of Richard Boyce [boy...@nku.edu<mailto:boy...@nku.edu>]
Sent: 24 March 2014 13:23
To: r-sig-ecology@r-project.org<mailto:r-sig-ecology@r-project.org>
Subject: Re: [R-sig-eco] report out by t.test

Mike,

There is no way that your data meet the assumptions of a t-test (normal 
distributions, equal variance). A nonparametric Mann-Whitney (aka Wilcoxon) 
test is much better suited to your data.

Here's what I got when I ran it:

Q<-c(13,0,10,2,0,0,1,0,0,1,5)
WD<-c(0,0,1,0,0,0,0,0,0,0,1)
wilcox.test(Q,WD)

Wilcoxon rank sum test with continuity correction

data:  Q and WD
W = 86.5, p-value = 0.05119
alternative hypothesis: true location shift is not equal to 0

Warning message:
In wilcox.test.default(Q, WD) : cannot compute exact p-value with ties

This has a p-value quite close to 0.05, giving some evidence that there's a 
difference between your groups. Note that this you have different null and 
alternative hypothesis: groups are the same vs. groups are different.

Rick Boyce

On Mar 24, 2014, at 7:00 AM, 
r-sig-ecology-requ...@r-project.org<mailto:r-sig-ecology-requ...@r-project.org><mailto:r-sig-ecology-requ...@r-project.org>
 wrote:

Message: 1
Date: Sun, 23 Mar 2014 14:21:41 -0700
From: Michael Marsh 
<sw...@blarg.net<mailto:sw...@blarg.net><mailto:sw...@blarg.net>>
To: 
r-sig-ecology@r-project.org<mailto:r-sig-ecology@r-project.org><mailto:r-sig-ecology@r-project.org>
Subject: [R-sig-eco] report out by t.test
Message-ID: 
<532f5065.7030...@blarg.net<mailto:532f5065.7030...@blarg.net><mailto:532f5065.7030...@blarg.net>>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

I test differences between frequency of hits of exotic annual forbs in plots on 
 two sites, Q and WD.

Q<-c(13,0,10,2,0,0,1,0,0,1,5)
WD<-c(0,0,1,0,0,0,0,0,0,0,1)
t.test(Q,WD)

       Welch Two Sample t-test

data:  Q and WD
t = 1.9807, df = 10.158, p-value = 0.07533 alternative hypothesis: true 
difference in means is not equal to 0
95 percent confidence interval:
-0.3342006  5.7887460
sample estimates:
mean of x mean of y
2.9090909 0.1818182

The p-value is greater than 0.05, thus does not reach the 95% confidence level, 
yet the difference in means is reported as not equal to 0.
Am I encountering a one-sided versus two sided comparison that I don't 
understand, or is ther another explanation?

Mike Marsh




================================
Richard L. Boyce, Ph.D.
Director, Environmental Science Program
Professor
Department of Biological Sciences, SC 150 Northern Kentucky University Nunn 
Drive Highland Heights, KY  41099  USA

859-572-1407 (tel.)
859-572-5639 (fax)
boy...@nku.edu<mailto:boy...@nku.edu><mailto:boy...@nku.edu>
http://www.nku.edu/~boycer/
=================================

"One of the advantages of being disorderly is that one is constantly making 
exciting discoveries." - A.A. Milne






       [[alternative HTML version deleted]]

_______________________________________________
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology

_______________________________________________
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
This email is intended for the addressee(s) named and may contain confidential 
and/or privileged information.
If you are not the intended recipient, please notify the sender and then delete 
it immediately.
Any views expressed in this email are those of the individual sender except 
where the sender expressly and with authority states them to be the views of 
the Office of Environment and Heritage, NSW Department of Premier and Cabinet.

PLEASE CONSIDER THE ENVIRONMENT BEFORE PRINTING THIS EMAIL



================================
Richard L. Boyce, Ph.D.
Director, Environmental Science Program
Professor
Department of Biological Sciences, SC 150
Northern Kentucky University
Nunn Drive
Highland Heights, KY  41099  USA

859-572-1407 (tel.)
859-572-5639 (fax)
boy...@nku.edu<mailto:boy...@nku.edu>
http://www.nku.edu/~boycer/
=================================

"One of the advantages of being disorderly is that one is constantly making 
exciting discoveries." - A.A. Milne






        [[alternative HTML version deleted]]

_______________________________________________
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology

Reply via email to