aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKen Kellner <ken@kenkellner.com>2022-11-02 11:11:33 -0400
committerKen Kellner <ken@kenkellner.com>2022-11-02 11:11:33 -0400
commit5847d0fa1734b1206a3a5bb1acffbceeaa159452 (patch)
tree17c7adef6b79ee7b7b770b9c1019857cd5b8608d
parentcfaa7345c60b9063650bd5f3c6b00c4f991d6699 (diff)
Change log_lik default and fix some compiler warnings
-rw-r--r--DESCRIPTION4
-rw-r--r--R/colext.R2
-rw-r--r--R/multinomPois.R2
-rw-r--r--R/occu.R2
-rw-r--r--R/occuRN.R2
-rw-r--r--R/occuTTD.R2
-rw-r--r--R/pcount.R2
-rw-r--r--src/Makevars7
-rw-r--r--src/exp_counts_occu.cpp2
-rw-r--r--src/loglik.cpp1
-rw-r--r--tests/testthat/test_occu.R6
-rw-r--r--tests/testthat/test_ubmsFit_methods.R6
12 files changed, 21 insertions, 17 deletions
diff --git a/DESCRIPTION b/DESCRIPTION
index f586af0..7dc6c71 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,6 +1,6 @@
Package: ubms
-Version: 1.1.9006
-Date: 2022-09-20
+Version: 1.1.9007
+Date: 2022-11-02
Title: Bayesian Models for Data from Unmarked Animals using 'Stan'
Authors@R: person("Ken", "Kellner", email="contact@kenkellner.com",
role=c("cre","aut"))
diff --git a/R/colext.R b/R/colext.R
index 40cea5b..f2c97a5 100644
--- a/R/colext.R
+++ b/R/colext.R
@@ -63,7 +63,7 @@ stan_colext <- function(psiformula = ~1,
prior_intercept_det = logistic(0, 1),
prior_coef_det = logistic(0, 1),
prior_sigma = gamma(1, 1),
- log_lik = FALSE,
+ log_lik = TRUE,
...){
umf <- process_umf(data)
diff --git a/R/multinomPois.R b/R/multinomPois.R
index 88618d3..9b99f39 100644
--- a/R/multinomPois.R
+++ b/R/multinomPois.R
@@ -42,7 +42,7 @@ stan_multinomPois <- function(formula,
prior_intercept_det = logistic(0, 1),
prior_coef_det = logistic(0, 1),
prior_sigma = gamma(1, 1),
- log_lik = FALSE,
+ log_lik = TRUE,
...){
forms <- split_formula(formula)
diff --git a/R/occu.R b/R/occu.R
index 8f1e47b..3def23a 100644
--- a/R/occu.R
+++ b/R/occu.R
@@ -49,7 +49,7 @@ stan_occu <- function(formula,
prior_intercept_det = logistic(0, 1),
prior_coef_det = logistic(0, 1),
prior_sigma = gamma(1, 1),
- log_lik = FALSE,
+ log_lik = TRUE,
...){
forms <- split_formula(formula)
diff --git a/R/occuRN.R b/R/occuRN.R
index 77c8e47..9e10f09 100644
--- a/R/occuRN.R
+++ b/R/occuRN.R
@@ -50,7 +50,7 @@ stan_occuRN <- function(formula,
prior_intercept_det = logistic(0, 1),
prior_coef_det = logistic(0, 1),
prior_sigma = gamma(1, 1),
- log_lik = FALSE,
+ log_lik = TRUE,
...){
forms <- split_formula(formula)
diff --git a/R/occuTTD.R b/R/occuTTD.R
index 83aef23..9eff184 100644
--- a/R/occuTTD.R
+++ b/R/occuTTD.R
@@ -91,7 +91,7 @@ stan_occuTTD <- function(psiformula=~1,
prior_coef_det = normal(0, 2.5),
prior_intercept_shape = normal(0,2.5),
prior_sigma = gamma(1, 1),
- log_lik = FALSE,
+ log_lik = TRUE,
...){
if(data@numPrimary > 1) stop("Dynamic models not yet supported", call.=FALSE)
diff --git a/R/pcount.R b/R/pcount.R
index c44abfa..fca62c8 100644
--- a/R/pcount.R
+++ b/R/pcount.R
@@ -50,7 +50,7 @@ stan_pcount <- function(formula,
prior_intercept_det = logistic(0, 1),
prior_coef_det = logistic(0, 1),
prior_sigma = gamma(1, 1),
- log_lik = FALSE,
+ log_lik = TRUE,
...){
forms <- split_formula(formula)
diff --git a/src/Makevars b/src/Makevars
index a9f7369..8b94986 100644
--- a/src/Makevars
+++ b/src/Makevars
@@ -1,10 +1,17 @@
STANHEADERS_SRC = $(shell "$(R_HOME)/bin$(R_ARCH_BIN)/Rscript" -e "message()" -e "cat(system.file('include', 'src', package = 'StanHeaders', mustWork = TRUE))" -e "message()" | grep "StanHeaders")
STANC_FLAGS = $(shell "$(R_HOME)/bin$(R_ARCH_BIN)/Rscript" -e "cat(ifelse(utils::packageVersion('rstan') >= 2.26, '-DUSE_STANC3',''))")
+
+# COMMENT THIS OUT WHEN TESTING CLANG
PKG_CPPFLAGS = -I"../inst/include" -I"$(STANHEADERS_SRC)" -DBOOST_DISABLE_ASSERTS -DEIGEN_NO_DEBUG -DBOOST_MATH_OVERFLOW_ERROR_POLICY=errno_on_error $(STANC_FLAGS)
+
+# UNCOMMENT THIS WHEN TESTING CLANG
+#PKG_CPPFLAGS = -I"../inst/include" -isystem"$(STANHEADERS_SRC)" -DBOOST_DISABLE_ASSERTS -DEIGEN_NO_DEBUG -DBOOST_MATH_OVERFLOW_ERROR_POLICY=errno_on_error $(STANC_FLAGS)
+
PKG_CXXFLAGS = $(shell "$(R_HOME)/bin$(R_ARCH_BIN)/Rscript" -e "RcppParallel::CxxFlags()") $(shell "$(R_HOME)/bin$(R_ARCH_BIN)/Rscript" -e "StanHeaders:::CxxFlags()")
PKG_LIBS = $(shell "$(R_HOME)/bin$(R_ARCH_BIN)/Rscript" -e "RcppParallel::RcppParallelLibs()") $(shell "$(R_HOME)/bin$(R_ARCH_BIN)/Rscript" -e "StanHeaders:::LdFlags()")
+# COMMENT THIS OUT WHEN TESTING CLANG COMPILER
CXX_STD = CXX14
diff --git a/src/exp_counts_occu.cpp b/src/exp_counts_occu.cpp
index a79df67..fc37099 100644
--- a/src/exp_counts_occu.cpp
+++ b/src/exp_counts_occu.cpp
@@ -28,7 +28,6 @@ arma::vec exp_counts_occu(arma::mat obs, arma::ivec no_detects,
int n_eh = obs.n_cols;
vec counts_expect = zeros(n_eh);
- int idx = 0;
int pstart, pend;
for (int i=0; i < n_eh; i++){
pstart = 0;
@@ -73,7 +72,6 @@ arma::vec exp_counts_occuRN(arma::mat obs, arma::ivec Kmin,
int n_eh = obs.n_cols;
vec counts_expect = zeros(n_eh);
- int idx = 0;
int pstart, pend;
for (int i=0; i < n_eh; i++){
pstart = 0;
diff --git a/src/loglik.cpp b/src/loglik.cpp
index 78a97b9..4c92f93 100644
--- a/src/loglik.cpp
+++ b/src/loglik.cpp
@@ -317,7 +317,6 @@ arma::mat get_loglik_occuTTD(arma::vec y, int M, arma::imat si, arma::mat psimat
mat out(S,M);
vec lam_s(lammat.n_rows);
vec e_lamt;
- int J;
vec y_m, lam_m;
ivec delta_m;
double lik;
diff --git a/tests/testthat/test_occu.R b/tests/testthat/test_occu.R
index 29b0c9f..558c2f7 100644
--- a/tests/testthat/test_occu.R
+++ b/tests/testthat/test_occu.R
@@ -95,11 +95,11 @@ test_that("log_lik argument controls saving log_lik parameter", {
iter=100, refresh=0))
set.seed(123)
fit2 <- suppressWarnings(stan_occu(~x2~x1, umf[1:10,], chains=2,
- iter=100, refresh=0, log_lik=TRUE))
+ iter=100, refresh=0, log_lik=FALSE))
expect_equal(fit@loo$estimates, fit2@loo$estimates)
- expect_false("log_lik" %in% fit@stanfit@sim$pars_oi)
- expect_true("log_lik" %in% fit2@stanfit@sim$pars_oi)
+ expect_true("log_lik" %in% fit@stanfit@sim$pars_oi)
+ expect_false("log_lik" %in% fit2@stanfit@sim$pars_oi)
})
diff --git a/tests/testthat/test_ubmsFit_methods.R b/tests/testthat/test_ubmsFit_methods.R
index 8a66f87..3237ce2 100644
--- a/tests/testthat/test_ubmsFit_methods.R
+++ b/tests/testthat/test_ubmsFit_methods.R
@@ -88,7 +88,7 @@ test_that("extract method works for ubmsFit",{
ex_all <- extract(fit)
expect_is(ex_all, "list")
expect_equal(names(ex_all), c("beta_state","b_state","sigma_state",
- "beta_det","lp__"))
+ "beta_det","log_lik","lp__"))
})
test_that("traceplot method works for ubmsFit",{
@@ -172,13 +172,13 @@ test_that("rebuild_inputs can get Stan inputs from fitted model",{
test_that("calculate_par works",{
inps <- rebuild_inputs(fit)
cp <- calculate_par(fit, inps, 'state')
- expect_equal(dim(cp), c(3,40))
+ expect_equal(dim(cp), c(3,40))
cp_mean <- apply(cp, 1, mean)
pr <- predict(fit, 'state')
expect_equivalent(cp_mean, pr$Predicted)
})
-test_that("extract_posterior works",{
+test_that("extract_posterior works",{
post <- extract_posterior(fit, 'beta_state')
expect_is(post, "matrix")
expect_equal(dim(post), c(40, 2))