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

Dave Roberts dvrbts at ecology.msu.montana.edu
Fri Aug 29 00:47:19 CEST 2014


Hi Elliot,

    If you copy (or just rename) your FDresults$x.axes to 
FDresults$sites you can use all the vegan ordi__ functions on your results.

E.g.

FDresults$sites <- FDresults$x.axes
demo <- ordiplot(FDresults)
ordisurf(demo,to.ordinate$attack.height)

which is a little more informative than envfit unless you're convinced 
the response should be linear.

In addition, if you want, you could add the species in

FDresults$species <- t(road.map)
demo <- ordiplot(FDresults)

to see species centroids.

Dave



On 08/27/2014 09:24 AM, Eliot Miller 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]]
>
> _______________________________________________
> R-sig-ecology mailing list
> R-sig-ecology at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
David W. Roberts                                     office 406-994-4548
Professor and Head                                      FAX 406-994-3190
Department of Ecology                         email droberts at montana.edu
Montana State University
Bozeman, MT 59717-3460



More information about the R-sig-ecology mailing list