model
    {

    for ( i in 1:N ) {
      y[i]~dnorm(param[i],Tau[i])
      t[i]~dbern(paramt[i])
      param[i] <-ifelse(x[i]<c,a1l*(xc[i])+a0l+ilogit(100*(kl-x[i]))*((a3l)*(xc[i])^3+(a2l)*(xc[i])^2),a1r*(xc[i])+a0r+ilogit(100*(x[i]-kr))*((a3r)*(xc[i])^3+(a2r)*(xc[i])^2))
      Tau[i]<-ifelse(x[i]<c,tau1l+tau2l*ilogit(100*(kl-x[i])),tau1r+tau2r*ilogit(100*(x[i]-kr)))
      paramt[i] <- ifelse(x[i]<c,ifelse(x[i]>=c-k1t,a1lt*x[i]+b1lt,a2lt*x[i]+b2lt),ifelse(x[i]<=c+k2t,a1rt*x[i]+b1rt,a2rt*x[i]+b2rt))
    }
    ## pr=0.0001
    MAX=max(x)
    MIN=min(x)


    ### Define the priors
    c0~dbeta(alpha,beta)
    c=c0*(cub-clb)+clb
    xc=x-c
    j~dunif(jlb,1)
    k1t~dunif(lb,c-ublt)
    k2t~dunif(lb,ubrt-c)
    a2lt~dunif(0,(1-j)/(c-k1t-MIN))
    b2lt~dunif(-a2lt*MIN,1-j-a2lt*(c-k1t))
    a1lt~dunif(0,(1-j-a2lt*(c-k1t)-b2lt)/k1t)
    b1lt=(c-k1t)*(a2lt-a1lt)+b2lt
    a1rt~dunif(0,(1-a1lt*c-b1lt-j)/k2t)
    b1rt=a1lt*c+b1lt+j-a1rt*c
    a2rt~dunif(0,(1-b1rt-(c+k2t)*a1rt)/(MAX-c-k2t))
    b2rt=(c+k2t)*(a1rt-a2rt)+b1rt
    ## df=7
    tau1l~dgamma(shape, scale)
    tau2pl~dbeta(1,1)
    tau2l=-tau2pl*tau1l
    kl~dunif(ubl,c-lb)
    a0l~dnorm(0,pr)
    a1l~dnorm(0,pr)
    a2l~dnorm(0,pr*(c-kl))
    a3l~dnorm(0,pr*(c-kl))

    tau1r~dgamma(shape, scale)
    tau2pr~dbeta(1,1)
    tau2r=-tau2pr*tau1r
    kr~dunif(c+lb,ubr)
    a0r~dnorm(0,pr)
    a1r~dnorm(0,pr)
    a2r~dnorm(0,pr*(kr-c))
    a3r~dnorm(0,pr*(kr-c))



    eff=(a0r-a0l)/j

    }