Skip to content

Commit

Permalink
Future (future) RStan Compatibility (#4)
Browse files Browse the repository at this point in the history
* Update bounds code for 2.31 compat

* Syntax backwards compat with 2.21

* version bump

---------

Co-authored-by: FBartos <f.bartos96@gmail.com>
  • Loading branch information
andrjohns and FBartos authored Mar 30, 2023
1 parent 506aa6a commit c77c563
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 15 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: RoBTT
Title: Robust Bayesian T-Test
Version: 1.0.1
Version: 1.0.3
Maintainer: František Bartoš <f.bartos96@gmail.com>
Authors@R: c(
person("František", "Bartoš", role = c("aut", "cre"),
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
## version 1.0.3
Compatibility update for the rstan 2.31.
(correct CRAN commit)

## version 1.0.1
Compatibility update for the rstan 2.26.
2 changes: 2 additions & 0 deletions R/utilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ assign("max_cores", parallel::detectCores(logical = TRUE) - 1, envir = Ro
paste0(RoBTT.version, collapse = "."),
"1.0.0" = c("0.2.12", "999.999.999"),
"1.0.1" = c("0.2.12", "999.999.999"),
"1.0.2" = c("0.2.12", "999.999.999"),
"1.0.3" = c("0.2.12", "999.999.999"),
stop("New RoBTT version needs to be defined in '.check_BayesTools' function!")
)

Expand Down
4 changes: 2 additions & 2 deletions inst/stan/beta.stan
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ data {
parameters{
real<lower = 0, upper = 1> mu;
real<lower = 0> sigma2;
real<lower = coefs_lb(bounds_type_d[1], bounds_d[1]), upper = coefs_ub(bounds_type_d[2], bounds_d[2])> delta[is_d];
real<lower = coefs_lb(bounds_type_r[1], bounds_r[1]), upper = coefs_ub(bounds_type_r[2], bounds_r[2])> rho[is_r];
real<lower = coefs_lb(bounds_type_d, bounds_d), upper = coefs_ub(bounds_type_d, bounds_d)> delta[is_d];
real<lower = coefs_lb(bounds_type_r, bounds_r), upper = coefs_ub(bounds_type_r, bounds_r)> rho[is_r];
}
transformed parameters {
real pooled_sigma;
Expand Down
4 changes: 2 additions & 2 deletions inst/stan/gamma.stan
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ data {
parameters{
real<lower = 0> mu;
real<lower = 0> sigma2;
real<lower = coefs_lb(bounds_type_d[1], bounds_d[1]), upper = coefs_ub(bounds_type_d[2], bounds_d[2])> delta[is_d];
real<lower = coefs_lb(bounds_type_r[1], bounds_r[1]), upper = coefs_ub(bounds_type_r[2], bounds_r[2])> rho[is_r];
real<lower = coefs_lb(bounds_type_d, bounds_d), upper = coefs_ub(bounds_type_d, bounds_d)> delta[is_d];
real<lower = coefs_lb(bounds_type_r, bounds_r), upper = coefs_ub(bounds_type_r, bounds_r)> rho[is_r];
}
transformed parameters {
real pooled_sigma;
Expand Down
22 changes: 19 additions & 3 deletions inst/stan/include/common_functions.stan
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
functions {

// default Jeffrey priors for sigma and mu
real Jeffreys_mu_lpdf(real mu){
return 0;
Expand All @@ -14,16 +14,32 @@ functions {
}

// function for setting parameter bounds
real coefs_lb(int type, real bound) {
real coefs_lb(int[] type_in, vector bound_in) {
int type;
real bound;
real lb;
if (num_elements(type_in) == 0) {
return negative_infinity();
} else {
type = type_in[1];
bound = bound_in[1];
}
if (type == 0)
lb = negative_infinity();
else
lb = bound;
return lb;
}
real coefs_ub(int type, real bound) {
real coefs_ub(int[] type_in, vector bound_in) {
int type;
real bound;
real lb;
if (num_elements(type_in) == 0) {
return positive_infinity();
} else {
type = type_in[2];
bound = bound_in[2];
}
if (type == 0)
lb = positive_infinity();
else
Expand Down
4 changes: 2 additions & 2 deletions inst/stan/lognormal.stan
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ data {
parameters{
real<lower = 0> mu;
real<lower = 0> sigma2;
real<lower = coefs_lb(bounds_type_d[1], bounds_d[1]), upper = coefs_ub(bounds_type_d[2], bounds_d[2])> delta[is_d];
real<lower = coefs_lb(bounds_type_r[1], bounds_r[1]), upper = coefs_ub(bounds_type_r[2], bounds_r[2])> rho[is_r];
real<lower = coefs_lb(bounds_type_d, bounds_d), upper = coefs_ub(bounds_type_d, bounds_d)> delta[is_d];
real<lower = coefs_lb(bounds_type_r, bounds_r), upper = coefs_ub(bounds_type_r, bounds_r)> rho[is_r];
}
transformed parameters {
real pooled_sigma;
Expand Down
4 changes: 2 additions & 2 deletions inst/stan/normal.stan
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ data {
parameters{
real mu;
real<lower = 0> sigma2;
real<lower = coefs_lb(bounds_type_d[1], bounds_d[1]), upper = coefs_ub(bounds_type_d[2], bounds_d[2])> delta[is_d];
real<lower = coefs_lb(bounds_type_r[1], bounds_r[1]), upper = coefs_ub(bounds_type_r[2], bounds_r[2])> rho[is_r];
real<lower = coefs_lb(bounds_type_d, bounds_d), upper = coefs_ub(bounds_type_d, bounds_d)> delta[is_d];
real<lower = coefs_lb(bounds_type_r, bounds_r), upper = coefs_ub(bounds_type_r, bounds_r)> rho[is_r];
}
transformed parameters {
real pooled_sigma;
Expand Down
6 changes: 3 additions & 3 deletions inst/stan/t.stan
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ data {
parameters{
real mu;
real<lower = 0> sigma2;
real<lower = coefs_lb(bounds_type_d[1], bounds_d[1]), upper = coefs_ub(bounds_type_d[2], bounds_d[2])> delta[is_d];
real<lower = coefs_lb(bounds_type_r[1], bounds_r[1]), upper = coefs_ub(bounds_type_r[2], bounds_r[2])> rho[is_r];
real<lower = coefs_lb(bounds_type_nu[1], bounds_nu[1]), upper = coefs_ub(bounds_type_nu[2], bounds_nu[2])> nu_p[is_nu];
real<lower = coefs_lb(bounds_type_d, bounds_d), upper = coefs_ub(bounds_type_d, bounds_d)> delta[is_d];
real<lower = coefs_lb(bounds_type_r, bounds_r), upper = coefs_ub(bounds_type_r, bounds_r)> rho[is_r];
real<lower = coefs_lb(bounds_type_nu, bounds_nu), upper = coefs_ub(bounds_type_nu, bounds_nu)> nu_p[is_nu];
}
transformed parameters {
real pooled_sigma;
Expand Down

0 comments on commit c77c563

Please sign in to comment.