[Rcpp-commits] r2467 - in pkg/RcppArmadillo: . R inst

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Nov 19 18:37:19 CET 2010


Author: edd
Date: 2010-11-19 18:37:18 +0100 (Fri, 19 Nov 2010)
New Revision: 2467

Modified:
   pkg/RcppArmadillo/ChangeLog
   pkg/RcppArmadillo/R/fastLm.R
   pkg/RcppArmadillo/inst/NEWS
Log:
made summary() return rsq and adj.rsq


Modified: pkg/RcppArmadillo/ChangeLog
===================================================================
--- pkg/RcppArmadillo/ChangeLog	2010-11-19 14:55:37 UTC (rev 2466)
+++ pkg/RcppArmadillo/ChangeLog	2010-11-19 17:37:18 UTC (rev 2467)
@@ -1,8 +1,12 @@
+2010-11-19  Dirk Eddelbuettel  <edd at debian.org>
+
+	* R/fastLm.R: Also provide two R-squared measures in summary method
+
 2010-11-19  Romain Francois <romain at r-enthusiasts.com>
 
 	* DESCRIPTION: remove dependency on GNU make
-	
-	* R/RcppArmadillo.package.skeleton.R: updated skeleton generator so that the 
+
+	* R/RcppArmadillo.package.skeleton.R: updated skeleton generator so that the
 	dependency on GNU make is removed
 
 2010-11-11  Dirk Eddelbuettel  <edd at debian.org>

Modified: pkg/RcppArmadillo/R/fastLm.R
===================================================================
--- pkg/RcppArmadillo/R/fastLm.R	2010-11-19 14:55:37 UTC (rev 2466)
+++ pkg/RcppArmadillo/R/fastLm.R	2010-11-19 17:37:18 UTC (rev 2467)
@@ -67,8 +67,22 @@
     rownames(TAB) <- names(object$coefficients)
     colnames(TAB) <- c("Estimate", "StdErr", "t.value", "p.value")
 
+    ## cf src/stats/R/lm.R and case with no weights and an intercept
+    f <- object$fitted.values
+    r <- object$residuals
+    mss <- sum((f - mean(f))^2)
+    rss <- sum(r^2)
+
+    r.squared <- mss/(mss + rss)
+    df.int <- 1 		# case of intercept
+    n <- length(f)
+    rdf <- object$df
+    adj.r.squared <- 1 - (1 - r.squared) * ((n - df.int)/rdf)
+
     res <- list(call=object$call,
-                coefficients=TAB)
+                coefficients=TAB,
+                r.squared=r.squared,
+                adj.r.squared=adj.r.squared)
 
     class(res) <- "summary.fastLm"
     res
@@ -80,6 +94,11 @@
     cat("\n")
 
     printCoefmat(x$coefficients, P.value=TRUE, has.Pvalue=TRUE)
+    digits <- max(3, getOption("digits") - 3)
+    cat("Multiple R-squared: ", formatC(x$r.squared, digits=digits),
+        ",\tAdjusted R-squared: ",formatC(x$adj.r.squared, digits=digits),
+        "\n", sep="")
+    invisible(x)
 }
 
 fastLm.formula <- function(formula, data=list(), ...) {

Modified: pkg/RcppArmadillo/inst/NEWS
===================================================================
--- pkg/RcppArmadillo/inst/NEWS	2010-11-19 14:55:37 UTC (rev 2466)
+++ pkg/RcppArmadillo/inst/NEWS	2010-11-19 17:37:18 UTC (rev 2467)
@@ -1,3 +1,7 @@
+0.2.10  TBD
+
+    o   summary() for fastLm() objects now returns r.squared and adj.r.squared
+
 0.2.9   2010-11-11
 
     o   Upgraded to Armadillo 0.9.92 "Wall Street Gangster":



More information about the Rcpp-commits mailing list