[Vegan-commits] r2293 - in pkg/vegan: R inst

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Sep 19 15:36:28 CEST 2012


Author: jarioksa
Date: 2012-09-19 15:36:28 +0200 (Wed, 19 Sep 2012)
New Revision: 2293

Modified:
   pkg/vegan/R/fitted.radfit.R
   pkg/vegan/R/predict.radline.R
   pkg/vegan/R/rad.null.R
   pkg/vegan/R/rad.preempt.R
   pkg/vegan/inst/ChangeLog
Log:
fitted.rad* return now named vectors or matrices

Modified: pkg/vegan/R/fitted.radfit.R
===================================================================
--- pkg/vegan/R/fitted.radfit.R	2012-09-19 13:06:35 UTC (rev 2292)
+++ pkg/vegan/R/fitted.radfit.R	2012-09-19 13:36:28 UTC (rev 2293)
@@ -1,7 +1,7 @@
 `fitted.radfit` <-
     function(object, ...)
 {
-    matrix(sapply(object$models, fitted), ncol=length(object$models))
+    sapply(object$models, fitted)
 }
 
 `fitted.radfit.frame` <-

Modified: pkg/vegan/R/predict.radline.R
===================================================================
--- pkg/vegan/R/predict.radline.R	2012-09-19 13:06:35 UTC (rev 2292)
+++ pkg/vegan/R/predict.radline.R	2012-09-19 13:36:28 UTC (rev 2293)
@@ -19,25 +19,22 @@
     adj <- total/sum(object$y)
     nobs <- length(object$y)
     p <- coef(object)
-    out <-
-        switch(object$model,
-               ## linear interpolation, no extrapolation
-               `Brokenstick` = approx(seq_len(nobs),
-               object$fitted.values, x, ...)$y * adj,
-               `Preemption` = exp(log(total) + log(p) + log(1 - p)*(x-1)),
-               ## NaN when rank outside proportional rank 0...1 
-               `Log-Normal` = {
-                   slope <- diff(range(ppoints(nobs)))/(nobs-1)
-                   intcpt <- 0.5 - slope * (nobs + 1) / 2
-                   xnorm <- -qnorm(intcpt + slope * x)
-                   exp(p[1] + p[2]*xnorm)*adj
-               },
-               `Zipf` = exp(log(total) + log(p[1]) + p[2]*log(x)),
-               `Zipf-Mandelbrot` = exp(log(total) + log(p[1]) +
-               p[2]*log(x + p[3]))
-               )
-    names(out) <- names(object$y)
-    out
+    switch(object$model,
+           ## linear interpolation, no extrapolation
+           `Brokenstick` = approx(seq_len(nobs),
+           object$fitted.values, x, ...)$y * adj,
+           `Preemption` = exp(log(total) + log(p) + log(1 - p)*(x-1)),
+           ## NaN when rank outside proportional rank 0...1 
+           `Log-Normal` = {
+               slope <- diff(range(ppoints(nobs)))/(nobs-1)
+               intcpt <- 0.5 - slope * (nobs + 1) / 2
+               xnorm <- -qnorm(intcpt + slope * x)
+               exp(p[1] + p[2]*xnorm)*adj
+           },
+           `Zipf` = exp(log(total) + log(p[1]) + p[2]*log(x)),
+           `Zipf-Mandelbrot` = exp(log(total) + log(p[1]) +
+           p[2]*log(x + p[3]))
+           )
 }
 
 `predict.radfit`<-

Modified: pkg/vegan/R/rad.null.R
===================================================================
--- pkg/vegan/R/rad.null.R	2012-09-19 13:06:35 UTC (rev 2292)
+++ pkg/vegan/R/rad.null.R	2012-09-19 13:36:28 UTC (rev 2293)
@@ -21,6 +21,7 @@
     }
     residuals <- x - fit
     rdf <- nsp
+    names(fit) <- names(x)
     p <- NA
     names(p) <- "S"
     out <- list(model = "Brokenstick", family=fam, y = x, coefficients = p,

Modified: pkg/vegan/R/rad.preempt.R
===================================================================
--- pkg/vegan/R/rad.preempt.R	2012-09-19 13:06:35 UTC (rev 2292)
+++ pkg/vegan/R/rad.preempt.R	2012-09-19 13:36:28 UTC (rev 2293)
@@ -45,6 +45,7 @@
             aic <- NA
         rdf <- length(x) - 1
     }
+    names(fit) <- names(x)
     names(p) <- c("alpha")
     out <- list(model = "Preemption", family = fam, y = x, coefficients = p, 
                 fitted.values = fit, aic = aic, rank = 1, df.residual = rdf, 

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2012-09-19 13:06:35 UTC (rev 2292)
+++ pkg/vegan/inst/ChangeLog	2012-09-19 13:36:28 UTC (rev 2293)
@@ -18,7 +18,8 @@
 
 	* radfit: added fitted() method for radfit.frame objects similar
 	to predict. The predict() method gained new argument to change the
-	expected 'total' size of communities.
+	expected 'total' size of communities. The fitted() returns now
+	named vectors or matrices.
 	
 Version 2.1-19 (closed September 16, 2012)
 



More information about the Vegan-commits mailing list