[R-sig-eco] a possible hack for adding species scores?

Eliot Miller eliotmiller at umsl.edu
Fri Aug 29 19:05:57 CEST 2014


Hi Dave,

Thanks a million for the response! Your solution is good in some
respects--when applied to my real data it shows me why I should be cautious
of assuming any linearity in the response of my continuous variables.
However, it doesn't work for the factors (which makes sense). You can run,

ordisurf(demo, to.ordinate$leafiness)

to see what I mean. Would it be reasonable to use some combination of
ordisurf for the continuous variables, with the locations of the factors
determined via envfit?

Thanks again for the push in the right direction!

Cheers,
Eliot


On Wed, Aug 27, 2014 at 10:24 AM, Eliot Miller <eliotmiller at umsl.edu> wrote:

> Hi all,
>
> A few months ago I ran into a problem that others seem to have had. In
> short, if you use the FD package to calculate a Gower distance matrix which
> you then either feed back into vegan or use directly in FD, you "lose the
> species" scores associated with the points. You can't see what explains the
> distances among points. Examples of similar problems are here:
>
> http://r.789695.n4.nabble.com/Ordination-Plotting-Warning-Species-scores-not-available-td4664025.html
> https://www.mail-archive.com/r-help@r-project.org/msg153765.html
>
> I am less concerned with the plotting of the results than the previous
> posters have been. I am more concerned with simply seeing the table of
> "loadings" (don't think that term is correct for the PCoA). Perhaps this is
> an acceptable and widespread solution to the problem, and I simply haven't
> stumbled on it yet. It takes advantage of the vegan function envfit(). Or
> perhaps it is an incorrect solution. I'm wondering which of those two
> things it is, and hoping for a bit of input. In my case, I am making a
> distance matrix among foraging observations spread across a number of
> species. I want to know each species' niche size using the FDis metric. I
> made an example dataset and completely worked through example. The main
> point here is that I want to know whether the object "fitted" at the end is
> correctly explaining how things are "loaded". Any help is greatly
> appreciated.
>
> Thanks in advance!
> Eliot
>
> library(FD)
>
> #these first few lines are just building up an example dataset of foraging
> observations
> set.seed(0)
> maneuver <-
> sample(c(rep("sally",10),rep("probe",10),rep("glean",10),rep("hover",10)))
>
> set.seed(0)
> substrate <-
> sample(c(rep("leaf",10),rep("flower",10),rep("air",10),rep("branch",10)))
>
> set.seed(0)
> attack.height <- rnorm(40, mean=5)
>
> set.seed(0)
> relative.height <- rnorm(40, 0.5)
> relative.height[relative.height < 0] <- 0
> relative.height[relative.height > 1.1] <- 1.1
>
> set.seed(0)
> leafiness <- sample(c(0:5), size=40, replace=TRUE)
> #convert this to an ordinal variable
> leafiness <- ordered(leafiness)
>
> set.seed(0)
> distance <- sample(c(1:4), size=40, replace=TRUE)
> #convert to ordinal
> distance <- ordered(distance)
>
> #here is the complete dataset of example foraging observations
> to.ordinate <- data.frame(maneuver, substrate, attack.height,
> relative.height, leafiness, distance)
>
> #now make a second table that identifies to which species each observation
> belongs
> road.map <- matrix(ncol=40, nrow=3, 0)
>
> colnames(road.map) <- 1:40
> row.names(road.map) <- c("species1","species2","species3")
>
> #this for loop assigns each foraging observations to one of the species
> set.seed(0)
> for(i in 1:dim(road.map)[2])
> {
>     species <- sample(row.names(road.map), 1)
>     road.map[species,i] <- 1
> }
>
> #run the FD calculations
> FDresults <- dbFD(x=to.ordinate, a=road.map, corr="lingoes",
> calc.FRic=FALSE, calc.FGR=FALSE, calc.CWM=FALSE, calc.FDiv=FALSE,
> print.pco=TRUE)
>
> #use the vegan function envfit() to see what is driving each axis from the
> PCoA
> fitted <- envfit(ord=FDresults$x.axes, env=to.ordinate, permutations=0,
> choices=1:10)
>
>

	[[alternative HTML version deleted]]



More information about the R-sig-ecology mailing list