Change shape parameters in a beta distribution based in each datapoint I am new to Bayesian statistics and I have been trying to implement a Beta Binomial model from a PhD thesis in rjags. The thesis describes prior distribution for the variables but I am stuck in how to implement the following part of the model:
$p_{j k} \mid \alpha_{j k}, F_{k} \sim \begin{cases}\operatorname{Beta}\left(\alpha_{j k}\left(1-F_{k}\right) / F_{k},\left(1-\alpha_{j k}\right)\left(1-F_{k}\right) / F_{k}),\right. & \text { if } G_{j k}=0 \\ \text {Uniform }[0,1], & \text { if } G_{j k}=1\end{cases}$
Depending on the value of $p_{j k}$ (an observed variable), we assume either a Beta or a Uniform distribution: if the value falls within a standard deviation from the mean we consider that it was drawn from the above Beta, otherwise we consider it an Uniform-drawn value. I reckon that the Uniform is a special case of Beta distribution, so I guess the key is to code JAGS to test the fit of each value of $p_{j k}$ to the Beta and then change the shape parameters to (1,1) if the input value falls outside that range ($G_{j k}$ is actually indicating the result of this test, with 0 signing success).
In short, I would like to add an if statement before the prior distribution of $p_{j k}$, if that is possible, or something equivalent, and then change the Beta shape parameters accordingly. I could not find a solution in JAGS manual or anywhere else, any help is welcomed.
Edit
So far, I could think of the likelihoods as follows (I've set alpha to 1, Fk to 0.5 and sum 1 to parameter beta when $p_{j k}$ is beyond alpha$\pm$SD the so that I can get a Beta(1,1), that is, a Uniform(0,1)). But I am not sure this translates to the model and if will work properly in JAGS.
    library("rjags")
    
    set.seed(8361289)
    model_string = "model { 
   for (j in 1:length(SNP)) {   #iterate though SNPs
      alpha[j] <- ifelse(Padmix[j]>alpha[j]+(alpha[j]*Fk[j]*(1-alpha[i])), 1, alpha[j])
      alpha[j] <- ifelse(Padmix[j]<alpha[j]-(alpha[j]*Fk[j]*(1-alpha[i])), 1, alpha[j])
      Fk <- ifelse(Padmix[j]>alpha[j]+(alpha[j]*Fk[j]*(1-alpha[i])), 0.5, Fk[j])
      Fk <- ifelse(Padmix[j]<alpha[j]-(alpha[j]*Fk[j]*(1-alpha[i])), 0.5, Fk[j])
      G[j] <- ifelse(Padmix[j]>alpha[j]+(alpha[j]*Fk[j]*(1-alpha[i])), 1, 0)
      G[j] <- ifelse(Padmix[j]<alpha[j]-(alpha[j]*Fk[j]*(1-alpha[i])), 1, 0)
      Padmix[j] ~ dbeta(alpha[j]*(1-Fk[j])/Fk[j], (1-alpha[j])*(1-Fk[j])/(Fk[j])+G[j]) # beta for allele frequency in admixed pop
      Xadmix[j] ~ dbin(Padmix[j], Nadmix[j]) # draw allele count from a bin with p=allele frequency (Padmix) and n=nonmiss alleles (Nadmix)
      Pdonor[j] ~ dbeta(x[donor[j]]+1, n[donor[j]]-x[donor[j]]+1)
      alpha[j] = sum(beta[donor[j]] * Pdonor[donor[j]])
          
        }
      Fk[j] ~ dbeta(1, 500)
      G[j] ~ dbern(0.001) 
      
      for (d in 1:max(donor)) {
          beta[d] = anc_prop[d]
       }
      Padmix = MAF
      Nadmix = nonmiss_admix
      x = allele_count_donor
      n = nonmiss_donor
      
    }"

Detailed model description (in: Detecting signals of selection in the genomes of Native Americans and admixed Latin Americans. Mendoza-Revilla, 2018):



To simplify the distributional expression, define the quantities:
$$\begin{align}
R_k 
&\equiv \frac{1-F_k}{F_k} \\[18pt]
A_{jk} 
&\equiv \begin{cases}
\alpha_{j k} R_k & & & & & \ \ \text { if } G_{j k} = 0 \\[6pt]
1 & & & & & \ \ \text { if } G_{j k} = 1 \\[6pt]
\end{cases} \\[18pt]
B_{jk} 
&\equiv \begin{cases}
\alpha_{j k} (1- R_k) & & & \text { if } G_{j k} = 0 \\[6pt]
1 & & & \text { if } G_{j k} = 1 \\[6pt]
\end{cases}
\end{align}$$
You then have:
$$p_{j k} \mid \alpha_{j k}, F_{k} \sim \text{Beta}(A_{jk}, B_{jk}).$$
This form allows you to state the conditional distribution in a simple form based on previously stipulated parameters.  It should be simple to implement this in JAGS.
