[Rcpp-commits] r1270 - in pkg/RcppArmadillo: inst/announce man src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue May 18 16:48:40 CEST 2010
Author: edd
Date: 2010-05-18 16:48:40 +0200 (Tue, 18 May 2010)
New Revision: 1270
Modified:
pkg/RcppArmadillo/inst/announce/ANNOUNCE-0.2.0.txt
pkg/RcppArmadillo/man/fastLm.Rd
pkg/RcppArmadillo/src/fastLm.cpp
Log:
carried some text from the fastLm.Rd file to the announcement
more minor edits in the announcement
removed commented-out sig2 calc from fastLm.cpp
Modified: pkg/RcppArmadillo/inst/announce/ANNOUNCE-0.2.0.txt
===================================================================
--- pkg/RcppArmadillo/inst/announce/ANNOUNCE-0.2.0.txt 2010-05-18 14:14:44 UTC (rev 1269)
+++ pkg/RcppArmadillo/inst/announce/ANNOUNCE-0.2.0.txt 2010-05-18 14:48:40 UTC (rev 1270)
@@ -14,7 +14,7 @@
This library is useful if C++ has been decided as the language of choice
(due to speed and/or integration capabilities), rather than another language
-like Matlab ¨ or Octave. It is distributed under a license that is useful in
+like Matlab or Octave. It is distributed under a license that is useful in
both open-source and commercial contexts.
Armadillo is primarily developed by Conrad Sanderson at NICTA (Australia),
@@ -47,7 +47,8 @@
arma::colvec coef = arma::solve(X, y); // fit model y ~ X
arma::colvec resid = y - X*coef; // residuals
- double sig2 = arma::as_scalar( arma::trans(resid)*resid/(n-k) );
+ double sig2 = std::inner_product(resid.begin(), resid.end(), resid.begin(), double())/(n-k);
+
// std.error of estimate
arma::colvec stderrest = arma::sqrt( sig2 * arma::diagvec( arma::inv(arma::trans(X)*X)) );
@@ -58,10 +59,14 @@
}
+Note however that you may not want to compute a linear regression fit this
+way in order to protect from numerical inaccuracies on rank-deficient
+problems. The help page for fastLm() provides an examples.
+
===== Using RcppArmadillo in other packages =====
-RcppArmadillo is designed so that its classes are used from other packages.
+RcppArmadillo is designed so that its classes can be used from other packages.
Using RcppArmadillo requires:
@@ -69,21 +74,21 @@
typically achieved by adding this line in the DESCRIPTION file of the
client package:
- LinkingTo : Rcpp, RcppArmadillo
+ LinkingTo : Rcpp, RcppArmadillo
and the following line in the package code:
- #include <RcppArmadillo.h>
+ #include <RcppArmadillo.h>
- Linking against Rcpp dynamic or shared library and librairies needed
by Armadillo, which is achieved by adding this line in the src/Makevars
file of the client package:
- PKG_LIBS = $(shell $(R_HOME)/bin/Rscript -e "Rcpp:::LdFlags()" ) $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)
+ PKG_LIBS = $(shell $(R_HOME)/bin/Rscript -e "Rcpp:::LdFlags()" ) $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)
and this line in the file src/Makevars.win:
- PKG_LIBS = $(shell Rscript.exe -e "Rcpp:::LdFlags()") $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)
+ PKG_LIBS = $(shell Rscript.exe -e "Rcpp:::LdFlags()") $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)
RcppArmadillo contains a function RcppArmadillo.package.skeleton, modelled
after package.skeleton from the utils package in base r, that creates a
@@ -130,7 +135,9 @@
http://sourceforge.net/apps/phpbb/arma/
- -- Doug Bates, Dirk Eddelbuettel and Romain Francois
- Madison, WI, USA; Chicago, IL, USA; and Montpellier, France
- May 2010
+ -- Romain Francois, Montpellier, France
+ Dirk Eddelbuettel, Chicago, IL, USA
+ Doug Bates, Madison, WI, USA
+ May 2010
+
Modified: pkg/RcppArmadillo/man/fastLm.Rd
===================================================================
--- pkg/RcppArmadillo/man/fastLm.Rd 2010-05-18 14:14:44 UTC (rev 1269)
+++ pkg/RcppArmadillo/man/fastLm.Rd 2010-05-18 14:48:40 UTC (rev 1270)
@@ -64,13 +64,13 @@
conventional linear algebra software.
}
\value{
- \code{fastLm} returns a list with three components:
+ \code{fastLmPure} returns a list with three components:
\item{coefficients}{a vector of coefficients}
\item{stderr}{a vector of the (estimated) standard errors of the coefficient estimates}
\item{df}{a scalar denoting the degrees of freedom in the model}
\code{fastLm} returns a richer object which also includes the
- residuals and call similar to the \code{\link{lm}} or
+ residuals, fitted values and call argument similar to the \code{\link{lm}} or
\code{\link[MASS]{rlm}} functions..
}
\seealso{\code{\link{lm}}, \code{\link{lm.fit}}}
Modified: pkg/RcppArmadillo/src/fastLm.cpp
===================================================================
--- pkg/RcppArmadillo/src/fastLm.cpp 2010-05-18 14:14:44 UTC (rev 1269)
+++ pkg/RcppArmadillo/src/fastLm.cpp 2010-05-18 14:48:40 UTC (rev 1270)
@@ -36,8 +36,7 @@
double sig2 = std::inner_product(resid.begin(), resid.end(),
resid.begin(), double())/(n-k);
-// arma::as_scalar( arma::trans(resid)*resid/(n-k) );
-
+
// std.error of estimate
arma::colvec stderrest = arma::sqrt(sig2 * arma::diagvec( arma::inv(arma::trans(X)*X) ));
More information about the Rcpp-commits
mailing list