You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Something seems broken when having custom families with more than one additional variables. From the second onward, the variable name is copied in the call to the density function in the model block.
A short minimal reprex based on the example in ?custom_family to which we add the second variable foo which becomes foofoo in the code.
library("brms")
## Not run: ## demonstrate how to fit a beta-binomial model## generate some fake dataphi<-0.7n<-300z<- rnorm(n, sd=0.2)
ntrials<- sample(1:10, n, replace=TRUE)
eta<-1+zmu<- exp(eta) / (1+ exp(eta))
a<-mu*phib<- (1-mu) *phip<- rbeta(n, a, b)
y<- rbinom(n, ntrials, p)
dat<-data.frame(y, z, ntrials)
beta_binomial2<- custom_family(
"beta_binomial2", dpars= c("mu", "phi"),
links= c("logit", "log"), lb= c(NA, 0),
type="int", vars= c("trials[n]", "foo")
)
# define the corresponding Stan density functionstan_funs<-" real beta_binomial2_lpmf(int y, real mu, real phi, int N, real foo) { return beta_binomial_lpmf(y | N, mu * phi, (1 - mu) * phi); }"svars<- stanvar(scode=stan_funs, block="functions")
make_stancode(y| trials(ntrials) ~z, data=dat,
family=beta_binomial2, stanvars=svars)
This produces (only relevant part):
for (n in 1:N) {
target += beta_binomial2_lpmf(Y[n] | mu[n], phi, trials[n], foofoo);
}
As can be seen, instead of foo we get foofoo.
The text was updated successfully, but these errors were encountered:
Something seems broken when having custom families with more than one additional variables. From the second onward, the variable name is copied in the call to the density function in the
model
block.A short minimal reprex based on the example in
?custom_family
to which we add the second variablefoo
which becomesfoofoo
in the code.This produces (only relevant part):
As can be seen, instead of
foo
we getfoofoo
.The text was updated successfully, but these errors were encountered: