[Rcpp-commits] r1244 - in pkg/RcppArmadillo: R inst/unitTests man src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri May 14 16:55:09 CEST 2010


Author: edd
Date: 2010-05-14 16:55:08 +0200 (Fri, 14 May 2010)
New Revision: 1244

Modified:
   pkg/RcppArmadillo/R/fastLm.R
   pkg/RcppArmadillo/inst/unitTests/runit.RcppArmadillo.R
   pkg/RcppArmadillo/man/fastLm.Rd
   pkg/RcppArmadillo/src/fastLm.cpp
Log:
do not return the vcov from C++ to R


Modified: pkg/RcppArmadillo/R/fastLm.R
===================================================================
--- pkg/RcppArmadillo/R/fastLm.R	2010-05-14 12:09:57 UTC (rev 1243)
+++ pkg/RcppArmadillo/R/fastLm.R	2010-05-14 14:55:08 UTC (rev 1244)
@@ -34,9 +34,10 @@
     y <- as.numeric(y)
 
     res <- fastLmCall(y, x)
+
     res$coefficients <- res$coefficient[,1] # force into single-col vector
 
-    names(res$coefficients) <- colnames(res$vcov) <- rownames(res$vcov) <- colnames(x)
+    names(res$coefficients) <- colnames(x)
 
     res$fitted.values <- as.vector(x %*% res$coefficients)
     res$residuals <- y - res$fitted.values

Modified: pkg/RcppArmadillo/inst/unitTests/runit.RcppArmadillo.R
===================================================================
--- pkg/RcppArmadillo/inst/unitTests/runit.RcppArmadillo.R	2010-05-14 12:09:57 UTC (rev 1243)
+++ pkg/RcppArmadillo/inst/unitTests/runit.RcppArmadillo.R	2010-05-14 14:55:08 UTC (rev 1244)
@@ -86,13 +86,13 @@
                 msg="fastLm.stderr")
 }
 
-test.fastLmFormula <- function() {
+test.fastLm.formula <- function() {
     data(trees)
     flm <- fastLm(log(Volume) ~ log(Girth), data=trees)
     fit <- lm(log(Volume) ~ log(Girth), data=trees)
 
-    checkEquals(flm$coef, coef(fit), msg="fastLm.coef")
+    checkEquals(flm$coef, coef(fit), msg="fastLm.formula.coef")
     checkEquals(as.numeric(flm$stderr), as.numeric(coef(summary(fit))[,2]),
-                msg="fastLm.stderr")
+                msg="fastLm.formula.stderr")
 }
 

Modified: pkg/RcppArmadillo/man/fastLm.Rd
===================================================================
--- pkg/RcppArmadillo/man/fastLm.Rd	2010-05-14 12:09:57 UTC (rev 1243)
+++ pkg/RcppArmadillo/man/fastLm.Rd	2010-05-14 14:55:08 UTC (rev 1244)
@@ -61,10 +61,9 @@
   algebra software.
 }
 \value{
-  \code{fastLm} returns a list with four components:
+  \code{fastLm} 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{vcov}{the covariance matrix of the estimates}
   \item{df}{a scalar denoting the degrees of freedom in the model}
  
   \code{fastLm} returns a richer object which also includes the

Modified: pkg/RcppArmadillo/src/fastLm.cpp
===================================================================
--- pkg/RcppArmadillo/src/fastLm.cpp	2010-05-14 12:09:57 UTC (rev 1243)
+++ pkg/RcppArmadillo/src/fastLm.cpp	2010-05-14 14:55:08 UTC (rev 1244)
@@ -31,17 +31,16 @@
 	arma::mat X(Xr.begin(), n, k, false);   	// reuses memory and avoids extra copy
 	arma::colvec y(yr.begin(), yr.size(), false);
 
-	arma::colvec coef = arma::solve(X, y);      // fit model y ~ X
+	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) );
     						
-	arma::mat covmat = sig2 * arma::inv(arma::trans(X)*X); 	// covmat
-	arma::colvec stderrest = arma::sqrt(arma::diagvec(covmat));	// std.error of estimate 
+							// std.error of estimate 
+	arma::colvec stderrest = arma::sqrt(sig2 * arma::diagvec( arma::inv(arma::trans(X)*X) ));	
 
 	return Rcpp::List::create(Rcpp::Named("coefficients") = coef,
 				  Rcpp::Named("stderr")       = stderrest,
-				  Rcpp::Named("vcov")         = covmat,
 				  Rcpp::Named("df")           = n - k
 				  );
 



More information about the Rcpp-commits mailing list