aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKen Kellner <ken@kenkellner.com>2023-07-02 18:38:32 -0400
committerKen Kellner <ken@kenkellner.com>2023-07-02 18:38:32 -0400
commit3dd331abb652b70ad10f7af0530701ffb2d31d81 (patch)
treee963a29866f05d01df50bffbe789c5d3abb91ae6
parent9f70da0502068e6f82d4fa11c5a8a9d68422d82e (diff)
Progress on #258
-rw-r--r--DESCRIPTION4
-rw-r--r--R/RcppExports.R36
-rw-r--r--R/distsamp.R6
-rw-r--r--R/distsampOpen.R2
-rw-r--r--R/multinomPois.R6
-rw-r--r--R/multmixOpen.R2
-rw-r--r--R/occu.R6
-rw-r--r--R/occuMS.R7
-rw-r--r--R/occuPEN.R15
-rw-r--r--R/occuTTD.R6
-rw-r--r--R/pcountOpen.R5
-rw-r--r--R/predict.R9
-rw-r--r--src/RcppExports.cpp232
-rw-r--r--src/get_lik_trans.cpp13
-rw-r--r--src/get_lik_trans.h8
-rw-r--r--src/get_mlogit.cpp20
-rw-r--r--src/get_mlogit.h8
-rw-r--r--src/nll_distsamp.cpp24
-rw-r--r--src/nll_distsamp.h10
-rw-r--r--src/nll_multinomPois.cpp38
-rw-r--r--src/nll_multinomPois.h10
-rw-r--r--src/nll_occu.cpp23
-rw-r--r--src/nll_occu.h9
-rw-r--r--src/nll_occuMS.cpp66
-rw-r--r--src/nll_occuMS.h12
-rw-r--r--src/nll_occuPEN.cpp24
-rw-r--r--src/nll_occuPEN.h9
-rw-r--r--src/nll_occuTTD.cpp40
-rw-r--r--src/nll_occuTTD.h13
-rw-r--r--src/nll_pcountOpen.cpp54
-rw-r--r--src/nll_pcountOpen.h10
31 files changed, 381 insertions, 346 deletions
diff --git a/DESCRIPTION b/DESCRIPTION
index 94ae43e..1d71836 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,6 +1,6 @@
Package: unmarked
-Version: 1.3.1
-Date: 2023-06-29
+Version: 1.3.1.9001
+Date: 2023-07-02
Type: Package
Title: Models for Data from Unmarked Animals
Authors@R: c(
diff --git a/R/RcppExports.R b/R/RcppExports.R
index 2d11a6c..5a85138 100644
--- a/R/RcppExports.R
+++ b/R/RcppExports.R
@@ -1,6 +1,18 @@
# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
+get_lik_trans <- function(I, I1) {
+ .Call(`_unmarked_get_lik_trans`, I, I1)
+}
+
+get_mlogit <- function(lp_mat, type, S, guide) {
+ .Call(`_unmarked_get_mlogit`, lp_mat, type, S, guide)
+}
+
+nll_distsamp <- function(y, lam, sig, scale, a, u, w, db, keyfun, survey) {
+ .Call(`_unmarked_nll_distsamp`, y, lam, sig, scale, a, u, w, db, keyfun, survey)
+}
+
nll_gdistremoval <- function(beta, n_param, yDistance, yRemoval, ysum, mixture, keyfun, Xlam, A, Xphi, Xrem, Xdist, db, a, u, w, pl, K, Kmin, threads) {
.Call(`_unmarked_nll_gdistremoval`, beta, n_param, yDistance, yRemoval, ysum, mixture, keyfun, Xlam, A, Xphi, Xrem, Xdist, db, a, u, w, pl, K, Kmin, threads)
}
@@ -17,15 +29,39 @@ nll_gpcount <- function(ym, Xlam, Xphi, Xp, beta_lam, beta_phi, beta_p, log_alph
.Call(`_unmarked_nll_gpcount`, ym, Xlam, Xphi, Xp, beta_lam, beta_phi, beta_p, log_alpha, Xlam_offset, Xphi_offset, Xp_offset, M, mixture, T, threads)
}
+nll_multinomPois <- function(beta, pi_fun, Xlam, Xlam_offset, Xdet, Xdet_offset, y, navec, nP, nAP) {
+ .Call(`_unmarked_nll_multinomPois`, beta, pi_fun, Xlam, Xlam_offset, Xdet, Xdet_offset, y, navec, nP, nAP)
+}
+
nll_nmixTTD <- function(beta, y, delta, W, V, pinds, mixture, tdist, N, J, K, naflag, threads) {
.Call(`_unmarked_nll_nmixTTD`, beta, y, delta, W, V, pinds, mixture, tdist, N, J, K, naflag, threads)
}
+nll_occu <- function(y, X, V, beta_psi, beta_p, nd, knownOcc, navec, X_offset, V_offset, link_psi) {
+ .Call(`_unmarked_nll_occu`, y, X, V, beta_psi, beta_p, nd, knownOcc, navec, X_offset, V_offset, link_psi)
+}
+
+nll_occuMS <- function(beta, y, dm_state, dm_phi, dm_det, sind, pind, dind, prm, S, T, J, N, naflag, guide) {
+ .Call(`_unmarked_nll_occuMS`, beta, y, dm_state, dm_phi, dm_det, sind, pind, dind, prm, S, T, J, N, naflag, guide)
+}
+
+nll_occuPEN <- function(y, X, V, beta_psi, beta_p, nd, knownOcc, navec, X_offset, V_offset, penalty) {
+ .Call(`_unmarked_nll_occuPEN`, y, X, V, beta_psi, beta_p, nd, knownOcc, navec, X_offset, V_offset, penalty)
+}
+
nll_occuRN <- function(beta, n_param, y, X, V, X_offset, V_offset, K, Kmin, threads) {
.Call(`_unmarked_nll_occuRN`, beta, n_param, y, X, V, X_offset, V_offset, K, Kmin, threads)
}
+nll_occuTTD <- function(beta, y, delta, W, V, Xgam, Xeps, pind, dind, cind, eind, lpsi, tdist, N, T, J, naflag) {
+ .Call(`_unmarked_nll_occuTTD`, beta, y, delta, W, V, Xgam, Xeps, pind, dind, cind, eind, lpsi, tdist, N, T, J, naflag)
+}
+
nll_pcount <- function(beta, n_param, y, X, V, X_offset, V_offset, K, Kmin, mixture, threads) {
.Call(`_unmarked_nll_pcount`, beta, n_param, y, X, V, X_offset, V_offset, K, Kmin, mixture, threads)
}
+nll_pcountOpen <- function(ym, Xlam, Xgam, Xom, Xp, Xiota, beta_lam, beta_gam, beta_om, beta_p, beta_iota, log_alpha, Xlam_offset, Xgam_offset, Xom_offset, Xp_offset, Xiota_offset, ytna, ynam, lk, mixture, first, last, M, J, T, delta, dynamics, fix, go_dims, immigration, I, I1, Ib, Ip) {
+ .Call(`_unmarked_nll_pcountOpen`, ym, Xlam, Xgam, Xom, Xp, Xiota, beta_lam, beta_gam, beta_om, beta_p, beta_iota, log_alpha, Xlam_offset, Xgam_offset, Xom_offset, Xp_offset, Xiota_offset, ytna, ynam, lk, mixture, first, last, M, J, T, delta, dynamics, fix, go_dims, immigration, I, I1, Ib, Ip)
+}
+
diff --git a/R/distsamp.R b/R/distsamp.R
index 5aa01cc..a6f29c0 100644
--- a/R/distsamp.R
+++ b/R/distsamp.R
@@ -220,11 +220,11 @@ distsamp <- function(formula, data,
if(identical(output, "density"))
lambda <- lambda * A
sigma <- drop(exp(V %*% beta.sig + V.offset))
- .Call("nll_distsamp",
+ nll_distsamp(
y, lambda, sigma, scale,
a, u, w, db,
- keyfun, survey, rel.tol,
- PACKAGE="unmarked")
+ keyfun, survey
+ )
}
}
diff --git a/R/distsampOpen.R b/R/distsampOpen.R
index 0f9f743..c74cd42 100644
--- a/R/distsampOpen.R
+++ b/R/distsampOpen.R
@@ -212,7 +212,7 @@ distsampOpen <- function(lambdaformula, gammaformula, omegaformula, pformula,
#finding all unique likelihood transitions
I <- cbind(rep(k, times=lk), rep(k, each=lk))
I1 <- I[I[,1] <= I[,2],]
- lik_trans <- .Call("get_lik_trans", I, I1, PACKAGE="unmarked")
+ lik_trans <- get_lik_trans(I, I1)
beta_ind <- matrix(NA, 7, 2)
beta_ind[1,] <- c(1, nAP) #Abundance
diff --git a/R/multinomPois.R b/R/multinomPois.R
index 924e77b..076410f 100644
--- a/R/multinomPois.R
+++ b/R/multinomPois.R
@@ -46,11 +46,11 @@ multinomPois <- function(formula, data, starts, method = "BFGS",
}
nll_C <- function(params) {
- .Call("nll_multinomPois",
+ nll_multinomPois(
params,piFun,
X, X.offset, V, V.offset,
- yC, navecC, nP,nAP,
- PACKAGE = "unmarked")
+ yC, navecC, nP,nAP
+ )
}
if(engine=="R"){
diff --git a/R/multmixOpen.R b/R/multmixOpen.R
index 725c9fc..9fb9743 100644
--- a/R/multmixOpen.R
+++ b/R/multmixOpen.R
@@ -153,7 +153,7 @@ multmixOpen <- function(lambdaformula, gammaformula, omegaformula, pformula,
#finding all unique likelihood transitions
I <- cbind(rep(k, times=lk), rep(k, each=lk))
I1 <- I[I[,1] <= I[,2],]
- lik_trans <- .Call("get_lik_trans", I, I1, PACKAGE="unmarked")
+ lik_trans <- get_lik_trans(I, I1)
beta_ind <- matrix(NA, 6, 2)
beta_ind[1,] <- c(1, nAP) #Abundance
diff --git a/R/occu.R b/R/occu.R
index 0379ca8..3402f5f 100644
--- a/R/occu.R
+++ b/R/occu.R
@@ -52,10 +52,10 @@ occu <- function(formula, data, knownOcc = numeric(0),
nll <- function(params) {
beta.psi <- params[1:nOP]
beta.p <- params[(nOP+1):nP]
- .Call("nll_occu",
+ nll_occu(
yvec, X, V, beta.psi, beta.p, nd, knownOccLog, navec,
- X.offset, V.offset, linkPsi,
- PACKAGE = "unmarked")
+ X.offset, V.offset, linkPsi
+ )
}
} else if (identical(engine, "R")){
diff --git a/R/occuMS.R b/R/occuMS.R
index 5bf2d36..3d1bf0f 100644
--- a/R/occuMS.R
+++ b/R/occuMS.R
@@ -177,11 +177,12 @@ occuMS <- function(detformulas, psiformulas, phiformulas=NULL, data,
#Likelihood function in C++--------------------------------------------------
naflag <- is.na(y)
nll_C <- function(params){
- .Call("nll_occuMS",
+ if(!is.matrix(pind)) pind <- matrix()
+ nll_occuMS(
params, y, gd$dm_state, gd$dm_phi, gd$dm_det,
sind-1, pind-1, dind-1, parameterization,
- S, T, J, N, naflag, guide-1,
- PACKAGE = "unmarked")
+ S, T, J, N, naflag, guide-1
+ )
}
#----------------------------------------------------------------------------
diff --git a/R/occuPEN.R b/R/occuPEN.R
index 2f24ff9..55c7563 100644
--- a/R/occuPEN.R
+++ b/R/occuPEN.R
@@ -77,10 +77,10 @@ occuPEN_CV <- function(formula, data, knownOcc = numeric(0), starts,
nll <- function(params) {
beta.psi <- params[1:nOP]
beta.p <- params[(nOP+1):nP]
- .Call("nll_occu",
+ nll_occu(
yvec, X, V, beta.psi, beta.p, nd, knownOccLog, navec,
- X.offset, V.offset, "logit",
- PACKAGE = "unmarked")
+ X.offset, V.offset, "logit"
+ )
}
} else {
nll <- function(params) { # penalize this function
@@ -252,12 +252,9 @@ occuPEN <- function(formula, data, knownOcc = numeric(0), starts,
} else {
stop("pen.type not found")
}
-
- .Call("nll_occuPEN",
- yvec, X, V, beta.psi, beta.p, nd, knownOccLog, navec,
- X.offset, V.offset, penalty,
- PACKAGE = "unmarked")
- }
+ nll_occuPEN(yvec, X, V, beta.psi, beta.p, nd, knownOccLog, navec,
+ X.offset, V.offset, penalty)
+ }
} else {
nll <- function(params) { # penalize this function
psi <- plogis(X %*% params[1 : nOP] + X.offset)
diff --git a/R/occuTTD.R b/R/occuTTD.R
index c9965f5..5751450 100644
--- a/R/occuTTD.R
+++ b/R/occuTTD.R
@@ -135,12 +135,12 @@ occuTTD <- function(psiformula=~1, gammaformula=~1, epsilonformula=~1,
}
nll_C <- function(params){
- .Call("nll_occuTTD",
+ nll_occuTTD(
params, yvec, delta, W, V, X.gam, X.eps,
range(psi_inds)-1, range(det_inds)-1,
range(col_inds)-1, range(ext_inds)-1,
- linkPsi, ttdDist, N, T, J, naflag,
- PACKAGE = "unmarked")
+ linkPsi, ttdDist, N, T, J, naflag
+ )
}
nll <- nll_C
diff --git a/R/pcountOpen.R b/R/pcountOpen.R
index 6f814f6..9156aad 100644
--- a/R/pcountOpen.R
+++ b/R/pcountOpen.R
@@ -148,7 +148,7 @@ nll <- function(parms) {
log.alpha <- 1
if(mixture %in% c("NB", "ZIP"))
log.alpha <- parms[nP]
- .Call("nll_pcountOpen",
+ nll_pcountOpen(
ym,
Xlam, Xgam, Xom, Xp, Xiota,
beta.lam, beta.gam, beta.om, beta.p, beta.iota, log.alpha,
@@ -156,8 +156,7 @@ nll <- function(parms) {
ytna, yna,
lk, mixture, first, last, M, J, T,
delta, dynamics, fix, go.dims, immigration,
- I, I1, Ib, Ip,
- PACKAGE = "unmarked")
+ I, I1, Ib, Ip)
}
if(missing(starts))
starts <- rep(0, nP)
diff --git a/R/predict.R b/R/predict.R
index 37b9f87..4f3b5fb 100644
--- a/R/predict.R
+++ b/R/predict.R
@@ -881,9 +881,8 @@ setMethod("predict", "unmarkedFitOccuMS",
out
}
- get_mlogit <- function(lp_mat){
- .Call("get_mlogit",
- lp_mat, type, S, guide-1)
+ get_mlogit_C <- function(lp_mat){
+ get_mlogit(lp_mat, type, S, guide-1) # via Rcpp
}
#----------------------------------------------------------------------------
@@ -919,7 +918,7 @@ setMethod("predict", "unmarkedFitOccuMS",
} else if (object@parameterization == "multinomial"){
lp <- get_lp(coef(object), dm_list, ind)
- pred <- get_mlogit(lp)
+ pred <- get_mlogit_C(lp)
M <- nrow(pred)
upr <- lwr <- se <- matrix(NA,M,P)
@@ -933,7 +932,7 @@ setMethod("predict", "unmarkedFitOccuMS",
get_pr <- function(i){
lp <- get_lp(rparam[i,], dm_list, ind)
- get_mlogit(lp)
+ get_mlogit_C(lp)
}
samp <- sapply(1:nsims, get_pr, simplify='array')
diff --git a/src/RcppExports.cpp b/src/RcppExports.cpp
index 1b7e11b..87ca901 100644
--- a/src/RcppExports.cpp
+++ b/src/RcppExports.cpp
@@ -12,6 +12,52 @@ Rcpp::Rostream<true>& Rcpp::Rcout = Rcpp::Rcpp_cout_get();
Rcpp::Rostream<false>& Rcpp::Rcerr = Rcpp::Rcpp_cerr_get();
#endif
+// get_lik_trans
+List get_lik_trans(arma::umat I, arma::umat I1);
+RcppExport SEXP _unmarked_get_lik_trans(SEXP ISEXP, SEXP I1SEXP) {
+BEGIN_RCPP
+ Rcpp::RObject rcpp_result_gen;
+ Rcpp::RNGScope rcpp_rngScope_gen;
+ Rcpp::traits::input_parameter< arma::umat >::type I(ISEXP);
+ Rcpp::traits::input_parameter< arma::umat >::type I1(I1SEXP);
+ rcpp_result_gen = Rcpp::wrap(get_lik_trans(I, I1));
+ return rcpp_result_gen;
+END_RCPP
+}
+// get_mlogit
+arma::mat get_mlogit(arma::mat lp_mat, std::string type, int S, arma::mat guide);
+RcppExport SEXP _unmarked_get_mlogit(SEXP lp_matSEXP, SEXP typeSEXP, SEXP SSEXP, SEXP guideSEXP) {
+BEGIN_RCPP
+ Rcpp::RObject rcpp_result_gen;
+ Rcpp::RNGScope rcpp_rngScope_gen;
+ Rcpp::traits::input_parameter< arma::mat >::type lp_mat(lp_matSEXP);
+ Rcpp::traits::input_parameter< std::string >::type type(typeSEXP);
+ Rcpp::traits::input_parameter< int >::type S(SSEXP);
+ Rcpp::traits::input_parameter< arma::mat >::type guide(guideSEXP);
+ rcpp_result_gen = Rcpp::wrap(get_mlogit(lp_mat, type, S, guide));
+ return rcpp_result_gen;
+END_RCPP
+}
+// nll_distsamp
+double nll_distsamp(Rcpp::IntegerMatrix y, Rcpp::NumericVector lam, Rcpp::NumericVector sig, double scale, Rcpp::NumericMatrix a, Rcpp::NumericMatrix u, Rcpp::NumericVector w, Rcpp::NumericVector db, std::string keyfun, std::string survey);
+RcppExport SEXP _unmarked_nll_distsamp(SEXP ySEXP, SEXP lamSEXP, SEXP sigSEXP, SEXP scaleSEXP, SEXP aSEXP, SEXP uSEXP, SEXP wSEXP, SEXP dbSEXP, SEXP keyfunSEXP, SEXP surveySEXP) {
+BEGIN_RCPP
+ Rcpp::RObject rcpp_result_gen;
+ Rcpp::RNGScope rcpp_rngScope_gen;
+ Rcpp::traits::input_parameter< Rcpp::IntegerMatrix >::type y(ySEXP);
+ Rcpp::traits::input_parameter< Rcpp::NumericVector >::type lam(lamSEXP);
+ Rcpp::traits::input_parameter< Rcpp::NumericVector >::type sig(sigSEXP);
+ Rcpp::traits::input_parameter< double >::type scale(scaleSEXP);
+ Rcpp::traits::input_parameter< Rcpp::NumericMatrix >::type a(aSEXP);
+ Rcpp::traits::input_parameter< Rcpp::NumericMatrix >::type u(uSEXP);
+ Rcpp::traits::input_parameter< Rcpp::NumericVector >::type w(wSEXP);
+ Rcpp::traits::input_parameter< Rcpp::NumericVector >::type db(dbSEXP);
+ Rcpp::traits::input_parameter< std::string >::type keyfun(keyfunSEXP);
+ Rcpp::traits::input_parameter< std::string >::type survey(surveySEXP);
+ rcpp_result_gen = Rcpp::wrap(nll_distsamp(y, lam, sig, scale, a, u, w, db, keyfun, survey));
+ return rcpp_result_gen;
+END_RCPP
+}
// nll_gdistremoval
double nll_gdistremoval(arma::vec beta, arma::uvec n_param, arma::vec yDistance, arma::vec yRemoval, arma::mat ysum, int mixture, std::string keyfun, arma::mat Xlam, arma::vec A, arma::mat Xphi, arma::mat Xrem, arma::mat Xdist, arma::vec db, arma::mat a, arma::mat u, arma::vec w, arma::uvec pl, int K, arma::uvec Kmin, int threads);
RcppExport SEXP _unmarked_nll_gdistremoval(SEXP betaSEXP, SEXP n_paramSEXP, SEXP yDistanceSEXP, SEXP yRemovalSEXP, SEXP ysumSEXP, SEXP mixtureSEXP, SEXP keyfunSEXP, SEXP XlamSEXP, SEXP ASEXP, SEXP XphiSEXP, SEXP XremSEXP, SEXP XdistSEXP, SEXP dbSEXP, SEXP aSEXP, SEXP uSEXP, SEXP wSEXP, SEXP plSEXP, SEXP KSEXP, SEXP KminSEXP, SEXP threadsSEXP) {
@@ -127,6 +173,26 @@ BEGIN_RCPP
return rcpp_result_gen;
END_RCPP
}
+// nll_multinomPois
+double nll_multinomPois(arma::vec beta, std::string pi_fun, arma::mat Xlam, arma::vec Xlam_offset, arma::mat Xdet, arma::vec Xdet_offset, arma::vec y, arma::vec navec, int nP, int nAP);
+RcppExport SEXP _unmarked_nll_multinomPois(SEXP betaSEXP, SEXP pi_funSEXP, SEXP XlamSEXP, SEXP Xlam_offsetSEXP, SEXP XdetSEXP, SEXP Xdet_offsetSEXP, SEXP ySEXP, SEXP navecSEXP, SEXP nPSEXP, SEXP nAPSEXP) {
+BEGIN_RCPP
+ Rcpp::RObject rcpp_result_gen;
+ Rcpp::RNGScope rcpp_rngScope_gen;
+ Rcpp::traits::input_parameter< arma::vec >::type beta(betaSEXP);
+ Rcpp::traits::input_parameter< std::string >::type pi_fun(pi_funSEXP);
+ Rcpp::traits::input_parameter< arma::mat >::type Xlam(XlamSEXP);
+ Rcpp::traits::input_parameter< arma::vec >::type Xlam_offset(Xlam_offsetSEXP);
+ Rcpp::traits::input_parameter< arma::mat >::type Xdet(XdetSEXP);
+ Rcpp::traits::input_parameter< arma::vec >::type Xdet_offset(Xdet_offsetSEXP);
+ Rcpp::traits::input_parameter< arma::vec >::type y(ySEXP);
+ Rcpp::traits::input_parameter< arma::vec >::type navec(navecSEXP);
+ Rcpp::traits::input_parameter< int >::type nP(nPSEXP);
+ Rcpp::traits::input_parameter< int >::type nAP(nAPSEXP);
+ rcpp_result_gen = Rcpp::wrap(nll_multinomPois(beta, pi_fun, Xlam, Xlam_offset, Xdet, Xdet_offset, y, navec, nP, nAP));
+ return rcpp_result_gen;
+END_RCPP
+}
// nll_nmixTTD
double nll_nmixTTD(const arma::vec beta, const arma::vec y, const arma::vec delta, const arma::mat W, const arma::mat V, const arma::umat pinds, const std::string mixture, const std::string tdist, int N, int J, int K, const arma::vec naflag, int threads);
RcppExport SEXP _unmarked_nll_nmixTTD(SEXP betaSEXP, SEXP ySEXP, SEXP deltaSEXP, SEXP WSEXP, SEXP VSEXP, SEXP pindsSEXP, SEXP mixtureSEXP, SEXP tdistSEXP, SEXP NSEXP, SEXP JSEXP, SEXP KSEXP, SEXP naflagSEXP, SEXP threadsSEXP) {
@@ -150,6 +216,73 @@ BEGIN_RCPP
return rcpp_result_gen;
END_RCPP
}
+// nll_occu
+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);
+RcppExport SEXP _unmarked_nll_occu(SEXP ySEXP, SEXP XSEXP, SEXP VSEXP, SEXP beta_psiSEXP, SEXP beta_pSEXP, SEXP ndSEXP, SEXP knownOccSEXP, SEXP navecSEXP, SEXP X_offsetSEXP, SEXP V_offsetSEXP, SEXP link_psiSEXP) {
+BEGIN_RCPP
+ Rcpp::RObject rcpp_result_gen;
+ Rcpp::RNGScope rcpp_rngScope_gen;
+ Rcpp::traits::input_parameter< arma::icolvec >::type y(ySEXP);
+ Rcpp::traits::input_parameter< arma::mat >::type X(XSEXP);
+ Rcpp::traits::input_parameter< arma::mat >::type V(VSEXP);
+ Rcpp::traits::input_parameter< arma::colvec >::type beta_psi(beta_psiSEXP);
+ Rcpp::traits::input_parameter< arma::colvec >::type beta_p(beta_pSEXP);
+ Rcpp::traits::input_parameter< Rcpp::IntegerVector >::type nd(ndSEXP);
+ Rcpp::traits::input_parameter< Rcpp::LogicalVector >::type knownOcc(knownOccSEXP);
+ Rcpp::traits::input_parameter< Rcpp::LogicalVector >::type navec(navecSEXP);
+ Rcpp::traits::input_parameter< arma::colvec >::type X_offset(X_offsetSEXP);
+ Rcpp::traits::input_parameter< arma::colvec >::type V_offset(V_offsetSEXP);
+ Rcpp::traits::input_parameter< std::string >::type link_psi(link_psiSEXP);
+ rcpp_result_gen = Rcpp::wrap(nll_occu(y, X, V, beta_psi, beta_p, nd, knownOcc, navec, X_offset, V_offset, link_psi));
+ return rcpp_result_gen;
+END_RCPP
+}
+// nll_occuMS
+double nll_occuMS(arma::vec beta, arma::mat y, Rcpp::List dm_state, Rcpp::List dm_phi, Rcpp::List dm_det, arma::mat sind, arma::mat pind, arma::mat dind, std::string prm, int S, int T, int J, int N, arma::mat naflag, arma::mat guide);
+RcppExport SEXP _unmarked_nll_occuMS(SEXP betaSEXP, SEXP ySEXP, SEXP dm_stateSEXP, SEXP dm_phiSEXP, SEXP dm_detSEXP, SEXP sindSEXP, SEXP pindSEXP, SEXP dindSEXP, SEXP prmSEXP, SEXP SSEXP, SEXP TSEXP, SEXP JSEXP, SEXP NSEXP, SEXP naflagSEXP, SEXP guideSEXP) {
+BEGIN_RCPP
+ Rcpp::RObject rcpp_result_gen;
+ Rcpp::RNGScope rcpp_rngScope_gen;
+ Rcpp::traits::input_parameter< arma::vec >::type beta(betaSEXP);
+ Rcpp::traits::input_parameter< arma::mat >::type y(ySEXP);
+ Rcpp::traits::input_parameter< Rcpp::List >::type dm_state(dm_stateSEXP);
+ Rcpp::traits::input_parameter< Rcpp::List >::type dm_phi(dm_phiSEXP);
+ Rcpp::traits::input_parameter< Rcpp::List >::type dm_det(dm_detSEXP);
+ Rcpp::traits::input_parameter< arma::mat >::type sind(sindSEXP);
+ Rcpp::traits::input_parameter< arma::mat >::type pind(pindSEXP);
+ Rcpp::traits::input_parameter< arma::mat >::type dind(dindSEXP);
+ Rcpp::traits::input_parameter< std::string >::type prm(prmSEXP);
+ Rcpp::traits::input_parameter< int >::type S(SSEXP);
+ Rcpp::traits::input_parameter< int >::type T(TSEXP);
+ Rcpp::traits::input_parameter< int >::type J(JSEXP);
+ Rcpp::traits::input_parameter< int >::type N(NSEXP);
+ Rcpp::traits::input_parameter< arma::mat >::type naflag(naflagSEXP);
+ Rcpp::traits::input_parameter< arma::mat >::type guide(guideSEXP);
+ rcpp_result_gen = Rcpp::wrap(nll_occuMS(beta, y, dm_state, dm_phi, dm_det, sind, pind, dind, prm, S, T, J, N, naflag, guide));
+ return rcpp_result_gen;
+END_RCPP
+}
+// nll_occuPEN
+double nll_occuPEN(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, double penalty);
+RcppExport SEXP _unmarked_nll_occuPEN(SEXP ySEXP, SEXP XSEXP, SEXP VSEXP, SEXP beta_psiSEXP, SEXP beta_pSEXP, SEXP ndSEXP, SEXP knownOccSEXP, SEXP navecSEXP, SEXP X_offsetSEXP, SEXP V_offsetSEXP, SEXP penaltySEXP) {
+BEGIN_RCPP
+ Rcpp::RObject rcpp_result_gen;
+ Rcpp::RNGScope rcpp_rngScope_gen;
+ Rcpp::traits::input_parameter< arma::icolvec >::type y(ySEXP);
+ Rcpp::traits::input_parameter< arma::mat >::type X(XSEXP);
+ Rcpp::traits::input_parameter< arma::mat >::type V(VSEXP);
+ Rcpp::traits::input_parameter< arma::colvec >::type beta_psi(beta_psiSEXP);
+ Rcpp::traits::input_parameter< arma::colvec >::type beta_p(beta_pSEXP);
+ Rcpp::traits::input_parameter< Rcpp::IntegerVector >::type nd(ndSEXP);
+ Rcpp::traits::input_parameter< Rcpp::LogicalVector >::type knownOcc(knownOccSEXP);
+ Rcpp::traits::input_parameter< Rcpp::LogicalVector >::type navec(navecSEXP);
+ Rcpp::traits::input_parameter< arma::colvec >::type X_offset(X_offsetSEXP);
+ Rcpp::traits::input_parameter< arma::colvec >::type V_offset(V_offsetSEXP);
+ Rcpp::traits::input_parameter< double >::type penalty(penaltySEXP);
+ rcpp_result_gen = Rcpp::wrap(nll_occuPEN(y, X, V, beta_psi, beta_p, nd, knownOcc, navec, X_offset, V_offset, penalty));
+ return rcpp_result_gen;
+END_RCPP
+}
// nll_occuRN
double nll_occuRN(const arma::vec beta, const arma::uvec n_param, const arma::mat y, const arma::mat X, const arma::mat V, const arma::vec X_offset, const arma::vec V_offset, int K, const arma::uvec Kmin, int threads);
RcppExport SEXP _unmarked_nll_occuRN(SEXP betaSEXP, SEXP n_paramSEXP, SEXP ySEXP, SEXP XSEXP, SEXP VSEXP, SEXP X_offsetSEXP, SEXP V_offsetSEXP, SEXP KSEXP, SEXP KminSEXP, SEXP threadsSEXP) {
@@ -170,6 +303,33 @@ BEGIN_RCPP
return rcpp_result_gen;
END_RCPP
}
+// nll_occuTTD
+double nll_occuTTD(arma::vec beta, arma::vec y, arma::vec delta, arma::mat W, arma::mat V, arma::mat Xgam, arma::mat Xeps, arma::vec pind, arma::vec dind, arma::vec cind, arma::vec eind, std::string lpsi, std::string tdist, int N, int T, int J, arma::vec naflag);
+RcppExport SEXP _unmarked_nll_occuTTD(SEXP betaSEXP, SEXP ySEXP, SEXP deltaSEXP, SEXP WSEXP, SEXP VSEXP, SEXP XgamSEXP, SEXP XepsSEXP, SEXP pindSEXP, SEXP dindSEXP, SEXP cindSEXP, SEXP eindSEXP, SEXP lpsiSEXP, SEXP tdistSEXP, SEXP NSEXP, SEXP TSEXP, SEXP JSEXP, SEXP naflagSEXP) {
+BEGIN_RCPP
+ Rcpp::RObject rcpp_result_gen;
+ Rcpp::RNGScope rcpp_rngScope_gen;
+ Rcpp::traits::input_parameter< arma::vec >::type beta(betaSEXP);
+ Rcpp::traits::input_parameter< arma::vec >::type y(ySEXP);
+ Rcpp::traits::input_parameter< arma::vec >::type delta(deltaSEXP);
+ Rcpp::traits::input_parameter< arma::mat >::type W(WSEXP);
+ Rcpp::traits::input_parameter< arma::mat >::type V(VSEXP);
+ Rcpp::traits::input_parameter< arma::mat >::type Xgam(XgamSEXP);
+ Rcpp::traits::input_parameter< arma::mat >::type Xeps(XepsSEXP);
+ Rcpp::traits::input_parameter< arma::vec >::type pind(pindSEXP);
+ Rcpp::traits::input_parameter< arma::vec >::type dind(dindSEXP);
+ Rcpp::traits::input_parameter< arma::vec >::type cind(cindSEXP);
+ Rcpp::traits::input_parameter< arma::vec >::type eind(eindSEXP);
+ Rcpp::traits::input_parameter< std::string >::type lpsi(lpsiSEXP);
+ Rcpp::traits::input_parameter< std::string >::type tdist(tdistSEXP);
+ Rcpp::traits::input_parameter< int >::type N(NSEXP);
+ Rcpp::traits::input_parameter< int >::type T(TSEXP);
+ Rcpp::traits::input_parameter< int >::type J(JSEXP);
+ Rcpp::traits::input_parameter< arma::vec >::type naflag(naflagSEXP);
+ rcpp_result_gen = Rcpp::wrap(nll_occuTTD(beta, y, delta, W, V, Xgam, Xeps, pind, dind, cind, eind, lpsi, tdist, N, T, J, naflag));
+ return rcpp_result_gen;
+END_RCPP
+}
// nll_pcount
double nll_pcount(const arma::vec beta, const arma::uvec n_param, const arma::mat y, const arma::mat X, const arma::mat V, const arma::vec X_offset, const arma::vec V_offset, int K, const arma::uvec Kmin, int mixture, int threads);
RcppExport SEXP _unmarked_nll_pcount(SEXP betaSEXP, SEXP n_paramSEXP, SEXP ySEXP, SEXP XSEXP, SEXP VSEXP, SEXP X_offsetSEXP, SEXP V_offsetSEXP, SEXP KSEXP, SEXP KminSEXP, SEXP mixtureSEXP, SEXP threadsSEXP) {
@@ -191,44 +351,80 @@ BEGIN_RCPP
return rcpp_result_gen;
END_RCPP
}
+// nll_pcountOpen
+double nll_pcountOpen(arma::imat ym, arma::mat Xlam, arma::mat Xgam, arma::mat Xom, arma::mat Xp, arma::mat Xiota, arma::colvec beta_lam, arma::colvec beta_gam, arma::colvec beta_om, arma::colvec beta_p, arma::colvec beta_iota, double log_alpha, arma::colvec Xlam_offset, arma::colvec Xgam_offset, arma::colvec Xom_offset, arma::colvec Xp_offset, arma::colvec Xiota_offset, arma::imat ytna, arma::imat ynam, int lk, std::string mixture, Rcpp::IntegerVector first, Rcpp::IntegerVector last, int M, int J, int T, arma::imat delta, std::string dynamics, std::string fix, std::string go_dims, bool immigration, arma::imat I, arma::imat I1, Rcpp::List Ib, Rcpp::List Ip);
+RcppExport SEXP _unmarked_nll_pcountOpen(SEXP ymSEXP, SEXP XlamSEXP, SEXP XgamSEXP, SEXP XomSEXP, SEXP XpSEXP, SEXP XiotaSEXP, SEXP beta_lamSEXP, SEXP beta_gamSEXP, SEXP beta_omSEXP, SEXP beta_pSEXP, SEXP beta_iotaSEXP, SEXP log_alphaSEXP, SEXP Xlam_offsetSEXP, SEXP Xgam_offsetSEXP, SEXP Xom_offsetSEXP, SEXP Xp_offsetSEXP, SEXP Xiota_offsetSEXP, SEXP ytnaSEXP, SEXP ynamSEXP, SEXP lkSEXP, SEXP mixtureSEXP, SEXP firstSEXP, SEXP lastSEXP, SEXP MSEXP, SEXP JSEXP, SEXP TSEXP, SEXP deltaSEXP, SEXP dynamicsSEXP, SEXP fixSEXP, SEXP go_dimsSEXP, SEXP immigrationSEXP, SEXP ISEXP, SEXP I1SEXP, SEXP IbSEXP, SEXP IpSEXP) {
+BEGIN_RCPP
+ Rcpp::RObject rcpp_result_gen;
+ Rcpp::RNGScope rcpp_rngScope_gen;
+ Rcpp::traits::input_parameter< arma::imat >::type ym(ymSEXP);
+ Rcpp::traits::input_parameter< arma::mat >::type Xlam(XlamSEXP);
+ Rcpp::traits::input_parameter< arma::mat >::type Xgam(XgamSEXP);
+ Rcpp::traits::input_parameter< arma::mat >::type Xom(XomSEXP);
+ Rcpp::traits::input_parameter< arma::mat >::type Xp(XpSEXP);
+ Rcpp::traits::input_parameter< arma::mat >::type Xiota(XiotaSEXP);
+ Rcpp::traits::input_parameter< arma::colvec >::type beta_lam(beta_lamSEXP);
+ Rcpp::traits::input_parameter< arma::colvec >::type beta_gam(beta_gamSEXP);
+ Rcpp::traits::input_parameter< arma::colvec >::type beta_om(beta_omSEXP);
+ Rcpp::traits::input_parameter< arma::colvec >::type beta_p(beta_pSEXP);
+ Rcpp::traits::input_parameter< arma::colvec >::type beta_iota(beta_iotaSEXP);
+ Rcpp::traits::input_parameter< double >::type log_alpha(log_alphaSEXP);
+ Rcpp::traits::input_parameter< arma::colvec >::type Xlam_offset(Xlam_offsetSEXP);
+ Rcpp::traits::input_parameter< arma::colvec >::type Xgam_offset(Xgam_offsetSEXP);
+ Rcpp::traits::input_parameter< arma::colvec >::type Xom_offset(Xom_offsetSEXP);
+ Rcpp::traits::input_parameter< arma::colvec >::type Xp_offset(Xp_offsetSEXP);
+ Rcpp::traits::input_parameter< arma::colvec >::type Xiota_offset(Xiota_offsetSEXP);
+ Rcpp::traits::input_parameter< arma::imat >::type ytna(ytnaSEXP);
+ Rcpp::traits::input_parameter< arma::imat >::type ynam(ynamSEXP);
+ Rcpp::traits::input_parameter< int >::type lk(lkSEXP);
+ Rcpp::traits::input_parameter< std::string >::type mixture(mixtureSEXP);
+ Rcpp::traits::input_parameter< Rcpp::IntegerVector >::type first(firstSEXP);
+ Rcpp::traits::input_parameter< Rcpp::IntegerVector >::type last(lastSEXP);
+ Rcpp::traits::input_parameter< int >::type M(MSEXP);
+ Rcpp::traits::input_parameter< int >::type J(JSEXP);
+ Rcpp::traits::input_parameter< int >::type T(TSEXP);
+ Rcpp::traits::input_parameter< arma::imat >::type delta(deltaSEXP);
+ Rcpp::traits::input_parameter< std::string >::type dynamics(dynamicsSEXP);
+ Rcpp::traits::input_parameter< std::string >::type fix(fixSEXP);
+ Rcpp::traits::input_parameter< std::string >::type go_dims(go_dimsSEXP);
+ Rcpp::traits::input_parameter< bool >::type immigration(immigrationSEXP);
+ Rcpp::traits::input_parameter< arma::imat >::type I(ISEXP);
+ Rcpp::traits::input_parameter< arma::imat >::type I1(I1SEXP);
+ Rcpp::traits::input_parameter< Rcpp::List >::type Ib(IbSEXP);
+ Rcpp::traits::input_parameter< Rcpp::List >::type Ip(IpSEXP);
+ rcpp_result_gen = Rcpp::wrap(nll_pcountOpen(ym, Xlam, Xgam, Xom, Xp, Xiota, beta_lam, beta_gam, beta_om, beta_p, beta_iota, log_alpha, Xlam_offset, Xgam_offset, Xom_offset, Xp_offset, Xiota_offset, ytna, ynam, lk, mixture, first, last, M, J, T, delta, dynamics, fix, go_dims, immigration, I, I1, Ib, Ip));
+ return rcpp_result_gen;
+END_RCPP
+}
-RcppExport SEXP get_lik_trans(void *, void *);
-RcppExport SEXP get_mlogit(void *, void *, void *, void *);
RcppExport SEXP getDetVecs(void *, void *, void *, void *, void *);
RcppExport SEXP getSingleDetVec(void *, void *, void *);
-RcppExport SEXP nll_distsamp(void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *);
RcppExport SEXP nll_distsampOpen(void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *);
-RcppExport SEXP nll_multinomPois(void *, void *, void *, void *, void *, void *, void *, void *, void *, void *);
RcppExport SEXP nll_multmixOpen(void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *);
-RcppExport SEXP nll_occu(void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *);
-RcppExport SEXP nll_occuMS(void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *);
RcppExport SEXP nll_occuMulti(void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *);
-RcppExport SEXP nll_occuPEN(void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *);
-RcppExport SEXP nll_occuTTD(void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *);
-RcppExport SEXP nll_pcountOpen(void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *);
static const R_CallMethodDef CallEntries[] = {
+ {"_unmarked_get_lik_trans", (DL_FUNC) &_unmarked_get_lik_trans, 2},
+ {"_unmarked_get_mlogit", (DL_FUNC) &_unmarked_get_mlogit, 4},
+ {"_unmarked_nll_distsamp", (DL_FUNC) &_unmarked_nll_distsamp, 10},
{"_unmarked_nll_gdistremoval", (DL_FUNC) &_unmarked_nll_gdistremoval, 20},
{"_unmarked_nll_gdistsamp", (DL_FUNC) &_unmarked_nll_gdistsamp, 23},
{"_unmarked_nll_gmultmix", (DL_FUNC) &_unmarked_nll_gmultmix, 17},
{"_unmarked_nll_gpcount", (DL_FUNC) &_unmarked_nll_gpcount, 15},
+ {"_unmarked_nll_multinomPois", (DL_FUNC) &_unmarked_nll_multinomPois, 10},
{"_unmarked_nll_nmixTTD", (DL_FUNC) &_unmarked_nll_nmixTTD, 13},
+ {"_unmarked_nll_occu", (DL_FUNC) &_unmarked_nll_occu, 11},
+ {"_unmarked_nll_occuMS", (DL_FUNC) &_unmarked_nll_occuMS, 15},
+ {"_unmarked_nll_occuPEN", (DL_FUNC) &_unmarked_nll_occuPEN, 11},
{"_unmarked_nll_occuRN", (DL_FUNC) &_unmarked_nll_occuRN, 10},
+ {"_unmarked_nll_occuTTD", (DL_FUNC) &_unmarked_nll_occuTTD, 17},
{"_unmarked_nll_pcount", (DL_FUNC) &_unmarked_nll_pcount, 11},
- {"get_lik_trans", (DL_FUNC) &get_lik_trans, 2},
- {"get_mlogit", (DL_FUNC) &get_mlogit, 4},
+ {"_unmarked_nll_pcountOpen", (DL_FUNC) &_unmarked_nll_pcountOpen, 35},
{"getDetVecs", (DL_FUNC) &getDetVecs, 5},
{"getSingleDetVec", (DL_FUNC) &getSingleDetVec, 3},
- {"nll_distsamp", (DL_FUNC) &nll_distsamp, 11},
{"nll_distsampOpen", (DL_FUNC) &nll_distsampOpen, 42},
- {"nll_multinomPois", (DL_FUNC) &nll_multinomPois, 10},
{"nll_multmixOpen", (DL_FUNC) &nll_multmixOpen, 39},
- {"nll_occu", (DL_FUNC) &nll_occu, 11},
- {"nll_occuMS", (DL_FUNC) &nll_occuMS, 15},
{"nll_occuMulti", (DL_FUNC) &nll_occuMulti, 16},
- {"nll_occuPEN", (DL_FUNC) &nll_occuPEN, 11},
- {"nll_occuTTD", (DL_FUNC) &nll_occuTTD, 17},
- {"nll_pcountOpen", (DL_FUNC) &nll_pcountOpen, 35},
{NULL, NULL, 0}
};
diff --git a/src/get_lik_trans.cpp b/src/get_lik_trans.cpp
index 472bdb2..d4ae6af 100644
--- a/src/get_lik_trans.cpp
+++ b/src/get_lik_trans.cpp
@@ -1,12 +1,11 @@
-#include "get_lik_trans.h"
+#include <RcppArmadillo.h>
using namespace Rcpp;
using namespace arma;
-SEXP get_lik_trans(SEXP I_, SEXP I1_){
+// [[Rcpp::export]]
- umat I = as<umat>(I_);
- umat I1 = as<umat>(I1_);
+List get_lik_trans(arma::umat I, arma::umat I1){
List Ib(I.n_rows);
List Ip(I.n_rows);
@@ -16,15 +15,15 @@ SEXP get_lik_trans(SEXP I_, SEXP I1_){
IntegerVector Ztmp = seq(0, minI);
uvec Z = as<uvec>(Ztmp);
-
+
uvec Ib_el = find( I1.col(0) <= minI && I1.col(1) == I(i,0) );
- uvec Ip_el = I(i, 1) - Z;
+ uvec Ip_el = I(i, 1) - Z;
Ib[i] = Ib_el;
Ip[i] = Ip_el;
}
List out = List::create(Named("Ib") = Ib , _["Ip"] = Ip);
- return(wrap(out));
+ return out;
}
diff --git a/src/get_lik_trans.h b/src/get_lik_trans.h
deleted file mode 100644
index d903b48..0000000
--- a/src/get_lik_trans.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef _unmarked_NLL_LIKTRANS_H
-#define _unmarked_NLL_LIKTRANS_H
-
-#include <RcppArmadillo.h>
-
-RcppExport SEXP get_lik_trans(SEXP I_, SEXP I1_);
-
-#endif
diff --git a/src/get_mlogit.cpp b/src/get_mlogit.cpp
index 77eb15c..70c52ff 100644
--- a/src/get_mlogit.cpp
+++ b/src/get_mlogit.cpp
@@ -1,14 +1,10 @@
-#include "get_mlogit.h"
+#include <RcppArmadillo.h>
using namespace Rcpp;
using namespace arma;
-SEXP get_mlogit(SEXP lp_mat_, SEXP type_, SEXP S_, SEXP guide_){
-
- const mat lp_mat = as<mat>(lp_mat_);
- const std::string type = as<std::string>(type_);
- int S = as<int>(S_);
- const mat guide = as<mat>(guide_);
+// [[Rcpp::export]]
+arma::mat get_mlogit(arma::mat lp_mat, std::string type, int S, arma::mat guide){
int R = lp_mat.n_rows;
int C = lp_mat.n_cols;
@@ -22,7 +18,7 @@ SEXP get_mlogit(SEXP lp_mat_, SEXP type_, SEXP S_, SEXP guide_){
out(r,c) = out(r,c) / row_sum;
}
}
- return(wrap(out));
+ return out;
} else if(type == "phi"){
@@ -37,9 +33,9 @@ SEXP get_mlogit(SEXP lp_mat_, SEXP type_, SEXP S_, SEXP guide_){
ix += (S-1);
}
}
- return(wrap(out));
+ return out;
} else if(type == "det"){
-
+
mat out(R,C);
for(int r=0; r<R; r++){
mat sdp = zeros(S,S);
@@ -52,12 +48,12 @@ SEXP get_mlogit(SEXP lp_mat_, SEXP type_, SEXP S_, SEXP guide_){
for (int j=0; j<S; j++){
sdp(s,j) = sdp(s,j) / row_sum;
}
- }
+ }
for(int c=0; c<C; c++){
out(r,c) = sdp( guide(c,0), guide(c,1) );
}
}
- return(wrap(out));
+ return out;
} else {
stop("type must be 'psi','phi',or 'det'");
}
diff --git a/src/get_mlogit.h b/src/get_mlogit.h
deleted file mode 100644
index f143c7a..0000000
--- a/src/get_mlogit.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef _unmarked_NLL_MULTPROB_H
-#define _unmarked_NLL_MULTPROB_H
-
-#include <RcppArmadillo.h>
-
-RcppExport SEXP get_mlogit(SEXP lp_mat_, SEXP type_, SEXP S_, SEXP guide_);
-
-#endif
diff --git a/src/nll_distsamp.cpp b/src/nll_distsamp.cpp
index 2cdd3d7..6b0956a 100644
--- a/src/nll_distsamp.cpp
+++ b/src/nll_distsamp.cpp
@@ -1,18 +1,12 @@
-#include "nll_distsamp.h"
+#include <RcppArmadillo.h>
+#include <float.h>
+#include "detfuns.h"
-
-SEXP nll_distsamp( SEXP y_, SEXP lam_, SEXP sig_, SEXP scale_, SEXP a_, SEXP u_, SEXP w_, SEXP db_, SEXP keyfun_, SEXP survey_, SEXP reltol_ ) {
-
- Rcpp::IntegerMatrix y(y_);
- Rcpp::NumericVector lam(lam_);
- Rcpp::NumericVector sig(sig_);
- double scale = Rcpp::as<double>(scale_);
- Rcpp::NumericMatrix a(a_);
- Rcpp::NumericMatrix u(u_);
- Rcpp::NumericVector w(w_);
- Rcpp::NumericVector db(db_);
- std::string keyfun = Rcpp::as<std::string>(keyfun_);
- std::string survey = Rcpp::as<std::string>(survey_);
+// [[Rcpp::export]]
+double nll_distsamp(Rcpp::IntegerMatrix y, Rcpp::NumericVector lam,
+ Rcpp::NumericVector sig, double scale, Rcpp::NumericMatrix a,
+ Rcpp::NumericMatrix u, Rcpp::NumericVector w, Rcpp::NumericVector db,
+ std::string keyfun, std::string survey) {
int R = y.nrow(); //y.n_rows;
int J = y.ncol(); // y.n_cols;
@@ -66,5 +60,5 @@ SEXP nll_distsamp( SEXP y_, SEXP lam_, SEXP sig_, SEXP scale_, SEXP a_, SEXP u_,
ll += std::max(Rf_dpois(y(i,j), lam[i]*cp, true), lnmin);
}
}
- return Rcpp::wrap(-ll);
+ return -ll;
}
diff --git a/src/nll_distsamp.h b/src/nll_distsamp.h
deleted file mode 100644
index 8bb31e3..0000000
--- a/src/nll_distsamp.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef _UNMARKED_NLL_DISTSAMP_H
-#define _UNMARKED_NLL_DISTSAMP_H
-
-#include <Rcpp.h>
-#include <float.h>
-#include "detfuns.h"
-
-RcppExport SEXP nll_distsamp( SEXP y_, SEXP lam_, SEXP sig_, SEXP scale_, SEXP a_, SEXP u_, SEXP w_, SEXP db_, SEXP keyfun_, SEXP survey_, SEXP reltol_ ) ;
-
-#endif
diff --git a/src/nll_multinomPois.cpp b/src/nll_multinomPois.cpp
index 581ab53..e12ba82 100644
--- a/src/nll_multinomPois.cpp
+++ b/src/nll_multinomPois.cpp
@@ -1,4 +1,4 @@
-#include "nll_multinomPois.h"
+#include <RcppArmadillo.h>
#include "pifun.h"
using namespace Rcpp;
@@ -8,32 +8,18 @@ mat inv_logit_( mat inp ){
return(1 / (1 + exp(-1 * inp)));
}
-SEXP nll_multinomPois(SEXP betaR, SEXP pi_funR,
- SEXP XlamR, SEXP Xlam_offsetR, SEXP XdetR, SEXP Xdet_offsetR,
- SEXP yR, SEXP navecR, SEXP nPr, SEXP nAPr){
-
- //Inputs
- vec beta = as<vec>(betaR);
- std::string pi_fun = as<std::string>(pi_funR);
-
- mat Xlam = as<mat>(XlamR);
- vec Xlam_offset = as<vec>(Xlam_offsetR);
- mat Xdet = as<mat>(XdetR);
- vec Xdet_offset = as<vec>(Xdet_offsetR);
-
- vec y = as<vec>(yR);
- vec navec = as<vec>(navecR);
-
- int nP = as<int>(nPr);
- int nAP = as<int>(nAPr);
+// [[Rcpp::export]]
+double nll_multinomPois(arma::vec beta, std::string pi_fun,
+ arma::mat Xlam, arma::vec Xlam_offset, arma::mat Xdet, arma::vec Xdet_offset,
+ arma::vec y, arma::vec navec, int nP, int nAP){
int M = Xlam.n_rows;
vec lambda = exp( Xlam * beta.subvec(0, (nAP - 1) ) + Xlam_offset );
-
+
int J = Xdet.n_rows / M;
- int R = y.size() / M;
+ int R = y.size() / M;
vec p = inv_logit_( Xdet * beta.subvec(nAP,(nP-1)) + Xdet_offset);
-
+
int y_ind = 0;
int p_ind = 0;
@@ -43,11 +29,11 @@ SEXP nll_multinomPois(SEXP betaR, SEXP pi_funR,
int y_stop = y_ind + R - 1;
int p_stop = p_ind + J - 1;
- vec na_sub = navec.subvec(y_ind, y_stop);
+ vec na_sub = navec.subvec(y_ind, y_stop);
if( ! all(na_sub) ){
- vec pi_lam = piFun( p.subvec(p_ind, p_stop), pi_fun ) * lambda(m);
-
+ vec pi_lam = piFun( p.subvec(p_ind, p_stop), pi_fun ) * lambda(m);
+
for (int r=0; r<R; r++){
if( ! na_sub(r) ){
ll(m,r) = R::dpois(y(y_ind+r), pi_lam(r), 1);
@@ -59,6 +45,6 @@ SEXP nll_multinomPois(SEXP betaR, SEXP pi_funR,
p_ind += J;
}
- return(wrap(-accu(ll)));
+ return -accu(ll);
}
diff --git a/src/nll_multinomPois.h b/src/nll_multinomPois.h
deleted file mode 100644
index 19f503f..0000000
--- a/src/nll_multinomPois.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef _unmarked_NLL_MULTINOMPOIS_H
-#define _unmarked_NLL_MULTINOMPOIS_H
-
-#include <RcppArmadillo.h>
-
-RcppExport SEXP nll_multinomPois(SEXP betaR, SEXP pi_funR,
- SEXP XlamR, SEXP Xlam_offsetR, SEXP XdetR, SEXP Xdet_offsetR,
- SEXP yR, SEXP navecR, SEXP nPr, SEXP nAPr) ;
-
-#endif
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;
}
-
diff --git a/src/nll_occu.h b/src/nll_occu.h
deleted file mode 100644
index e8592f6..0000000
--- a/src/nll_occu.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifndef _unmarked_NLL_OCCU_H
-#define _unmarked_NLL_OCCU_H
-
-#include <RcppArmadillo.h>
-#include <float.h>
-
-RcppExport 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 ) ;
-
-#endif
diff --git a/src/nll_occuMS.cpp b/src/nll_occuMS.cpp
index 70ff5d1..da2bf8f 100644
--- a/src/nll_occuMS.cpp
+++ b/src/nll_occuMS.cpp
@@ -1,4 +1,4 @@
-#include "nll_occuMS.h"
+#include <RcppArmadillo.h>
using namespace Rcpp;
using namespace arma;
@@ -15,7 +15,7 @@ mat get_param(const List& dm_list, const vec& beta, const mat& ind){
mat X = as<mat>(dm_list[i]);
out.col(i) = X * beta.subvec(ind(i,0), ind(i,1));
}
-
+
return(out);
}
@@ -34,12 +34,12 @@ rowvec multinom_logit(const rowvec& lp){
//calculate final psi depending on parameterization
mat get_psi(const mat& lp, const std::string& prm){
int R = lp.n_rows;
-
+
if(prm == "multinomial"){
//[ 1 - psi_1:psi_m, psi_1:psi_m ]
mat out(R, lp.n_cols + 1);
for (int i=0; i<R; i++){
- out.row(i) = multinom_logit(lp.row(i));
+ out.row(i) = multinom_logit(lp.row(i));
}
return(out);
@@ -60,9 +60,9 @@ mat get_psi(const mat& lp, const std::string& prm){
//calculate phi matrix for a site-year depending on parameterization
mat get_phi(int S, const rowvec& lp, const std::string& prm){
-
+
mat out(S,S);
-
+
if(prm == "multinomial"){
int index = 0;
for (int i=0; i<S; i++){ //row
@@ -78,7 +78,7 @@ mat get_phi(int S, const rowvec& lp, const std::string& prm){
out.row(i) = lp_row / sum(lp_row);
}
return(out);
-
+
} else if(prm == "condbinom"){
rowvec lp_logit = 1 / ( 1 + exp(-lp));
for(int i=0; i<S; i++){
@@ -92,12 +92,12 @@ mat get_phi(int S, const rowvec& lp, const std::string& prm){
}
}
-mat get_sdp(int S, const rowvec& lp, const mat& guide,
+mat get_sdp(int S, const rowvec& lp, const mat& guide,
const std::string& prm){
mat out = zeros(S,S);
- if(prm == "multinomial"){
+ if(prm == "multinomial"){
for (unsigned int i=0; i<lp.size(); i++){
out( guide(i,0), guide(i,1) ) = exp(lp(i));
}
@@ -125,9 +125,9 @@ mat get_sdp(int S, const rowvec& lp, const mat& guide,
}
}
-vec get_ph(const int S, const rowvec& y, const mat& probs,
+vec get_ph(const int S, const rowvec& y, const mat& probs,
const rowvec& navec, const mat& guide, const std::string prm){
-
+
int J = probs.n_rows;
vec out = ones(S);
@@ -143,42 +143,20 @@ vec get_ph(const int S, const rowvec& y, const mat& probs,
return(out);
}
-SEXP nll_occuMS( SEXP beta_, SEXP y_,
- SEXP dm_state_, SEXP dm_phi_, SEXP dm_det_,
- SEXP sind_, SEXP pind_, SEXP dind_, SEXP prm_,
- SEXP S_, SEXP T_, SEXP J_, SEXP N_,
- SEXP naflag_, SEXP guide_){
-
- //Inputs
- const vec beta = as<vec>(beta_);
- const mat y = as<mat>(y_);
- const List dm_state(dm_state_);
- const List dm_phi(dm_phi_);
- const List dm_det(dm_det_);
-
- const mat sind = as<mat>(sind_);
- const mat dind = as<mat>(dind_);
- const mat guide = as<mat>(guide_);
-
- const std::string prm = as<std::string>(prm_);
-
- const mat naflag = as<mat>(naflag_);
-
- int N = as<int>(N_);
- int S = as<int>(S_);
- int T = as<int>(T_);
- int J = as<int>(J_);
-
+// [[Rcpp::export]]
+double nll_occuMS(arma::vec beta, arma::mat y,
+ Rcpp::List dm_state, Rcpp::List dm_phi, Rcpp::List dm_det,
+ arma::mat sind, arma::mat pind, arma::mat dind, std::string prm,
+ int S, int T, int J, int N,
+ arma::mat naflag, arma::mat guide){
//Get psi values
const mat raw_psi = get_param(dm_state, beta, sind);
const mat psi = get_psi(raw_psi, prm);
-
+
//Get phi values
mat raw_phi;
- mat pind;
if(T>1){
- pind = as<mat>(pind_);
raw_phi = get_param(dm_phi, beta, pind);
}
@@ -197,7 +175,7 @@ SEXP nll_occuMS( SEXP beta_, SEXP y_,
rowvec nasub = naflag.row(n);
ystart = 0;
mat phi_prod = eye(S,S);
-
+
if(T>1){
for(int t=0; t<(T-1); t++){
pend = pstart + J - 1;
@@ -214,7 +192,7 @@ SEXP nll_occuMS( SEXP beta_, SEXP y_,
phi_index += 1;
}
}
-
+
pend = pstart + J - 1;
yend = ystart + J - 1;
@@ -222,12 +200,12 @@ SEXP nll_occuMS( SEXP beta_, SEXP y_,
p.rows(span(pstart, pend)),
nasub.subvec(ystart,yend), guide, prm);
pstart += J;
-
+
rowvec psi_phi = psi.row(n) * phi_prod;
lik(n) = dot(psi_phi, ph_T);
}
- return(wrap(-sum(log(lik))));
+ return -sum(log(lik));
}
diff --git a/src/nll_occuMS.h b/src/nll_occuMS.h
deleted file mode 100644
index 847c099..0000000
--- a/src/nll_occuMS.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef _unmarked_NLL_OCCUMS_H
-#define _unmarked_NLL_OCCUMS_H
-
-#include <RcppArmadillo.h>
-
-RcppExport SEXP nll_occuMS( SEXP beta_, SEXP y_,
- SEXP dm_state_, SEXP dm_phi_, SEXP dm_det_,
- SEXP sind_, SEXP pind_, SEXP dind_, SEXP prm_,
- SEXP S_, SEXP T_, SEXP J_, SEXP N_,
- SEXP naflag_, SEXP guide_) ;
-
-#endif
diff --git a/src/nll_occuPEN.cpp b/src/nll_occuPEN.cpp
index 5e41a50..32c362a 100644
--- a/src/nll_occuPEN.cpp
+++ b/src/nll_occuPEN.cpp
@@ -1,20 +1,14 @@
-#include "nll_occuPEN.h"
+#include <RcppArmadillo.h>
+#include <float.h>
using namespace Rcpp ;
-SEXP nll_occuPEN( 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 penaltyR ) {
- 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::double penalty = as<std::double>(penaltyR);
- double penalty = as<double>(penaltyR);
+// [[Rcpp::export]]
+double nll_occuPEN(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, double penalty) {
+
int R = X.n_rows;
int J = y.n_elem / R;
arma::colvec logit_psi = X*beta_psi + X_offset;
@@ -38,6 +32,6 @@ SEXP nll_occuPEN( SEXP yR, SEXP Xr, SEXP Vr, SEXP beta_psiR, SEXP beta_pR, SEXP
ll += log(cp * psi(i) + (1-psi(i)) + DBL_MIN);
}
ll = ll - penalty;
- return wrap(-ll);
+ return -ll;
}
diff --git a/src/nll_occuPEN.h b/src/nll_occuPEN.h
deleted file mode 100644
index b5875fd..0000000
--- a/src/nll_occuPEN.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifndef _unmarked_NLL_OCCUPEN_H
-#define _unmarked_NLL_OCCUPEN_H
-
-#include <RcppArmadillo.h>
-#include <float.h>
-
-RcppExport SEXP nll_occuPEN( 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 penaltyR ) ;
-
-#endif
diff --git a/src/nll_occuTTD.cpp b/src/nll_occuTTD.cpp
index 4324403..8005f2a 100644
--- a/src/nll_occuTTD.cpp
+++ b/src/nll_occuTTD.cpp
@@ -1,4 +1,4 @@
-#include "nll_occuTTD.h"
+#include <RcppArmadillo.h>
using namespace Rcpp;
using namespace arma;
@@ -30,35 +30,15 @@ using namespace arma;
//}
-SEXP nll_occuTTD( SEXP beta_, SEXP y_, SEXP delta_,
- SEXP W_, SEXP V_, SEXP Xgam_, SEXP Xeps_,
- SEXP pind_, SEXP dind_, SEXP cind_, SEXP eind_,
- SEXP lpsi_, SEXP tdist_,
- SEXP N_, SEXP T_, SEXP J_,
- SEXP naflag_){
-
- //Inputs
- const vec beta = as<vec>(beta_);
- const vec y = as<vec>(y_);
- const vec delta = as<vec>(delta_);
- const vec naflag = as<vec>(naflag_);
- const mat W = as<mat>(W_);
- const mat V = as<mat>(V_);
- const vec pind = as<vec>(pind_);
- const vec dind = as<vec>(dind_);
- const std::string lpsi = as<std::string>(lpsi_);
- const std::string tdist = as<std::string>(tdist_);
-
- int N = as<int>(N_);
- int T = as<int>(T_);
- int J = as<int>(J_);
- int ys = y.size();
+// [[Rcpp::export]]
+double nll_occuTTD( arma::vec beta, arma::vec y, arma::vec delta,
+ arma::mat W, arma::mat V, arma::mat Xgam, arma::mat Xeps,
+ arma::vec pind, arma::vec dind, arma::vec cind, arma::vec eind,
+ std::string lpsi, std::string tdist,
+ int N, int T, int J,
+ arma::vec naflag){
- //Dynamic stuff
- const mat Xgam = as<mat>(Xgam_);
- const mat Xeps = as<mat>(Xeps_);
- const vec cind = as<vec>(cind_);
- const vec eind = as<vec>(eind_);
+ int ys = y.size();
//Get psi values
colvec raw_psi = W * beta.subvec(pind(0), pind(1));
@@ -131,6 +111,6 @@ SEXP nll_occuTTD( SEXP beta_, SEXP y_, SEXP delta_,
}
- return(wrap(-sum(log(lik))));
+ return -sum(log(lik));
}
diff --git a/src/nll_occuTTD.h b/src/nll_occuTTD.h
deleted file mode 100644
index 2991898..0000000
--- a/src/nll_occuTTD.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef _unmarked_NLL_OCCUTTD_H
-#define _unmarked_NLL_OCCUTTD_H
-
-#include <RcppArmadillo.h>
-
-RcppExport SEXP nll_occuTTD( SEXP beta_, SEXP y_, SEXP delta_,
- SEXP W_, SEXP V_, SEXP Xgam_, SEXP Xeps_,
- SEXP pind_, SEXP dind_, SEXP cind_, SEXP eind_,
- SEXP lpsi_, SEXP tdist_,
- SEXP N_, SEXP T_, SEXP J_,
- SEXP naflag_) ;
-
-#endif
diff --git a/src/nll_pcountOpen.cpp b/src/nll_pcountOpen.cpp
index 9d31e8e..235976c 100644
--- a/src/nll_pcountOpen.cpp
+++ b/src/nll_pcountOpen.cpp
@@ -1,44 +1,24 @@
-#include "nll_pcountOpen.h"
-#include "tranprobs.h"
+#include <RcppArmadillo.h>
+#include <float.h>
#include "distr.h"
+#include "tranprobs.h"
using namespace Rcpp ;
+// [[Rcpp::export]]
+double nll_pcountOpen(arma::imat ym, arma::mat Xlam, arma::mat Xgam, arma::mat Xom,
+ arma::mat Xp, arma::mat Xiota, arma::colvec beta_lam, arma::colvec beta_gam,
+ arma::colvec beta_om, arma::colvec beta_p, arma::colvec beta_iota,
+ double log_alpha, arma::colvec Xlam_offset, arma::colvec Xgam_offset,
+ arma::colvec Xom_offset, arma::colvec Xp_offset, arma::colvec Xiota_offset,
+ arma::imat ytna, arma::imat ynam, int lk, std::string mixture,
+ Rcpp::IntegerVector first, Rcpp::IntegerVector last, int M, int J, int T,
+ arma::imat delta, std::string dynamics, std::string fix, std::string go_dims,
+ bool immigration, arma::imat I, arma::imat I1, Rcpp::List Ib, Rcpp::List Ip) {
-SEXP nll_pcountOpen( SEXP y_, SEXP Xlam_, SEXP Xgam_, SEXP Xom_, SEXP Xp_, SEXP Xiota_, SEXP beta_lam_, SEXP beta_gam_, SEXP beta_om_, SEXP beta_p_, SEXP beta_iota_, SEXP log_alpha_, SEXP Xlam_offset_, SEXP Xgam_offset_, SEXP Xom_offset_, SEXP Xp_offset_, SEXP Xiota_offset_, SEXP ytna_, SEXP yna_, SEXP lk_, SEXP mixture_, SEXP first_, SEXP last_, SEXP M_, SEXP J_, SEXP T_, SEXP delta_, SEXP dynamics_, SEXP fix_, SEXP go_dims_, SEXP immigration_, SEXP I_, SEXP I1_, SEXP Ib_, SEXP Ip_) {
- int lk = as<int>(lk_);
Rcpp::IntegerVector N = seq_len(lk)-1;
- int M = as<int>(M_);
- int J = as<int>(J_);
- int T = as<int>(T_);
- arma::imat ym = as<arma::imat>(y_);
- arma::mat Xlam = as<arma::mat>(Xlam_);
- arma::mat Xgam = as<arma::mat>(Xgam_);
- arma::mat Xom = as<arma::mat>(Xom_);
- arma::mat Xp = as<arma::mat>(Xp_);
- arma::mat Xiota = as<arma::mat>(Xiota_);
- arma::colvec beta_lam = as<arma::colvec>(beta_lam_);
- arma::colvec beta_gam = as<arma::colvec>(beta_gam_);
- arma::colvec beta_om = as<arma::colvec>(beta_om_);
- arma::colvec beta_p = as<arma::colvec>(beta_p_);
- arma::colvec beta_iota = as<arma::colvec>(beta_iota_);
- double log_alpha = as<double>(log_alpha_);
- arma::colvec Xlam_offset = as<arma::colvec>(Xlam_offset_);
- arma::colvec Xgam_offset = as<arma::colvec>(Xgam_offset_);
- arma::colvec Xom_offset = as<arma::colvec>(Xom_offset_);
- arma::colvec Xp_offset = as<arma::colvec>(Xp_offset_);
- arma::colvec Xiota_offset = as<arma::colvec>(Xiota_offset_);
- std::string mixture = as<std::string>(mixture_);
- std::string dynamics = as<std::string>(dynamics_);
- std::string fix = as<std::string>(fix_);
- std::string go_dims = as<std::string>(go_dims_);
- bool immigration = as<bool>(immigration_);
- arma::imat I = as<arma::imat>(I_);
- arma::imat I1 = as<arma::imat>(I1_);
- Rcpp::List Ib(Ib_);
- Rcpp::List Ip(Ip_);
int nrI = I.n_rows;
int nrI1 = I1.n_rows;
double alpha=0.0, psi=0.0;
@@ -46,11 +26,7 @@ SEXP nll_pcountOpen( SEXP y_, SEXP Xlam_, SEXP Xgam_, SEXP Xom_, SEXP Xp_, SEXP
alpha = exp(log_alpha);
else if(mixture=="ZIP")
psi = 1.0/(1.0+exp(-log_alpha));
- Rcpp::IntegerVector first(first_);
- Rcpp::IntegerVector last(last_);
- arma::imat ytna = as<arma::imat>(ytna_); // y[i,,t] are all NA
- arma::imat ynam = as<arma::imat>(yna_); // y[i,j,t] is NA
- arma::imat delta = as<arma::imat>(delta_);
+
// linear predictors
arma::colvec lam = exp(Xlam*beta_lam + Xlam_offset);
arma::mat omv = arma::ones<arma::colvec>(M*(T-1));
@@ -232,5 +208,5 @@ SEXP nll_pcountOpen( SEXP y_, SEXP Xlam_, SEXP Xgam_, SEXP Xom_, SEXP Xp_, SEXP
}
ll += log(ll_i + DBL_MIN);
}
- return wrap(-ll);
+ return -ll;
}
diff --git a/src/nll_pcountOpen.h b/src/nll_pcountOpen.h
deleted file mode 100644
index 34549bc..0000000
--- a/src/nll_pcountOpen.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef _unmarked_NLL_PCOUNTOPEN_H
-#define _unmarked_NLL_PCOUNTOPEN_H
-
-#include "tranprobs.h"
-#include <float.h>
-
-RcppExport SEXP nll_pcountOpen( SEXP y_, SEXP Xlam_, SEXP Xgam_, SEXP Xom_, SEXP Xp_, SEXP Ximm_, SEXP beta_lam_, SEXP beta_gam_, SEXP beta_om_, SEXP beta_p_, SEXP beta_imm_, SEXP log_alpha_, SEXP Xlam_offset_, SEXP Xgam_offset_, SEXP Xom_offset_, SEXP Xp_offset_, SEXP Ximm_offset_, SEXP ytna_, SEXP yna_, SEXP lk_, SEXP mixture_, SEXP first_, SEXP last_, SEXP M_, SEXP J_, SEXP T_, SEXP delta_, SEXP dynamics_, SEXP fix_, SEXP go_dims_, SEXP immigration_, SEXP I_, SEXP I1_, SEXP Ib_, SEXP Ip_) ;
-
-
-#endif