From 04393391f3b2fb7c2923b9eccded8bc1d7accdac Mon Sep 17 00:00:00 2001 From: Ven Popov Date: Sat, 23 Mar 2024 04:05:55 +0100 Subject: [PATCH] change default prior for von_mises mu tan_half link --- R/family-lists.R | 9 ++++++++- tests/testthat/tests.stancode.R | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/R/family-lists.R b/R/family-lists.R index 3ae17dd4f..1ad1d6150 100644 --- a/R/family-lists.R +++ b/R/family-lists.R @@ -350,7 +350,14 @@ ybounds = c(-pi, pi), closed = c(TRUE, TRUE), ad = c("weights", "subset", "cens", "trunc", "mi", "index"), include = c("fun_tan_half.stan", "fun_von_mises.stan"), - normalized = "" + normalized = "", + # experimental use of default priors stored in families #1614 + prior = function(dpar, link = "identity", ...) { + if (dpar == "mu" && link == "tan_half") { + return("student_t(1, 0, 1)") + } + NULL + } ) } diff --git a/tests/testthat/tests.stancode.R b/tests/testthat/tests.stancode.R index f4cf0e3cd..4c8a2e978 100644 --- a/tests/testthat/tests.stancode.R +++ b/tests/testthat/tests.stancode.R @@ -113,6 +113,8 @@ test_that("specified priors appear in the Stan code", { # tests use of default priors stored in families #1614 scode <- stancode(y ~ x1, dat, family = negbinomial()) expect_match2(scode, "lprior += inv_gamma_lpdf(shape | 0.4, 0.3);") + scode <- stancode(y ~ x2, dat, family = von_mises()) + expect_match2(scode, "lprior += student_t_lpdf(Intercept | 1, 0, 1);") prior <- prior(gamma(0, 1), coef = x1) expect_warning(stancode(y ~ x1, dat, prior = prior),