WinBUGS code for: "Changing approaches of prosecutors towards juvenile repeated sex-offenders: A Bayesian evaluation" #Covariates: Age = Age at offense; Repoff = Indicator of repeat offense; Severe = Indicator of a severe offense; Prosyear = year of prosecution; Ind2000 = Indicator of the year of notification; Chngpt[i]= step(Prosyear[i]-U[i]); Lin.chngpt[i] =(Prosyear[i]-U[i])*step(Prosyear[i]-U[i]); Quad.chngpt[i] = pow((Prosyear[i]-U[i]),2)*step(Prosyear[i]-U[i]); model { # Begin model statement myr<-mean(Prosyear[]) pi <- 22/7 for (i in 1:N){ ### Total number of observations is N dec[i] ~dbern(p[i]) # This is done to bound probabilities between 0.001 and 0.999 p[i]<-max(0.001,min(0.999,Q1[i])) ## Regression model using nested indexing, w is the random effects logit(Q1[i]) <- beta[1]+beta[2]*Age[i]+beta[3]*Repoff[i]+ beta[4]*Severe[i]+beta[5]*(Prosyear[i]-myr)+beta[6]*Ind2000[i]+ beta[7]*Chngpt[i]+beta[8]*Lin.chngpt[i]+beta[9]*Quad.chngpt[i]+ beta[10]*Repoff[i]*Chngpt[i]+w[id[i]] # Log-likelihood LL[i] <- dec[i]*log(p[i])+(1-dec[i])*log(1-p[i]) U[i]<- 1991 + T } T ~ dcat(P[]) # Intercept A <- beta[1]-beta[5]*myr # Bridge Density using zeros trick C<- 1000 U1 <- sin(phi*pi) V1 <- cos(phi*pi) for (j in 1:M) { # Total number of subjects is M zero[j] <- 0 w[j] ~ dflat() br[j] <- -log(U1)+log(V1 +(exp(phi*w[j])+exp(-phi*w[j]))*0.5) + C zero[j] ~ dpois(br[j])} for (k in 1:10) {odds[k] <- exp(phi*beta[k]) } # Priors phi ~ dbeta(a,b) P[1:5] ~ ddirch(alpha[]) for (i in 1:10){beta[i] ~ ddexp(0,tau)} } # end model statement