[Vegan-commits] r346 - in pkg: R inst man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun May 11 08:28:19 CEST 2008


Author: jarioksa
Date: 2008-05-11 08:28:19 +0200 (Sun, 11 May 2008)
New Revision: 346

Added:
   pkg/R/fieller.MOStest.R
Modified:
   pkg/inst/ChangeLog
   pkg/man/MOStest.Rd
Log:
Approximate CI for MOStest based on Fieller theorem

Added: pkg/R/fieller.MOStest.R
===================================================================
--- pkg/R/fieller.MOStest.R	                        (rev 0)
+++ pkg/R/fieller.MOStest.R	2008-05-11 06:28:19 UTC (rev 346)
@@ -0,0 +1,34 @@
+`fieller.MOStest` <-
+    function (object, level = 0.95) 
+{
+    smodel <- summary(object$mod)
+    var <- smodel$cov.scaled
+    fam <- family(object$mod)
+    if (fam$family %in% c("poisson", "binomial"))
+        od <- 1
+    else
+        od <- deviance(object$mod)/df.residual(object$mod)
+    k <- coef(object$mod)
+    b2 <- -2 * k[3]
+    u <- -k[2]/2/k[3]
+    alpha <- (1-level)/2
+    limits <- numeric(2)
+    names(limits) <- paste(round(100*(c(alpha, 1-alpha)), 1), "%") 
+    wvar <- var[2,2] * od
+    uvar <- 4 * var[3,3] * od
+    vvar <- -2 * var[2,3] * od
+    z <- qnorm(1 - alpha)
+    g <- z^2 * uvar/b2^2
+    if (g >= 1) {
+        limits <- c(NA, NA)
+    }
+    else {
+        x <- u - g * vvar/uvar
+        f <- z/b2
+        s <- sqrt(wvar - 2 * u * vvar + u^2 * uvar - g * (wvar - 
+                                                              vvar^2/uvar))
+        limits[1] <- (x - f * s)/(1 - g)
+        limits[2] <- (x + f * s)/(1 - g)
+    }
+    limits
+}

Modified: pkg/inst/ChangeLog
===================================================================
--- pkg/inst/ChangeLog	2008-05-09 18:19:28 UTC (rev 345)
+++ pkg/inst/ChangeLog	2008-05-11 06:28:19 UTC (rev 346)
@@ -17,6 +17,16 @@
 	arguments without issuing an warning. These warnings were harmless
 	but it is neater to stop them happening in the first place.
 
+	* MOStest: added fieller.MOStest for approximate confidence
+	intervals of the location of the hump or pit. The method is based
+	on Fieller's theorem following ter Braak & Looman (Vegatatio 65,
+	3-11; 1986) and based on the code from the ESA Ecological Archives
+	accompanying Oksanen et al. (Ecology 82, 1191-1197; 2001) and
+	published in package optgrad
+	(http://www.esapubs.org/archive/ecol/E082/015/default.htm).  The
+	optgrad package also has profile method, but it is not yet
+	implemented. 
+
 Version 1.12-14 (closed May 9, 2008)
 
 	* mso: added Helene Wagner's mso function for direct multi-scale

Modified: pkg/man/MOStest.Rd
===================================================================
--- pkg/man/MOStest.Rd	2008-05-09 18:19:28 UTC (rev 345)
+++ pkg/man/MOStest.Rd	2008-05-11 06:28:19 UTC (rev 346)
@@ -3,6 +3,7 @@
 \alias{MOStest}
 \alias{print.MOStest}
 \alias{plot.MOStest}
+\alias{fieller.MOStest}
 
 
 \title{ Mitchell-Olds \& Shaw Test for the Location of Quadratic Extreme }
@@ -17,16 +18,19 @@
 \usage{
 MOStest(x, y, interval, ...)
 \method{plot}{MOStest}(x, which = c(1,2,3,6), ...)
+fieller.MOStest(object, level = 0.95)
 }
 
 \arguments{
-  \item{x}{The independent variable. }
+  \item{x}{The independent variable or plotting object in \code{plot}. }
   \item{y}{The dependent variable. }
   \item{interval}{The two points at which the test statistic is
     evaluated. If missing, the estremes of \code{x} are used. }
   \item{which}{Subset of plots produced. Values \code{which=1} and
     \code{2} define plots specific to \code{MOStest} (see Details), and
-    larger values select a graphs of \code{\link{plot.lm}} (minus 2). }
+    larger values select a graphs of \code{\link{plot.lm}} (minus2). }
+  \item{object}{A result object from \code{MOStest}.}
+  \item{level}{The confidence level required.}
   \item{\dots}{ Other variables passed to functions. Function
     \code{mitchell.olds.test} passes these to \code{\link{glm}} so that
     these can include \code{\link{family}}. The other functions pass
@@ -60,6 +64,12 @@
   graphs from \code{\link{plot.lm}}. That is, you must add 2 to the
   value of \code{which} in \code{\link{plot.lm}}.
 
+  Function \code{fieller.MOStest} approximates the confidence limits
+  of the location of the extreme point (hump or pit) using Fieller's
+  theorem following ter Braak & Looman (1986). The test is based on
+  quasideviance except if the \code{\link{family}} is \code{poisson}
+  or \code{binomial}.
+
   The test is typically used in assessing the significance of diversity
   hump against productivity gradient (Mittelbach et al. 2001). It also
   can be used for the location of the pit (deepest points) instead of
@@ -89,14 +99,27 @@
 Mittelbach, G.C. Steiner, C.F., Scheiner, S.M., Gross, K.L., Reynolds,
 H.L., Waide, R.B., Willig, R.M., Dodson, S.I. & Gough, L. 2001. What is
 the observed richness between species richness and productivity?
-\emph{Ecology} 82: 2381--2396.
+\emph{Ecology} 82, 2381--2396.
 
 Oksanen, J., Läärä, E., Tolonen, K. & Warner, B.G. 2001. Confidence
 intervals for the optimum in the Gaussian response
 function. \emph{Ecology} 82, 1191--1197.
+
+ter Braak, C.J.F & Looman, C.W.N 1986. Weighted averaging, logistic
+regression and the Gaussian response model. \emph{Vegetatio} 65,
+3--11. 
 }
 \author{Jari Oksanen }
 
+\note{ 
+Function \code{fieller.MOStest} is based on package \pkg{optgrad} in
+the Ecological Archives
+(\url{http://www.esapubs.org/archive/ecol/E082/015/default.htm})
+accompanying Oksanen et al. (2001). The Ecological Archive package
+\pkg{optgrad} also contains profile deviance method for the location
+of the hump or pit, but it is not (yet) implemented in \pkg{vegan}. 
+}
+
 \seealso{The nointeraction model can be fitted with \code{\link{humpfit}}. }
 \examples{
 ## The Al-Mufti data analysed in humpfit():
@@ -113,6 +136,8 @@
 mod
 plot(mod)
 par(op)
+## Infinite confidence limits (NA)
+fieller.MOStest(mod)
 }
 
 \keyword{ models }



More information about the Vegan-commits mailing list