[Rcpp-commits] r824 - pkg/RcppArmadillo/src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Mar 3 00:19:00 CET 2010


Author: edd
Date: 2010-03-03 00:18:59 +0100 (Wed, 03 Mar 2010)
New Revision: 824

Modified:
   pkg/RcppArmadillo/src/RcppArmadillo.cpp
Log:
don't compute sig2 explicitly avoiding the as_scalar() issue post-0.9.0


Modified: pkg/RcppArmadillo/src/RcppArmadillo.cpp
===================================================================
--- pkg/RcppArmadillo/src/RcppArmadillo.cpp	2010-03-02 15:46:15 UTC (rev 823)
+++ pkg/RcppArmadillo/src/RcppArmadillo.cpp	2010-03-02 23:18:59 UTC (rev 824)
@@ -194,13 +194,13 @@
 
     arma::colvec y(yr.begin(), yr.size());
 
-    arma::colvec coef = solve(X, y);		// fit model y ~ X
+    arma::colvec coef = solve(X, y);            // fit model y ~ X
 
     arma::colvec resid = y - X*coef; 
-    double sig2 = trans(resid)*resid/(n-k);
-    arma::mat covmat = sig2 * arma::inv(arma::trans(X)*X);
-	arma::colvec stderrest = sqrt(covmat.diag());
 
+    arma::mat covmat = trans(resid) * resid / (n-k) * arma::inv(arma::trans(X)*X);
+    arma::colvec stderrest = sqrt(covmat.diag());
+
     Rcpp::Pairlist res(Rcpp::Named( "coef", coef),
                        Rcpp::Named( "stderr", stderrest));
     return res;



More information about the Rcpp-commits mailing list