Can you provide an example how to convert Armadillo colvec to uvec vector which I assume works as selector for rows?<br><br>Thanks<br><br><div class="gmail_quote">On 9 October 2012 18:17, <a href="mailto:mateusz.kaduk@gmail.com">mateusz.kaduk@gmail.com</a> <span dir="ltr"><<a href="mailto:mateusz.kaduk@gmail.com" target="_blank">mateusz.kaduk@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Dear Dirk,<br><br>I dont see how to do that in Armadillo, but I think I can create same size NumericMatrix B = <a href="http://is.na" target="_blank">is.na</a>(X);<br>
This maybe I could use for indexing ? To save time, and not to introduce extra looping.<br>
<br>Also, I want to perform regression column X on Z, and column Y on Z.<br>Does arma::solve(...) handle nan values ? or I guess I have to check that myself ?<br><br>The function works nicely, and while R implementation takes at least 40min (surely more because I terminated), Armadillo computes everything in less then one minute. But I skipped columns with missing cells, which now I want to include.<br>
<br>Thanks,<br>Mateusz<div class="HOEnZb"><div class="h5"><br><br><div class="gmail_quote">On 9 October 2012 17:37, Dirk Eddelbuettel <span dir="ltr"><<a href="mailto:edd@debian.org" target="_blank">edd@debian.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
On 9 October 2012 at 10:08, Douglas Bates wrote:<br>
| You may find it easier to use the Rcpp class NumericMatrix than to use<br>
| RcppArmadillo. Detection of NA's is built in to R and Rcpp classes but not<br>
| RcppArmadillo. For each pair of columns, run a loop that checks for NA's at<br>
| each position in each column, skips the position if NA's are detected and<br>
| otherwise increments the squared sums, cross-product and number of elements.<br>
<br>
All true, but at the same time, once in RcppArmadillo or RcppEigen ... it is<br>
convenient to stay there.<br>
<br>
You should be able to set up a little "sweeper" function which applies one of<br>
<br>
R_IsNA just NA<br>
R_IsNaN just NaN<br>
R_IsFinite NA, NaN or Inf<br>
<br>
across a vector or matrix and returns you an index vector. Armadillo can use<br>
indexing vectors in ways that are similar in R.<br>
<br>
Dirk<br>
<br>
<br>
|<br>
| On Oct 9, 2012 9:53 AM, "<a href="mailto:mateusz.kaduk@gmail.com" target="_blank">mateusz.kaduk@gmail.com</a>" <<a href="mailto:mateusz.kaduk@gmail.com" target="_blank">mateusz.kaduk@gmail.com</a>><br>
| wrote:<br>
|<br>
| Hi,<br>
|<br>
| I have written small code in C++ using Armadillo and inline with<br>
| RcppArmadillo package.<br>
| The input is data.marix(X). Some cells might be NAs. Example in R: X =<br>
| matrix(sample(c(rnorm(10*9.9),NA)),ncol=10)<br>
|<br>
| I am calculating conditional correlation on columns of that matrix, just<br>
| picking vectors, so cor(X,Y).<br>
| The problem is that sometimes I might have empty cell in one or both<br>
| vectors, in that case I would like to skip that row, and procede with<br>
| calculating Pearson's correlation on remaining data. I know that there will<br>
| be difference in degrees of freedom, but I have over 100 rows, so skiping<br>
| few shouldnt matter that much.<br>
|<br>
| Basically my question boils down to solving the problem:<br>
| How to find which colvec cells are nan, and remove this index from both X<br>
| and Y colvec, before calculating correlation.<br>
|<br>
| I would be very grateful for help,<br>
|<br>
| Kind regards,<br>
| Mateusz Kaduk<br>
|<br>
| _______________________________________________<br>
| Rcpp-devel mailing list<br>
| <a href="mailto:Rcpp-devel@lists.r-forge.r-project.org" target="_blank">Rcpp-devel@lists.r-forge.r-project.org</a><br>
| <a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel</a><br>
|<br>
|<br>
| ----------------------------------------------------------------------<br>
| _______________________________________________<br>
| Rcpp-devel mailing list<br>
| <a href="mailto:Rcpp-devel@lists.r-forge.r-project.org" target="_blank">Rcpp-devel@lists.r-forge.r-project.org</a><br>
| <a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel</a><br>
<span><font color="#888888">--<br>
Dirk Eddelbuettel | <a href="mailto:edd@debian.org" target="_blank">edd@debian.org</a> | <a href="http://dirk.eddelbuettel.com" target="_blank">http://dirk.eddelbuettel.com</a><br>
</font></span></blockquote></div><br>
</div></div></blockquote></div><br>