R : Copyright 2005, The R Foundation for Statistical Computing Version 2.1.1 (2005-06-20), ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for a HTML browser interface to help. Type 'q()' to quit R. > ### *
> ### > attach(NULL, name = "CheckExEnv") > assign(".CheckExEnv", as.environment(2), pos = length(search())) # base > ## add some hooks to label plot pages for base and grid graphics > setHook("plot.new", ".newplot.hook") > setHook("persp", ".newplot.hook") > setHook("grid.newpage", ".gridplot.hook") > > assign("cleanEx", + function(env = .GlobalEnv) { + rm(list = ls(envir = env, all.names = TRUE), envir = env) + RNGkind("default", "default") + set.seed(1) + options(warn = 1) + delayedAssign("T", stop("T used instead of TRUE"), + assign.env = .CheckExEnv) + delayedAssign("F", stop("F used instead of FALSE"), + assign.env = .CheckExEnv) + sch <- search() + newitems <- sch[! sch %in% .oldSearch] + for(item in rev(newitems)) + eval(substitute(detach(item), list(item=item))) + missitems <- .oldSearch[! .oldSearch %in% sch] + if(length(missitems)) + warning("items ", paste(missitems, collapse=", "), + " have been removed from the search path") + }, + env = .CheckExEnv) > assign("..nameEx", "__{must remake R-ex/*.R}__", env = .CheckExEnv) # for now > assign("ptime", proc.time(), env = .CheckExEnv) > grDevices::postscript("vegan-Examples.ps") > assign("par.postscript", graphics::par(no.readonly = TRUE), env = .CheckExEnv) > options(contrasts = c(unordered = "contr.treatment", ordered = "contr.poly")) > options(warn = 1) > library('vegan') > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "BCI" > > ### * BCI > > flush(stderr()); flush(stdout()) > > ### Name: BCI > ### Title: Barro Colorado Island Tree Counts > ### Aliases: BCI > ### Keywords: datasets > > ### ** Examples > > data(BCI) > > > > cleanEx(); ..nameEx <- "anosim" > > ### * anosim > > flush(stderr()); flush(stdout()) > > ### Name: anosim > ### Title: Analysis of Similarities > ### Aliases: anosim print.anosim summary.anosim plot.anosim > ### Keywords: multivariate nonparametric htest > > ### ** Examples > > data(dune) > data(dune.env) > dune.dist <- vegdist(dune) > attach(dune.env) > dune.ano <- anosim(dune.dist, Management) > summary(dune.ano) Call: anosim(dis = dune.dist, grouping = Management) Dissimilarity: bray ANOSIM statistic R: 0.2579 Significance: 0.005 Based on 1000 permutations Empirical upper confidence limits of R: 90% 95% 97.5% 99% 0.116 0.160 0.203 0.233 Dissimilarity ranks between and within classes: 0% 25% 50% 75% 100% N Between 4 58.50 104.00 145.500 188.0 147 BF 5 15.25 25.50 41.250 57.0 3 HF 1 7.25 46.25 68.125 89.5 10 NM 6 64.75 124.50 156.250 181.0 15 SF 3 32.75 53.50 99.250 184.0 15 > plot(dune.ano) > > > > cleanEx(); ..nameEx <- "anova.cca" > > ### * anova.cca > > flush(stderr()); flush(stdout()) > > ### Name: anova.cca > ### Title: Permutation Test for Constrained Correspondence Analysis, > ### Redundancy Analysis and Constrained Analysis of Principal Coordinates > ### Aliases: anova.cca permutest.cca print.permutest.cca print.anova.cca > ### Keywords: multivariate htest > > ### ** Examples > > data(varespec) > data(varechem) > vare.cca <- cca(varespec ~ Al + P + K, varechem) > anova(vare.cca) Permutation test for cca under reduced model Model: cca(formula = varespec ~ Al + P + K, data = varechem) Df Chisq F N.Perm Pr(>F) Model 3 0.6441 2.9840 200 < 0.005 *** Residual 20 1.4391 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 > permutest.cca(vare.cca) Permutation test for cca Call: cca(formula = varespec ~ Al + P + K, data = varechem) Test for significance of all constrained eigenvalues Pseudo-F: 2.984036 Significance: < 0.01 Based on 100 permutations under reduced model. > ## Test for adding variable N to the previous model: > anova(cca(varespec ~ N + Condition(Al + P + K), varechem), step=40) Permutation test for cca under reduced model Model: cca(formula = varespec ~ N + Condition(Al + P + K), data = varechem) Df Chisq F N.Perm Pr(>F) Model 1 0.1063 1.5148 40 0.2 Residual 19 1.3328 > > > > cleanEx(); ..nameEx <- "bioenv" > > ### * bioenv > > flush(stderr()); flush(stdout()) > > ### Name: bioenv > ### Title: Best Subset of Environmental Variables with Maximum (Rank) > ### Correlation with Community Dissimilarities > ### Aliases: bioenv bioenv.default bioenv.formula print.bioenv > ### summary.bioenv print.summary.bioenv ripley.subsets ripley.subs > ### Keywords: multivariate > > ### ** Examples > > # The method is very slow for large number of possible subsets. > # Therefore only 6 variables in this example. > data(varespec) > data(varechem) > sol <- bioenv(wisconsin(varespec) ~ log(N) + P + K + Ca + pH + Al, varechem) > sol Call: bioenv(formula = wisconsin(varespec) ~ log(N) + P + K + Ca + pH + Al, data = varechem) Subset of environmental variables with best correlation to community data. Correlations: spearman Dissimilarities: bray Best model has 3 parameters (max. 6 allowed): P Ca Al with correlation 0.4004806 > summary(sol) size correlation P 1 0.2516 P Al 2 0.4004 P Ca Al 3 0.4005 P Ca pH Al 4 0.3619 log(N) P Ca pH Al 5 0.3216 log(N) P K Ca pH Al 6 0.2822 > > > > cleanEx(); ..nameEx <- "capscale" > > ### * capscale > > flush(stderr()); flush(stdout()) > > ### Name: capscale > ### Title: [Partial] Constrained Analysis of Principal Coordinates > ### Aliases: capscale > ### Keywords: multivariate > > ### ** Examples > > data(varespec) > data(varechem) > vare.cap <- capscale(varespec ~ N + P + K + Condition(Al), varechem, dist="bray") Warning in cmdscale(X, k = k, eig = TRUE, add = add) : some of the first 23 eigenvalues are < 0 Warning in sqrt(ev) : NaNs produced > vare.cap Call: capscale(formula = varespec ~ N + P + K + Condition(Al), data = varechem, distance = "bray") Inertia Rank Total 110.48 Conditional 22.48 1 Constrained 22.93 3 Unconstrained 65.07 15 Inertia is squared Bray distance Eigenvalues for constrained axes: CAP1 CAP2 CAP3 12.451 7.510 2.974 Eigenvalues for unconstrained axes: PC1 PC2 PC3 PC4 PC5 PC6 PC7 PC8 20.84991 11.79310 7.77204 6.03974 4.67406 3.72053 2.85601 1.96810 PC9 PC10 PC11 PC12 PC13 PC14 PC15 1.58427 1.34196 1.15191 0.63797 0.47930 0.16803 0.03093 > plot(vare.cap) > anova(vare.cap) Permutation test for capscale under reduced model Model: capscale(formula = varespec ~ N + P + K + Condition(Al), data = varechem, distance = "bray") Df Var F N.Perm Pr(>F) Model 3 22.935 1.7624 200.000 < 0.005 *** Residual 15 65.068 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 > > > > cleanEx(); ..nameEx <- "cca" > > ### * cca > > flush(stderr()); flush(stdout()) > > ### Name: cca > ### Title: [Partial] [Constrained] Correspondence Analysis and Redundancy > ### Analysis > ### Aliases: cca cca.default cca.formula print.cca summary.cca > ### print.summary.cca rda rda.default rda.formula summary.rda > ### Keywords: multivariate > > ### ** Examples > > data(varespec) > data(varechem) > ## Common but bad way: use all variables you happen to have in your > ## environmental data matrix > vare.cca <- cca(varespec, varechem) > vare.cca Call: cca(X = varespec, Y = varechem) Inertia Rank Total 2.0832 Constrained 1.4415 14 Unconstrained 0.6417 9 Inertia is mean squared contingency coefficient Eigenvalues for constrained axes: CCA1 CCA2 CCA3 CCA4 CCA5 CCA6 CCA7 CCA8 0.438870 0.291775 0.162847 0.142130 0.117952 0.089029 0.070295 0.058359 CCA9 CCA10 CCA11 CCA12 CCA13 CCA14 0.031141 0.013294 0.008364 0.006538 0.006156 0.004733 Eigenvalues for unconstrained axes: CA1 CA2 CA3 CA4 CA5 CA6 CA7 CA8 0.197765 0.141926 0.101174 0.070787 0.053303 0.033299 0.018868 0.015104 CA9 0.009488 > plot(vare.cca) > ## Formula interface and a better model > vare.cca <- cca(varespec ~ Al + P*(K + Baresoil), data=varechem) > vare.cca Call: cca(formula = varespec ~ Al + P * (K + Baresoil), data = varechem) Inertia Rank Total 2.083 Constrained 1.046 6 Unconstrained 1.038 17 Inertia is mean squared contingency coefficient Eigenvalues for constrained axes: CCA1 CCA2 CCA3 CCA4 CCA5 CCA6 0.37563 0.23419 0.14067 0.13229 0.10675 0.05614 Eigenvalues for unconstrained axes: CA1 CA2 CA3 CA4 CA5 CA6 CA7 CA8 0.27577 0.15411 0.13536 0.11803 0.08887 0.05511 0.04919 0.03781 (Showed only 8 of all 17 unconstrained eigenvalues) > plot(vare.cca) > ## `Partialling out' and `negative components of variance' > cca(varespec ~ Ca, varechem) Call: cca(formula = varespec ~ Ca, data = varechem) Inertia Rank Total 2.0832 Constrained 0.1572 1 Unconstrained 1.9260 22 Inertia is mean squared contingency coefficient Eigenvalues for constrained axes: CCA1 0.1572 Eigenvalues for unconstrained axes: CA1 CA2 CA3 CA4 CA5 CA6 CA7 CA8 0.47455 0.29389 0.21403 0.19541 0.17482 0.11711 0.11207 0.08797 (Showed only 8 of all 22 unconstrained eigenvalues) > cca(varespec ~ Ca + Condition(pH), varechem) Call: cca(formula = varespec ~ Ca + Condition(pH), data = varechem) Inertia Rank Total 2.0832 Conditional 0.1458 1 Constrained 0.1827 1 Unconstrained 1.7547 21 Inertia is mean squared contingency coefficient Eigenvalues for constrained axes: CCA1 0.1827 Eigenvalues for unconstrained axes: CA1 CA2 CA3 CA4 CA5 CA6 CA7 CA8 0.38343 0.27487 0.21233 0.17599 0.17013 0.11613 0.10892 0.08797 (Showed only 8 of all 21 unconstrained eigenvalues) > ## RDA > data(dune) > data(dune.env) > dune.Manure <- rda(dune ~ Manure, dune.env) > plot(dune.Manure) > > > > cleanEx(); ..nameEx <- "decorana" > > ### * decorana > > flush(stderr()); flush(stdout()) > > ### Name: decorana > ### Title: Detrended Correspondence Analysis and Basic Reciprocal Averaging > ### Aliases: decorana print.decorana summary.decorana > ### print.summary.decorana plot.decorana downweight scores.decorana > ### Keywords: multivariate > > ### ** Examples > > data(varespec) > vare.dca <- decorana(varespec) > vare.dca Call: decorana(veg = varespec) Detrended correspondence analysis with 26 segments. Rescaling of axes with 4 iterations. DCA1 DCA2 DCA3 DCA4 Eigenvalues 0.5235 0.3253 0.2001 0.19176 Decorana values 0.5249 0.1572 0.0967 0.06075 Axis lengths 2.8161 2.2054 1.5465 1.64864 > summary(vare.dca) Call: decorana(veg = varespec) Detrended correspondence analysis with 26 segments. Rescaling of axes with 4 iterations. DCA1 DCA2 DCA3 DCA4 Eigenvalues 0.5235 0.3253 0.2001 0.19176 Decorana values 0.5249 0.1572 0.0967 0.06075 Axis lengths 2.8161 2.2054 1.5465 1.64864 Species scores: DCA1 DCA2 DCA3 DCA4 Totals Cal.vul 0.04119 -1.53268 -2.55101 1.32277 45.07 Emp.nig 0.09019 0.82274 0.20569 0.30631 151.99 Led.pal 1.34533 2.47141 -0.34970 -1.13823 8.39 Vac.myr 1.86298 1.71424 -0.60535 -0.40205 50.71 Vac.vit 0.16641 0.71095 0.00313 -0.55801 275.03 Pin.syl -0.73490 1.62050 -1.60275 -2.10199 4.11 Des.fle 1.97061 1.81651 1.74896 -0.91463 5.60 Bet.pub 0.79745 3.36374 -0.94546 -1.01741 0.29 Vac.uli -0.08912 -1.17478 2.86624 0.87025 15.22 Dip.mon -0.82669 -0.44195 2.58579 -0.38459 3.24 Dic.sp 2.37743 -0.27373 -0.47099 -1.89036 40.50 Dic.fus 1.58267 -1.33770 -1.33563 1.47417 113.52 Dic.pol 0.86689 2.39519 -0.82064 -3.41534 6.06 Hyl.spl 2.66242 1.19669 1.48288 -0.69978 18.04 Ple.sch 1.64098 0.15607 0.30044 -0.26717 377.97 Pol.pil -0.56213 0.14009 0.25198 0.49177 0.61 Pol.jun 1.22244 -0.89173 0.61287 3.60066 13.85 Pol.com 1.01545 2.08388 0.06402 0.84199 0.71 Poh.nut -0.00712 1.09704 -0.82126 -1.59862 2.62 Pti.cil 0.48093 2.86420 -0.71801 -1.02698 14.01 Bar.lyc 0.58303 3.71792 -0.84212 -1.88837 3.19 Cla.arb -0.18554 -1.18973 0.68113 0.55399 255.05 Cla.ran -0.83427 -0.78085 0.90603 0.70057 388.71 Cla.ste -1.67768 0.98907 -0.83789 -0.60206 486.71 Cla.unc 0.97686 -1.70859 -1.68281 -2.26756 56.28 Cla.coc -0.27221 -0.76713 -0.63836 0.66927 2.79 Cla.cor 0.29068 -0.97039 0.50414 0.95738 6.22 Cla.gra 0.21778 -0.41879 0.06530 -0.31472 5.14 Cla.fim 0.00889 -0.23922 -0.26505 0.33123 3.96 Cla.cri 0.37774 -1.09161 -0.55627 0.23868 7.47 Cla.chl -0.91983 1.54955 -0.58109 -1.48643 1.16 Cla.bot 0.66438 2.19584 -0.90331 -0.91391 0.47 Cla.ama -0.96418 -0.98992 2.71458 0.52352 0.14 Cla.sp -1.12318 -0.15330 -0.69833 0.44040 0.52 Cet.eri 0.27163 -1.28867 -0.81682 -1.93935 3.60 Cet.isl -0.50158 2.22098 -1.16461 -1.89349 2.03 Cet.niv -1.67937 -3.67985 4.15644 3.18919 11.85 Nep.arc 2.18561 -0.82837 0.71958 5.81930 5.26 Ste.sp -0.78699 -2.01214 2.31212 2.03946 17.52 Pel.aph 0.45763 -0.34395 0.09916 1.34695 0.76 Ich.eri 0.04950 -1.97605 1.41509 2.10154 0.22 Cla.cer -1.21585 -2.30519 2.55186 3.41532 0.10 Cla.def 0.60517 -1.19771 -0.33388 0.22585 10.23 Cla.phy -1.53959 1.48574 -1.43209 -1.52387 0.80 Site scores: DCA1 DCA2 DCA3 DCA4 Totals 18 -0.1729 -0.2841 0.4775 0.2521 89.2 15 0.8539 -0.3360 0.0708 0.0924 89.8 24 1.2467 -0.1183 -0.1211 -0.8718 94.2 27 1.0675 0.4169 0.2897 -0.1758 125.6 23 0.4234 0.0112 0.2179 0.1265 90.5 19 0.0252 0.3600 -0.0263 -0.1168 81.3 22 1.0695 -0.3707 -0.4285 0.4145 109.8 16 0.7724 -0.5325 -0.2856 0.5269 88.5 28 1.6189 0.5482 0.2342 -0.3333 110.7 13 -0.2642 -0.6851 -0.3777 0.5003 101.9 14 0.6431 -0.9604 -0.6000 -0.2885 81.7 20 0.4504 -0.1666 0.1850 -0.1291 64.1 25 1.2501 -0.2248 0.0244 0.3741 94.1 7 -0.3910 -0.7618 0.8640 0.5557 103.4 5 -0.6407 -0.9427 0.9465 0.7769 94.8 6 -0.4523 -0.5529 0.3988 0.2781 110.9 3 -1.1043 0.2106 -0.0653 -0.0539 106.7 4 -0.9454 -0.5974 0.4639 0.4889 84.8 2 -1.1971 0.5691 -0.3246 -0.2522 119.1 9 -1.0983 0.7850 -0.5274 -0.4848 122.6 12 -0.8673 0.5621 -0.3254 -0.3217 119.8 10 -1.1842 0.7442 -0.4995 -0.3917 122.4 11 -0.4134 0.0260 0.0107 -0.0682 112.8 21 0.3210 1.2450 -0.2541 -0.5253 99.2 > plot(vare.dca) > ### the detrending rationale: > gaussresp <- function(x,u) exp(-(x-u)^2/2) > x <- seq(0,6,length=15) ## The gradient > u <- seq(-2,8,len=23) ## The optima > pack <- outer(x,u,gaussresp) > matplot(x, pack, type="l", main="Species packing") > opar <- par(mfrow=c(2,2)) > plot(scores(prcomp(pack)), asp=1, type="b", main="PCA") > plot(scores(decorana(pack, ira=1)), asp=1, type="b", main="CA") > plot(scores(decorana(pack)), asp=1, type="b", main="DCA") > plot(scores(cca(pack ~ x), dis="sites"), asp=1, type="b", main="CCA") > ### Let's add some noise: > noisy <- (0.5 + runif(length(pack)))*pack > par(mfrow=c(2,1)) > matplot(x, pack, type="l", main="Ideal model") > matplot(x, noisy, type="l", main="Noisy model") > par(mfrow=c(2,2)) > plot(scores(prcomp(noisy)), type="b", main="PCA", asp=1) > plot(scores(decorana(noisy, ira=1)), type="b", main="CA", asp=1) > plot(scores(decorana(noisy)), type="b", main="DCA", asp=1) > plot(scores(cca(noisy ~ x), dis="sites"), asp=1, type="b", main="CCA") > par(opar) > > > > graphics::par(get("par.postscript", env = .CheckExEnv)) > cleanEx(); ..nameEx <- "decostand" > > ### * decostand > > flush(stderr()); flush(stdout()) > > ### Name: decostand > ### Title: Standardizaton Methods for Community Ecology > ### Aliases: decostand wisconsin > ### Keywords: multivariate manip > > ### ** Examples > > data(varespec) > sptrans <- decostand(varespec, "max") > apply(sptrans, 2, max) Cal.vul Emp.nig Led.pal Vac.myr Vac.vit Pin.syl Des.fle Bet.pub Vac.uli Dip.mon 1 1 1 1 1 1 1 1 1 1 Dic.sp Dic.fus Dic.pol Hyl.spl Ple.sch Pol.pil Pol.jun Pol.com Poh.nut Pti.cil 1 1 1 1 1 1 1 1 1 1 Bar.lyc Cla.arb Cla.ran Cla.ste Cla.unc Cla.coc Cla.cor Cla.gra Cla.fim Cla.cri 1 1 1 1 1 1 1 1 1 1 Cla.chl Cla.bot Cla.ama Cla.sp Cet.eri Cet.isl Cet.niv Nep.arc Ste.sp Pel.aph 1 1 1 1 1 1 1 1 1 1 Ich.eri Cla.cer Cla.def Cla.phy 1 1 1 1 > sptrans <- wisconsin(varespec) > # Chi-square: Similar but not identical to Correspondence Analysis. > sptrans <- decostand(varespec, "chi.square") > plot(procrustes(rda(sptrans), cca(varespec))) > # Hellinger transformation (Legendre & Callagher 2001): > sptrans <- sqrt(decostand(varespec, "total")) > > > > cleanEx(); ..nameEx <- "deviance.cca" > > ### * deviance.cca > > flush(stderr()); flush(stdout()) > > ### Name: deviance.cca > ### Title: Statistics Resembling Deviance and AIC for Constrained > ### Ordination > ### Aliases: deviance.cca deviance.rda deviance.capscale extractAIC.cca > ### Keywords: multivariate models > > ### ** Examples > > # The deviance of correspondence analysis equals Chi-square > data(dune) > data(dune.env) > chisq.test(dune) Warning in chisq.test(dune) : Chi-squared approximation may be incorrect Pearson's Chi-squared test data: dune X-squared = 1448.956, df = 551, p-value < 2.2e-16 > deviance(cca(dune)) [1] 1448.956 > # Backward elimination from a complete model "dune ~ ." > ord <- cca(dune ~ ., dune.env) > ord Call: cca(formula = dune ~ A1 + Moisture + Management + Use + Manure, data = dune.env) Inertia Rank Total 2.1153 Constrained 1.5032 12 Unconstrained 0.6121 7 Inertia is mean squared contingency coefficient Some constraints were aliased because they were collinear (redundant) Eigenvalues for constrained axes: CCA1 CCA2 CCA3 CCA4 CCA5 CCA6 CCA7 CCA8 CCA9 CCA10 0.46713 0.34102 0.17606 0.15317 0.09528 0.07027 0.05887 0.04993 0.03183 0.02596 CCA11 CCA12 0.02282 0.01082 Eigenvalues for unconstrained axes: CA1 CA2 CA3 CA4 CA5 CA6 CA7 0.27237 0.10876 0.08975 0.06305 0.03489 0.02529 0.01798 > step(ord) Start: AIC= 86.86 dune ~ A1 + Moisture + Management + Use + Manure Df AIC - Use 2 86.711 86.857 - Management 2 87.470 - Manure 3 87.819 - A1 1 88.181 - Moisture 3 89.179 Step: AIC= 86.71 dune ~ A1 + Moisture + Management + Manure Df AIC - Manure 3 86.190 - Management 2 86.446 86.711 - Moisture 3 87.873 - A1 1 88.430 Step: AIC= 86.19 dune ~ A1 + Moisture + Management Df AIC 86.190 - Moisture 3 86.460 - A1 1 86.813 - Management 3 86.992 Call: cca(formula = dune ~ A1 + Moisture + Management, data = dune.env) Inertia Rank Total 2.1153 Constrained 1.1392 7 Unconstrained 0.9761 12 Inertia is mean squared contingency coefficient Eigenvalues for constrained axes: CCA1 CCA2 CCA3 CCA4 CCA5 CCA6 CCA7 0.44826 0.30014 0.14995 0.10733 0.05668 0.04335 0.03345 Eigenvalues for unconstrained axes: CA1 CA2 CA3 CA4 CA5 CA6 CA7 CA8 0.306366 0.131911 0.115157 0.109469 0.077242 0.075754 0.048714 0.037582 CA9 CA10 CA11 CA12 0.031058 0.021024 0.012542 0.009277 > # Stepwise selection (forward from an empty model "dune ~ 1") > step(cca(dune ~ 1, dune.env), scope = formula(ord)) Start: AIC= 87.66 dune ~ 1 Df AIC + Moisture 3 86.608 + Management 3 86.935 + A1 1 87.411 87.657 + Manure 4 88.832 + Use 2 89.134 Step: AIC= 86.61 dune ~ Moisture Df AIC 86.608 + Management 3 86.813 + A1 1 86.992 + Use 2 87.259 + Manure 4 87.342 - Moisture 3 87.657 Call: cca(formula = dune ~ Moisture, data = dune.env) Inertia Rank Total 2.1153 Constrained 0.6283 3 Unconstrained 1.4870 16 Inertia is mean squared contingency coefficient Eigenvalues for constrained axes: CCA1 CCA2 CCA3 0.4187 0.1330 0.0766 Eigenvalues for unconstrained axes: CA1 CA2 CA3 CA4 CA5 CA6 CA7 CA8 0.409782 0.225913 0.176062 0.123389 0.108171 0.090751 0.085878 0.060894 CA9 CA10 CA11 CA12 CA13 CA14 CA15 CA16 0.056606 0.046688 0.041926 0.020103 0.014335 0.009917 0.008505 0.008033 > # ANOVA for the added variable > anova(cca(dune ~ Moisture, dune.env)) Permutation test for cca under reduced model Model: cca(formula = dune ~ Moisture, data = dune.env) Df Chisq F N.Perm Pr(>F) Model 3 0.6283 2.2536 200 < 0.005 *** Residual 16 1.4870 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 > # ANOVA for the next candidate variable that was not added > anova(cca(dune ~ Condition(Moisture) + Management, dune.env), perm.max=1000) Permutation test for cca under reduced model Model: cca(formula = dune ~ Condition(Moisture) + Management, data = dune.env) Df Chisq F N.Perm Pr(>F) Model 3 0.3741 1.4565 1000 0.051 . Residual 13 1.1129 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 > > > > cleanEx(); ..nameEx <- "distconnected" > > ### * distconnected > > flush(stderr()); flush(stdout()) > > ### Name: distconnected > ### Title: Connectedness and Minimum Spanning Tree for Dissimilarities > ### Aliases: distconnected no.shared spantree > ### Keywords: multivariate > > ### ** Examples > > ## There are no disconnected data in vegan, and the following uses an > ## extremely low threshold limit for connectedness. This is for > ## illustration only, and not a recommended practice. > data(dune) > dis <- vegdist(dune) > ord <- cmdscale(dis) ## metric MDS > gr <- distconnected(dis, toolong=0.4) Connectivity of distance matrix with threshold dissimilarity 0.4 Data are disconnected: 6 groups Groups sizes 1 2 3 4 5 6 11 4 1 1 2 1 > tr <- spantree(dis, toolong=0.4) > ordiplot(ord, type="n") Warning in ordiplot(ord, type = "n") : Species scores not available > ordispantree(ord, tr, col="red", lwd=2) > points(ord, cex=1.3, pch=21, col=1, bg = gr) > # Make sites with no shared species as NA in Manhattan dissimilarities > dis <- vegdist(dune, "manhattan") > is.na(dis) <- no.shared(dune) > > > > cleanEx(); ..nameEx <- "diversity" > > ### * diversity > > flush(stderr()); flush(stdout()) > > ### Name: diversity > ### Title: Ecological Diversity Indices and Rarefaction Species Richness > ### Aliases: diversity rarefy renyi fisher.alpha specnumber > ### Keywords: univar > > ### ** Examples > > data(BCI) > H <- diversity(BCI) > simp <- diversity(BCI, "simpson") > invsimp <- diversity(BCI, "inv") > r.2 <- rarefy(BCI, 2) > alpha <- fisher.alpha(BCI) > pairs(cbind(H, simp, invsimp, r.2, alpha), pch="+", col="blue") > ## Species richness (S) and Pielou's evenness (J): > S <- specnumber(BCI) ## rowSums(BCI > 0) does the same... > J <- H/log(S) > > > > cleanEx(); ..nameEx <- "dune" > > ### * dune > > flush(stderr()); flush(stdout()) > > ### Name: dune > ### Title: Vegetation and Environment in Dutch Dune Meadows. > ### Aliases: dune dune.env > ### Keywords: datasets > > ### ** Examples > > data(dune) > > > > cleanEx(); ..nameEx <- "envfit" > > ### * envfit > > flush(stderr()); flush(stdout()) > > ### Name: envfit > ### Title: Fits an Environmental Vector or Factor onto an Ordination > ### Aliases: envfit envfit.default envfit.formula vectorfit factorfit > ### plot.envfit print.envfit print.factorfit print.vectorfit > ### scores.envfit > ### Keywords: multivariate aplot htest > > ### ** Examples > > data(varespec) > data(varechem) > library(MASS) > ord <- metaMDS(varespec) Square root transformation Wisconsin double standardization Run 0 stress 18.44915 Run 1 stress 18.45800 ... rmse 0.05246287 max residual 0.1748373 Run 2 stress 24.19514 Run 3 stress 19.69805 Run 4 stress 19.74406 Run 5 stress 18.43204 ... New best solution ... rmse 0.00448445 max residual 0.01722444 Run 6 stress 19.48415 Run 7 stress 19.48414 Run 8 stress 20.57245 Run 9 stress 21.00656 Run 10 stress 20.06919 Run 11 stress 18.52397 Run 12 stress 21.37384 Run 13 stress 19.5049 Run 14 stress 21.67150 Run 15 stress 22.65719 Run 16 stress 21.0961 Run 17 stress 18.25659 ... New best solution ... rmse 0.04191616 max residual 0.1532558 Run 18 stress 19.48413 Run 19 stress 21.77541 Run 20 stress 22.24925 > (fit <- envfit(ord, varechem, perm = 1000)) ***VECTORS NMDS1 NMDS2 r2 Pr(>r) N -0.057349 -0.998354 0.2537 0.045 * P 0.619854 0.784717 0.1938 0.102 K 0.766510 0.642232 0.1810 0.142 Ca 0.685179 0.728375 0.4119 0.007 ** Mg 0.632611 0.774470 0.4272 0.003 ** S 0.191631 0.981467 0.1752 0.139 Al -0.871518 0.490363 0.5269 <0.001 *** Fe -0.936058 0.351845 0.4451 0.001 *** Mn 0.798539 -0.601944 0.5230 <0.001 *** Zn 0.617746 0.786378 0.1879 0.124 Mo -0.902967 0.429710 0.0609 0.537 Baresoil 0.924867 -0.380290 0.2508 0.039 * Humdepth 0.932733 -0.360568 0.5202 0.001 *** pH -0.647704 0.761892 0.2309 0.059 . --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 P values based on 1000 permutations. > scores(fit, "vectors") NMDS1 NMDS2 N -0.02888867 -0.5029042 P 0.27288032 0.3454586 K 0.32607474 0.2732065 Ca 0.43973962 0.4674626 Mg 0.41345930 0.5061752 S 0.08021282 0.4108214 Al -0.63261567 0.3559438 Fe -0.62449816 0.2347361 Mn 0.57751792 -0.4353369 Zn 0.26779998 0.3409037 Mo -0.22279874 0.1060270 Baresoil 0.46316302 -0.1904451 Humdepth 0.67270911 -0.2600505 pH -0.31126667 0.3661418 > plot(ord) > plot(fit) > plot(fit, p.max = 0.05, col = "red") > ## Adding fitted arrows to CCA. We use "lc" scores, and hope > ## that arrows are scaled similarly in cca and envfit plots > ord <- cca(varespec ~ Al + P + K, varechem) > plot(ord, type="p") > fit <- envfit(ord, varechem, perm = 1000, display = "lc") > plot(fit, p.max = 0.05, col = "red") > ## Class variables, formula interface, and displaying the > ## inter-class variability with `ordispider' > data(dune) > data(dune.env) > attach(dune.env) > ord <- cca(dune) > fit <- envfit(ord ~ Moisture + A1, dune.env) > plot(ord, type = "n") > ordispider(ord, Moisture, col="skyblue") > points(ord, display = "sites", col = as.numeric(Moisture), pch=16) > plot(fit, cex=1.2, axis=TRUE) > > > > cleanEx(); ..nameEx <- "fisherfit" > > ### * fisherfit > > flush(stderr()); flush(stdout()) > > ### Name: fisherfit > ### Title: Fit Fisher's Logseries and Preston's Lognormal Model to > ### Abundance Data > ### Aliases: fisherfit as.fisher plot.fisherfit print.fisherfit > ### profile.fisherfit confint.fisherfit plot.profile.fisherfit prestonfit > ### prestondistr as.preston plot.prestonfit lines.prestonfit > ### print.prestonfit veiledspec > ### Keywords: univar distribution > > ### ** Examples > > data(BCI) > mod <- fisherfit(BCI[5,]) > mod Fisher log series model No. of species: 101 Estimate Std. Error alpha 37.964 4.6847 > plot(profile(mod)) > confint(mod) Loading required package: MASS 2.5 % 97.5 % 29.65932 48.12558 > # prestonfit seems to need large samples > mod.oct <- prestonfit(colSums(BCI)) > mod.ll <- prestondistr(colSums(BCI)) > mod.oct Preston lognormal model Method: Poisson fit to octaves No. of species: 225 mode width S0 4.682037 3.232425 29.886591 Frequencies by Octave 0 1 2 3 4 5 6 7 Observed 19.00000 13.0000 14.00000 18.00000 30.00000 34.00000 31.00000 26.00000 Fitted 10.46872 15.6214 21.18270 26.10223 29.22866 29.74235 27.50278 23.11070 8 9 10 11 Observed 18.00000 13.00000 7.000000 2.000000 Fitted 17.64755 12.24591 7.722047 4.424956 > mod.ll Preston lognormal model Method: maximized likelihood to log2 abundances No. of species: 225 mode width S0 4.365002 2.753531 33.458185 Frequencies by Octave 0 1 2 3 4 5 6 Observed 19.00000 13.00000 14.00000 18.00000 30.00000 34.00000 31.00000 Fitted 9.52392 15.85637 23.13724 29.58961 33.16552 32.58022 28.05054 7 8 9 10 11 Observed 26.00000 18.00000 13.000000 7.000000 2.000000 Fitted 21.16645 13.99829 8.113746 4.121808 1.835160 > plot(mod.oct) > lines(mod.ll, line.col="blue3") # Different > ## Smoothed density > den <- density(log2(colSums(BCI))) > lines(den$x, ncol(BCI)*den$y, lwd=2) # Fairly similar to mod.oct > ## Extrapolated richness > veiledspec(mod.oct) Extrapolated Observed Veiled 242.15571 225.00000 17.15571 > veiledspec(mod.ll) Extrapolated Observed Veiled 230.931018 225.000000 5.931018 > > > > cleanEx(); ..nameEx <- "goodness.cca" > > ### * goodness.cca > > flush(stderr()); flush(stdout()) > > ### Name: goondess.cca > ### Title: Diagnostic Tools for [Constrained] Ordination (CCA, RDA, DCA, > ### CA, PCA) > ### Aliases: goodness goodness.rda goodness.cca inertcomp spenvcor vif.cca > ### alias.cca > ### Keywords: multivariate > > ### ** Examples > > data(dune) > data(dune.env) > mod <- cca(dune ~ A1 + Management + Condition(Moisture), data=dune.env) > goodness(mod) CCA1 CCA2 CCA3 CCA4 Belper 0.41185412 0.4179432 0.4847618 0.4849622 Empnig 0.27089495 0.3132399 0.3153052 0.3154203 Junbuf 0.70439967 0.7226263 0.7228786 0.7257471 Junart 0.43923609 0.4492937 0.4871043 0.5224072 Airpra 0.36213737 0.3698100 0.3816619 0.3908018 Elepal 0.55132024 0.6099415 0.6193301 0.6259818 Rumace 0.44788204 0.5211145 0.7673956 0.7691199 Viclat 0.17824132 0.1784611 0.3762406 0.4279428 Brarut 0.15585567 0.1641095 0.1672797 0.2449864 Ranfla 0.68677962 0.6983001 0.7020461 0.7064850 Cirarv 0.29041563 0.3013655 0.3080671 0.3591280 Hyprad 0.31349648 0.3371809 0.3387669 0.3388716 Leoaut 0.54312496 0.5510319 0.6078931 0.6140593 Potpal 0.16338257 0.6836790 0.7390659 0.7963425 Poapra 0.40267189 0.4944813 0.5014516 0.5326546 Calcus 0.30771429 0.3143582 0.3308502 0.3518027 Tripra 0.37328840 0.4101104 0.6624199 0.6625703 Trirep 0.03048149 0.2115857 0.3300132 0.4207437 Antodo 0.24619147 0.2795001 0.3509172 0.3609709 Salrep 0.64788354 0.7264891 0.7276110 0.7639711 Achmil 0.36630013 0.3822685 0.3838616 0.4934158 Poatri 0.49694972 0.5409439 0.5468830 0.5594817 Chealb 0.23594716 0.2684323 0.2828928 0.2885321 Elyrep 0.25239595 0.2710266 0.2761491 0.2882666 Sagpro 0.27039747 0.3497634 0.3553109 0.3613746 Plalan 0.54969676 0.6084389 0.6802195 0.6826265 Agrsto 0.67247051 0.6724758 0.6779597 0.7773267 Lolper 0.48141171 0.5720410 0.5727299 0.6034007 Alogen 0.61547145 0.6966105 0.7042650 0.7212918 Brohor 0.33487622 0.3397416 0.3870032 0.5505037 > goodness(mod, summ = TRUE) Belper Empnig Junbuf Junart Airpra Elepal Rumace Viclat 0.4849622 0.3154203 0.7257471 0.5224072 0.3908018 0.6259818 0.7691199 0.4279428 Brarut Ranfla Cirarv Hyprad Leoaut Potpal Poapra Calcus 0.2449864 0.7064850 0.3591280 0.3388716 0.6140593 0.7963425 0.5326546 0.3518027 Tripra Trirep Antodo Salrep Achmil Poatri Chealb Elyrep 0.6625703 0.4207437 0.3609709 0.7639711 0.4934158 0.5594817 0.2885321 0.2882666 Sagpro Plalan Agrsto Lolper Alogen Brohor 0.3613746 0.6826265 0.7773267 0.6034007 0.7212918 0.5505037 > # Inertia components > inertcomp(mod, prop = TRUE) pCCA CCA CA Belper 0.40972447 0.07523776 0.5150378 Empnig 0.10361994 0.21180040 0.6845797 Junbuf 0.66622672 0.05952038 0.2742529 Junart 0.43439190 0.08801527 0.4775928 Airpra 0.06404726 0.32675457 0.6091982 Elepal 0.53954819 0.08643366 0.3740182 Rumace 0.40125987 0.36786003 0.2308801 Viclat 0.12125433 0.30668844 0.5720572 Brarut 0.07222706 0.17275938 0.7550136 Ranfla 0.68509904 0.02138594 0.2935150 Cirarv 0.26649913 0.09262886 0.6408720 Hyprad 0.03889627 0.29997533 0.6611284 Leoaut 0.10895437 0.50510492 0.3859407 Potpal 0.16096277 0.63537969 0.2036575 Poapra 0.39408053 0.13857406 0.4673454 Calcus 0.29447422 0.05732850 0.6481973 Tripra 0.34544815 0.31712212 0.3374297 Trirep 0.02132183 0.39942191 0.5792563 Antodo 0.10259139 0.25837947 0.6390291 Salrep 0.12527838 0.63869277 0.2360289 Achmil 0.34271900 0.15069678 0.5065842 Poatri 0.05598349 0.50349824 0.4405183 Chealb 0.11064346 0.17788865 0.7114679 Elyrep 0.22234322 0.06592337 0.7117334 Sagpro 0.26050435 0.10087025 0.6386254 Plalan 0.51993753 0.16268893 0.3173735 Agrsto 0.55602406 0.22130269 0.2226733 Lolper 0.46273045 0.14067027 0.3965993 Alogen 0.34238968 0.37890210 0.2787082 Brohor 0.33046684 0.22003683 0.4494963 > inertcomp(mod, stat="d") pCCA CCA CA Belper 0.81483759 0.14962874 1.0242789 Empnig 2.18604651 4.46830527 14.4424224 Junbuf 2.60346194 0.23259205 1.0717177 Junart 1.36667524 0.27691192 1.5025932 Airpra 0.91341031 4.66001211 8.6880830 Elepal 2.18604651 0.35019669 1.5153810 Rumace 1.09684464 1.00554611 0.6311112 Viclat 0.84063811 2.12622500 3.9659871 Brarut 0.04517898 0.10806328 0.4722710 Ranfla 2.18604651 0.06823926 0.9365617 Cirarv 3.79020979 1.31738817 9.1146243 Hyprad 0.35520990 2.73944513 6.0375798 Leoaut 0.03887246 0.18021004 0.1376949 Potpal 2.18604651 8.62913533 2.7658870 Poapra 0.20406096 0.07175578 0.2419987 Calcus 2.18604651 0.42558147 4.8119302 Tripra 1.74000000 1.59732360 1.6996117 Trirep 0.01215418 0.22768437 0.3301962 Antodo 0.31403667 0.79091068 1.9560957 Salrep 0.88898328 4.53220433 1.6748757 Achmil 0.74393575 0.32711556 1.0996359 Poatri 0.03136359 0.28207442 0.2467912 Chealb 2.18604651 3.51464840 14.0568809 Elyrep 0.51093664 0.15148951 1.6355375 Sagpro 0.51772816 0.20047024 1.2692085 Plalan 0.96463794 0.30183609 0.5888218 Agrsto 0.65154706 0.25932172 0.2609277 Lolper 0.43502729 0.13224850 0.3728553 Alogen 0.62026287 0.68640768 0.5048995 Brohor 0.82257902 0.54770300 1.1188603 > # vif.cca > vif.cca(mod) Moisture.L Moisture.Q Moisture.C A1 ManagementHF ManagementNM 1.504327 1.284489 1.347660 1.367328 2.238653 2.570972 ManagementSF 2.424444 > # Aliased constraints > mod <- cca(dune ~ ., dune.env) > mod Call: cca(formula = dune ~ A1 + Moisture + Management + Use + Manure, data = dune.env) Inertia Rank Total 2.1153 Constrained 1.5032 12 Unconstrained 0.6121 7 Inertia is mean squared contingency coefficient Some constraints were aliased because they were collinear (redundant) Eigenvalues for constrained axes: CCA1 CCA2 CCA3 CCA4 CCA5 CCA6 CCA7 CCA8 CCA9 CCA10 0.46713 0.34102 0.17606 0.15317 0.09528 0.07027 0.05887 0.04993 0.03183 0.02596 CCA11 CCA12 0.02282 0.01082 Eigenvalues for unconstrained axes: CA1 CA2 CA3 CA4 CA5 CA6 CA7 0.27237 0.10876 0.08975 0.06305 0.03489 0.02529 0.01798 > vif.cca(mod) A1 Moisture.L Moisture.Q Moisture.C ManagementHF ManagementNM 3.208249e+00 2.934142e+00 3.072715e+00 4.225058e+00 6.914185e+00 7.737385e+31 ManagementSF Use.L Use.Q Manure.L Manure.Q Manure.C 1.337251e+01 2.667560e+00 3.089394e+00 3.345539e+31 2.600928e+31 8.476579e+30 Manure^4 1.401215e+30 > alias(mod) Model : dune ~ A1 + Moisture + Management + Use + Manure Complete : A1 Moisture.L Moisture.Q Moisture.C ManagementHF ManagementNM Manure^4 8.366600 ManagementSF Use.L Use.Q Manure.L Manure.Q Manure.C Manure^4 5.291503 -4.472136 2.645751 > with(dune.env, table(Management, Manure)) Manure Management 0 1 2 3 4 BF 0 2 1 0 0 HF 0 1 2 2 0 NM 6 0 0 0 0 SF 0 0 1 2 3 > > > > cleanEx(); ..nameEx <- "goodness.metaMDS" > > ### * goodness.metaMDS > > flush(stderr()); flush(stdout()) > > ### Name: goodness.metaMDS > ### Title: Goodness of Fit and Shepard Plot for Nonmetric Multidimensional > ### Scaling > ### Aliases: goodness.metaMDS stressplot > ### Keywords: multivariate > > ### ** Examples > > data(varespec) > mod <- metaMDS(varespec) Square root transformation Wisconsin double standardization Loading required package: MASS Run 0 stress 18.44915 Run 1 stress 18.45800 ... rmse 0.05246287 max residual 0.1748373 Run 2 stress 24.19514 Run 3 stress 19.69805 Run 4 stress 19.74406 Run 5 stress 18.43204 ... New best solution ... rmse 0.00448445 max residual 0.01722444 Run 6 stress 19.48415 Run 7 stress 19.48414 Run 8 stress 20.57245 Run 9 stress 21.00656 Run 10 stress 20.06919 Run 11 stress 18.52397 Run 12 stress 21.37384 Run 13 stress 19.5049 Run 14 stress 21.67150 Run 15 stress 22.65719 Run 16 stress 21.0961 Run 17 stress 18.25659 ... New best solution ... rmse 0.04191616 max residual 0.1532558 Run 18 stress 19.48413 Run 19 stress 21.77541 Run 20 stress 22.24925 > stressplot(mod) Square root transformation Wisconsin double standardization > gof <- goodness(mod) Square root transformation Wisconsin double standardization > gof 18 15 24 27 23 19 22 16 2.984496 3.514129 4.188692 4.598210 4.002773 3.441293 3.294609 3.051738 28 13 14 20 25 7 5 6 3.060659 2.993482 3.526967 2.621578 3.829350 2.982187 3.370348 2.226679 3 4 2 9 12 10 11 21 3.561311 3.506032 6.577579 3.268019 3.502878 2.957059 5.167546 4.601390 > plot(mod, display = "sites", type = "n") > points(mod, display = "sites", cex = gof/2) > > > > cleanEx(); ..nameEx <- "humpfit" > > ### * humpfit > > flush(stderr()); flush(stdout()) > > ### Name: humpfit > ### Title: No-interaction Model for Hump-backed Species Richness vs. > ### Biomass > ### Aliases: humpfit print.humpfit summary.humpfit print.summary.humpfit > ### lines.humpfit plot.humpfit points.humpfit predict.humpfit > ### profile.humpfit > ### Keywords: models regression nonlinear > > ### ** Examples > > ## > ## Data approximated from Al-Mufti et al. (1977) > ## > mass <- c(140,230,310,310,400,510,610,670,860,900,1050,1160,1900,2480) > spno <- c(1, 4, 3, 9, 18, 30, 20, 14, 3, 2, 3, 2, 5, 2) > sol <- humpfit(mass, spno) Warning in log(x) : NaNs produced Warning in log(x) : NaNs produced Warning in dpois(x, lambda, log) : NaNs produced Warning: NA/Inf replaced by maximum positive value Warning in log(x) : NaNs produced Warning in log(x) : NaNs produced Warning in dpois(x, lambda, log) : NaNs produced Warning: NA/Inf replaced by maximum positive value Warning in log(x) : NaNs produced Warning in log(x) : NaNs produced Warning in dpois(x, lambda, log) : NaNs produced Warning: NA/Inf replaced by maximum positive value > summary(sol) # Almost infinite alpha... Hump-backed Null model of richness vs. productivity Family: poisson Link function: Fisher diversity Coefficients: Estimate Std. Error hump 5.3766e+02 3.3547e+01 scale 1.8394e+01 1.7470e+00 alpha 4.3952e+06 1.2719e+07 Dispersion parameter for poisson family taken to be 1 Deviance 41.44823 with 11 residual degrees of freedom AIC: 96.37776 BIC: 98.29494 Correlation of Coefficients: hump scale scale -0.21 alpha 0.02 -0.05 Diagnostics from nlm: Number of iterations: 75, code: 1 > plot(sol) > # confint is in MASS, and impicitly calls profile.humpfit. > # Parameter 3 (alpha) is too extreme for profile and confint, and we > # must use only "hump" and "scale". > library(MASS) > plot(profile(sol, parm=1:2)) > confint(sol, parm=c(1,2)) Waiting for profiling to be done... 2.5 % 97.5 % hump 494.13821 607.26013 scale 15.17641 22.02865 > > > > cleanEx(); ..nameEx <- "make.cepnames" > > ### * make.cepnames > > flush(stderr()); flush(stdout()) > > ### Name: make.cepnames > ### Title: Abbreviates a Botanical or Zoological Latin Name into an > ### Eight-character Name > ### Aliases: make.cepnames > ### Keywords: character > > ### ** Examples > > make.cepnames(c("Aa maderoi", "Poa sp.", "Cladina rangiferina", + "Cladonia cornuta", "Cladonia cornuta var. groenlandica", + "Cladonia rangiformis", "Bryoerythrophyllum")) [1] "Aamade" "Poasp" "Cladrang" "Cladcorn" "Cladgroe" [6] "Cladrang.1" "Bryrythr" > data(BCI) > colnames(BCI) <- make.cepnames(colnames(BCI)) > > > > cleanEx(); ..nameEx <- "mantel" > > ### * mantel > > flush(stderr()); flush(stdout()) > > ### Name: mantel > ### Title: Mantel and Partial Mantel Tests for Dissimilarity Matrices > ### Aliases: mantel mantel.partial print.mantel > ### Keywords: multivariate htest > > ### ** Examples > > ## Is vegetation related to environment? > data(varespec) > data(varechem) > veg.dist <- vegdist(varespec) # Bray-Curtis > env.dist <- vegdist(scale(varechem), "euclid") > mantel(veg.dist, env.dist) Mantel statistic based on Pearson's product-moment correlation Call: mantel(xdis = veg.dist, ydis = env.dist) Mantel statistic r: 0.3047 Significance: < 0.001 Empirical upper confidence limits of r: 90% 95% 97.5% 99% 0.107 0.145 0.169 0.200 Based on 1000 permutations > mantel(veg.dist, env.dist, method="spear") Mantel statistic based on Spearman's rank correlation rho Call: mantel(xdis = veg.dist, ydis = env.dist, method = "spear") Mantel statistic r: 0.2838 Significance: < 0.001 Empirical upper confidence limits of r: 90% 95% 97.5% 99% 0.108 0.141 0.169 0.196 Based on 1000 permutations > > > > cleanEx(); ..nameEx <- "metaMDS" > > ### * metaMDS > > flush(stderr()); flush(stdout()) > > ### Name: metaMDS > ### Title: Nonmetric Multidimensional Scaling with Stable Solution from > ### Random Starts, Axis Scaling and Species Scores > ### Aliases: metaMDS metaMDSdist metaMDSiter metaMDSredist initMDS postMDS > ### print.metaMDS plot.metaMDS points.metaMDS text.metaMDS scores.metaMDS > ### Keywords: multivariate > > ### ** Examples > > ## The recommended way of running NMDS (Minchin 1987) > ## > data(dune) > library(MASS) ## isoMDS > # NMDS > sol <- metaMDS(dune) Run 0 stress 12.05894 Run 1 stress 18.21960 Run 2 stress 18.97837 Run 3 stress 18.57544 Run 4 stress 19.42521 Run 5 stress 12.04546 ... New best solution ... rmse 0.003139708 max residual 0.01078196 Run 6 stress 18.91766 Run 7 stress 12.04548 ... rmse 0.0001744095 max residual 0.0004460873 *** Solution reached > sol Call: metaMDS(comm = dune) Nonmetric Multidimensional Scaling using isoMDS (MASS package) Data: dune Distance: bray Dimensions: 2 Stress: 12.04546 Two convergent solutions found after 7 tries Score scaling: centring, PC rotation, halfchange scaling > plot(sol, type="t") > > > > cleanEx(); ..nameEx <- "ordihull" > > ### * ordihull > > flush(stderr()); flush(stdout()) > > ### Name: ordihull > ### Title: Add Graphical Items to Ordination Diagrams > ### Aliases: ordihull ordiarrows ordisegments ordigrid ordispider > ### ordiellipse ordicluster ordispantree weights.cca weights.rda > ### weights.decorana > ### Keywords: aplot > > ### ** Examples > > data(dune) > data(dune.env) > mod <- cca(dune ~ Moisture, dune.env) > attach(dune.env) > plot(mod, type="n") > ordihull(mod, Moisture) > ordispider(mod, col="red") > plot(mod, type = "p", display="sites") > ordicluster(mod, hclust(vegdist(dune)), prune=3, col = "blue") > # The following is not executed automatically because it needs > # a non-standard library `ellipse'. > ## Not run: ordiellipse(mod, Moisture, kind="se", level=0.95, lwd=2, col="blue") > > > > cleanEx(); ..nameEx <- "ordiplot" > > ### * ordiplot > > flush(stderr()); flush(stdout()) > > ### Name: ordiplot > ### Title: Alternative plot and identify Functions for Ordination > ### Aliases: ordiplot identify.ordiplot scores.ordiplot points.ordiplot > ### text.ordiplot > ### Keywords: hplot iplot aplot > > ### ** Examples > > # Draw a cute NMDS plot from a non-vegan ordinatin (isoMDS). > # Function metaMDS would be an easier alternative. > data(dune) > dune.dis <- vegdist(wisconsin(dune)) > library(MASS) > dune.mds <- isoMDS(dune.dis) initial value 17.440604 iter 5 value 11.776556 iter 10 value 11.603233 iter 10 value 11.596516 final value 11.562320 converged > dune.mds <- postMDS(dune.mds, dune.dis) > dune.mds$species <- wascores(dune.mds$points, dune, expand = TRUE) > fig <- ordiplot(dune.mds, type = "none") > points(fig, "sites", pch=21, col="red", bg="yellow") > text(fig, "species", col="blue", cex=0.9) > # A quick plot of the previous. > # identify is not run automatically because it needs user interaction: > ## Not run: fig <- ordiplot(dune.mds) > ## Not run: identify(fig, "spec") > > > > cleanEx(); ..nameEx <- "ordiplot3d" > > ### * ordiplot3d > > flush(stderr()); flush(stdout()) > > ### Name: ordiplot3d > ### Title: Three-Dimensional and Dynamic Ordination Graphics > ### Aliases: ordiplot3d ordirgl orglpoints orgltext orglsegments orglspider > ### Keywords: hplot dynamic > > ### ** Examples > > ## Examples are not run, because they need non-standard packages > ## 'scatterplot3d' and 'rgl' (and the latter needs user interaction). > ##### > #### Default 'ordiplot3d' > ## Not run: data(dune) > ## Not run: data(dune.env) > ## Not run: ord <- cca(dune ~ A1 + Moisture, dune.env) > ## Not run: ordiplot3d(ord) > #### A boxed 'pin' version > ## Not run: ordiplot3d(ord, type = "h") > #### More user control > ## Not run: pl <- ordiplot3d(ord, angle=15, type="n") > ## Not run: points(pl, "points", pch=16, col="red", cex = 0.7) > #### identify(pl, "arrows", col="blue") would put labels in better positions > ## Not run: text(pl, "arrows", col="blue", pos=3) > ## Not run: text(pl, "centroids", col="blue", pos=1, cex = 1.2) > #### ordirgl > ## Not run: ordirgl(ord, size=2) > ## Not run: ordirgl(ord, display = "species", type = "t") > ## Not run: rgl.quit() ## Safe with me, but may crash > > > > cleanEx(); ..nameEx <- "ordisurf" > > ### * ordisurf > > flush(stderr()); flush(stdout()) > > ### Name: ordisurf > ### Title: Smooths Variables and Plots Contours on Ordination. > ### Aliases: ordisurf > ### Keywords: multivariate aplot > > ### ** Examples > > ## The examples are not run by `example(ordisurf)' because they need > ## libraries `mgcv' and `akima' which may not exist in every system. > ## Not run: data(varespec) > ## Not run: data(varechem) > ## Not run: library(MASS) > ## Not run: vare.dist <- vegdist(varespec) > ## Not run: vare.mds <- isoMDS(vare.dist) > ## Not run: attach(varespec) > ## Not run: attach(varechem) > ## Not run: ordisurf(vare.mds, Baresoil, xlab="Dim1", ylab="Dim2") > ## Total cover of reindeer lichens > ## Not run: ordisurf(vare.mds, Cla.ste+Cla.arb+Cla.ran, xlab="Dim1", ylab="Dim2") > > > > cleanEx(); ..nameEx <- "plot.cca" > > ### * plot.cca > > flush(stderr()); flush(stdout()) > > ### Name: plot.cca > ### Title: Plot or Extract Results of Constrained Correspondence Analysis > ### or Redundancy Analysis > ### Aliases: plot.cca text.cca points.cca scores.cca > ### Keywords: hplot aplot > > ### ** Examples > > data(dune) > data(dune.env) > mod <- cca(dune ~ A1 + Moisture + Management, dune.env) > plot(mod, type="n") > text(mod, dis="cn", arrow = 2) > points(mod, pch=21, col="red", bg="yellow", cex=1.2) > text(mod, "species", col="blue", cex=0.8) > > > > cleanEx(); ..nameEx <- "predict.cca" > > ### * predict.cca > > flush(stderr()); flush(stdout()) > > ### Name: predict.cca > ### Title: Prediction Tools for [Constrained] Ordination (CCA, RDA, DCA, > ### CA, PCA) > ### Aliases: fitted.cca fitted.rda residuals.cca residuals.rda predict.cca > ### predict.rda predict.decorana coef.cca coef.rda calibrate.cca > ### Keywords: multivariate > > ### ** Examples > > data(dune) > data(dune.env) > mod <- cca(dune ~ A1 + Management + Condition(Moisture), data=dune.env) > # Definition of the concepts 'fitted' and 'residuals' > mod Call: cca(formula = dune ~ A1 + Management + Condition(Moisture), data = dune.env) Inertia Rank Total 2.1153 Conditional 0.6283 3 Constrained 0.5109 4 Unconstrained 0.9761 12 Inertia is mean squared contingency coefficient Eigenvalues for constrained axes: CCA1 CCA2 CCA3 CCA4 0.24932 0.12090 0.08160 0.05904 Eigenvalues for unconstrained axes: CA1 CA2 CA3 CA4 CA5 CA6 CA7 CA8 0.306366 0.131911 0.115157 0.109469 0.077242 0.075754 0.048714 0.037582 CA9 CA10 CA11 CA12 0.031058 0.021024 0.012542 0.009277 > cca(fitted(mod)) Call: cca(X = fitted(mod)) Inertia Rank Total 0.5109 Unconstrained 0.5109 4 Inertia is mean squared contingency coefficient Eigenvalues for unconstrained axes: CA1 CA2 CA3 CA4 0.24932 0.12090 0.08160 0.05904 > cca(residuals(mod)) Call: cca(X = residuals(mod)) Inertia Rank Total 0.9761 Unconstrained 0.9761 12 Inertia is mean squared contingency coefficient Eigenvalues for unconstrained axes: CA1 CA2 CA3 CA4 CA5 CA6 CA7 CA8 0.306366 0.131911 0.115157 0.109469 0.077242 0.075754 0.048714 0.037582 CA9 CA10 CA11 CA12 0.031058 0.021024 0.012542 0.009277 > # Remove rare species (freq==1) from 'cca' and find their scores > # 'passively'. > freq <- specnumber(dune, MARGIN=2) > freq Belper Empnig Junbuf Junart Airpra Elepal Rumace Viclat Brarut Ranfla Cirarv 6 1 4 5 2 5 5 3 15 6 1 Hyprad Leoaut Potpal Poapra Calcus Tripra Trirep Antodo Salrep Achmil Poatri 3 18 2 14 3 3 16 6 3 7 13 Chealb Elyrep Sagpro Plalan Agrsto Lolper Alogen Brohor 1 6 7 7 10 12 8 5 > mod <- cca(dune[, freq>1] ~ A1 + Management + Condition(Moisture), dune.env) > predict(mod, type="sp", newdata=dune[, freq==1], scaling=2) CCA1 CCA2 CCA3 CCA4 Empnig -1.8771953 0.9904299 0.2446222 -0.04858656 Cirarv 0.5945146 0.3714228 0.2862647 -0.88373727 Chealb 1.5737337 0.7842538 -0.5503660 -0.35108333 > # New sites > predict(mod, type="lc", new=data.frame(A1 = 3, Management="NM", Moisture="2"), scal=2) CCA1 CCA2 CCA3 CCA4 1 -0.4015781 1.294107 0.2743152 1.313303 > # Calibration and residual plot > mod <- cca(dune ~ A1 + Moisture, dune.env) > pred <- calibrate.cca(mod) > pred A1 Moisture.L Moisture.Q Moisture.C 2 4.0510042 -0.47341146 -0.36986691 0.474939409 13 4.9034218 0.47069541 -0.54378271 -0.118643453 4 4.5398659 0.03192745 -1.12417368 0.932223234 16 7.9892176 0.96421599 0.46793089 0.373647014 6 5.1962100 -0.91316862 1.11354235 -0.804453944 1 2.2630533 -0.62633470 -0.20456759 0.220761764 8 5.0208369 0.43886340 0.08169514 0.132995916 5 5.0409406 -0.84235946 0.43000738 -0.291599200 17 0.9218684 -0.15822891 0.14593271 1.189161582 15 10.7829689 0.69208513 0.82190786 0.237311062 10 4.0411356 -0.65472729 0.02832164 0.558402684 11 2.8280051 -0.45762457 0.63079135 -0.089977975 9 4.2663219 0.10720486 -0.34067849 -0.675151598 18 3.1680733 -0.41737900 1.03352732 -0.236938282 3 4.2752294 -0.07214500 -0.60797514 0.303213289 20 4.7876770 1.00324330 1.49898460 0.009202396 14 11.6455841 0.60920550 0.78341426 0.532852308 19 -1.2003506 0.57033354 0.72777285 0.509955590 12 5.1204137 0.36328912 -0.69118581 -0.665622948 7 4.2452549 -0.76452556 0.60464291 -0.484842066 > with(dune.env, plot(A1, pred[,"A1"] - A1, ylab="Prediction Error")) > abline(h=0) > > > > cleanEx(); ..nameEx <- "procrustes" > > ### * procrustes > > flush(stderr()); flush(stdout()) > > ### Name: procrustes > ### Title: Procrustes Rotation of Two Configurations > ### Aliases: procrustes print.procrustes summary.procrustes > ### print.summary.procrustes plot.procrustes points.procrustes > ### lines.procrustes residuals.procrustes fitted.procrustes protest > ### print.protest > ### Keywords: multivariate htest > > ### ** Examples > > data(varespec) > vare.dist <- vegdist(wisconsin(varespec)) > library(MASS) ## isoMDS > mds.null <- isoMDS(vare.dist, tol=1e-7) initial value 27.004018 iter 5 value 19.627798 iter 10 value 19.080657 iter 15 value 18.587495 iter 20 value 18.075166 iter 25 value 17.922314 iter 30 value 17.858977 iter 35 value 17.823041 iter 40 value 17.816456 iter 45 value 17.812079 iter 50 value 17.811040 final value 17.811040 stopped after 50 iterations > mds.alt <- isoMDS(vare.dist, initMDS(vare.dist), maxit=200, tol=1e-7) initial value 40.946864 iter 5 value 35.233817 iter 10 value 29.213576 iter 15 value 27.267129 iter 20 value 26.789268 iter 25 value 26.326361 iter 30 value 26.022929 iter 35 value 25.583087 iter 40 value 24.798014 iter 45 value 24.186366 iter 50 value 22.970805 iter 55 value 22.791064 iter 60 value 22.650504 iter 65 value 22.192285 iter 70 value 22.042446 iter 75 value 22.016123 iter 80 value 22.006493 iter 85 value 22.003260 iter 90 value 22.002696 iter 95 value 22.002568 final value 22.002559 converged > vare.proc <- procrustes(mds.alt, mds.null) > vare.proc Call: procrustes(X = mds.alt, Y = mds.null) Procrustes sum of squares: 476.9 > summary(vare.proc) Call: procrustes(X = mds.alt, Y = mds.null) Number of objects: 24 Number of dimensions: 2 Procrustes sum of squares: 476.9 Procrustes root mean squared error: 4.458 Quantiles of Procrustes errors: Min 1Q Median 3Q Max 0.4414805 1.4921114 2.0623186 4.1475454 13.2852587 > plot(vare.proc) > plot(vare.proc, kind=2) > residuals(vare.proc) 18 15 24 27 23 19 22 1.9188822 0.7545389 7.8149973 3.8711767 2.3330069 0.8367255 1.9704564 16 28 13 14 20 25 7 1.3378486 7.4734078 1.9821648 1.2580153 0.4414805 2.3028258 3.4903312 5 6 3 4 2 9 12 5.6982274 1.5244639 1.9559438 4.9766513 13.2852587 1.8906924 1.3950539 10 11 21 2.1424725 3.4187558 6.6343849 > > > > cleanEx(); ..nameEx <- "radfit" > > ### * radfit > > flush(stderr()); flush(stdout()) > > ### Name: radfit > ### Title: Rank - Abundance or Dominance / Diversity Models > ### Aliases: radfit radfit.default radfit.data.frame AIC.radfit as.rad > ### coef.radfit fitted.radfit lines.radline plot.radfit.frame plot.radfit > ### plot.radline plot.rad points.radline print.radfit.frame print.radfit > ### print.radline rad.preempt rad.lognormal rad.veil rad.zipf > ### rad.zipfbrot > ### Keywords: univar distribution > > ### ** Examples > > data(BCI) > mod <- rad.veil(BCI[1,]) > mod RAD model: Veil Log-Normal Family: poisson No. of species: 93 Total abundance: 448 log.mu log.sigma veil Deviance AIC BIC 0.9603092 1.0678903 0.9387607 23.0642419 304.9744085 312.5722070 > plot(mod) > mod <- radfit(BCI[1,]) > plot(mod) > # Take a subset of BCI to save time and nerves > mod <- radfit(BCI[2:5,]) > mod Deviance for RAD models: 2 3 4 5 Preemption 29.5066 58.9295 39.7817 76.3108 Lognormal 18.8511 29.2719 16.6588 17.0775 Veiled.LN 15.8990 22.9190 13.3208 8.3445 Zipf 48.4277 50.1262 47.9108 30.9358 Mandelbrot 4.7586 5.7342 5.5665 10.5733 > plot(mod, pch=".") Loading required package: lattice > > > > cleanEx(); ..nameEx <- "rankindex" > > ### * rankindex > > flush(stderr()); flush(stdout()) > > ### Name: rankindex > ### Title: Compares Dissimilarity Indices for Gradient Detection > ### Aliases: rankindex > ### Keywords: multivariate > > ### ** Examples > > data(varespec) > data(varechem) > ## The next scales all environmental variables to unit variance. > ## Some would use PCA transformation. > rankindex(scale(varechem), varespec) euc man gow bra kul 0.2396330 0.2735087 0.2288358 0.2837910 0.2839834 > rankindex(scale(varechem), wisconsin(varespec)) euc man gow bra kul 0.4200990 0.4215642 0.3708606 0.4215642 0.4215642 > > > > cleanEx(); ..nameEx <- "read.cep" > > ### * read.cep > > flush(stderr()); flush(stdout()) > > ### Name: read.cep > ### Title: Reads a CEP (Canoco) data file > ### Aliases: read.cep > ### Keywords: IO file > > ### ** Examples > > ## Provided that you have the file `dune.spe' > ## Not run: theclassic <- read.cep("dune.spe", force=T) > > > > cleanEx(); ..nameEx <- "scores" > > ### * scores > > flush(stderr()); flush(stdout()) > > ### Name: scores > ### Title: Get Species or Site Scores from an Ordination > ### Aliases: scores scores.default > ### Keywords: multivariate > > ### ** Examples > > data(varespec) > vare.pca <- prcomp(varespec) > scores(vare.pca, choices=c(1,2)) PC1 PC2 18 -10.7847878 18.7094315 15 -27.8036826 -11.7414745 24 -25.6919559 -14.5399684 27 -31.7820166 -31.2216800 23 -19.6315869 -2.5541193 19 -0.2413294 -11.4974077 22 -26.6771373 -12.3140897 16 -21.9230366 0.4449159 28 -39.6083051 -41.8877392 13 -4.0664328 20.4191153 14 -18.4416245 5.4406988 20 -17.3999191 2.3653380 25 -25.1673547 -13.2508067 7 -11.4065430 41.7356300 5 -8.4243752 45.3805255 6 -2.0759474 36.9311222 3 39.8617580 8.0590041 4 13.1065901 12.8377217 2 57.6827011 -4.8983565 9 63.3138332 -22.4481549 12 44.1073111 -10.1653935 10 64.9418975 -16.7633564 11 11.5313633 3.9720890 21 -3.4194194 -3.0130455 > > > > cleanEx(); ..nameEx <- "specaccum" > > ### * specaccum > > flush(stderr()); flush(stdout()) > > ### Name: specaccum > ### Title: Species Accumulation Curves > ### Aliases: specaccum print.specaccum summary.specaccum plot.specaccum > ### boxplot.specaccum > ### Keywords: univar > > ### ** Examples > > data(BCI) > sp1 <- specaccum(BCI) Warning in cor(x, y, na.method, method == "kendall") : the standard deviation is zero > sp2 <- specaccum(BCI, "random") > sp2 Species Accumulation Curve Accumulation method: random, with 100 permutations Call: specaccum(comm = BCI, method = "random") Sites 1.00000 2.000000 3.000000 4.000000 5.000000 6.000000 Richness 91.34000 121.010000 138.720000 150.540000 159.540000 166.500000 sd 7.21001 6.928925 6.748109 6.509387 6.125654 5.934831 Sites 7.000000 8.000000 9.000000 10.000000 11.000000 12.000000 Richness 171.820000 176.180000 179.790000 182.730000 185.950000 188.590000 sd 5.603714 5.182293 5.129229 5.175418 4.719131 4.521766 Sites 13.000000 14.000000 15.000000 16.000000 17.000000 18.000000 Richness 191.080000 193.100000 194.920000 196.870000 198.270000 199.670000 sd 4.421435 4.372781 4.527536 4.421378 4.287296 4.032832 Sites 19.000000 20.000000 21.000000 22.000000 23.000000 24.000000 Richness 201.000000 202.470000 203.950000 205.180000 206.210000 207.230000 sd 4.005047 3.968194 3.952687 3.774931 3.682596 3.700546 Sites 25.000000 26.000000 27.000000 28.000000 29.000000 30.000000 Richness 208.380000 209.390000 210.540000 211.430000 212.290000 213.230000 sd 3.323561 3.323911 3.316381 3.156699 3.098696 2.957118 Sites 31.000000 32.000000 33.000000 34.000000 35.000000 36.000000 Richness 214.100000 214.880000 215.620000 216.370000 217.000000 217.550000 sd 2.761569 2.575251 2.529742 2.588455 2.486326 2.371442 Sites 37.000000 38.000000 39.000000 40.000000 41.000000 42.000000 Richness 218.160000 218.770000 219.340000 219.970000 220.600000 221.210000 sd 2.364382 2.210421 2.041093 2.071719 1.964328 1.945183 Sites 43.000000 44.000000 45.000000 46.000000 47.000000 48.0000000 Richness 221.850000 222.360000 222.890000 223.320000 223.710000 224.1700000 sd 1.771691 1.586050 1.490000 1.476277 1.208514 0.9749903 Sites 49.0000000 50 Richness 224.6500000 225 sd 0.6092718 0 > summary(sp2) 1 sites 2 sites 3 sites 4 sites Min. : 77.00 Min. :105.0 Min. :123.0 Min. :135.0 1st Qu.: 86.00 1st Qu.:116.0 1st Qu.:133.8 1st Qu.:145.8 Median : 91.00 Median :120.5 Median :140.0 Median :150.5 Mean : 91.34 Mean :121.0 Mean :138.7 Mean :150.5 3rd Qu.: 97.00 3rd Qu.:127.0 3rd Qu.:144.0 3rd Qu.:155.0 Max. :109.00 Max. :136.0 Max. :158.0 Max. :162.0 5 sites 6 sites 7 sites 8 sites Min. :144.0 Min. :152.0 Min. :156.0 Min. :160.0 1st Qu.:155.0 1st Qu.:162.0 1st Qu.:168.0 1st Qu.:173.0 Median :159.5 Median :167.0 Median :173.0 Median :177.0 Mean :159.5 Mean :166.5 Mean :171.8 Mean :176.2 3rd Qu.:164.0 3rd Qu.:171.0 3rd Qu.:175.2 3rd Qu.:179.0 Max. :174.0 Max. :180.0 Max. :183.0 Max. :187.0 9 sites 10 sites 11 sites 12 sites Min. :161.0 Min. :164.0 Min. :174.0 Min. :178.0 1st Qu.:177.0 1st Qu.:179.0 1st Qu.:182.8 1st Qu.:186.0 Median :180.0 Median :184.0 Median :187.0 Median :189.0 Mean :179.8 Mean :182.7 Mean :185.9 Mean :188.6 3rd Qu.:183.0 3rd Qu.:186.0 3rd Qu.:188.0 3rd Qu.:191.0 Max. :194.0 Max. :196.0 Max. :198.0 Max. :199.0 13 sites 14 sites 15 sites 16 sites Min. :179.0 Min. :181.0 Min. :185.0 Min. :186.0 1st Qu.:188.0 1st Qu.:191.0 1st Qu.:192.0 1st Qu.:194.0 Median :191.0 Median :193.0 Median :195.0 Median :197.0 Mean :191.1 Mean :193.1 Mean :194.9 Mean :196.9 3rd Qu.:194.0 3rd Qu.:196.0 3rd Qu.:198.0 3rd Qu.:200.0 Max. :201.0 Max. :203.0 Max. :205.0 Max. :207.0 17 sites 18 sites 19 sites 20 sites 21 sites Min. :187.0 Min. :189.0 Min. :189 Min. :189.0 Min. :189.0 1st Qu.:195.8 1st Qu.:197.0 1st Qu.:199 1st Qu.:200.0 1st Qu.:202.0 Median :198.0 Median :200.0 Median :201 Median :202.5 Median :204.0 Mean :198.3 Mean :199.7 Mean :201 Mean :202.5 Mean :203.9 3rd Qu.:201.0 3rd Qu.:202.2 3rd Qu.:204 3rd Qu.:205.0 3rd Qu.:207.0 Max. :208.0 Max. :209.0 Max. :211 Max. :212.0 Max. :213.0 22 sites 23 sites 24 sites 25 sites Min. :194.0 Min. :195.0 Min. :197.0 Min. :198.0 1st Qu.:203.0 1st Qu.:204.0 1st Qu.:205.0 1st Qu.:206.0 Median :205.0 Median :206.5 Median :207.0 Median :209.0 Mean :205.2 Mean :206.2 Mean :207.2 Mean :208.4 3rd Qu.:207.2 3rd Qu.:209.0 3rd Qu.:210.0 3rd Qu.:211.0 Max. :213.0 Max. :215.0 Max. :216.0 Max. :216.0 26 sites 27 sites 28 sites 29 sites Min. :199.0 Min. :201.0 Min. :202.0 Min. :203.0 1st Qu.:207.0 1st Qu.:208.8 1st Qu.:210.0 1st Qu.:211.0 Median :209.0 Median :211.0 Median :211.0 Median :212.0 Mean :209.4 Mean :210.5 Mean :211.4 Mean :212.3 3rd Qu.:212.0 3rd Qu.:213.0 3rd Qu.:214.0 3rd Qu.:214.0 Max. :218.0 Max. :218.0 Max. :218.0 Max. :219.0 30 sites 31 sites 32 sites 33 sites Min. :203.0 Min. :204.0 Min. :206.0 Min. :206.0 1st Qu.:211.0 1st Qu.:212.0 1st Qu.:213.0 1st Qu.:214.0 Median :213.0 Median :214.0 Median :215.0 Median :216.0 Mean :213.2 Mean :214.1 Mean :214.9 Mean :215.6 3rd Qu.:215.0 3rd Qu.:216.0 3rd Qu.:217.0 3rd Qu.:218.0 Max. :220.0 Max. :220.0 Max. :220.0 Max. :220.0 34 sites 35 sites 36 sites 37 sites 38 sites Min. :208.0 Min. :209 Min. :209.0 Min. :212.0 Min. :214.0 1st Qu.:214.8 1st Qu.:216 1st Qu.:216.0 1st Qu.:217.0 1st Qu.:217.0 Median :216.0 Median :217 Median :218.0 Median :218.0 Median :219.0 Mean :216.4 Mean :217 Mean :217.6 Mean :218.2 Mean :218.8 3rd Qu.:218.0 3rd Qu.:219 3rd Qu.:219.0 3rd Qu.:220.0 3rd Qu.:220.0 Max. :222.0 Max. :222 Max. :223.0 Max. :223.0 Max. :224.0 39 sites 40 sites 41 sites 42 sites Min. :214.0 Min. :214.0 Min. :216.0 Min. :216.0 1st Qu.:218.0 1st Qu.:219.0 1st Qu.:219.0 1st Qu.:220.0 Median :220.0 Median :220.0 Median :221.0 Median :221.0 Mean :219.3 Mean :220.0 Mean :220.6 Mean :221.2 3rd Qu.:221.0 3rd Qu.:222.0 3rd Qu.:222.0 3rd Qu.:223.0 Max. :224.0 Max. :224.0 Max. :224.0 Max. :225.0 43 sites 44 sites 45 sites 46 sites Min. :217.0 Min. :217.0 Min. :219.0 Min. :219.0 1st Qu.:221.0 1st Qu.:221.8 1st Qu.:222.0 1st Qu.:223.0 Median :222.0 Median :223.0 Median :223.0 Median :224.0 Mean :221.8 Mean :222.4 Mean :222.9 Mean :223.3 3rd Qu.:223.0 3rd Qu.:223.0 3rd Qu.:224.0 3rd Qu.:224.0 Max. :225.0 Max. :225.0 Max. :225.0 Max. :225.0 47 sites 48 sites 49 sites 50 sites Min. :220.0 Min. :221.0 Min. :222.0 Min. :225 1st Qu.:223.0 1st Qu.:224.0 1st Qu.:224.0 1st Qu.:225 Median :224.0 Median :224.0 Median :225.0 Median :225 Mean :223.7 Mean :224.2 Mean :224.7 Mean :225 3rd Qu.:225.0 3rd Qu.:225.0 3rd Qu.:225.0 3rd Qu.:225 Max. :225.0 Max. :225.0 Max. :225.0 Max. :225 > plot(sp1, ci.type="poly", col="blue", lwd=2, ci.lty=0, ci.col="lightblue") > boxplot(sp2, col="yellow", add=TRUE, pch="+") > > > > cleanEx(); ..nameEx <- "specpool" > > ### * specpool > > flush(stderr()); flush(stdout()) > > ### Name: specpool > ### Title: Extrapolated Species Richness in a Species Pool > ### Aliases: specpool specpool2vect estimateR estimateR.default > ### estimateR.matrix estimateR.data.frame > ### Keywords: univar > > ### ** Examples > > data(dune) > data(dune.env) > attach(dune.env) > pool <- specpool(dune, Management) > pool Species Chao Chao.SE Jack.1 Jack1.SE Jack.2 Boot Boot.SE n BF 16 17.28906 2.189126 19.33333 2.211083 19.83333 17.74074 1.646379 3 HF 21 21.39844 1.119337 23.40000 1.876166 22.05000 22.56864 1.821518 5 NM 21 22.70370 2.501562 26.00000 3.291403 25.73333 23.77696 2.300982 6 SF 21 28.25000 10.270418 27.66667 3.496029 31.40000 23.99496 1.850288 6 > op <- par(mfrow=c(1,2)) > boxplot(specnumber(dune) ~ Management, col="hotpink", border="cyan3", + notch=TRUE) > boxplot(specnumber(dune)/specpool2vect(pool) ~ Management, col="hotpink", + border="cyan3", notch=TRUE) > par(op) > data(BCI) > estimateR(BCI[1:5,]) 1 2 3 4 5 S.obs 93.000000 84.000000 90.000000 94.000000 101.000000 S.chao1 117.516620 117.293367 141.340237 111.583750 136.055556 se.chao1 12.578970 17.841763 26.075747 9.647692 16.882684 S.ACE 122.848959 117.317307 134.669844 118.729941 137.114088 se.ACE 5.736054 5.571998 6.191618 5.367571 5.848474 > > > > graphics::par(get("par.postscript", env = .CheckExEnv)) > cleanEx(); ..nameEx <- "stepacross" > > ### * stepacross > > flush(stderr()); flush(stdout()) > > ### Name: stepacross > ### Title: Stepacross as Flexible Shortest Paths or Extended > ### Dissimilarities > ### Aliases: stepacross > ### Keywords: multivariate > > ### ** Examples > > # There are no data sets with high beta diversity in vegan, but this > # should give an idea. > data(dune) > dis <- vegdist(dune) > edis <- stepacross(dis) Too long or NA distances: 5 out of 190 (2.6%) Stepping across 190 dissimilarities... > plot(edis, dis, xlab = "Shortest path", ylab = "Original") > ## Manhattan distance have no fixed upper limit. > dis <- vegdist(dune, "manhattan") > is.na(dis) <- no.shared(dune) > dis <- stepacross(dis, toolong=0) Too long or NA distances: 5 out of 190 (2.6%) Stepping across 190 dissimilarities... > > > > cleanEx(); ..nameEx <- "varechem" > > ### * varechem > > flush(stderr()); flush(stdout()) > > ### Name: varespec > ### Title: Vegetation and environment in lichen pastures > ### Aliases: varechem varespec > ### Keywords: datasets > > ### ** Examples > > data(varespec) > data(varechem) > > > > cleanEx(); ..nameEx <- "vegdist" > > ### * vegdist > > flush(stderr()); flush(stdout()) > > ### Name: vegdist > ### Title: Dissimilarity Indices for Community Ecologists > ### Aliases: vegdist > ### Keywords: multivariate > > ### ** Examples > > data(varespec) > vare.dist <- vegdist(varespec) > # Orlóci's Chord distance: range 0 .. sqrt(2) > vare.dist <- vegdist(decostand(varespec, "norm"), "euclidean") > > > > cleanEx(); ..nameEx <- "vegemite" > > ### * vegemite > > flush(stderr()); flush(stdout()) > > ### Name: vegemite > ### Title: Prints a Compact, Ordered Vegetation Table > ### Aliases: vegemite coverscale > ### Keywords: print manip > > ### ** Examples > > data(varespec) > ## Print only more common species > freq <- apply(varespec > 0, 2, sum) > vegemite(varespec, scale="Hult", sp.ind = freq > 10) 1122212121122 1112 854739268340575634292011 Cal.vul 111...11.311...1111.111. Emp.nig 211332121112211111212213 Vac.vit 323332212113221211233234 Pin.syl 111.111111111.11.1111111 Dic.fus 12.111441121211111111111 Dic.pol .11.11.11..1.11....1.111 Ple.sch 144533435123411111111131 Pol.jun 111.11.111112111.111.111 Poh.nut 111111111111.1..11.11111 Pti.cil 1111111111..1..11.11..12 Cla.arb 321122121332143423111121 Cla.ran 321221131312145443313241 Cla.ste 11111311.211.11254555542 Cla.unc 112111111131111111111111 Cla.coc 11..11111111111111.1.11. Cla.cor 111111111111111111111111 Cla.gra 111111111111111111111.11 Cla.fim 11.1111111111111111111.1 Cla.cri 111111111111111111111111 Cla.chl ..1.111..1...1.11.11.1.1 Cet.eri 111...11.111111111.1.1.. Cet.isl .11....1111.1....1.11111 Ste.sp 111.11.1111.112111...11. Cla.def 1111111111111111111111.1 > ## Order by correspondence analysis, use Hill scaling and layout: > dca <- decorana(varespec) > vegemite(varespec, dca, "Hill", zero="-") 1 1 1 11122211122222 203942561738913046572458 Cet.niv -1114-11-1-11-1--------- Cla.ste 5555551451425411111211-- Cla.phy -1-1----1-------1------- Cla.cer 1---1-----------------1- Cla.sp ---11--1--11---1-1-11-1- Cla.ama --1---1----1------------ Cla.chl 1111---1-11-111-----11-- Cla.ran 535254555555223414332321 Dip.mon --11-----112----------1- Ste.sp -11-1-4111111-1-111--111 Pin.syl 11-111111-111111111-1111 Pol.pil ------111--11-11--1----- Cet.isl -1-111--1-1--1--111--111 Cla.coc -1111-1111111-11111-1-11 Cla.arb 113142453555313343413231 Vac.uli --1-1----3-1---1---12-11 Poh.nut -11111--11111111111111-1 Cla.fim 11111111-111111111111-11 Cal.vul 111-21-12-51---1221-21-- Ich.eri ------1--1------11------ Emp.nig 342214131314344333143131 Vac.vit 342514244334455432444443 Cla.gra 1-1111111111111111111111 Cet.eri -1111-11-111---1111-111- Cla.cor 111111111111111111111111 Cla.cri 111111111111111111111111 Pel.aph --------1-11--1----1--1- Pti.cil 1-11---11-11141--1111111 Bar.lyc ----------1-121----1---- Cla.def 11111111-111111111111111 Cla.bot ----------1-1111---1-1-1 Bet.pub -------------1------1-1- Dic.pol -1-1--1-11--1211-11--1-1 Cla.unc 111111122111111251212311 Pol.com ------------11--1--1--1- Pol.jun 11-11-1111111121111--131 Led.pal ----------1--2-----21--1 Dic.fus 111111111121112145425-41 Ple.sch 111213114132524434555555 Vac.myr ---1------1-24--12133--4 Des.fle ----1----1--11-----21-11 Nep.arc --1------1-1---1------2- Dic.sp -----1----1--1-1-11-1541 Hyl.spl ---------------1---3--13 > > > > cleanEx(); ..nameEx <- "wascores" > > ### * wascores > > flush(stderr()); flush(stdout()) > > ### Name: wascores > ### Title: Weighted Averages Scores for Species > ### Aliases: wascores eigengrad > ### Keywords: multivariate univar > > ### ** Examples > > data(varespec) > data(varechem) > library(MASS) ## isoMDS > vare.dist <- vegdist(wisconsin(varespec)) > vare.mds <- isoMDS(vare.dist) initial value 27.004018 iter 5 value 19.627798 iter 10 value 19.080657 iter 15 value 18.587495 iter 20 value 18.075166 iter 20 value 18.064314 final value 17.850149 converged > vare.points <- postMDS(vare.mds$points, vare.dist) > vare.wa <- wascores(vare.points, varespec) > plot(scores(vare.points), pch="+", asp=1) > text(vare.wa, rownames(vare.wa), cex=0.8, col="blue") > ## Omit rare species (frequency <= 4) > freq <- apply(varespec>0, 2, sum) > plot(scores(vare.points), pch="+", asp=1) > text(vare.wa[freq > 4,], rownames(vare.wa)[freq > 4],cex=0.8,col="blue") > ## Works for environmental variables, too. > wascores(varechem, varespec) N P K Ca Mg S Al Cal.vul 25.12401 41.66188 246.92383 572.3431 99.40828 49.10552 245.15751 Emp.nig 21.61371 44.17350 158.92517 580.8403 89.20628 35.75327 107.05670 Led.pal 22.34553 40.35530 162.31108 643.8819 95.07712 30.84303 28.83159 Vac.myr 24.96352 49.80649 189.70177 656.4179 96.75529 34.55190 32.75705 Vac.vit 21.14028 45.86984 162.12372 613.2126 94.30084 37.26975 116.14656 Pin.syl 18.37299 44.24818 163.60195 670.9387 93.52214 37.02238 150.45523 Des.fle 22.24089 54.74804 212.20357 771.0159 114.15179 38.00000 24.64143 Bet.pub 21.51034 28.86552 112.28276 513.5586 75.15172 23.55172 33.12414 Vac.uli 28.00729 33.48758 114.90230 372.9653 70.89954 29.32378 202.89008 Dip.mon 22.34228 39.71049 127.44259 446.1565 80.16173 32.32963 122.31574 Dic.sp 21.33007 60.03758 185.04563 828.0544 148.67509 46.75427 90.42294 Dic.fus 23.45681 39.14575 162.91954 578.2309 77.81648 33.48086 60.66890 Dic.pol 20.65446 43.87409 150.51485 665.5845 115.22112 36.17079 90.16733 Hyl.spl 26.10599 67.88980 245.78681 779.6520 111.96685 42.27433 24.92738 Ple.sch 22.60476 54.22534 199.96241 712.6278 109.23425 40.01132 70.43900 Pol.pil 23.17377 43.75902 144.82623 724.9738 85.42623 30.58525 145.73115 Pol.jun 22.89480 47.98022 154.81906 643.3864 87.27819 33.63863 53.24888 Pol.com 21.73521 41.17042 154.91549 631.8704 101.84789 32.17324 46.80986 Poh.nut 19.99885 48.59198 169.68855 678.3813 104.31641 39.94427 132.05458 Pti.cil 21.27880 33.44211 127.08522 564.5652 85.96417 27.11720 56.60692 Bar.lyc 21.17461 27.93323 113.13542 497.9138 77.50564 23.72288 42.09749 Cla.arb 23.56127 38.04952 142.03073 454.9019 74.00779 33.81002 173.12698 Cla.ran 24.28421 38.60534 135.31177 463.2750 70.54209 32.53349 183.79979 Cla.ste 19.28049 46.71060 158.00576 540.4904 80.19153 40.29106 225.89526 Cla.unc 21.41240 45.49844 163.40402 621.9100 98.35538 40.00734 119.59481 Cla.coc 21.72473 42.80681 156.32330 557.9007 80.95448 36.25161 149.82616 Cla.cor 22.11640 47.06656 160.36881 623.5185 95.17781 36.75273 104.71463 Cla.gra 22.51887 44.06576 156.50214 583.1558 94.10292 36.93930 134.13424 Cla.fim 21.77980 41.82652 153.29444 512.4646 78.28232 35.62323 128.96061 Cla.cri 20.88795 44.12262 171.04016 574.5672 92.52169 38.24003 116.03507 Cla.chl 19.51207 45.39655 150.93190 571.0233 95.77586 39.50862 156.81983 Cla.bot 22.97660 38.89574 167.20000 590.8021 99.57234 34.79362 87.75957 Cla.ama 25.07143 35.84286 105.07857 395.2214 68.18571 27.11429 95.91429 Cla.sp 19.21923 47.37308 168.49231 526.7654 79.54423 45.15385 215.33846 Cet.eri 21.00944 47.76972 165.07972 579.6322 99.14944 42.25472 163.46000 Cet.isl 18.36552 42.73695 151.78374 626.2813 89.77833 35.33498 132.68227 Cet.niv 18.56110 61.18194 207.67705 502.9203 60.91755 50.22532 396.82405 Nep.arc 23.33099 49.10019 146.84715 618.1601 64.27319 29.95760 31.72300 Ste.sp 28.19743 32.84800 94.33459 389.5143 53.25377 24.22175 95.39326 Pel.aph 21.08553 54.45395 193.38816 886.5487 119.35132 37.92500 106.16447 Ich.eri 28.88636 27.00000 87.86818 307.0500 40.48182 22.17273 89.94091 Cla.cer 20.25000 56.79000 192.36000 519.2300 62.10000 45.18000 314.92000 Cla.def 22.19198 45.22981 167.73069 583.7983 92.01320 38.51369 100.46139 Cla.phy 15.73750 54.56875 180.39375 775.4500 99.65625 43.35000 208.55000 Fe Mn Zn Mo Baresoil Humdepth pH Cal.vul 75.457843 52.38247 8.281074 0.4734635 27.241036 2.187819 2.845108 Emp.nig 38.146102 53.49357 7.159938 0.3289657 27.324317 2.367439 2.888078 Led.pal 5.560906 70.48260 7.444100 0.2251490 37.325030 2.689154 2.895352 Vac.myr 5.589213 75.17221 7.838533 0.2666732 31.404171 2.798935 2.855216 Vac.vit 37.586067 51.81515 7.617213 0.3680289 26.307701 2.307879 2.923128 Pin.syl 39.121898 35.22311 7.733333 0.3485401 17.762968 1.996350 3.049148 Des.fle 6.066429 110.87232 9.526607 0.2316071 22.740179 2.834821 2.822857 Bet.pub 5.417241 37.53448 5.637931 0.2068966 51.496552 2.527586 2.979310 Vac.uli 93.963929 37.73062 4.593824 0.3780552 21.410710 2.041196 3.006965 Dip.mon 73.281173 46.88025 4.593827 0.3725309 31.836574 2.103704 2.856790 Dic.sp 22.504617 65.35020 13.060765 0.5610370 23.182889 2.232247 2.954272 Dic.fus 13.922252 61.40958 6.922859 0.3218816 26.918674 2.484399 2.806431 Dic.pol 20.973927 33.28779 9.110561 0.3892739 37.304043 2.228713 3.015842 Hyl.spl 4.729157 115.14606 9.885976 0.2851996 20.956264 2.925000 2.807594 Ple.sch 19.113811 77.12277 9.007860 0.3405945 24.584979 2.596881 2.858446 Pol.pil 51.993443 36.74754 8.045902 0.2204918 17.368852 1.493443 3.227869 Pol.jun 12.885704 82.56274 7.945126 0.2760289 28.116303 2.615523 2.874729 Pol.com 7.895775 68.22535 7.843662 0.2591549 38.687324 2.926761 2.860563 Poh.nut 33.089313 42.02290 8.452290 0.3935115 24.709351 2.147328 2.985496 Pti.cil 14.036188 33.93547 5.906924 0.2303712 48.941884 2.502498 2.973376 Bar.lyc 8.199687 31.11379 5.550784 0.2084639 54.331975 2.514734 2.986834 Cla.arb 65.470394 38.28429 6.387500 0.4464046 22.592997 2.048540 2.937879 Cla.ran 76.612752 34.86010 6.616452 0.3903501 17.270158 1.799128 3.022346 Cla.ste 84.639467 33.27903 7.287216 0.4054879 9.854042 1.851973 3.052167 Cla.unc 27.463504 40.10322 9.108102 0.5120114 28.312376 2.362687 2.858564 Cla.coc 46.653763 43.53584 7.269176 0.3698925 19.972222 2.025090 2.974194 Cla.cor 32.916238 53.38441 7.518489 0.3639871 26.620868 2.399518 2.890997 Cla.gra 45.758366 44.63911 7.702724 0.4244163 25.546654 2.230350 2.933658 Cla.fim 41.710354 47.83687 6.815152 0.3887626 24.763889 2.239394 2.902778 Cla.cri 34.729585 44.75984 6.933735 0.3746988 29.711352 2.400000 2.841633 Cla.chl 42.089655 35.13276 7.908621 0.3814655 22.319655 2.075000 3.022414 Cla.bot 23.374468 46.54255 7.263830 0.3106383 45.725532 2.580851 2.904255 Cla.ama 68.971429 41.98571 4.928571 0.3214286 27.592857 1.857143 2.914286 Cla.sp 47.913462 49.61923 8.421154 0.6173077 16.864423 2.213462 2.921154 Cet.eri 42.614167 36.96694 9.516389 0.5687500 21.452639 2.058056 2.923889 Cet.isl 29.617734 33.24138 7.518227 0.3192118 26.417980 2.027586 3.065025 Cet.niv 94.339916 37.03232 9.116371 0.9987764 19.692312 1.799241 2.923629 Nep.arc 12.910837 115.15684 7.743536 0.2180608 23.135932 2.541065 2.918251 Ste.sp 30.226998 31.97061 7.635502 0.2828767 15.844007 1.477740 3.038756 Pel.aph 37.598684 56.64079 7.652632 0.2046053 28.321053 2.286842 3.026316 Ich.eri 24.236364 23.95909 6.618182 0.2863636 18.727273 1.568182 2.968182 Cla.cer 111.090000 52.04000 8.530000 0.6800000 15.393000 1.870000 2.900000 Cla.def 25.116325 48.81105 7.599609 0.4096285 33.814545 2.468133 2.823656 Cla.phy 50.475000 35.28125 8.568750 0.2812500 7.728125 1.575000 3.231250 > ## And the strengths of these variables are: > eigengrad(varechem, varespec) N P K Ca Mg S Al 0.13000842 0.18880078 0.16246365 0.15722067 0.16359171 0.13391967 0.29817406 Fe Mn Zn Mo Baresoil Humdepth pH 0.20766831 0.27254480 0.16783834 0.09542514 0.20931501 0.25051326 0.14583161 > > > > ### *