[Mattice-commits] r30 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Nov 14 22:00:03 CET 2008


Author: andrew_hipp
Date: 2008-11-14 22:00:03 +0100 (Fri, 14 Nov 2008)
New Revision: 30

Modified:
   pkg/R/informationCriterion.R
   pkg/R/summarizingAnalyses.R
Log:
more changes for summarizing analysis

Modified: pkg/R/informationCriterion.R
===================================================================
--- pkg/R/informationCriterion.R	2008-11-14 19:50:49 UTC (rev 29)
+++ pkg/R/informationCriterion.R	2008-11-14 21:00:03 UTC (rev 30)
@@ -1,20 +1,19 @@
 informationCriterion <- function(u = NULL, lnL = NULL, K, n = 0, names = NULL) {
-## Returns information criterion values + weights for a vector of u or lnL, K (= df), and n (sample size); names for analyses are optional
-  if(identical(u,NULL)) u <- -2 * lnL
-  
-  AIC = vector("numeric", length(u))
-  BIC = vector("numeric", length(u))
-  AICc = vector("numeric", length(u))
+## Returns information criterion values + weights for a vector of u or lnL, a vector of K (= df), and a single n (sample size); names for analyses are optional
+  if(identical(u,NULL)) u <- -2 * lnL # deviance (u) needed; take from lnL if not provided, ignore lnL if provided
+  AIC <- vector("numeric", length(u))
+  BIC <- vector("numeric", length(u))
+  AICc <- vector("numeric", length(u))
   for(i in 1:length(u)) {
-    AICc[i] = u[i] + (2 * K[i] * (n / (n - K[i] - 1)))
-    AIC[i] = u[i] + (2 * K[i])
-    BIC[i] = u[i] + (log(n) * K[i]) }
-  deltaAIC = as.vector(lapply(AIC, function(x, allX) {x - min(allX)}, allX = AIC), mode = "numeric")
-  deltaAICc = as.vector(lapply(AICc, function(x, allX) {x - min(allX)}, allX = AICc), mode = "numeric")
-  deltaBIC = as.vector(lapply(BIC, function(x, allX) {x - min(allX)}, allX = BIC), mode = "numeric")
-  AICwi = as.vector(lapply(deltaAIC, function(x, allDelta) {exp(-0.5 * x) / sum(exp(-0.5 * allDelta))}, allDelta = deltaAIC), mode = "numeric")
-  AICcwi = as.vector(lapply(deltaAICc, function(x, allDelta) {exp(-0.5 * x) / sum(exp(-0.5 * allDelta))}, allDelta = deltaAICc), mode = "numeric")
-  BICwi = as.vector(lapply(deltaBIC, function(x, allDelta) {exp(-0.5 * x) / sum(exp(-0.5 * allDelta))}, allDelta = deltaBIC), mode = "numeric")
+    AICc[i] <- u[i] + (2 * K[i] * (n / (n - K[i] - 1)))
+    AIC[i] <- u[i] + (2 * K[i])
+    BIC[i] <- u[i] + (log(n) * K[i]) }
+  deltaAIC <- as.vector(lapply(AIC, function(x, allX) {x - min(allX)}, allX = AIC), mode = "numeric")
+  deltaAICc <- as.vector(lapply(AICc, function(x, allX) {x - min(allX)}, allX = AICc), mode = "numeric")
+  deltaBIC <- as.vector(lapply(BIC, function(x, allX) {x - min(allX)}, allX = BIC), mode = "numeric")
+  AICwi <- as.vector(lapply(deltaAIC, function(x, allDelta) {exp(-0.5 * x) / sum(exp(-0.5 * allDelta))}, allDelta = deltaAIC), mode = "numeric")
+  AICcwi <- as.vector(lapply(deltaAICc, function(x, allDelta) {exp(-0.5 * x) / sum(exp(-0.5 * allDelta))}, allDelta = deltaAICc), mode = "numeric")
+  BICwi <- as.vector(lapply(deltaBIC, function(x, allDelta) {exp(-0.5 * x) / sum(exp(-0.5 * allDelta))}, allDelta = deltaBIC), mode = "numeric")
   return(list(names = names, u = u, K = K, AIC = AIC, AICc = AICc, BIC = BIC, AICwi = AICwi, AICcwi = AICcwi, BICwi = BICwi)) }
 
 informationCriterion.hansenBatch <- function(hansenBatch)

Modified: pkg/R/summarizingAnalyses.R
===================================================================
--- pkg/R/summarizingAnalyses.R	2008-11-14 19:50:49 UTC (rev 29)
+++ pkg/R/summarizingAnalyses.R	2008-11-14 21:00:03 UTC (rev 30)
@@ -24,6 +24,7 @@
 
 summary.hansenBatch <- function(hansenBatch){
 ## items in output: hansens, regimeList, regimeMatrix
-## the summary will sum weights over all nodes over all trees
-
+## the summary will eventually sum weights over all nodes over all trees
+## for now, only doing first tree
+  
   }
\ No newline at end of file



More information about the Mattice-commits mailing list