[R-gregmisc-users] SF.net SVN: r-gregmisc:[1707] trunk/gmodels
Brought to you by:
warnes
From: <wa...@us...> - 2013-07-18 13:46:04
|
Revision: 1707 http://sourceforge.net/p/r-gregmisc/code/1707 Author: warnes Date: 2013-07-18 13:46:00 +0000 (Thu, 18 Jul 2013) Log Message: ----------- Correct bug in estimable.mlm Modified Paths: -------------- trunk/gmodels/R/estimable.mlm.R Added Paths: ----------- trunk/gmodels/test/test_estimable_mlm.R Modified: trunk/gmodels/R/estimable.mlm.R =================================================================== --- trunk/gmodels/R/estimable.mlm.R 2013-07-15 18:13:11 UTC (rev 1706) +++ trunk/gmodels/R/estimable.mlm.R 2013-07-18 13:46:00 UTC (rev 1707) @@ -1,28 +1,28 @@ `estimable.mlm` <- function (obj, cm, beta0, conf.int=NULL, show.beta0, ...) { - coef <- coef(object) + coef <- coef(obj) ny <- ncol(coef) - effects <- object$effects - resid <- object$residuals - fitted <- object$fitted + effects <- obj$effects + resid <- obj$residuals + fitted <- obj$fitted ynames <- colnames(coef) if (is.null(ynames)) { - lhs <- object$terms[[2]] + lhs <- obj$terms[[2]] if (mode(lhs) == "call" && lhs[[1]] == "cbind") ynames <- as.character(lhs)[-1] else ynames <- paste("Y", seq(ny), sep = "") } value <- vector("list", ny) names(value) <- paste("Response", ynames) - cl <- oldClass(object) - class(object) <- cl[match("mlm", cl):length(cl)][-1] + cl <- oldClass(obj) + class(obj) <- cl[match("mlm", cl):length(cl)][-1] for (i in seq(ny)) { - object$coefficients <- coef[, i] - object$residuals <- resid[, i] - object$fitted.values <- fitted[, i] - object$effects <- effects[, i] - object$call$formula[[2]] <- object$terms[[2]] <- as.name(ynames[i]) + obj$coefficients <- coef[, i] + obj$residuals <- resid[, i] + obj$fitted.values <- fitted[, i] + obj$effects <- effects[, i] + obj$call$formula[[2]] <- obj$terms[[2]] <- as.name(ynames[i]) value[[i]] <- estimable(obj, cm, beta0, conf.int=NULL, show.beta0, ...) } class(value) <- "listof" Added: trunk/gmodels/test/test_estimable_mlm.R =================================================================== --- trunk/gmodels/test/test_estimable_mlm.R (rev 0) +++ trunk/gmodels/test/test_estimable_mlm.R 2013-07-18 13:46:00 UTC (rev 1707) @@ -0,0 +1,15 @@ +library(gmodels) + +y <- cbind(rnorm(100), rnorm(100)) + +x1 <- rnorm(100) +x2 <- rnorm(100) + +cm <- t(matrix(c(0, 1,-1))) +lm.1 <- lm(y ~ x1 + x2) + +estimable(lm.1, cm) + +## >> Error in coef(object) : object 'object' not found + +gmodels:::estimable.mlm(lm.1, cm) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |