[Rcpp-commits] r3065 - in pkg/RcppGSL: . R man src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Jun 15 00:34:50 CEST 2011
Author: dmbates
Date: 2011-06-15 00:34:50 +0200 (Wed, 15 Jun 2011)
New Revision: 3065
Modified:
pkg/RcppGSL/DESCRIPTION
pkg/RcppGSL/R/fastLm.R
pkg/RcppGSL/man/fastLm.Rd
pkg/RcppGSL/src/fastLm.cpp
Log:
Change order of arguments in fastLm.cpp and fastLm.R and documentation. New version.
Modified: pkg/RcppGSL/DESCRIPTION
===================================================================
--- pkg/RcppGSL/DESCRIPTION 2011-06-14 20:18:55 UTC (rev 3064)
+++ pkg/RcppGSL/DESCRIPTION 2011-06-14 22:34:50 UTC (rev 3065)
@@ -1,7 +1,7 @@
Package: RcppGSL
Type: Package
Title: Rcpp integration for GNU GSL vectors and matrices
-Version: 0.1.1.1
+Version: 0.1.2
Date: $Date$
Author: Romain Francois and Dirk Eddelbuettel
Maintainer: Dirk Eddelbuettel and Romain Francois <RomainAndDirk at r-enthusiasts.com>
Modified: pkg/RcppGSL/R/fastLm.R
===================================================================
--- pkg/RcppGSL/R/fastLm.R 2011-06-14 20:18:55 UTC (rev 3064)
+++ pkg/RcppGSL/R/fastLm.R 2011-06-14 22:34:50 UTC (rev 3065)
@@ -17,25 +17,25 @@
## You should have received a copy of the GNU General Public License
## along with RcppGSL. If not, see <http://www.gnu.org/licenses/>.
-fastLmPure <- function(y, X) {
+fastLmPure <- function(X, y) {
stopifnot(is.matrix(X))
stopifnot(nrow(y)==nrow(X))
- res <- .Call("fastLm", y, X, package="RcppGSL")
+ res <- .Call("fastLm", X, y, package="RcppGSL")
}
fastLm <- function(x, ...) UseMethod("fastLm")
-fastLm.default <- function(x, y, ...) {
+fastLm.default <- function(X, y, ...) {
- x <- as.matrix(x)
+ X <- as.matrix(X)
y <- as.numeric(y)
- res <- fastLmPure(y, x)
- names(res$coefficients) <- colnames(x)
+ res <- fastLmPure(X, y)
+ names(res$coefficients) <- colnames(X)
- res$fitted.values <- as.vector(x %*% res$coefficients)
+ res$fitted.values <- as.vector(X %*% res$coefficients)
res$residuals <- y - res$fitted.values
res$call <- match.call()
@@ -60,8 +60,8 @@
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
@@ -94,10 +94,10 @@
fastLm.formula <- function(formula, data=list(), ...) {
mf <- model.frame(formula=formula, data=data)
- x <- model.matrix(attr(mf, "terms"), data=mf)
+ X <- model.matrix(attr(mf, "terms"), data=mf)
y <- model.response(mf)
- res <- fastLm.default(x, y, ...)
+ res <- fastLm.default(X, y, ...)
res$call <- match.call()
res$formula <- formula
res
Modified: pkg/RcppGSL/man/fastLm.Rd
===================================================================
--- pkg/RcppGSL/man/fastLm.Rd 2011-06-14 20:18:55 UTC (rev 3064)
+++ pkg/RcppGSL/man/fastLm.Rd 2011-06-14 22:34:50 UTC (rev 3065)
@@ -10,16 +10,15 @@
function of the \code{GNU GSL} library.
}
\usage{
-fastLmPure(y, X)
+fastLmPure(X, y)
-fastLm(x, \dots)
-\method{fastLm}{default}(x, y, \dots)
+fastLm(X, \dots)
+\method{fastLm}{default}(X, y, \dots)
\method{fastLm}{formula}(formula, data = list(), \dots)
}
\arguments{
\item{y}{a vector containing the explained variable.}
- \item{X}{a data.frame or matrix containing the explanatory variables.}
- \item{x}{a numeric design matrix for the model.}
+ \item{X}{a model matrix.}
\item{formula}{a symbolic description of the model to be fit.}
\item{data}{an optional data frame containing the variables in the model.}
\item{\ldots}{not used}
Modified: pkg/RcppGSL/src/fastLm.cpp
===================================================================
--- pkg/RcppGSL/src/fastLm.cpp 2011-06-14 20:18:55 UTC (rev 3064)
+++ pkg/RcppGSL/src/fastLm.cpp 2011-06-14 22:34:50 UTC (rev 3065)
@@ -24,7 +24,7 @@
#include <gsl/gsl_multifit.h>
#include <cmath>
-extern "C" SEXP fastLm(SEXP ys, SEXP Xs) {
+extern "C" SEXP fastLm(SEXP Xs, SEXP ys) {
try {
@@ -51,8 +51,8 @@
std::transform( std_err.begin(), std_err.end(), std_err.begin(), sqrt );
Rcpp::List res = Rcpp::List::create(Rcpp::Named("coefficients") = coef,
- Rcpp::Named("stderr") = std_err,
- Rcpp::Named("df") = n - k);
+ Rcpp::Named("stderr") = std_err,
+ Rcpp::Named("df.residual") = n - k);
// free all the GSL vectors and matrices -- as these are really C data structures
// we cannot take advantage of automatic memory management
More information about the Rcpp-commits
mailing list