[Mattice-commits] r164 - pkg/misc

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Jan 27 19:43:02 CET 2009


Author: andrew_hipp
Date: 2009-01-27 19:43:02 +0100 (Tue, 27 Jan 2009)
New Revision: 164

Modified:
   pkg/misc/multiModels.R
Log:


Modified: pkg/misc/multiModels.R
===================================================================
--- pkg/misc/multiModels.R	2009-01-20 20:11:38 UTC (rev 163)
+++ pkg/misc/multiModels.R	2009-01-27 18:43:02 UTC (rev 164)
@@ -42,16 +42,17 @@
    if(i %in% pSum) next
    else allParams <- c(allParams, paste(treeNames, i, sep = ""))
    }
-  analysis <- ifelse(model == "brown",
-                     lapply(phyList, brown, data = dat),
-                     lapply(phyList, hansen, data = dat, 
-                            regimes = structure(rep(1, phyList[[1]]@nnodes), 
-                                                names = phyList[[1]]@nodes, 
-                                                levels = 1, class = 'factor'),       ## won't work... multiple subtrees, different regimes!
-                            sigma = 1, alpha = 1)
-                     )
+  if(model == "brown") analysis <- lapply(phyList, brown, data = dat),
+  else {
+    analysis <- list(length(phyList))
+    for (i in seq(length(phyList))) analysis[[i]] <- hansen(data = dat, tree = phyList[[i]], 
+                                                            regimes = structure(rep(1, phyList[[i]]@nnodes), 
+                                                                                names = phyList[[i]]@nodes, 
+                                                                                levels = 1, class = 'factor'),
+                                                            sigma = 1, alpha = 1)
+    } # close else
   params <- lapply(analysis, function(x) {unlist(summary(x)[pV])[pV]}, pV = allParams)
-  rawMat <- matrix(unlist(params), nrow = length(params), ncol = length(allParams), dimnames = list(treeNames, allParams))
+  rawMat <- matrix(unlist(params), nrow = length(params), ncol = length(allParams), byrow = T, dimnames = list(treeNames, allParams))
   params <- colSums(rawMat, na.rm = T)
   out <- list(analysis = analysis, rawMat = rawMat, params = params)
   return(out)



More information about the Mattice-commits mailing list