ibartomeus/fundiv

Can the null function also be used to test if a single trait is sig. different from the null expectation?

Closed this issue · 10 comments

Hi all,

I was wondering if the null function null.fd can be also used/modified to test if a single trait is significantly different from the null expectation? Specifically, I have a list of traits for which I want to test if they are over-or underdispersed compared to random expectations.

I would be happy about any feedback!
Thanks a lot!

Best wishes,
Belinda

Hi Belinda,

In the case of FD, the null or random expectation is constrained by the number of species. So, given a random set of X species, which are the expected FD values. I guess you can ask the same question using a single trait, but it would require a bit of tweaking the code. I think the idea is quite simple, and you can simply use a for loop to select a random set of species and calculate your trait CWM, (or any other metric of interest), and compare the obtained distribution with your observed value.

Best,
Nacho

Hi Nacho,

thank you for your response. Could you maybe explain a bit more on how to modify the code :) ? Also, I tried using the code when using all my traits combined and interestingly it works fine for only 10 iterations but as soon as I use 100 or even 1000 iterations I receive the following error message:
Error in convhulln(tr.FRic, "FA") :
Received error code 2 from qhull. Qhull error:
qhull precision warning:
The initial hull is narrow (cosine of min. angle is 1.0000000000000000).
Is the input lower dimensional (e.g., on a plane in 3-d)? Qhull may
produce a wide facet. Options 'QbB' (scale to unit box) or 'Qbb' (scale
last coordinate) may remove this warning. Use 'Pp' to skip this warning.
See 'Limitations' in qh-impre.htm.
QH6114 qhull precision error: initial simplex is not convex. Distance=-3.1e-016

While executing: | qhull FA Qt
Options selected for Qhull 2015.2.r 2016/01/18:
run-id 1120387837 FArea-total Qtriangulate _pre-merge _zero-centrum
_max-width 5.5 Error-roundoff 6.1e-015 _one-merge 4.3e-014
_near-inside 2.1e-013 Visible-distance 1.2e-014
U-coplanar-distance 1.2e-014 Width-outside 2.4e-014 _wide-facet 7.3e-014
_narrow-hull 0

precision problems (corrected unless 'Q0' or an error)
1 flipped facets

The input to qhull appears to be less than 3 dimensional, or a
comput
In addition: Warning messages:
1: In if (Weigthedby != "abundance") { :
the condition has length > 1 and only the first element will be used
2: In if (Weigthedby == "biomasCarabids") { :
the condition has length > 1 and only the first element will be used
3: In if (Weigthedby == "biomasBees") { :
the condition has length > 1 and only the first element will be used
4: In is.euclid(x.dist) : Zero distance(s)
5: In is.euclid(x.dist) : Zero distance(s)
6: In is.euclid(distmat) : Zero distance(s)
7: In dudi.pco(x.dist2, scannf = FALSE, full = TRUE) :
Non euclidean distance
8: In is.euclid(x.dist) : Zero distance(s)
9: In is.euclid(x.dist) : Zero distance(s)
10: In is.euclid(x.dist) :

Any idea why that happens? Thanks a lot again!

Best,
Belinda

P.S: I forgot to mention that my trait is discrete

Dear Nacho,

sorry to bother you again but could the error be due to a lack of data? Because some locations have only 4 species and for some traits we do not have information for some species...
Thanks again for your help!

Best,
Belinda

This is explained in the help of the FDindexes function, and is not related to any of the function I coded.

  • op_qhull access the options for calculating the volume of the convex hull. If a long scary warning appears mentioning qhull read convhulln{geometry} help page. Default in FD is= "FA", but sometimes is needed to add stuff.

I never worked out this part in detail, so you will need to see why this is failing. Small datasets, especially with low variability may be problematic.

Best!

Dear Nacho,

thanks for your response. Ok, So I have to tweak the op_qhull parameter. Or would it also be proper to just run 10 Iterations several times (cause for 10 Iterations I always get an output) , average the resulting null observations and compute p-values by hand?

Best wishes,
Belinda

My gut feeling is that it fails for some combinations and with n=10 you don't hit any of those combinations, but you do when this is larger. So yes, using several N= 10 manually may do the trick.

Thanks. I just tried that and the values I get are exactly identical for the null expectation- isn't that a bit odd?

Ok, all good, solved it. Thanks again for your help!

Best,
Belinda

Great! Good job.