[Caic-commits] r86 - branches/newPGLS/R pkg pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Jan 23 14:25:45 CET 2009


Author: davidorme
Date: 2009-01-23 14:25:45 +0100 (Fri, 23 Jan 2009)
New Revision: 86

Modified:
   branches/newPGLS/R/pglm.R
   pkg/DESCRIPTION
   pkg/R/macrocaic.R
Log:
Added checks for negative or non-integer species richness values in macrocaic()

Modified: branches/newPGLS/R/pglm.R
===================================================================
--- branches/newPGLS/R/pglm.R	2008-12-09 11:54:38 UTC (rev 85)
+++ branches/newPGLS/R/pglm.R	2009-01-23 13:25:45 UTC (rev 86)
@@ -444,6 +444,7 @@
 		n <- length(x[,1])
 		logDetV <- determinant(V, logarithm = TRUE)$modulus[1]
 		ll <- -n / 2.0 * log( 2 * pi) - n / 2.0 * log(s2) - logDetV / 2.0 - (n - 1)/2.0
+
 		ypred <- x%*%mu	
 
 		# if being used for optimization, only return the log likelihood
@@ -536,9 +537,9 @@
 	fm <- list(coef = coeffs, aic = aic, log.lik = log.lik)
 	
 	logDetV <- determinant(V, logarithm = TRUE)$modulus[1]
- 	
-	logLikY <- -n / 2.0 * log( 2 * pi) - n / 2.0 * log(ll$s2) - logDetV / 2.0  - (n - 1 )/ 2.0
 	
+	logLikY <- -n / 2.0 * log( 2 * pi) - n / 2.0 * log( (n - k) * ll$s2 / n) - logDetV / 2.0  - n / 2.0
+
 	RMS <- ll$s2
 	RSSQ <- ll$s2 * (n - k)
 	NMS <- RMS

Modified: pkg/DESCRIPTION
===================================================================
--- pkg/DESCRIPTION	2008-12-09 11:54:38 UTC (rev 85)
+++ pkg/DESCRIPTION	2009-01-23 13:25:45 UTC (rev 86)
@@ -1,9 +1,9 @@
 Package: CAIC
 Type: Package
 Title: Comparative Analyses using Independent Contrasts
-Version: 1.0.4-85
+Version: 1.0.4-86
 Date: 2008-10-01
-Author: David Orme, Rob Freckleton, Gavin Thomas
+Author: David Orme, Rob Freckleton, Gavin Thomas, Thomas Petzoldt
 Maintainer: David Orme <d.orme at imperial.ac.uk>
 Depends: R (>= 2.6.0), ape, MASS, mvtnorm
 Description: Functions for performing comparative analysis using independent contrasts and tree simulation.

Modified: pkg/R/macrocaic.R
===================================================================
--- pkg/R/macrocaic.R	2008-12-09 11:54:38 UTC (rev 85)
+++ pkg/R/macrocaic.R	2009-01-23 13:25:45 UTC (rev 86)
@@ -120,7 +120,12 @@
         macroMf <- as.matrix(model.response(initMf))
         colnames(macroMf) <- with(attributes(attr(initMf, "terms")), rownames(factors)[response])
         if(any(is.na(macroMf))) stop("MacroCAIC analyses cannot have missing species richness values")
+        if(any(macroMf <= 0)) stop("Species richness values cannot be negative or zero")
         
+        if(any((macroMf %% 1) > 0)) {
+            macroMf <- floor(macroMf)
+            warning("Non-integer species richness values present: data have been rounded down to the nearest integer")
+        }
         
     # CALCULATE MODEL 
     # GET THE MODEL MATRIX and Model Response



More information about the Caic-commits mailing list