In a fixed power prior model, the model is set up as:
Suppose that the event follows a Bernoulli distribution with probability p_i, what I want is to raise the Bernoulli likelihood to the power of w in jags:
mod1<-function(){
for(i in 1 : N) {
y[i] ~ dbern(p[i])^w #<-------------------
logit(p[i]) <- a[group[i]] + t[group[i]]*d[i]
}
for (j in 1:3) {
a[j] ~ dnorm(mu.a, pow(sd.a,-2))
t[j] ~ dnorm(mu.t, pow(sd.t,-2))
}
mu.a~dnorm(0,0.01)
mu.t~dnorm(0,0.01)
sd.a ~ dunif(0,10)
sd.t ~ dunif(0,10)
}
However JAGS does not recognize such code.
As an alternative, I wrote the following STAN code:
mod1 <- '
data {
int<lower = 1> N;
real w;
int y[N];
vector[N] d;
int group[N];
}
parameters {
vector[3] a;
vector<lower=0>[3] t;
real mua;
real mut;
real sigmaa;
real sigmat;
}
model {
real p[N];
//prior
mua~normal(0,10);
mut~normal(0,10);
sigmaa ~ uniform(0,10);
sigmat ~ uniform(0,10);
for (j in 1:3) {
a[j] ~ normal(mua, sigmaa);
t[j] ~ normal(mut, sigmat);
}
//likelihood
for (i in 1:N) {
p[i]=inv_logit(a[group[i]] + t[group[i]]*d[i]);
target += bernoulli_lpmf(y[i]|(p[i]))*w;
}
}
'
which works, but I'd like to use JAGS (R2jags) for this project and was wondering if there is a JAGS equivalent for the above STAN code. THanks!
Here is the sample data if you want to test the code:
y <- rbinom(160, 1, 0.3)
d <- runif(160, 0, 41)
group <- sample(1:3, 160, replace = TRUE)
w <- rep(0.5, 160)
N=160
mydata <- data.frame(y, d, group, x4,N)

I would have thought that using the ones or zeros trick would do the trick. Here's an example with the zeros trick:
Jags Model:
Stan Model
Generate Data
Run Models
Model Summaries
Created on 2023-03-28 with reprex v2.0.2
The models look pretty comparable. Note, that I took the
<lower=0>constraint away fromtjust to make the JAGS and Stan models look otherwise equivalent. The results look pretty comparable. I also generated unequal weights.