diff options
Diffstat (limited to 'src/nll_occu.cpp')
-rw-r--r-- | src/nll_occu.cpp | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/src/nll_occu.cpp b/src/nll_occu.cpp index 7d8bf1b..0a8abe4 100644 --- a/src/nll_occu.cpp +++ b/src/nll_occu.cpp @@ -1,19 +1,13 @@ -#include "nll_occu.h" +#include <RcppArmadillo.h> +#include <float.h> using namespace Rcpp ; -SEXP nll_occu( SEXP yR, SEXP Xr, SEXP Vr, SEXP beta_psiR, SEXP beta_pR, SEXP ndR, SEXP knownOccR, SEXP navecR, SEXP X_offsetR, SEXP V_offsetR, SEXP link_psiR ) { - arma::icolvec y = as<arma::icolvec>(yR); - arma::mat X = as<arma::mat>(Xr); - arma::mat V = as<arma::mat>(Vr); - arma::colvec beta_psi = as<arma::colvec>(beta_psiR); - arma::colvec beta_p = as<arma::colvec>(beta_pR); - Rcpp::IntegerVector nd(ndR); - Rcpp::LogicalVector knownOcc(knownOccR); - Rcpp::LogicalVector navec(navecR); - arma::colvec X_offset = as<arma::colvec>(X_offsetR); - arma::colvec V_offset = as<arma::colvec>(V_offsetR); - std::string link_psi = as<std::string>(link_psiR); +// [[Rcpp::export]] +double nll_occu(arma::icolvec y, arma::mat X, arma::mat V, + arma::colvec beta_psi, arma::colvec beta_p, + Rcpp::IntegerVector nd, Rcpp::LogicalVector knownOcc, Rcpp::LogicalVector navec, + arma::colvec X_offset, arma::colvec V_offset, std::string link_psi) { int R = X.n_rows; int J = y.n_elem / R; @@ -47,6 +41,5 @@ SEXP nll_occu( SEXP yR, SEXP Xr, SEXP Vr, SEXP beta_psiR, SEXP beta_pR, SEXP ndR else if(nd(i)==1) ll += log(cp * psi(i) + (1-psi(i)) + DBL_MIN); } - return wrap(-ll); + return -ll; } - |