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

Douglas Bates bates at stat.wisc.edu
Tue Oct 9 20:18:34 CEST 2012


On Tue, Oct 9, 2012 at 1:06 PM, mateusz.kaduk at gmail.com
<mateusz.kaduk at gmail.com> wrote:
> Maybe I am not good in coding, but even though I managed to make uvec with
> ones and zeros, I cannot use it to select rows  in given column, compiler
> complains
> error: no matching function for call to
> ‘arma::Mat<double>::submat(arma::uvec&, int&)’

Basically your problem comes down to looking at each pair of columns
and determining the joint missingness pattern.  You can try to force
the calculation into arma but I think you are better off just writing
the code in loops.  To be careful you should calculate the means of
each column on the pairwise non-missing values as in the enclosed
function.

> On 9 October 2012 19:55, Dirk Eddelbuettel <edd at debian.org> wrote:
>>
>>
>> On 9 October 2012 at 19:07, mateusz.kaduk at gmail.com wrote:
>> | Can you provide an example how to convert Armadillo colvec to uvec
>> vector which
>> | I assume works as selector for rows?
>>
>> You may need to loop (or use STL iterators) to fill the uvec position by
>> position.  Then use the subset, and proceed with your correlation
>> calculation.  I don't think there is a shortcut.
>>
>> Dirk
>>
>> --
>> Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: foo.R
Type: application/octet-stream
Size: 1083 bytes
Desc: not available
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20121009/a0153bf4/attachment.obj>


More information about the Rcpp-devel mailing list