[Rcpp-commits] r858 - pkg/Rcpp/inst/examples/FastLM
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sun Mar 7 23:47:50 CET 2010
Author: edd
Date: 2010-03-07 23:47:50 +0100 (Sun, 07 Mar 2010)
New Revision: 858
Modified:
pkg/Rcpp/inst/examples/FastLM/lmArmadillo.R
Log:
now requires Armadillo 0.8.2 or later for arma::as_scalar
Modified: pkg/Rcpp/inst/examples/FastLM/lmArmadillo.R
===================================================================
--- pkg/Rcpp/inst/examples/FastLM/lmArmadillo.R 2010-03-07 22:47:09 UTC (rev 857)
+++ pkg/Rcpp/inst/examples/FastLM/lmArmadillo.R 2010-03-07 22:47:50 UTC (rev 858)
@@ -35,16 +35,16 @@
arma::colvec coef = solve(X, y); // fit model y ~ X
arma::colvec resid = y - X*coef; // to compute std. error of the coefficients
- double sig2 = trans(resid)*resid/(n-k);
+ double sig2 = arma::as_scalar(trans(resid)*resid)/(n-k); // requires Armadillo 0.8.2 or later
arma::mat covmat = sig2 * arma::inv(arma::trans(X)*X);
Rcpp::NumericVector coefr(k), stderrestr(k);
- for (int i=0; i<k; i++) { // this will be easier with proper wrappers
+ for (int i=0; i<k; i++) { // this is easier in RcppArmadillo with proper wrappers
coefr[i] = coef[i];
stderrestr[i] = sqrt(covmat(i,i));
}
- Rcpp::Pairlist res(Rcpp::Named( "coef", coefr),
+ Rcpp::Pairlist res(Rcpp::Named( "coefficients", coefr),
Rcpp::Named( "stderr", stderrestr));
return res;
'
More information about the Rcpp-commits
mailing list