Skip to content

Commit

Permalink
use zero as lower boundary for cosy correlations again (#878)
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-buerkner committed Apr 18, 2020
1 parent 8f08748 commit 6f91dd5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
1 change: 0 additions & 1 deletion NEWS.md
Expand Up @@ -11,7 +11,6 @@ Marta Kołczyńska.
`mm` for easy specification of group-level correlation structures.
* Improve workflow to feed back brms-created models which were
fitted somewhere else back into brms. (#745)
* Allow `cosy` correlations to be negative. (#878)

### Bug Fixes

Expand Down
13 changes: 7 additions & 6 deletions R/stan-predictor.R
Expand Up @@ -1202,14 +1202,15 @@ stan_ac <- function(bterms, data, prior, ...) {
if (NROW(acef_cosy)) {
# compound symmetry correlation structure
# most code is shared with ARMA covariance models
# cosy correlations may be negative (#878)
str_add(out$tdata_def) <- glue(
" real lb_cosy{p} = -1.0 / (max(nobs_tg{p}) - 1);",
" // lower bound of the cosy correlation\n"
)
# cosy correlations may be negative in theory but
# this causes problems divergent transitions (#878)
# str_add(out$tdata_def) <- glue(
# " real lb_cosy{p} = -1.0 / (max(nobs_tg{p}) - 1);",
# " // lower bound of the cosy correlation\n"
# )
str_add_list(out) <- stan_prior(
prior, class = "cosy", px = px, suffix = p,
type = glue("real<lower=lb_cosy{p},upper=1>"),
type = glue("real<lower=0,upper=1>"),
comment = "compound symmetry correlation"
)
}
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/tests.make_stancode.R
Expand Up @@ -690,7 +690,7 @@ test_that("Stan code for compound symmetry models is correct", {
y ~ x + cosy(time), dat,
prior = prior(normal(0, 2), cosy)
)
expect_match2(scode, "real<lower=lb_cosy,upper=1> cosy;")
expect_match2(scode, "real<lower=0,upper=1> cosy;")
expect_match2(scode, "chol_cor = cholesky_cor_cosy(cosy, max_nobs_tg);")
expect_match2(scode, "target += normal_lpdf(cosy | 0, 2);")

Expand Down

0 comments on commit 6f91dd5

Please sign in to comment.