Well,<br><br>That&#39;s sound good,<br>The distribution I need are multivariate normal, inverse gaussian.<br>Though, the biggest issue is that for one of the parameter there is no closed form so I am using Metropolis Hastings for it.<br>
Any idea about this variable reaffectation thing?<br>It seems to be specific to arma classes like arma::mat<br><br>Nicolas<br><br><div class="gmail_quote">On Wed, Jun 15, 2011 at 8:10 PM, Whit Armstrong <span dir="ltr">&lt;<a href="mailto:armstrong.whit@gmail.com">armstrong.whit@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">I&#39;m not giving up yet.  I&#39;ll implement the distribution that is<br>
missing, and send you the example if you lay out your model w/<br>
pseudocode.<br>
<font color="#888888"><br>
-Whit<br>
</font><div><div></div><div class="h5"><br>
<br>
On Wed, Jun 15, 2011 at 7:59 PM, Nicolas Heslot &lt;<a href="mailto:nh269@cornell.edu">nh269@cornell.edu</a>&gt; wrote:<br>
&gt; Hi,<br>
&gt;<br>
&gt; Thank you for your quick answer.<br>
&gt; Sorry that I did not explain well enought my issue.<br>
&gt; I did not know about cppbugs but I just checked and it does not seem that I<br>
&gt; can use it for my model because it lacks some of the distribution I need.<br>
&gt; The fraction of code could seems obscure but it is just the updating for a<br>
&gt; block of parameters in the model.<br>
&gt; My problem is rather simple I think.<br>
&gt; Once I affect a matrix to a variable I can&#39;t manage to overwrite the content<br>
&gt; of that variable with a different matrix. I really can&#39;t figure out how to<br>
&gt; do it.<br>
&gt;<br>
&gt; Nicolas<br>
&gt;<br>
&gt; On Wed, Jun 15, 2011 at 7:52 PM, Dirk Eddelbuettel &lt;<a href="mailto:edd@debian.org">edd@debian.org</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; Salut Nicolas,<br>
&gt;&gt;<br>
&gt;&gt; On 15 June 2011 at 17:03, Nicolas Heslot wrote:<br>
&gt;&gt; | Hi rcpp-devel!<br>
&gt;&gt; | First of all thank you for this awesome tool!<br>
&gt;&gt;<br>
&gt;&gt; Pleasure, and welcome.<br>
&gt;&gt;<br>
&gt;&gt; | I started a few days ago coding with Rcpp to try to reduce the computing<br>
&gt;&gt; time<br>
&gt;&gt; | of a MCMC model.<br>
&gt;&gt; | However, I don&#39;t have experience with C/C++ and I can&#39;t figure out how<br>
&gt;&gt; to<br>
&gt;&gt; | reaffect a new content to a variable.<br>
&gt;&gt; | This seems probably very simple to you but I can&#39;t figure it out, and<br>
&gt;&gt; this is<br>
&gt;&gt; | the last step preventing my code to work out I think...<br>
&gt;&gt; | The objects all_ui, all_ui2, all_ui3, all_rd and all_corMat are list<br>
&gt;&gt; objects<br>
&gt;&gt; | containing matrix<br>
&gt;&gt; | But once a matrice extracted from one of those lists is affected, to let<br>
&gt;&gt; say<br>
&gt;&gt; | the object ui I can&#39;t affect the next matrix to ui at the next<br>
&gt;&gt; iteration.<br>
&gt;&gt; | I tried to find a way to eliminate the object at each iteration or to<br>
&gt;&gt; empty it<br>
&gt;&gt; | using .reset but without success.<br>
&gt;&gt; |<br>
&gt;&gt; | So any help would be very much appreciated!<br>
&gt;&gt; | (fragment of code posted below)<br>
&gt;&gt; |<br>
&gt;&gt; | arma::mat tmp;<br>
&gt;&gt; | arma::mat tmp2;<br>
&gt;&gt; | arma::mat tmp3;<br>
&gt;&gt; | arma::mat ui;<br>
&gt;&gt; | arma::mat ui2;<br>
&gt;&gt; | arma::mat ui3;<br>
&gt;&gt; | arma::mat sigma;<br>
&gt;&gt; |<br>
&gt;&gt; | for (int j = 0; j &lt; P-1; j++) {<br>
&gt;&gt; | tmp2.fill(0);<br>
&gt;&gt; | tmp3.fill(0);<br>
&gt;&gt; |  for (int i = 0; i &lt; N-1; i++) {<br>
&gt;&gt; |  ui = all_ui[i];<br>
&gt;&gt; | ui2 = all_ui2[i];<br>
&gt;&gt; |  ui3 = all_ui3[i];<br>
&gt;&gt; | rdi = all_rd[i];<br>
&gt;&gt; | all_corMati = all_corMat[i];<br>
&gt;&gt; |  sigma = sigma2*all_corMat[i];<br>
&gt;&gt; | // calculate mean and variance<br>
&gt;&gt; | arma::mat tmp = (solve(sig%all_corMat[i])* gen_a(i,j))*all_ui[i];<br>
&gt;&gt; | arma::mat tmp2 += (all_rd[i] -<br>
&gt;&gt; mu*trans(all_ui3[i])-(X(i)*alpha)*trans(all_ui2<br>
&gt;&gt; | [i]) + gen_a(i,j)*a.row(j)*trans(all_ui[i]))*tmp;<br>
&gt;&gt; | arma::mat tmp3 += (gen_a(i,j)*trans(all_ui[i]))*tmp;<br>
&gt;&gt; | }<br>
&gt;&gt; | }<br>
&gt;&gt; |<br>
&gt;&gt; | Thank you for your help<br>
&gt;&gt;<br>
&gt;&gt; I&#39;m with Whit here and confess that I do not know your question is. If you<br>
&gt;&gt; show us what you tried, what you expected to happen and what actually<br>
&gt;&gt; happened we may help.<br>
&gt;&gt;<br>
&gt;&gt; (By the way, there is no tax on indentation in code and it does make it<br>
&gt;&gt; more<br>
&gt;&gt; readable for those of us who didn&#39;t write it ;-)<br>
&gt;&gt;<br>
&gt;&gt; Dirk<br>
&gt;&gt;<br>
&gt;&gt; | It probably does not help much<br>
&gt;&gt; | but I use R2.13 with the last version of the packages on a windows XP<br>
&gt;&gt; plateform<br>
&gt;&gt; |<br>
&gt;&gt; | Nicolas<br>
&gt;&gt; |<br>
&gt;&gt; |<br>
&gt;&gt; | ----------------------------------------------------------------------<br>
&gt;&gt; | _______________________________________________<br>
&gt;&gt; | Rcpp-devel mailing list<br>
&gt;&gt; | <a href="mailto:Rcpp-devel@lists.r-forge.r-project.org">Rcpp-devel@lists.r-forge.r-project.org</a><br>
&gt;&gt; | <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>
&gt;&gt;<br>
&gt;&gt; --<br>
&gt;&gt; Gauss once played himself in a zero-sum game and won $50.<br>
&gt;&gt;                      -- #11 at <a href="http://www.gaussfacts.com" target="_blank">http://www.gaussfacts.com</a><br>
&gt;<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; Rcpp-devel mailing list<br>
&gt; <a href="mailto:Rcpp-devel@lists.r-forge.r-project.org">Rcpp-devel@lists.r-forge.r-project.org</a><br>
&gt; <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>
&gt;<br>
&gt;<br>
</div></div></blockquote></div><br>