[Rcpp-commits] r3702 - in pkg/RcppArmadillo: . R inst inst/unitTests
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sat Jul 21 22:48:53 CEST 2012
Author: edd
Date: 2012-07-21 22:48:53 +0200 (Sat, 21 Jul 2012)
New Revision: 3702
Modified:
pkg/RcppArmadillo/ChangeLog
pkg/RcppArmadillo/DESCRIPTION
pkg/RcppArmadillo/R/fastLm.R
pkg/RcppArmadillo/inst/NEWS
pkg/RcppArmadillo/inst/unitTests/runit.fastLm.R
Log:
o expanded unit tests for fastLm
o simplified two stopifnot calls into one, and added a third (a la RcppEigen)
o rolled minor revision by one to indicate that this is not a CRAN release version
Modified: pkg/RcppArmadillo/ChangeLog
===================================================================
--- pkg/RcppArmadillo/ChangeLog 2012-07-21 17:54:46 UTC (rev 3701)
+++ pkg/RcppArmadillo/ChangeLog 2012-07-21 20:48:53 UTC (rev 3702)
@@ -1,3 +1,7 @@
+2012-07-21 Dirk Eddelbuettel <edd at debian.org>
+
+ * inst/unitTests/runit.fastLm.R: expanded unit tests for fastLm
+
2012-07-18 Dirk Eddelbuettel <edd at debian.org>
* R/fastLm.R (summary.fastLm): Also display residual standard error
Modified: pkg/RcppArmadillo/DESCRIPTION
===================================================================
--- pkg/RcppArmadillo/DESCRIPTION 2012-07-21 17:54:46 UTC (rev 3701)
+++ pkg/RcppArmadillo/DESCRIPTION 2012-07-21 20:48:53 UTC (rev 3702)
@@ -1,7 +1,7 @@
Package: RcppArmadillo
Type: Package
Title: Rcpp integration for Armadillo templated linear algebra library
-Version: 0.3.2.4
+Version: 0.3.2.4.1
Date: $Date$
Author: Romain Francois, Dirk Eddelbuettel and Doug Bates
Maintainer: Dirk Eddelbuettel <edd at debian.org>
Modified: pkg/RcppArmadillo/R/fastLm.R
===================================================================
--- pkg/RcppArmadillo/R/fastLm.R 2012-07-21 17:54:46 UTC (rev 3701)
+++ pkg/RcppArmadillo/R/fastLm.R 2012-07-21 20:48:53 UTC (rev 3702)
@@ -20,8 +20,7 @@
fastLmPure <- function(X, y) {
- stopifnot(is.matrix(X))
- stopifnot(nrow(y)==nrow(X))
+ stopifnot(is.matrix(X), is.numeric(y), nrow(y)==nrow(X))
.Call("fastLm", X, y, package = "RcppArmadillo")
}
Modified: pkg/RcppArmadillo/inst/NEWS
===================================================================
--- pkg/RcppArmadillo/inst/NEWS 2012-07-21 17:54:46 UTC (rev 3701)
+++ pkg/RcppArmadillo/inst/NEWS 2012-07-21 20:48:53 UTC (rev 3702)
@@ -3,6 +3,8 @@
o Corrected summary method to deal with the no intercept case when
using a formula; also display residual summary() statistics
+ o Expanded unit tests for fastLm
+
0.3.2.4 2012-07-11
o Upgraded to Armadillo release 3.2.4
Modified: pkg/RcppArmadillo/inst/unitTests/runit.fastLm.R
===================================================================
--- pkg/RcppArmadillo/inst/unitTests/runit.fastLm.R 2012-07-21 17:54:46 UTC (rev 3701)
+++ pkg/RcppArmadillo/inst/unitTests/runit.fastLm.R 2012-07-21 20:48:53 UTC (rev 3702)
@@ -1,6 +1,6 @@
#!/usr/bin/r -t
#
-# Copyright (C) 2010 - 2011 Dirk Eddelbuettel, Romain Francois and Douglas Bates
+# Copyright (C) 2010 - 2012 Dirk Eddelbuettel, Romain Francois and Douglas Bates
#
# This file is part of RcppArmadillo.
#
@@ -34,8 +34,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 <- RcppArmadillo:::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)
@@ -44,5 +102,11 @@
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