[Rcpp-commits] r3709 - in pkg/RcppGSL: . inst inst/unitTests

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Jul 22 23:48:22 CEST 2012


Author: edd
Date: 2012-07-22 23:48:22 +0200 (Sun, 22 Jul 2012)
New Revision: 3709

Modified:
   pkg/RcppGSL/ChangeLog
   pkg/RcppGSL/DESCRIPTION
   pkg/RcppGSL/inst/NEWS.Rd
   pkg/RcppGSL/inst/unitTests/runit.fastLm.R
Log:
 o Release 0.2.0
 o added more unit tests for fastLm


Modified: pkg/RcppGSL/ChangeLog
===================================================================
--- pkg/RcppGSL/ChangeLog	2012-07-22 20:04:44 UTC (rev 3708)
+++ pkg/RcppGSL/ChangeLog	2012-07-22 21:48:22 UTC (rev 3709)
@@ -1,5 +1,9 @@
 2012-07-22  Dirk Eddelbuettel  <edd at debian.org>
 
+	* DESCRIPTION: Version 0.2.0
+	
+	* inst/unitTests/runit.fastLm.R: expanded unit tests
+
 	* R/inline.R: Use two hidden global variables to store RcppGSL
 	compiler and linker flags instead of using assignInNamespace
 

Modified: pkg/RcppGSL/DESCRIPTION
===================================================================
--- pkg/RcppGSL/DESCRIPTION	2012-07-22 20:04:44 UTC (rev 3708)
+++ pkg/RcppGSL/DESCRIPTION	2012-07-22 21:48:22 UTC (rev 3709)
@@ -1,7 +1,7 @@
 Package: RcppGSL
 Type: Package
 Title: Rcpp integration for GNU GSL vectors and matrices
-Version: 0.1.1.5
+Version: 0.2.0
 Date: $Date$
 Author: Romain Francois and Dirk Eddelbuettel
 Maintainer: Dirk Eddelbuettel <edd at debian.org>

Modified: pkg/RcppGSL/inst/NEWS.Rd
===================================================================
--- pkg/RcppGSL/inst/NEWS.Rd	2012-07-22 20:04:44 UTC (rev 3708)
+++ pkg/RcppGSL/inst/NEWS.Rd	2012-07-22 21:48:22 UTC (rev 3709)
@@ -2,10 +2,11 @@
 \title{News for Package \pkg{RcppGSL}}
 \newcommand{\cpkg}{\href{http://CRAN.R-project.org/package=#1}{\pkg{#1}}}
 
-\section{Changes in version 0.1.2 (2012-xx-yy)}{
+\section{Changes in version 0.2.0 (2012-07-22)}{
   \itemize{
     \item{summary() for fastLm() now displays vastly more information}
     \item{fastLmPure() now uses same argument order as R's lm.fit()}
+    \item{Added more unit tests for fastLm() and related functions}
     \item{Export and document S3 methods in NAMESPACE and manual page as
       such}
     \item{Vignettes have been moved to the \code{vignettes/} directory}

Modified: pkg/RcppGSL/inst/unitTests/runit.fastLm.R
===================================================================
--- pkg/RcppGSL/inst/unitTests/runit.fastLm.R	2012-07-22 20:04:44 UTC (rev 3708)
+++ pkg/RcppGSL/inst/unitTests/runit.fastLm.R	2012-07-22 21:48:22 UTC (rev 3709)
@@ -1,7 +1,7 @@
 #!/usr/bin/r -t
 #                        Emacs make this -*- mode: R; tab-width: 4 -*-
 #
-# Copyright (C) 2010 - 2011	 Romain Francois and Dirk Eddelbuettel
+# Copyright (C) 2010 - 2012	 Romain Francois and Dirk Eddelbuettel
 #
 # This file is part of RcppGSL.
 #
@@ -30,8 +30,66 @@
                 msg="fastLm.coef")
     checkEquals( as.numeric(flm$stderr), as.numeric(coef(summary(fit))[,2]),
                 msg="fastLm.stderr")
+    checkEquals(as.numeric(flm$df.residual), as.numeric(fit$df.residual),
+                msg="fastLm.df.residual")
 }
 
+test.fastLm.default <- function() {
+    data(trees, package="datasets")
+    flm <- RcppGSL:::fastLm.default(cbind(1, log(trees$Girth)), log(trees$Volume))
+    fit <- lm(log(Volume) ~ log(Girth), data=trees)
+
+    checkEquals(as.numeric(flm$coefficients), as.numeric(coef(fit)),
+                msg="fastLm.default.coef")
+    checkEquals(as.numeric(flm$stderr), as.numeric(coef(summary(fit))[,2]),
+                msg="fastLm.default.stderr")
+    checkEquals(as.numeric(flm$df.residual), as.numeric(fit$df.residual),
+                msg="fastLm.default.df.residual")
+    checkEquals(as.numeric(flm$residuals), as.numeric(fit$residuals),
+                msg="fastLm.default.residuals")
+    checkEquals(as.numeric(flm$fitted.values), as.numeric(fit$fitted.values),
+                msg="fastLm.default.fitted.values")
+}
+
+test.summary.fastLm <- function() {
+    data(trees, package="datasets")
+    sflm <- summary(fastLm(log(Volume) ~ log(Girth), data=trees))
+    sfit <- summary(lm(log(Volume) ~ log(Girth), data=trees))
+
+    checkEquals(as.numeric(coef(sflm)), as.numeric(coef(sfit)),
+                msg="summary.fastLm.coef")
+    checkEquals(sflm$r.squared, sfit$r.squared,
+                msg="summary.fastLm.r.squared")
+    checkEquals(sflm$adj.r.squared, sfit$adj.r.squared,
+                msg="summary.fastLm.r.squared")
+    checkEquals(sflm$sigma, sfit$sigma,
+                msg="summary.fastLm.sigma")
+
+    ## no intercept case
+    sflm <- summary(fastLm(log(Volume) ~ log(Girth) - 1, data=trees))
+    sfit <- summary(lm(log(Volume) ~ log(Girth) - 1, data=trees))
+    checkEquals(as.numeric(coef(sflm)), as.numeric(coef(sfit)),
+                msg="summary.fastLm.coef.noint")
+    checkEquals(sflm$r.squared, sfit$r.squared,
+                msg="summary.fastLm.r.squared.noint")
+    checkEquals(sflm$adj.r.squared, sfit$adj.r.squared,
+                msg="summary.fastLm.r.squared.noint")
+    checkEquals(sflm$sigma, sfit$sigma,
+                msg="summary.fastLm.sigma.noint")
+
+    ## non-formula use
+    sflm <- summary(fastLm(log(trees$Girth), log(trees$Volume)))
+    sfit <- summary(lm(log(Volume) ~ log(Girth) - 1, data=trees))
+    checkEquals(as.numeric(coef(sflm)), as.numeric(coef(sfit)),
+                msg="summary.fastLm.coef.nonform")
+    checkEquals(sflm$r.squared, sfit$r.squared,
+                msg="summary.fastLm.r.squared.nonform")
+    checkEquals(sflm$adj.r.squared, sfit$adj.r.squared,
+                msg="summary.fastLm.r.squared.nonform")
+    checkEquals(sflm$sigma, sfit$sigma,
+                msg="summary.fastLm.sigma.nonform")
+}
+
 test.fastLm.formula <- function() {
     data(trees, package="datasets")
     flm <- fastLm(log(Volume) ~ log(Girth), data=trees)
@@ -40,6 +98,12 @@
     checkEquals(flm$coefficients, coef(fit), msg="fastLm.formula.coef")
     checkEquals(as.numeric(flm$stderr), as.numeric(coef(summary(fit))[,2]),
                 msg="fastLm.formula.stderr")
+    checkEquals(as.numeric(flm$df.residual), as.numeric(fit$df.residual),
+                msg="fastLm.formula.df.residual")
+    checkEquals(as.numeric(flm$residuals), as.numeric(fit$residuals),
+                msg="fastLm.formula.residuals")
+    checkEquals(as.numeric(flm$fitted.values), as.numeric(fit$fitted.values),
+                msg="fastLm.formula.fitted.values")
 }
 
 



More information about the Rcpp-commits mailing list