Message-ID: <1322150277396-4104406.post@n4.nabble.com>
Date: 2011-11-24T15:57:57Z
From: Brad Patrick Schneid
Subject: I cannot get species scores to plot with site scores in MDS when I use a distance matrix as input. Problems with NA's?
In-Reply-To: <DUB108-W469C2080D501A9B66FB6CCD1CE0@phx.gbl>
Try the daisy() function from the package "cluster", it seems to be able to
handle NAs and non-dummy coded character variables
metaMDS(daisy(df, metric="gower"))
Edwin Lebrija Trejos wrote
>
> Hi, First I should note I am relatively new to R so I would appreciate
> answers that take this into account.
>
> I am trying to perform an MDS ordination using the function ?metaMDS? of
> the ?vegan? package. I want to ordinate species according to a set of
> functional traits. ?Species? here refers to ?sites? in traditional
> vegetation analyses while ?traits? here correspond to ?species? in such
> analyses.
>
> My data looks like this:
>
> Trait1 Trait2 Trait3 Trait4 Trait5 Trait?
> Species1 228.44 16.56 1.66 13.22 1 short
> Species2 150.55 28.07 0.41 0.60 1 mid
> Species3 NA 25.89 NA 0.55 0 large
> Species4 147.70 17.65 0.42 1.12 NA large
> Species? 132.68 NA 1.28 2.75 0 short
>
>
> Because the traits have different variable types, different measurement
> scales, and also missing values for some species, I have calculated the
> matrix of species distances using the Gower coefficient of similarity
> available in Package ?FD? (which allows missing values).
> My problem comes when I create a bi-plot of species and traits. As I have
> used a distance matrix in function ?metaMDS? there are no species scores
> available. This is given as a warning in R:
>
> "> NMDSgowdis<- metaMDS(SpeciesGowdis)
>> plot(NMDSgowdis, type = "t")
> Warning message:In ordiplot(x, choices = choices, type = type, display =
> display, :Species scores not available?
>
> I have read from internet resources that in principle I could obtain the
> trait ("species") scores to plot them in the ordination but my attempts
> have been unsuccessful. I have tried using the function ?wascores? in
> package vegan and ?add.spec.scores? in package BiodiversityR. For this
> purpuse I have created a new species x traits table where factor traits
> were coded into dummy variables and all integer variables (including
> binary) were coerced to numeric variables. Here are the codes used and the
> error messages I have got:
>
> ?> NMDSgowdis<- metaMDS(SpeciesGowdis)
>> NMDSpoints<-postMDS(NMDSgowdis$points,SpeciesGowdis)
>> NMDSwasc<-wascores(NMDSpoints,TraitsNMDSdummies)
> Error in if (any(w < 0) || sum(w) == 0) stop("weights must be non-negative
> and not all zero") : missing value where TRUE/FALSE needed?
>
> I imagine the problem is with the NA?s in the data.
> Alternatively, I have used the ?add.spec.scores? function,
> method=?cor.scores?, found in package BiodiversityR. This seemed to work,
> as I got no error message, but the species scores were not returned. Here
> the R code and results:
> ?>
> A<-add.spec.scores(ordi=NMDSgowdis,comm=TraitsNMDSdummies,method="cor.scores",multi=1,
> Rscale=F,scaling="1")
>> plot(A)
> Warning message:In ordiplot(x, choices = choices, type = type, display =
> display, :Species scores not available?
>
> Can anyone guide me to get the trait (?species?) scores to plot together
> with my species (?site?) scores?
> Thanks in advance,
> Edwin
>
>
> ______________________________________________
> R-help@ mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
View this message in context: http://r.789695.n4.nabble.com/I-cannot-get-species-scores-to-plot-with-site-scores-in-MDS-when-I-use-a-distance-matrix-as-input-Pr-tp4103699p4104406.html
Sent from the R help mailing list archive at Nabble.com.