[Rcpp-commits] r1268 - pkg/RcppArmadillo/src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue May 18 16:14:10 CEST 2010
Author: dmbates
Date: 2010-05-18 16:14:09 +0200 (Tue, 18 May 2010)
New Revision: 1268
Modified:
pkg/RcppArmadillo/src/fastLm.cpp
Log:
Slight change in the calculation of sig2.
Modified: pkg/RcppArmadillo/src/fastLm.cpp
===================================================================
--- pkg/RcppArmadillo/src/fastLm.cpp 2010-05-18 10:10:34 UTC (rev 1267)
+++ pkg/RcppArmadillo/src/fastLm.cpp 2010-05-18 14:14:09 UTC (rev 1268)
@@ -34,7 +34,9 @@
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);
+// 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