[Rcpp-devel] Correlation in ArmadilloRcpp with missing values (nan)

mateusz.kaduk at gmail.com mateusz.kaduk at gmail.com
Tue Oct 9 19:55:11 CEST 2012


I am not running R's cor(..) function. I am calling arma::cor(...) on two
vectors. I cannot use R's function, because I have some nested loops and
extra steps before calculating Pearson's correlation.

The only thing I am providing in R is the matrix with values and matrix
with zeros and ones where missings are.
Now in ArmadilloRcpp I need to select rows with values.

The problem is that given arma::mat x and arma::colvec rowind, I cannot
select value in this way
colvec col = x(rowind,i);

So forget about correlations, there are more steps. The problem is how to
select with Armadillo values in rows from specific column.

Lets say colvec col = { 1,1,1,1,0,1}
and I want to select only values where there is 1 from column "i" of
arma::mat x

I hope it became clear, that this is not related to correlations, but how
to select values (without missings).

On 9 October 2012 19:43, Douglas Bates <bates at stat.wisc.edu> wrote:

> By the way, how are you calculating this correlation in R?  Are you
> using the cor function?
>
> I'm confused because the cor function in R does a bit of bookkeeping
> then calls a C function using .Internal.  It seems unlikely to me that
> one could make a C++/Rcpp function run much faster.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20121009/c4a5afc9/attachment.html>


More information about the Rcpp-devel mailing list