[Rcpp-commits] r3703 - in pkg/RcppGSL: . R inst
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sat Jul 21 23:50:00 CEST 2012
Author: edd
Date: 2012-07-21 23:50:00 +0200 (Sat, 21 Jul 2012)
New Revision: 3703
Added:
pkg/RcppGSL/inst/NEWS.Rd
Removed:
pkg/RcppGSL/inst/NEWS
Modified:
pkg/RcppGSL/ChangeLog
pkg/RcppGSL/DESCRIPTION
pkg/RcppGSL/R/fastLm.R
Log:
o updated fastLm as in RcppArmadillo to correctly reflectly intercepts in
R^2 and generally show more information
o changed Maintainer to single person per CRAN wishes
o converted NEWS to .Rd format
Modified: pkg/RcppGSL/ChangeLog
===================================================================
--- pkg/RcppGSL/ChangeLog 2012-07-21 20:48:53 UTC (rev 3702)
+++ pkg/RcppGSL/ChangeLog 2012-07-21 21:50:00 UTC (rev 3703)
@@ -1,3 +1,13 @@
+2012-07-21 Dirk Eddelbuettel <edd at debian.org>
+
+ * R/fastLm.R: expanded summary() display as in RcppArmadillo
+
+ * inst/NEWS.Rd: converted from ascii text to Rd format
+
+ * vignettes/*: moved from inst/doc/* per newer R Policy
+
+ * DESCRIPTION: changed Maintainer: to single person per CRAN Policy
+
2011-12-23 Dirk Eddelbuettel <edd at debian.org>
* inst/unitTests/runTests.R: unit tests output 'fallback' directory
Modified: pkg/RcppGSL/DESCRIPTION
===================================================================
--- pkg/RcppGSL/DESCRIPTION 2012-07-21 20:48:53 UTC (rev 3702)
+++ pkg/RcppGSL/DESCRIPTION 2012-07-21 21:50:00 UTC (rev 3703)
@@ -1,10 +1,10 @@
Package: RcppGSL
Type: Package
Title: Rcpp integration for GNU GSL vectors and matrices
-Version: 0.1.1.3
+Version: 0.1.1.4
Date: $Date$
Author: Romain Francois and Dirk Eddelbuettel
-Maintainer: Dirk Eddelbuettel and Romain Francois <RomainAndDirk at r-enthusiasts.com>
+Maintainer: Dirk Eddelbuettel <edd at debian.org>
Description: Rcpp integration for GNU GSL vectors and matrices
The GNU Scientific Library (GSL) is a collection of numerical routines for
scientific computing. It is particularly useful for C and C++ programs as it
Modified: pkg/RcppGSL/R/fastLm.R
===================================================================
--- pkg/RcppGSL/R/fastLm.R 2012-07-21 20:48:53 UTC (rev 3702)
+++ pkg/RcppGSL/R/fastLm.R 2012-07-21 21:50:00 UTC (rev 3703)
@@ -1,7 +1,7 @@
## fastLm.R: Rcpp/GSL implementation of lm()
##
-## Copyright (C) 2010 - 2011 Dirk Eddelbuettel and Romain Francois
+## Copyright (C) 2010 - 2012 Dirk Eddelbuettel and Romain Francois
##
## This file is part of RcppGSL.
##
@@ -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))
res <- .Call("fastLm", X, y, package="RcppGSL")
}
@@ -39,6 +38,7 @@
res$fitted.values <- as.vector(X %*% res$coefficients)
res$residuals <- y - res$fitted.values
res$call <- match.call()
+ res$intercept <- any(apply(X, 2, function(x) all(x == x[1])))
class(res) <- "fastLm"
res
@@ -61,17 +61,19 @@
p.value = 2*pt(-abs(tval), df=object$df))
# why do I need this here?
-# rownames(TAB) <- names(object$coefficients)
-# colnames(TAB) <- c("Estimate", "StdErr", "t.value", "p.value")
+ 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)
+ #mss <- sum((f - mean(f))^2)
+ mss <- if (object$intercept) sum((f - mean(f))^2) else sum(f^2)
rss <- sum(r^2)
r.squared <- mss/(mss + rss)
- df.int <- 1 # case of intercept
+ df.int <- if (object$intercept) 1L else 0L
+
n <- length(f)
rdf <- object$df
adj.r.squared <- 1 - (1 - r.squared) * ((n - df.int)/rdf)
@@ -79,7 +81,10 @@
res <- list(call=object$call,
coefficients=TAB,
r.squared=r.squared,
- adj.r.squared=adj.r.squared)
+ adj.r.squared=adj.r.squared,
+ sigma=sqrt(sum((object$residuals)^2)/rdf),
+ df=object$df,
+ residSum=summary(object$residuals, digits=5)[-4])
class(res) <- "summary.fastLm"
res
@@ -88,9 +93,18 @@
print.summary.fastLm <- function(x, ...) {
cat("\nCall:\n")
print(x$call)
+ cat("\nResiduals:\n")
+ print(x$residSum)
cat("\n")
printCoefmat(x$coefficients, P.values=TRUE, has.Pvalue=TRUE)
+ digits <- max(3, getOption("digits") - 3)
+ cat("\nResidual standard error: ", formatC(x$sigma, digits=digits), " on ",
+ formatC(x$df), " degrees of freedom\n", sep="")
+ 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(), ...) {
@@ -101,6 +115,7 @@
res <- fastLm.default(X, y, ...)
res$call <- match.call()
res$formula <- formula
+ res$intercept <- attr(attr(mf, "terms"), "intercept")
res
}
Deleted: pkg/RcppGSL/inst/NEWS
===================================================================
--- pkg/RcppGSL/inst/NEWS 2012-07-21 20:48:53 UTC (rev 3702)
+++ pkg/RcppGSL/inst/NEWS 2012-07-21 21:50:00 UTC (rev 3703)
@@ -1,24 +0,0 @@
-0.1.2 20xx-yy-zz
-
- o fastLmPure() now uses same argument order as R's lm.fit()
-
- o Export and document S3 methods in NAMESPACE and manual page as such
-
- o Accomodate int64 package which Rcpp now depends upon
-
-0.1.1 2011-04-05
-
- o Unit tests produce a summary vignette as for some of the other packages
-
- o The documentation Makefile now uses the $R_HOME environment variable
-
- o The documentation Makefile no longer calls clean in the all target
-
-0.1.0 2010-11-30
-
- o Initial CRAN release with basic functionality for vectors and matrices
-
- o A vignette provides an introduction and documentation about the package
-
- o An example package RcppGSLExample provides a complete stanza for
- creating your own package using RcppGSL (and the GSL and Rcpp)
Copied: pkg/RcppGSL/inst/NEWS.Rd (from rev 3697, pkg/RcppGSL/inst/NEWS)
===================================================================
--- pkg/RcppGSL/inst/NEWS.Rd (rev 0)
+++ pkg/RcppGSL/inst/NEWS.Rd 2012-07-21 21:50:00 UTC (rev 3703)
@@ -0,0 +1,34 @@
+\name{NEWS}
+\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)}{
+ \itemize{
+ \item{summary() for fastLm() now displays vastly more information}
+ \item{fastLmPure() now uses same argument order as R's lm.fit()}
+ \item{Export and document S3 methods in NAMESPACE and manual page as
+ such}
+ \item{Vignettes have been moved to the \code{vignettes/} directory}
+ \item{NEWS file converted to .Rd format}
+ }
+}
+\section{Changes in version 0.1.1 (2011-04-05)}{
+ \itemize{
+ \item{Unit tests produce a summary vignette as for some of the other
+ packages}
+ \item{The documentation Makefile now uses the $R_HOME environment
+ variable}
+ \item{The documentation Makefile no longer calls clean in the all
+ target}
+ }
+}
+\section{Changes in version 0.1.0 (2010-11-30)}{
+ \itemize{
+ \item{Initial CRAN release with basic functionality for vectors and
+ matrices}
+ \item{A vignette provides an introduction and documentation about
+ the package}
+ \item{An example package RcppGSLExample provides a complete stanza for
+ creating your own package using RcppGSL (and the GSL and Rcpp)}
+ }
+}
More information about the Rcpp-commits
mailing list