Skip to content

Commit

Permalink
Update deprecated syntax for future rstan compatibility (#8)
Browse files Browse the repository at this point in the history
* Update deprecated syntax

* update unit tests + skip examples + bump version

---------

Co-authored-by: FBartos <[email protected]>
  • Loading branch information
andrjohns and FBartos authored Sep 20, 2023
1 parent cfeef39 commit d1159af
Show file tree
Hide file tree
Showing 27 changed files with 1,540 additions and 1,529 deletions.
8 changes: 4 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: RoBTT
Title: Robust Bayesian T-Test
Version: 1.2.0
Version: 1.2.1
Maintainer: František Bartoš <[email protected]>
Authors@R: c(
person("František", "Bartoš", role = c("aut", "cre"),
Expand Down Expand Up @@ -30,8 +30,8 @@ RoxygenNote: 7.2.3
NeedsCompilation: yes
ByteCompile: true
LinkingTo:
StanHeaders (>= 2.18.1),
rstan (>= 2.21.2),
StanHeaders (>= 2.26.0),
rstan (>= 2.26.0),
BH (>= 1.69.0),
Rcpp (>= 0.12.15),
RcppEigen (>= 0.3.3.4.0),
Expand All @@ -40,7 +40,7 @@ Depends:
R (>= 4.0.0),
Rcpp (>= 0.12.19)
Imports:
rstan(>= 2.21.2),
rstan(>= 2.26.0),
rstantools(>= 1.5.0),
RcppParallel (>= 5.0.1),
BayesTools (>= 0.2.15),
Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## version 1.2.1
Compatibility update for the rstan 2.26.

## version 1.2.0
### Changes
- when specifying prior distribution for the nu parameter, coerce Spike(Inf) to NULL
Expand Down
5 changes: 3 additions & 2 deletions R/main.R
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
#'
#' @return \code{RoBTT} returns an object of \link[base]{class} \code{"RoBTT"}.
#'
#' @examples
#' @examples \dontrun{
#' # using the example data from Darwin
#' data("fertilization", package = "RoBTT")
#' fit <- RoBTT(
Expand All @@ -87,7 +87,8 @@
#'
#' # summary can provide many details about the model
#' summary(fit)
#'
#' }
#'
#' @references
#' \insertAllCited{}
#' @export RoBTT
Expand Down
3 changes: 2 additions & 1 deletion R/plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#' x-label, y-label, title, x-axis range, and y-axis range
#' respectively.
#'
#' @examples
#' @examples \dontrun{
#' data("fertilization", package = "RoBTT")
#' fit <- RoBTT(
#' x1 = fertilization$Self,
Expand All @@ -52,6 +52,7 @@
#'
#' # plot prior and posterior of the conditional effect size estimate
#' plot(fit, parameter = "delta", conditional = TRUE, prior = TRUE)
#' }
#'
#' @return \code{plot.RoBTT} returns either \code{NULL} if \code{plot_type = "base"}
#' or an object object of class 'ggplot2' if \code{plot_type = "ggplot2"}.
Expand Down
4 changes: 2 additions & 2 deletions R/summary.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ print.RoBTT <- function(x, ...){
#' be omitted from the summary. Defaults to \code{FALSE}.
#' @param ... additional arguments
#'
#' @examples
#' @examples \dontrun{
#' # using the example data from Darwin
#' data("fertilization", package = "RoBTT")
#' fit <- RoBTT(
Expand Down Expand Up @@ -72,7 +72,7 @@ print.RoBTT <- function(x, ...){
#'
#' # summary of individual models and their parameters can be further obtained by
#' summary(fit, type = "individual")
#'
#' }
#'
#' @return \code{summary.RoBTT} returns a list of tables of class 'BayesTools_table'.
#'
Expand Down
1 change: 1 addition & 0 deletions R/utilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ assign("max_cores", parallel::detectCores(logical = TRUE) - 1, envir = Ro
"1.0.3" = c("0.2.12", "999.999.999"),
"1.1.0" = c("0.2.14", "999.999.999"),
"1.2.0" = c("0.2.15", "999.999.999"),
"1.2.1" = c("0.2.15", "999.999.999"),
stop("New RoBTT version needs to be defined in '.check_BayesTools' function!")
)

Expand Down
8 changes: 4 additions & 4 deletions inst/stan/beta.stan
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ data {
// range of the parameters
vector[is_d == 1 ? 2 : 0] bounds_d;
vector[is_r == 1 ? 2 : 0] bounds_r;
int bounds_type_d[is_d == 1 ? 2 : 0];
int bounds_type_r[is_r == 1 ? 2 : 0];
array[is_d == 1 ? 2 : 0] int bounds_type_d;
array[is_r == 1 ? 2 : 0] int bounds_type_r;

// prior distribution specification of the parameteres
vector[is_d == 0 ? 1 : 0] fixed_d;
Expand All @@ -35,8 +35,8 @@ data {
parameters{
real<lower = 0, upper = 1> mu;
real<lower = 0> sigma2;
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];
array[is_d] real<lower = coefs_lb(bounds_type_d, bounds_d), upper = coefs_ub(bounds_type_d, bounds_d)> delta;
array[is_r] real<lower = coefs_lb(bounds_type_r, bounds_r), upper = coefs_ub(bounds_type_r, bounds_r)> rho;
}
transformed parameters {
real pooled_sigma;
Expand Down
8 changes: 4 additions & 4 deletions inst/stan/gamma.stan
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ data {
// range of the parameters
vector[is_d == 1 ? 2 : 0] bounds_d;
vector[is_r == 1 ? 2 : 0] bounds_r;
int bounds_type_d[is_d == 1 ? 2 : 0];
int bounds_type_r[is_r == 1 ? 2 : 0];
array[is_d == 1 ? 2 : 0] int bounds_type_d;
array[is_r == 1 ? 2 : 0] int bounds_type_r;

// prior distribution specification of the parameteres
vector[is_d == 0 ? 1 : 0] fixed_d;
Expand All @@ -35,8 +35,8 @@ data {
parameters{
real<lower = 0> mu;
real<lower = 0> sigma2;
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];
array[is_d] real<lower = coefs_lb(bounds_type_d, bounds_d), upper = coefs_ub(bounds_type_d, bounds_d)> delta;
array[is_r] real<lower = coefs_lb(bounds_type_r, bounds_r), upper = coefs_ub(bounds_type_r, bounds_r)> rho;
}
transformed parameters {
real pooled_sigma;
Expand Down
6 changes: 3 additions & 3 deletions inst/stan/include/common_functions.stan
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ functions {
}

// function for setting parameter bounds
real coefs_lb(int[] type_in, vector bound_in) {
real coefs_lb(array[] int type_in, vector bound_in) {
int type;
real bound;
real lb;
Expand All @@ -30,7 +30,7 @@ functions {
lb = bound;
return lb;
}
real coefs_ub(int[] type_in, vector bound_in) {
real coefs_ub(array[] int type_in, vector bound_in) {
int type;
real bound;
real lb;
Expand All @@ -56,7 +56,7 @@ functions {
// type 6 = inverse-gamma
// type 7 = uniform
// type 8 = beta
real set_prior(real parameter, int prior_type, vector prior_parameters, int[] bounds_type, vector bounds){
real set_prior(real parameter, int prior_type, vector prior_parameters, array[] int bounds_type, vector bounds){
real ll;

if(prior_type == 1){
Expand Down
8 changes: 4 additions & 4 deletions inst/stan/lognormal.stan
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ data {
// range of the parameters
vector[is_d == 1 ? 2 : 0] bounds_d;
vector[is_r == 1 ? 2 : 0] bounds_r;
int bounds_type_d[is_d == 1 ? 2 : 0];
int bounds_type_r[is_r == 1 ? 2 : 0];
array[is_d == 1 ? 2 : 0] int bounds_type_d;
array[is_r == 1 ? 2 : 0] int bounds_type_r;

// prior distribution specification of the parameteres
vector[is_d == 0 ? 1 : 0] fixed_d;
Expand All @@ -35,8 +35,8 @@ data {
parameters{
real<lower = 0> mu;
real<lower = 0> sigma2;
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];
array[is_d] real<lower = coefs_lb(bounds_type_d, bounds_d), upper = coefs_ub(bounds_type_d, bounds_d)> delta;
array[is_r] real<lower = coefs_lb(bounds_type_r, bounds_r), upper = coefs_ub(bounds_type_r, bounds_r)> rho;
}
transformed parameters {
real pooled_sigma;
Expand Down
8 changes: 4 additions & 4 deletions inst/stan/normal.stan
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ data {
// range of the parameters
vector[is_d == 1 ? 2 : 0] bounds_d;
vector[is_r == 1 ? 2 : 0] bounds_r;
int bounds_type_d[is_d == 1 ? 2 : 0];
int bounds_type_r[is_r == 1 ? 2 : 0];
array[is_d == 1 ? 2 : 0] int bounds_type_d;
array[is_r == 1 ? 2 : 0] int bounds_type_r;

// prior distribution specification of the parameteres
vector[is_d == 0 ? 1 : 0] fixed_d;
Expand All @@ -35,8 +35,8 @@ data {
parameters{
real mu;
real<lower = 0> sigma2;
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];
array[is_d] real<lower = coefs_lb(bounds_type_d, bounds_d), upper = coefs_ub(bounds_type_d, bounds_d)> delta;
array[is_r] real<lower = coefs_lb(bounds_type_r, bounds_r), upper = coefs_ub(bounds_type_r, bounds_r)> rho;
}
transformed parameters {
real pooled_sigma;
Expand Down
24 changes: 12 additions & 12 deletions inst/stan/t.stan
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ data {
vector[is_d == 1 ? 2 : 0] bounds_d;
vector[is_r == 1 ? 2 : 0] bounds_r;
vector[is_nu == 1 ? 2 : 0] bounds_nu;
int bounds_type_d[is_d == 1 ? 2 : 0];
int bounds_type_r[is_r == 1 ? 2 : 0];
int bounds_type_nu[is_nu == 1 ? 2 : 0];
array[is_d == 1 ? 2 : 0] int bounds_type_d;
array[is_r == 1 ? 2 : 0] int bounds_type_r;
array[is_nu == 1 ? 2 : 0] int bounds_type_nu;

// prior distribution specification of the parameteres
real fixed_d[is_d == 0 ? 1 : 0];
real fixed_r[is_r == 0 ? 1 : 0];
real fixed_nu[is_nu == 0 ? 1 : 0];
array[is_d == 0 ? 1 : 0] real fixed_d;
array[is_r == 0 ? 1 : 0] real fixed_r;
array[is_nu == 0 ? 1 : 0] real fixed_nu;
vector[is_d == 1 ? 3 : 0] prior_parameters_d;
vector[is_r == 1 ? 3 : 0] prior_parameters_r;
vector[is_nu == 1 ? 3 : 0] prior_parameters_nu;
Expand All @@ -41,15 +41,15 @@ data {
parameters{
real mu;
real<lower = 0> sigma2;
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];
array[is_d] real<lower = coefs_lb(bounds_type_d, bounds_d), upper = coefs_ub(bounds_type_d, bounds_d)> delta;
array[is_r] real<lower = coefs_lb(bounds_type_r, bounds_r), upper = coefs_ub(bounds_type_r, bounds_r)> rho;
array[is_nu] real<lower = coefs_lb(bounds_type_nu, bounds_nu), upper = coefs_ub(bounds_type_nu, bounds_nu)> nu_p;
}
transformed parameters {
real pooled_sigma;
real sigma_i[2];
real scale_i[2];
real mu_i[2];
array[2] real sigma_i;
array[2] real scale_i;
array[2] real mu_i;
real nu;


Expand Down
2 changes: 2 additions & 0 deletions man/RoBTT.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions man/plot.RoBTT.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion man/summary.RoBTT.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d1159af

Please sign in to comment.