Skip to content
Prev 2549 / 12125 Next

[R-pkg-devel] Warnings and error message in CRAN Package Check Results

Dear Duncan,

Thank you. I really appreciate your help!

Yes, the Fedora warning is self explanatory, but I'm still quite 
confused. Below are part of my Mstep.cpp file (both functions are in the 
same file). The fedora warned me that, among others,
Mstep.cpp:62:69: warning: explicitly assigning value of variable of type 
'int' to itself [-Wself-assign]
     arma::vec Pj = Calc_Pj(par = par, designMj = designMj, linkfunc = 
linkfunc, boundary = boundary, eps = eps);
                                                            ~~~~~~~~ ^ 
~~~~~~~~

So, basically, I called Calc_Pj function from Calc_Pj_jac function, but 
not sure why this is not allowed.

----------------------------

// [[Rcpp::depends(RcppArmadillo)]]
#include <RcppArmadillo.h>
using namespace Rcpp;
using namespace arma;
// [[Rcpp::export]]
arma::vec Calc_Pj(const arma::vec  par, const arma::mat  designMj,
const int & linkfunc,int boundary = 0,const double  eps = 1e-16){
   arma::vec Pj;
   if(linkfunc==1){ //identity
     Pj = designMj*par;
   }else if(linkfunc==2){//logit
     Pj = exp(designMj*par)/(1 + exp(designMj*par));
   }else if(linkfunc==3){//log
     Pj = exp(designMj*par);
   }
   if(boundary==1){
     Pj.elem(find(Pj<eps)).fill(eps);
     Pj.elem(find(Pj>1-eps)).fill(1-eps);
   }
   return Pj;
}

// [[Rcpp::export]]
arma::mat Calc_Pj_jac(arma::vec  par,
                   arma::mat designMj,
                   int & linkfunc,
                   int boundary = 0,
                   double eps = 1e-16){
   arma::mat ret = designMj;
   if(linkfunc>1){
     arma::vec Pj = Calc_Pj(par = par, designMj = designMj, linkfunc = 
linkfunc, boundary = boundary, eps = eps);
     if(linkfunc==2){//logit
       ret.each_col() %= Pj%(1-Pj);
     }else if(linkfunc==3){//log
       ret.each_col() %= Pj;
     }
   }
   return ret;
}
On 3/24/2018 6:18 PM, Duncan Murdoch wrote: