[R-sig-eco] Error randomiseMatrix/dbFD functions - functional trait data

Felicity Edwards felicity.edwards at sheffield.ac.uk
Thu Apr 5 10:12:54 CEST 2018


 *Dear group,*

*The background to my study* - I have a species x site matrix which
includes abundance data. I'm currently working on my fine scale data set. I
have 137 species across 48 points. I also have a species x trait matrix
which I've used to create a 'dist' object. Using these I've calculated
observed functional diversity metrics. I'm now trying to calculate expected
metrics from these data by using null models.

*My current code set up* - I'm randomising the community data within
samples, maintaining sample species richness, the 'richness' null model
within Picante allows me to do this. Below is the code I've been running.
This code worked for a data set with far fewer species (n=49).

####Null model permutations (=10,000 times)##obslog1FD$RaoQ - is the
observed metric##tcommlog1 = community data (species [columns] x
points [rows])##disecomor = dist object from dist.ktab (species by
traits)

set.seed(1)
null.model.type <- "richness"
nperm <- 10000
#creation of empty matric#
RaoQ <- matrix(NaN, nrow=nperm, ncol=length(obslog1FD$RaoQ))

abund.null <- vector(mode="list", nperm)
t1 <- Sys.time()
for(i in seq(nperm)){ # loop for each permutation
  # Create permutated abundance matrix
  abund.i <- randomizeMatrix(tcommlog1, null.model = null.model.type,
iterations = 999)
  traits.i <- disecomor

  abund.null[[i]] <- abund.i

  # Record results
  res.i <- dbFD(
    traits.i, abund.i, calc.FRic=FALSE, scale.RaoQ=FALSE,
    calc.FGR=FALSE, calc.CWM = FALSE, calc.FDiv = FALSE,
    print.pco = FALSE
  )
  # Save result
  RaoQ[i,] <- res.i$RaoQ

  rm(abund.i); rm(res.i)
  print(paste0(round(i/nperm*100), "% of permutations completed"))}

*My code problem* - When I try to calculate the expected metrics using the
larger species data set (n=139) the progress never gets beyond 10% and I
get the following error: *At least one species does not occur in any
community (zero total abundance across all communities).*

*My question's* - 1) Firstly, I'm confused as to why I get zero values
using this data set when all species are present at at least one sample
point (this was also the case for my smaller data set of 49 species which
did not have an error). Am I missing something on the way the community
data set is shuffled using the random null model?

2) Is it possible to get around the zero species abundances by excluding
those zero abundant species? This I realise would require code to check for
zero abundance and then exclude those identified species from the community
and trait distance matrices. Although I understand the principle my R
coding knowledge is limited to know how to implement this.

I have searched the internet for a solution and had no luck. I appreciate
any help or advice people can give.

	[[alternative HTML version deleted]]



More information about the R-sig-ecology mailing list