I'm trying to adapt some open source code for a phylogenetic generalized linear regression model. When I try to execute the code it says that there is a possible directed cycle on line 10 involving resid_pred. I'm unsure where this is happening because it worked before. Any advice is appreciated!
Here's the portion of the code where it says the error is happening and the sections below that involve the prediction variable:
cat("model {
#Sensitivity and specificity
spec <- sum(ifelse(equals(pred, infected) && infected == 0, 1, 0)) / sum(equals(infected, 0))
sens <- sum(ifelse(equals(pred, infected) && infected == 1, 1, 0)) / sum(equals(infected, 1))
#Posterior predictive check
ppc <- step(fit_pred - fit_data)
resid_data <- abs(infected) - prob
resid_pred <- abs(pred) - prob
fit_data <- sum(resid_data)
fit_pred <- sum(resid_pred)
#Phylogenetic logistic regression model
#Logistic regression w/ varying intercepts for each host species
for(i in 1:n_obs){
#likelihood
infected[i] ~ dbern(prob[i])
#simulated prediction
pred[i] ~ dbern(prob[i])
I've looked at some of the other similar posts, but have been unable to find a fix for what I've experienced. It's strange because it worked before on another dataset.