]> git.donarmstrong.com Git - ape.git/blobdiff - R/compar.gee.R
fix in drop.tip() and new option in pic()
[ape.git] / R / compar.gee.R
index caead0776b8dc6161a14034805071bdc89fbcc45..1df21079ca726daed70b8db034ea6e42eb8d42ce 100644 (file)
@@ -1,4 +1,4 @@
-## compar.gee.R (2010-07-20)
+## compar.gee.R (2011-06-14)
 
 ##   Comparative Analysis with GEEs
 
@@ -45,7 +45,7 @@ compar.gee <-
     }
 
     id <- rep(1, dim(R)[1])
-    geemod <<- geemod <- do.call("gee", list(formula, id, data = data, family = family, R = R,
+    geemod <- do.call("gee", list(formula, id, data = data, family = family, R = R,
                                   corstr = "fixed", scale.fix = scale.fix,
                                   scale.value = scale.value))
     W <- geemod$naive.variance
@@ -57,7 +57,7 @@ compar.gee <-
     ## <FIXME>
     ## maybe need to refine below in case of non-Brownian corStruct
     if (!missing(corStruct)) phy <- attr(corStruct, "tree")
-    dfP <- sum(phy$edge.length)*N / sum(diag(R))
+    dfP <- sum(phy$edge.length)*N / sum(diag(vcv(phy))) # need the variances
     ## </FIXME>
 
     ## compute QIC:
@@ -80,6 +80,7 @@ compar.gee <-
                 QIC = QIC,
                 coefficients = geemod$coefficients,
                 residuals = geemod$residuals,
+                fitted.values = MU,
                 family = geemod$family$family,
                 link = geemod$family$link,
                 scale = geemod$scale,
@@ -151,3 +152,13 @@ you should be careful when interpreting the significance of the main effects.")
                                   as.character(as.expression(fm)), "\n")
     ans
 }
+
+predict.compar.gee <-
+    function(object, type = c("link", "response"), ...)
+{
+    type <- match.arg(type)
+    pred <- object$fitted.values
+    if (type == "link") return(pred)
+    f <- match.fun(object$family)
+    f(link = object$link)$linkinv(pred)
+}