[Vegan-commits] r2082 - in branches/2.0: R inst man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sat Feb 11 08:53:28 CET 2012
Author: jarioksa
Date: 2012-02-11 08:53:27 +0100 (Sat, 11 Feb 2012)
New Revision: 2082
Modified:
branches/2.0/R/indpower.R
branches/2.0/R/permutest.betadisper.R
branches/2.0/inst/ChangeLog
branches/2.0/man/indpower.Rd
branches/2.0/man/renyi.Rd
Log:
merge r2060 (broken url), 2071,2 (indpower fix), 2079 (do not use .Internal)
Modified: branches/2.0/R/indpower.R
===================================================================
--- branches/2.0/R/indpower.R 2012-02-10 10:34:19 UTC (rev 2081)
+++ branches/2.0/R/indpower.R 2012-02-11 07:53:27 UTC (rev 2082)
@@ -11,12 +11,15 @@
j <- t(x) %*% x
ip1 <- sweep(j, 1, diag(j), "/")
ip2 <- 1 - sweep(-sweep(j, 2, diag(j), "-"), 1, n - diag(j), "/")
- ip <- sqrt(ip1 * ip2)
out <- switch(as.character(type),
- "0" = ip,
+ "0" = sqrt(ip1 * ip2),
"1" = ip1,
"2" = ip2)
- colnames(out) <- paste("t", colnames(out), sep=".")
- rownames(out) <- paste("i", rownames(out), sep=".")
+ cn <- if (is.null(colnames(out)))
+ 1:ncol(out) else colnames(out)
+ rn <- if (is.null(rownames(out)))
+ 1:ncol(out) else rownames(out)
+ colnames(out) <- paste("t", cn, sep=".")
+ rownames(out) <- paste("i", rn, sep=".")
out
}
Modified: branches/2.0/R/permutest.betadisper.R
===================================================================
--- branches/2.0/R/permutest.betadisper.R 2012-02-10 10:34:19 UTC (rev 2081)
+++ branches/2.0/R/permutest.betadisper.R 2012-02-11 07:53:27 UTC (rev 2082)
@@ -4,10 +4,10 @@
t.statistic <- function(x, y) {
m <- length(x)
n <- length(y)
- xbar <- .Internal(mean(x))
- ybar <- .Internal(mean(y))
- xvar <- .Internal(cov(x, NULL, 1, FALSE))
- yvar <- .Internal(cov(y, NULL, 1, FALSE))
+ xbar <- mean(x) ## .Internal(mean(x))
+ ybar <- mean(y) ## .Internal(mean(y))
+ xvar <- var(x) ## .Internal(cov(x, NULL, 1, FALSE))
+ yvar <- var(y) ## .Internal(cov(y, NULL, 1, FALSE))
pooled <- sqrt(((m-1)*xvar + (n-1)*yvar) / (m+n-2))
(xbar - ybar) / (pooled * sqrt(1/m + 1/n))
}
Modified: branches/2.0/inst/ChangeLog
===================================================================
--- branches/2.0/inst/ChangeLog 2012-02-10 10:34:19 UTC (rev 2081)
+++ branches/2.0/inst/ChangeLog 2012-02-11 07:53:27 UTC (rev 2082)
@@ -4,6 +4,9 @@
Version 2.0-3 (opened November 13, 2011)
+ * merge r2079: do not use .Internal().
+ * merge r2071,2: dimnames fix in indopower & expand example.
+ * merge r2068: broken url in renyi.Rd.
* merge r2060: adonis tells terms were added sequentially.
* mrege r2057: add .Rinstignore to silense R 2.15.0 checks.
* merge r2056: use inconsolata fonts in vignettes.
Modified: branches/2.0/man/indpower.Rd
===================================================================
--- branches/2.0/man/indpower.Rd 2012-02-10 10:34:19 UTC (rev 2081)
+++ branches/2.0/man/indpower.Rd 2012-02-11 07:53:27 UTC (rev 2082)
@@ -31,7 +31,7 @@
Total indicator power (TIP) of an indicator species is the column mean
(without its own value, see examples).
Halme et al. (2009) explain how to calculate confidence
- intervals for these statistics.
+ intervals for these statistics, see Examples.
}
\value{
A matrix with indicator species as rows and
@@ -56,7 +56,29 @@
ip <- indpower(dune)
## and TIP values
diag(ip) <- NA
-rowMeans(ip, na.rm=TRUE)
+(TIP <- rowMeans(ip, na.rm=TRUE))
+
+## p value calculation for a species
+## from Halme et al. 2009
+## i is ID for the species
+i <- 1
+fun <- function(x, i) indpower(x)[i,-i]
+## 'c0' randomizes species occurrences
+os <- oecosimu(dune, fun, "c0", i=i, nsimul=99)
+## get z values from oecosimu output
+z <- os$oecosimu$z
+## p-value
+(p <- sum(z) / sqrt(length(z)))
+## 'heterogeneity' measure
+(chi2 <- sum((z - mean(z))^2))
+pchisq(chi2, df=length(z)-1)
+## Halme et al.'s suggested output
+out <- c(TIP=TIP[i],
+ significance=p,
+ heterogeneity=chi2,
+ minIP=min(fun(dune, i=i)),
+ varIP=sd(fun(dune, i=i)^2))
+out
}
\keyword{ multivariate }
Modified: branches/2.0/man/renyi.Rd
===================================================================
--- branches/2.0/man/renyi.Rd 2012-02-10 10:34:19 UTC (rev 2081)
+++ branches/2.0/man/renyi.Rd 2012-02-11 07:53:27 UTC (rev 2082)
@@ -87,7 +87,7 @@
replaced with individual permutation results.
}
\references{
- \url{http://www.worldagroforestry.org/treesandmarkets/tree_diversity_analysis.asp}
+ \url{http://www.worldagroforestry.org/resources/databases/tree-diversity-analysis}
Hill, M.O. (1973). Diversity and evenness: a unifying notation and its
consequences. \emph{Ecology} 54, 427--473.
More information about the Vegan-commits
mailing list