[Vegan-commits] r1298 - in pkg/gravy: R inst man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Sep 3 08:47:16 CEST 2010
Author: jarioksa
Date: 2010-09-03 08:47:15 +0200 (Fri, 03 Sep 2010)
New Revision: 1298
Modified:
pkg/gravy/R/HOF.default.R
pkg/gravy/R/residuals.HOF.R
pkg/gravy/inst/ChangeLog
pkg/gravy/man/HOF.Rd
Log:
HOF returns 'family' & residuals gain type 'pearson'
Modified: pkg/gravy/R/HOF.default.R
===================================================================
--- pkg/gravy/R/HOF.default.R 2010-09-02 13:28:55 UTC (rev 1297)
+++ pkg/gravy/R/HOF.default.R 2010-09-03 06:47:15 UTC (rev 1298)
@@ -14,9 +14,10 @@
dev <- sum(dev.resids(y, mu, wt))
aic(y, n, mu, wt, dev)/2
}
- aic <- family()$aic
- dev.resids <- family()$dev.resids
- famname <- family()$family
+ fam <- eval(family())
+ aic <- fam$aic
+ dev.resids <- fam$dev.resids
+ famname <- fam$family
if (!(famname %in% c("binomial", "gaussian", "poisson")))
stop("Allowed familes: binomial, gaussian, poisson")
div <- if(famname == "binomial") M else 1
@@ -73,7 +74,7 @@
I = I.res)
out <- list(call = match.call(), x = x.orig, y = spec, x.name = x.name,
y.name = y.name, range = x.range, M = M, nobs = nobs,
- models = models)
+ models = models, family = fam)
class(out) <- "HOF"
out
}
Modified: pkg/gravy/R/residuals.HOF.R
===================================================================
--- pkg/gravy/R/residuals.HOF.R 2010-09-02 13:28:55 UTC (rev 1297)
+++ pkg/gravy/R/residuals.HOF.R 2010-09-03 06:47:15 UTC (rev 1298)
@@ -1,14 +1,21 @@
`residuals.HOF` <-
- function(object, type = c("deviance", "working", "response"), model, ...)
+ function(object,
+ type = c("deviance", "working", "response", "pearson"),
+ model, ...)
{
type <- match.arg(type)
y <- object$y
+ V <- object$family$variance
+ M <- object$M
+ if (length(M) == 1)
+ M <- rep(M, length(y))
mu <- sapply(object$models, fitted)
r <- sapply(object$models, residuals)
res <- switch(type,
deviance = ifelse(sweep(mu, 1, y, "<"), sqrt(r), -sqrt(r)),
working = r,
- response = -sweep(mu, 1, y, "-"))
+ response = -sweep(mu, 1, y, "-"),
+ pearson = -sweep(mu, 1, y, "-")/V(sweep(mu, 1, M, "/")))
if (!missing(model))
res <- res[, model]
res
Modified: pkg/gravy/inst/ChangeLog
===================================================================
--- pkg/gravy/inst/ChangeLog 2010-09-02 13:28:55 UTC (rev 1297)
+++ pkg/gravy/inst/ChangeLog 2010-09-03 06:47:15 UTC (rev 1298)
@@ -1,7 +1,7 @@
Version 0.1-3 September 2, 2010
- * HOF: gained residuals() method with (useful) alternatives 'type
- = "deviance"' and 'type = "response"' plue (useless) 'type =
- "working"'.
+ * HOF: gained residuals() method with (useful) 'type's "deviance",
+ "response" and "pearson" plus (useless) 'type = "working"'.
+ * HOF: returns 'family' object.
Version 0.1-2 March 18, 2010
* ssHOF: HOF gave unnecesarry warnings when used with non-integer
data.
Modified: pkg/gravy/man/HOF.Rd
===================================================================
--- pkg/gravy/man/HOF.Rd 2010-09-02 13:28:55 UTC (rev 1297)
+++ pkg/gravy/man/HOF.Rd 2010-09-03 06:47:15 UTC (rev 1298)
@@ -27,8 +27,8 @@
\method{plot}{HOF}(x, ...)
\method{plot}{HOF.frame}(x, level = 0.95, test ="F", species, ...)
\method{fitted}{HOF}(object, model, ...)
-\method{residuals}{HOF}(object, type = c("deviance", "working", "response"),
- model, ...)
+\method{residuals}{HOF}(object, type = c("deviance", "working",
+ "response", "pearson"), model, ...)
\method{predict}{HOF}(object, newdata, model, ...)
\method{GaussPara}{HOF}(resp, model, ...)
}
@@ -48,7 +48,7 @@
\item{test}{Test for model selection. Alternatives are \code{"F"},
\code{"Chisq"}, \code{"AIC"}, \code{"BIC"}. }
\item{type}{the type of residuals which should be returned (see
- \code{\link{predict.glm}}).}
+ \code{\link{residuals.glm}}).}
\item{species}{Names of the species displayed in graphs.}
\item{x, object}{An object from \code{HOF(spec, \dots)}.}
\item{newdata}{Vector of gradient values for prediction.}
More information about the Vegan-commits
mailing list