Re: [R-sig-eco] Testing difference between diversity indices with vegan::oecosimu

2012-04-26 Thread Chris Howden
Standard Hypothesis statistical testing often starts with the null
hypothesis that 2 things are identical, or that 2 population means are
identical. The p value is then used to reject this null and accept the
alternative, that they are indeed different.

Practically we're actually asking if we have enough information to indeed
say they are different.

I do agree though that stopping there is a bit silly. If there is a
statistical difference then we next need to look at the effect size or in
other words the magnitude of the difference and decide if this is
ecologically meaningful.


Chris Howden B.Sc. (Hons) GStat.
Founding Partner
Evidence Based Strategic Development, IP Commercialisation and Innovation,
Data Analysis, Modelling and Training
(mobile) 0410 689 945
(fax) +612 4782 9023
ch...@trickysolutions.com.au




Disclaimer: The information in this email and any attachments to it are
confidential and may contain legally privileged information. If you are
not the named or intended recipient, please delete this communication and
contact us immediately. Please note you are not authorised to copy, use or
disclose this communication or any attachments without our consent.
Although this email has been checked by anti-virus software, there is a
risk that email messages may be corrupted or infected by viruses or other
interferences. No responsibility is accepted for such interference. Unless
expressly stated, the views of the writer are not those of the company.
Tricky Solutions always does our best to provide accurate forecasts and
analyses based on the data supplied, however it is possible that some
important predictors were not included in the data sent to us. Information
provided by us should not be solely relied upon when making decisions and
clients should use their own judgement.


-Original Message-
From: r-sig-ecology-boun...@r-project.org
[mailto:r-sig-ecology-boun...@r-project.org] On Behalf Of David Valentim
Dias
Sent: Thursday, 26 April 2012 2:36 PM
To: r-sig-ecology@r-project.org
Subject: Re: [R-sig-eco] Testing difference between diversity indices with
vegan::oecosimu

Hello Cichini,

I cannot help with your code but seems like you have a silly hypothesis.
Think about it: Probability of two communities to be identical?
You need to restate it in some more useful way. We already know most
things are different but with what magnitude? Which factors are causing
these changes? How these changes matter from the environment and us?

2012/4/25 Chris Howden ch...@trickysolutions.com.au

 Why not try some type of ANOVA style glm?

 Chris Howden
 Founding Partner
 Tricky Solutions
 Tricky Solutions 4 Tricky Problems
 Evidence Based Strategic Development, IP Commercialisation and
 Innovation, Data Analysis, Modelling and Training

 (mobile) 0410 689 945
 (fax / office)
 ch...@trickysolutions.com.au

 Disclaimer: The information in this email and any attachments to it
 are confidential and may contain legally privileged information. If
 you are not the named or intended recipient, please delete this
 communication and contact us immediately. Please note you are not
 authorised to copy, use or disclose this communication or any
 attachments without our consent. Although this email has been checked
 by anti-virus software, there is a risk that email messages may be
 corrupted or infected by viruses or other interferences. No
 responsibility is accepted for such interference. Unless expressly
 stated, the views of the writer are not those of the company. Tricky
 Solutions always does our best to provide accurate forecasts and
 analyses based on the data supplied, however it is possible that some
 important predictors were not included in the data sent to us.
 Information provided by us should not be solely relied upon when
 making decisions and clients should use their own judgement.

 On 26/04/2012, at 7:19, Kay Cichini kay.cich...@gmail.com wrote:

  Hello all,
 
  I'd like to test if total diversity differs between two communities.
  For each community several samples were taken and abundances
  collapsed over groups to compute total diversity for each group. I
  tried to use vegan::oecosimu to test non-randomness of my statisitc
  (difference in Simpson-Diversity indices of collapsed abundances) -
  however, I am not quite sure if I oversee posssible pitfalls:
 
  library(vegan)
  data(dune)
 
  # a grouping variable:
  gr - gl(2, nrow(dune)/2)
 
  divdiff - function(x) abs(diversity(colSums(x[gr == 1, ]), simp)
-
diversity(colSums(x[gr == 2, ]),
  simp)) # testing function:
  divdiff(dune)
 
  oecosimu(dune, divdiff, r2dtable, nsimul = 1999) # oecosimu with
  1999 simulations # simulation method r2dtable # alternative
  hypothesis: true mean is not equal to the statistic
  #   statisticz 2.5%  50% 97.5% Pr(sim.)
  # statistic   0.00275 -0.20996  0.00013  0.00280  0.01 0.98
 
 [[alternative HTML version deleted

Re: [R-sig-eco] Testing difference between diversity indices with vegan::oecosimu

2012-04-26 Thread Kay Cichini
@David,
to ask for statistical *and* biological significance (effect size) is
indeed essential and
this statement does apply in general - but it does not contribute to a
solution of my problem at all..

@Chris,
as I want to test total diversity of each community (diversity calculated
from samples collapsed over groups) I have only two values and thus
ANOVA-like tests are not an option.

Kind regards,
Kay

ps: Sorry Chris for double posting.



 2012/4/26 Chris Howden ch...@trickysolutions.com.au

 Standard Hypothesis statistical testing often starts with the null
 hypothesis that 2 things are identical, or that 2 population means are
 identical. The p value is then used to reject this null and accept the
 alternative, that they are indeed different.

 Practically we're actually asking if we have enough information to indeed
 say they are different.

 I do agree though that stopping there is a bit silly. If there is a
 statistical difference then we next need to look at the effect size or in
 other words the magnitude of the difference and decide if this is
 ecologically meaningful.


 Chris Howden B.Sc. (Hons) GStat.
 Founding Partner
 Evidence Based Strategic Development, IP Commercialisation and Innovation,
 Data Analysis, Modelling and Training
 (mobile) 0410 689 945
 (fax) +612 4782 9023
 ch...@trickysolutions.com.au




 Disclaimer: The information in this email and any attachments to it are
 confidential and may contain legally privileged information. If you are
 not the named or intended recipient, please delete this communication and
 contact us immediately. Please note you are not authorised to copy, use or
 disclose this communication or any attachments without our consent.
 Although this email has been checked by anti-virus software, there is a
 risk that email messages may be corrupted or infected by viruses or other
 interferences. No responsibility is accepted for such interference. Unless
 expressly stated, the views of the writer are not those of the company.
 Tricky Solutions always does our best to provide accurate forecasts and
 analyses based on the data supplied, however it is possible that some
 important predictors were not included in the data sent to us. Information
 provided by us should not be solely relied upon when making decisions and
 clients should use their own judgement.


 -Original Message-
 From: r-sig-ecology-boun...@r-project.org
 [mailto:r-sig-ecology-boun...@r-project.org] On Behalf Of David Valentim
 Dias
 Sent: Thursday, 26 April 2012 2:36 PM
 To: r-sig-ecology@r-project.org
 Subject: Re: [R-sig-eco] Testing difference between diversity indices with
 vegan::oecosimu

 Hello Cichini,

 I cannot help with your code but seems like you have a silly hypothesis.
 Think about it: Probability of two communities to be identical?
 You need to restate it in some more useful way. We already know most
 things are different but with what magnitude? Which factors are causing
 these changes? How these changes matter from the environment and us?

 2012/4/25 Chris Howden ch...@trickysolutions.com.au

  Why not try some type of ANOVA style glm?
 
  Chris Howden
  Founding Partner
  Tricky Solutions
  Tricky Solutions 4 Tricky Problems
  Evidence Based Strategic Development, IP Commercialisation and
  Innovation, Data Analysis, Modelling and Training
 
  (mobile) 0410 689 945
  (fax / office)
  ch...@trickysolutions.com.au
 
  Disclaimer: The information in this email and any attachments to it
  are confidential and may contain legally privileged information. If
  you are not the named or intended recipient, please delete this
  communication and contact us immediately. Please note you are not
  authorised to copy, use or disclose this communication or any
  attachments without our consent. Although this email has been checked
  by anti-virus software, there is a risk that email messages may be
  corrupted or infected by viruses or other interferences. No
  responsibility is accepted for such interference. Unless expressly
  stated, the views of the writer are not those of the company. Tricky
  Solutions always does our best to provide accurate forecasts and
  analyses based on the data supplied, however it is possible that some
  important predictors were not included in the data sent to us.
  Information provided by us should not be solely relied upon when
  making decisions and clients should use their own judgement.
 
  On 26/04/2012, at 7:19, Kay Cichini kay.cich...@gmail.com wrote:
 
   Hello all,
  
   I'd like to test if total diversity differs between two communities.
   For each community several samples were taken and abundances
   collapsed over groups to compute total diversity for each group. I
   tried to use vegan::oecosimu to test non-randomness of my statisitc
   (difference in Simpson-Diversity indices of collapsed abundances) -
   however, I am not quite sure if I oversee posssible pitfalls:
  
   library(vegan)
   data(dune)
  
   # a grouping variable

Re: [R-sig-eco] Testing difference between diversity indices with vegan::oecosimu

2012-04-26 Thread Chris Howden
Then use a t test, unless the underlying distribution is exceptionally
skewed if they're means and the sample size is large enough u should
be able to assume normality.

If not the try a median test.

However u may find a more accurate result if rather than collapsing
over both communities u incorporate your study design via blocking or
mixed modelling.

Chris Howden
Founding Partner
Tricky Solutions
Tricky Solutions 4 Tricky Problems
Evidence Based Strategic Development, IP Commercialisation and
Innovation, Data Analysis, Modelling and Training

(mobile) 0410 689 945
(fax / office)
ch...@trickysolutions.com.au

Disclaimer: The information in this email and any attachments to it are
confidential and may contain legally privileged information. If you are not
the named or intended recipient, please delete this communication and
contact us immediately. Please note you are not authorised to copy,
use or disclose this communication or any attachments without our
consent. Although this email has been checked by anti-virus software,
there is a risk that email messages may be corrupted or infected by
viruses or other
interferences. No responsibility is accepted for such interference. Unless
expressly stated, the views of the writer are not those of the
company. Tricky Solutions always does our best to provide accurate
forecasts and analyses based on the data supplied, however it is
possible that some important predictors were not included in the data
sent to us. Information provided by us should not be solely relied
upon when making decisions and clients should use their own judgement.

On 26/04/2012, at 17:18, Kay Cichini kay.cich...@gmail.com wrote:

 @David,
 to ask for statistical *and* biological significance (effect size) is
 indeed essential and
 this statement does apply in general - but it does not contribute to a
 solution of my problem at all..

 @Chris,
 as I want to test total diversity of each community (diversity calculated
 from samples collapsed over groups) I have only two values and thus
 ANOVA-like tests are not an option.

 Kind regards,
 Kay

 ps: Sorry Chris for double posting.



 2012/4/26 Chris Howden ch...@trickysolutions.com.au

 Standard Hypothesis statistical testing often starts with the null
 hypothesis that 2 things are identical, or that 2 population means are
 identical. The p value is then used to reject this null and accept the
 alternative, that they are indeed different.

 Practically we're actually asking if we have enough information to indeed
 say they are different.

 I do agree though that stopping there is a bit silly. If there is a
 statistical difference then we next need to look at the effect size or in
 other words the magnitude of the difference and decide if this is
 ecologically meaningful.


 Chris Howden B.Sc. (Hons) GStat.
 Founding Partner
 Evidence Based Strategic Development, IP Commercialisation and Innovation,
 Data Analysis, Modelling and Training
 (mobile) 0410 689 945
 (fax) +612 4782 9023
 ch...@trickysolutions.com.au




 Disclaimer: The information in this email and any attachments to it are
 confidential and may contain legally privileged information. If you are
 not the named or intended recipient, please delete this communication and
 contact us immediately. Please note you are not authorised to copy, use or
 disclose this communication or any attachments without our consent.
 Although this email has been checked by anti-virus software, there is a
 risk that email messages may be corrupted or infected by viruses or other
 interferences. No responsibility is accepted for such interference. Unless
 expressly stated, the views of the writer are not those of the company.
 Tricky Solutions always does our best to provide accurate forecasts and
 analyses based on the data supplied, however it is possible that some
 important predictors were not included in the data sent to us. Information
 provided by us should not be solely relied upon when making decisions and
 clients should use their own judgement.


 -Original Message-
 From: r-sig-ecology-boun...@r-project.org
 [mailto:r-sig-ecology-boun...@r-project.org] On Behalf Of David Valentim
 Dias
 Sent: Thursday, 26 April 2012 2:36 PM
 To: r-sig-ecology@r-project.org
 Subject: Re: [R-sig-eco] Testing difference between diversity indices with
 vegan::oecosimu

 Hello Cichini,

 I cannot help with your code but seems like you have a silly hypothesis.
 Think about it: Probability of two communities to be identical?
 You need to restate it in some more useful way. We already know most
 things are different but with what magnitude? Which factors are causing
 these changes? How these changes matter from the environment and us?

 2012/4/25 Chris Howden ch...@trickysolutions.com.au

 Why not try some type of ANOVA style glm?

 Chris Howden
 Founding Partner
 Tricky Solutions
 Tricky Solutions 4 Tricky Problems
 Evidence Based Strategic Development, IP Commercialisation and
 Innovation, Data Analysis

Re: [R-sig-eco] Testing difference between diversity indices with vegan::oecosimu

2012-04-26 Thread Gavin Simpson
On Thu, 2012-04-26 at 00:36 -0400, David Valentim Dias wrote:
 Hello Cichini,
 
 I cannot help with your code but seems like you have a silly hypothesis.
 Think about it: Probability of two communities to be identical?
 You need to restate it in some more useful way. We already know most things
 are different but with what magnitude? Which factors are causing these
 changes? How these changes matter from the environment and us?

Surely if we knew the two things were different there would be no need
to test if they were? Most statistics assumes a Null model as we can say
something specific about the magnitude of the difference (it is zero)
and we can then see if the observations are consistent with that model.

I agree that subsequent analysis is required to understand why there are
differences, but we still need a mechanism to say, given the data
collected and the error processes, are the diversities of these two
samples the same?

G

 2012/4/25 Chris Howden ch...@trickysolutions.com.au
 
  Why not try some type of ANOVA style glm?
 
  Chris Howden
  Founding Partner
  Tricky Solutions
  Tricky Solutions 4 Tricky Problems
  Evidence Based Strategic Development, IP Commercialisation and
  Innovation, Data Analysis, Modelling and Training
 
  (mobile) 0410 689 945
  (fax / office)
  ch...@trickysolutions.com.au
 
  Disclaimer: The information in this email and any attachments to it are
  confidential and may contain legally privileged information. If you are not
  the named or intended recipient, please delete this communication and
  contact us immediately. Please note you are not authorised to copy,
  use or disclose this communication or any attachments without our
  consent. Although this email has been checked by anti-virus software,
  there is a risk that email messages may be corrupted or infected by
  viruses or other
  interferences. No responsibility is accepted for such interference. Unless
  expressly stated, the views of the writer are not those of the
  company. Tricky Solutions always does our best to provide accurate
  forecasts and analyses based on the data supplied, however it is
  possible that some important predictors were not included in the data
  sent to us. Information provided by us should not be solely relied
  upon when making decisions and clients should use their own judgement.
 
  On 26/04/2012, at 7:19, Kay Cichini kay.cich...@gmail.com wrote:
 
   Hello all,
  
   I'd like to test if total diversity differs between two communities. For
   each community several samples were taken and abundances collapsed over
   groups to compute total diversity for each group. I tried to use
   vegan::oecosimu to test non-randomness of my statisitc (difference in
   Simpson-Diversity indices of collapsed abundances) - however, I am not
   quite sure if I oversee posssible pitfalls:
  
   library(vegan)
   data(dune)
  
   # a grouping variable:
   gr - gl(2, nrow(dune)/2)
  
   divdiff - function(x) abs(diversity(colSums(x[gr == 1, ]), simp) -
 diversity(colSums(x[gr == 2, ]), simp))
   # testing function:
   divdiff(dune)
  
   oecosimu(dune, divdiff, r2dtable, nsimul = 1999)
   # oecosimu with 1999 simulations
   # simulation method r2dtable
   # alternative hypothesis: true mean is not equal to the statistic
   #   statisticz 2.5%  50% 97.5% Pr(sim.)
   # statistic   0.00275 -0.20996  0.00013  0.00280  0.01 0.98
  
  [[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
 
 
 
 
 ___
 R-sig-ecology mailing list
 R-sig-ecology@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-sig-ecology

-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,  [f] +44 (0)20 7679 0565
 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

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


Re: [R-sig-eco] Testing difference between diversity indices with vegan::oecosimu

2012-04-26 Thread Gavin Simpson
On Thu, 2012-04-26 at 09:17 +0200, Kay Cichini wrote:
 @David,
 to ask for statistical *and* biological significance (effect size) is
 indeed essential and
 this statement does apply in general - but it does not contribute to a
 solution of my problem at all..
 
 @Chris,
 as I want to test total diversity of each community (diversity calculated
 from samples collapsed over groups) I have only two values and thus
 ANOVA-like tests are not an option.

So you have two numbers? Diversity in Comm1 computed by summing total
number of unique species in Comm1 and the same but for Comm2. Hmm

How about a null model that presupposes that Comm1 and Comm2 have the
same diversity? Under that model can we reallocate the original samples
(before you collapsed down to the two communities) to one or other of
the communities, collapse to the community level, then compute the
difference in diversity in permuted Comm1 and Comm2. Repeat a lot of
times and look to see if the observed difference is extreme relative to
the Null distribution?

Would that make sense? If so you could cook that up with functions in
vegan or the permute package.

If you have the original counts, are they done to counts of species and
you are just extracting diversity indices from that or do you only have
the diversity indices?

If the former then the multivariate dispersion of the species counts in
samples for Comm1 and Comm2 will be equivalent if they are similarly
diverse. I.e. they should have the same spread/variance. That can be
tested using the work of Marti Anderson (her PERMDISP program) which is
available as function betadisper() in vegan (though the method is biased
with unbalanced sample designs - thanks to some excellent detective work
that has just been brought to our attention - so do check out the
R-forge version for changes to betadisper(). I'm not sure if the work
has been done to add a correction in R-Forge or just in Jars' Github
repo?).

Alternatively, and perhaps more powerfully, see David Warton's mvabund
package which has more formal glm-based tests of the distance-based
methods Marti developed in NPMANOVA and PERMDISP.

G

 Kind regards,
 Kay
 
 ps: Sorry Chris for double posting.
 
 
 
  2012/4/26 Chris Howden ch...@trickysolutions.com.au
 
  Standard Hypothesis statistical testing often starts with the null
  hypothesis that 2 things are identical, or that 2 population means are
  identical. The p value is then used to reject this null and accept the
  alternative, that they are indeed different.
 
  Practically we're actually asking if we have enough information to indeed
  say they are different.
 
  I do agree though that stopping there is a bit silly. If there is a
  statistical difference then we next need to look at the effect size or in
  other words the magnitude of the difference and decide if this is
  ecologically meaningful.
 
 
  Chris Howden B.Sc. (Hons) GStat.
  Founding Partner
  Evidence Based Strategic Development, IP Commercialisation and Innovation,
  Data Analysis, Modelling and Training
  (mobile) 0410 689 945
  (fax) +612 4782 9023
  ch...@trickysolutions.com.au
 
 
 
 
  Disclaimer: The information in this email and any attachments to it are
  confidential and may contain legally privileged information. If you are
  not the named or intended recipient, please delete this communication and
  contact us immediately. Please note you are not authorised to copy, use or
  disclose this communication or any attachments without our consent.
  Although this email has been checked by anti-virus software, there is a
  risk that email messages may be corrupted or infected by viruses or other
  interferences. No responsibility is accepted for such interference. Unless
  expressly stated, the views of the writer are not those of the company.
  Tricky Solutions always does our best to provide accurate forecasts and
  analyses based on the data supplied, however it is possible that some
  important predictors were not included in the data sent to us. Information
  provided by us should not be solely relied upon when making decisions and
  clients should use their own judgement.
 
 
  -Original Message-
  From: r-sig-ecology-boun...@r-project.org
  [mailto:r-sig-ecology-boun...@r-project.org] On Behalf Of David Valentim
  Dias
  Sent: Thursday, 26 April 2012 2:36 PM
  To: r-sig-ecology@r-project.org
  Subject: Re: [R-sig-eco] Testing difference between diversity indices with
  vegan::oecosimu
 
  Hello Cichini,
 
  I cannot help with your code but seems like you have a silly hypothesis.
  Think about it: Probability of two communities to be identical?
  You need to restate it in some more useful way. We already know most
  things are different but with what magnitude? Which factors are causing
  these changes? How these changes matter from the environment and us?
 
  2012/4/25 Chris Howden ch...@trickysolutions.com.au
 
   Why not try some type of ANOVA style glm?
  
   Chris Howden
   Founding Partner

Re: [R-sig-eco] Testing difference between diversity indices with vegan::oecosimu

2012-04-26 Thread Ivailo
On Thu, Apr 26, 2012 at 12:17 AM, Kay Cichini kay.cich...@gmail.com wrote:
 Hello all,

 I'd like to test if total diversity differs between two communities. For
 each community several samples were taken and abundances collapsed over
 groups to compute total diversity for each group. I tried to use
 vegan::oecosimu to test non-randomness of my statisitc (difference in
 Simpson-Diversity indices of collapsed abundances) - however, I am not
 quite sure if I oversee posssible pitfalls:

 library(vegan)
 data(dune)

 # a grouping variable:
 gr - gl(2, nrow(dune)/2)

 divdiff - function(x) abs(diversity(colSums(x[gr == 1, ]), simp) -
                           diversity(colSums(x[gr == 2, ]), simp))
 # testing function:
 divdiff(dune)

 oecosimu(dune, divdiff, r2dtable, nsimul = 1999)
 # oecosimu with 1999 simulations
 # simulation method r2dtable
 # alternative hypothesis: true mean is not equal to the statistic
 #           statistic        z     2.5%      50% 97.5% Pr(sim.)
 # statistic   0.00275 -0.20996  0.00013  0.00280  0.01     0.98

Dear Kay,

I am not sure about any possible pitfalls with your approach, but I
have tested the same data using the randomisation functions of the
rich library, and found that neither the Simpson diversity nor the
simple species richness differ significantly among the defined groups.

Here are the results following your example:

library(rich)

# prepare data
one - as.data.frame(dune[gr == 1, ])
two - as.data.frame(dune[gr == 2, ])

data - list(one, two)

# compare cumulative species richness
c2cv(com1=data[[1]],com2=data[[2]],nrandom=1999)
#$res
#
#cv1  27.
#cv2  28.
#cv1-cv2  -1.
#p 0.4220 # N.S.
#quantile 0.025   -4.
#quantile 0.9754.
#randomized cv1-cv20.0225
#nrandom1999.

# compare the Simpson diversity
simp.one - diversity(dune[gr == 1, ], simp)
simp.two - diversity(dune[gr == 2, ], simp)
c2m(pop1=simp.one,pop2=simp.two,nrandom=1999,verbose=FALSE)
#done.
#$res
#
#mv1 8.630e-01
#mv2 8.773e-01
#mv1-mv2-1.439e-02
#p   2.440e-01 # N.S.
#quantile 0.025 -3.456e-02
#quantile 0.975  3.351e-02
#randomized mv1-mv2  3.899e-04
#nrandom 1.999e+03
#

The possible pitfalls might be hidden under the different results ;-)

Cheers,
Ivailo
-- 
UBUNTU: a person is a person through other persons.

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


Re: [R-sig-eco] Testing difference between diversity indices with vegan::oecosimu

2012-04-26 Thread Kay Cichini
Hi,

thanks a lot - things are much clearer now!

Then I will take the one you and Gavin suggested.

Kind regards,
Kay

Am 26.04.2012 17:47 schrieb Jari Oksanen jari.oksa...@oulu.fi:


 On 26 Apr 2012, at 0:19, Kay Cichini wrote:

  Hello all,
 
  I'd like to test if total diversity differs between two communities. For
  each community several samples were taken and abundances collapsed over
  groups to compute total diversity for each group. I tried to use
  vegan::oecosimu to test non-randomness of my statisitc (difference in
  Simpson-Diversity indices of collapsed abundances) - however, I am not
  quite sure if I oversee posssible pitfalls:
 
  library(vegan)
  data(dune)
 
  # a grouping variable:
  gr - gl(2, nrow(dune)/2)
 
  divdiff - function(x) abs(diversity(colSums(x[gr == 1, ]), simp) -
diversity(colSums(x[gr == 2, ]), simp))
  # testing function:
  divdiff(dune)
 
  oecosimu(dune, divdiff, r2dtable, nsimul = 1999)
  # oecosimu with 1999 simulations
  # simulation method r2dtable
  # alternative hypothesis: true mean is not equal to the statistic
  #   statisticz 2.5%  50% 97.5% Pr(sim.)
  # statistic   0.00275 -0.20996  0.00013  0.00280  0.01 0.98
 
 Kay,

 I think that Gav's suggestion is the most natural one: permute your
classification vector and compare your observed difference to the
permutation values. Null models can be problematic, and you must very
carefully think what kind of null model you need and what is the null
hypothesis under each null model. Quantitative null models are even
trickier. I see the following possible problems with your idea:

 - You used r2dtable null model which fixes both row and column totals
(but not frequencies). This means that for all simulations the overall
gamma diversity is fixed: Simpson index is found from species totals, and
these are fixed. When you also fix row totals, the generated null models
can be too similar to each other, and this in turn gives too low P-values.
I think that when analysing overall diversities from marginal sums, you
should use a null model that allows those marginal sums to vary. This may
not be possible with the release version of vegan, but the development
version in R-Forge has a completely redesigned null model engine with
several new quantitative null models and allows plugging in your own null
models (which could even include permutation models).

 - If usual null models can be painful, the quantitative null models give
you double trouble. One problem is that they produce too evenly distributed
data. For r2dtable this holds in two ways: the method fixes marginal
totals, but not marginal frequencies (= number of non-zero cells).
Typically the number of zeros is much lower than in real data, and the
variance of rows and columns is lower than in any real data. Moreover, the
simulated samples are often much more similar to each other than real
re-sampling of Nature. This is like using Poisson glm for abundance data:
the data are regularly over-dispersed to Poisson, and therefore the
P-values are too low. You have just the same danger with these null models:
the simulation variation is too low, and therefore your P-values are too
low.

 - The r2dtable method requires that your data are individuals: they are
individuals that are swapped between cells. You used Dutch Dune meadow data
in your example. Technically this works, since the data are integers, but
they are cover class values and not individual, and therefore the swapping
of integer pieces of cover classes has no meaning. If you want to consider
null models, you should again switch to R-Forge version of vegan (currently
there at version 2.1-15) which allows some models that apply to data that
is not made of individuals, and also some methods that can retain the
original marginal variances of the data.

 There are many things that you need to consider if you want to use null
models. However, I think that permutation of classification vector saves a
lot of trouble, and is more easily understood and communicated.

 Cheers, Jari Oksanen


[[alternative HTML version deleted]]

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


Re: [R-sig-eco] Testing difference between diversity indices with vegan::oecosimu

2012-04-25 Thread Chris Howden
Why not try some type of ANOVA style glm?

Chris Howden
Founding Partner
Tricky Solutions
Tricky Solutions 4 Tricky Problems
Evidence Based Strategic Development, IP Commercialisation and
Innovation, Data Analysis, Modelling and Training

(mobile) 0410 689 945
(fax / office)
ch...@trickysolutions.com.au

Disclaimer: The information in this email and any attachments to it are
confidential and may contain legally privileged information. If you are not
the named or intended recipient, please delete this communication and
contact us immediately. Please note you are not authorised to copy,
use or disclose this communication or any attachments without our
consent. Although this email has been checked by anti-virus software,
there is a risk that email messages may be corrupted or infected by
viruses or other
interferences. No responsibility is accepted for such interference. Unless
expressly stated, the views of the writer are not those of the
company. Tricky Solutions always does our best to provide accurate
forecasts and analyses based on the data supplied, however it is
possible that some important predictors were not included in the data
sent to us. Information provided by us should not be solely relied
upon when making decisions and clients should use their own judgement.

On 26/04/2012, at 7:19, Kay Cichini kay.cich...@gmail.com wrote:

 Hello all,

 I'd like to test if total diversity differs between two communities. For
 each community several samples were taken and abundances collapsed over
 groups to compute total diversity for each group. I tried to use
 vegan::oecosimu to test non-randomness of my statisitc (difference in
 Simpson-Diversity indices of collapsed abundances) - however, I am not
 quite sure if I oversee posssible pitfalls:

 library(vegan)
 data(dune)

 # a grouping variable:
 gr - gl(2, nrow(dune)/2)

 divdiff - function(x) abs(diversity(colSums(x[gr == 1, ]), simp) -
   diversity(colSums(x[gr == 2, ]), simp))
 # testing function:
 divdiff(dune)

 oecosimu(dune, divdiff, r2dtable, nsimul = 1999)
 # oecosimu with 1999 simulations
 # simulation method r2dtable
 # alternative hypothesis: true mean is not equal to the statistic
 #   statisticz 2.5%  50% 97.5% Pr(sim.)
 # statistic   0.00275 -0.20996  0.00013  0.00280  0.01 0.98

[[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