[Vegan-commits] r1885 - in pkg/vegan: R man tests/Examples
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sun Sep 25 19:56:29 CEST 2011
Author: jarioksa
Date: 2011-09-25 19:56:29 +0200 (Sun, 25 Sep 2011)
New Revision: 1885
Modified:
pkg/vegan/R/oecosimu.R
pkg/vegan/man/oecosimu.Rd
pkg/vegan/tests/Examples/vegan-Ex.Rout.save
Log:
oecosimu can take either a method name or a commsim function: get back custom function in examples
Modified: pkg/vegan/R/oecosimu.R
===================================================================
--- pkg/vegan/R/oecosimu.R 2011-09-24 23:56:14 UTC (rev 1884)
+++ pkg/vegan/R/oecosimu.R 2011-09-25 17:56:29 UTC (rev 1885)
@@ -73,7 +73,7 @@
names(indstat) <- statistic
if (!is.list(ind))
ind <- list(statistic = ind)
- ind$oecosimu <- list(z = z, pval = p, simulated=simind, method=method,
+ ind$oecosimu <- list(z = z, pval = p, simulated=simind, method=nm$commsim$method,
statistic = indstat, alternative = alternative)
class(ind) <- c("oecosimu", class(ind))
ind
Modified: pkg/vegan/man/oecosimu.Rd
===================================================================
--- pkg/vegan/man/oecosimu.Rd 2011-09-24 23:56:14 UTC (rev 1884)
+++ pkg/vegan/man/oecosimu.Rd 2011-09-25 17:56:29 UTC (rev 1885)
@@ -38,7 +38,9 @@
community as the first argument, and returns either a plain number or
the result in list item with the name defined in argument
\code{statistic}. See Examples for defining your own functions.}
- \item{method}{Null model method. See details.}
+ \item{method}{Null model method: either a name (character string) of
+ a method defined in \code{\link{make.commsim}} or a
+ \code{\link{commsim}} function. See Details and Examples.}
\item{nsimul}{Number of simulated null communities.}
\item{burnin}{Number of null communities discarded before proper
analysis in sequential methods \code{"swap"} and \code{"tswap"}.}
@@ -256,7 +258,18 @@
meandist <- function(x) mean(vegdist(x, "bray"))
mbc1 <- oecosimu(dune, meandist, "r2dtable")
mbc1
+
+## Define your own null model as a 'commsim' function: shuffle cells
+## in each row
+foo <- function(x, n, nr, nc, ...) {
+ out <- array(0, c(nr, nc, n))
+ for (k in seq_len(n))
+ out[,,k] <- apply(x, 2, function(z) sample(z, length(z)))
+ out
}
+cf <- commsim("myshuffle", foo, isSeq = FALSE, binary = FALSE, mode = "double")
+oecosimu(dune, meandist, cf)
+}
\keyword{ multivariate }
\keyword{ datagen }
Modified: pkg/vegan/tests/Examples/vegan-Ex.Rout.save
===================================================================
--- pkg/vegan/tests/Examples/vegan-Ex.Rout.save 2011-09-24 23:56:14 UTC (rev 1884)
+++ pkg/vegan/tests/Examples/vegan-Ex.Rout.save 2011-09-25 17:56:29 UTC (rev 1885)
@@ -4330,8 +4330,27 @@
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
>
+> ## Define your own null model as a 'commsim' function: shuffle cells
+> ## in each row
+> foo <- function(x, n, nr, nc, ...) {
++ out <- array(0, c(nr, nc, n))
++ for (k in seq_len(n))
++ out[,,k] <- apply(x, 2, function(z) sample(z, length(z)))
++ out
++ }
+> cf <- commsim("myshuffle", foo, isSeq = FALSE, binary = FALSE, mode = "double")
+> oecosimu(dune, meandist, cf)
+oecosimu with 99 simulations
+simulation method myshuffle
+alternative hypothesis: true mean is not equal to the statistic
+
+ statistic z 2.5% 50% 97.5% Pr(sim.)
+statistic 0.64565 3.44557 0.62994 0.63487 0.6418 0.01 **
+---
+Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
>
>
+>
> cleanEx()
detaching ‘package:lattice’
@@ -4984,7 +5003,7 @@
Formula:
y ~ s(x1, x2, k = knots)
-<environment: 0x1074dd0a0>
+<environment: 0x107a4cd50>
Estimated degrees of freedom:
6.4351 total = 7.435071
@@ -5000,7 +5019,7 @@
Formula:
y ~ s(x1, x2, k = knots)
-<environment: 0x10696c9c8>
+<environment: 0x107008a38>
Estimated degrees of freedom:
6.1039 total = 7.103853
@@ -5156,7 +5175,7 @@
Formula:
y ~ s(x1, x2, k = knots)
-<environment: 0x1073b3118>
+<environment: 0x105ce1950>
Estimated degrees of freedom:
8.9275 total = 9.927492
@@ -5169,7 +5188,7 @@
Formula:
y ~ s(x1, x2, k = knots)
-<environment: 0x10715aa30>
+<environment: 0x105b6bc68>
Estimated degrees of freedom:
7.7529 total = 8.75294
@@ -5182,7 +5201,7 @@
Formula:
y ~ s(x1, x2, k = knots)
-<environment: 0x107d26cd8>
+<environment: 0x106f04f10>
Estimated degrees of freedom:
8.8962 total = 9.89616
@@ -7441,7 +7460,7 @@
Formula:
y ~ s(x1, x2, k = knots)
-<environment: 0x1072c38d0>
+<environment: 0x105b7de68>
Estimated degrees of freedom:
2 total = 3
@@ -7917,7 +7936,7 @@
> ### * <FOOTER>
> ###
> cat("Time elapsed: ", proc.time() - get("ptime", pos = 'CheckExEnv'),"\n")
-Time elapsed: 110.662 1.469 112.859 0 0
+Time elapsed: 112.312 1.473 115.297 0 0
> grDevices::dev.off()
null device
1
More information about the Vegan-commits
mailing list