Mdshdw
Mdshdw

Reputation: 1

R Processing Error - Error in checkForRemoteErrors(val) : 3 nodes produced errors; first error

I am a newbie to R. I am trying to run a nest survival model. Initially the code is running well, but at the end the error comes as follows:

 Error in checkForRemoteErrors(val) : 

3 nodes produced errors; first error: RUNTIME ERROR: Compilation error on line 8. Unknown variable nestdata Either supply values for this variable with the data or define it on the left hand side of a relation.

I have checked my dataset multiple times but there are no null values. please guide me where I am doing it wrong.

Here is my code:

sink("LogExp_model.txt")
cat(
  "
model{
  #priors
  alpha.a ~ dnorm(0,0.01)

  
  #random effect for years, with effect of precipitation
  for(i in 1:nnestdata){
  eta.y[i] ~ dnorm(0, tau.y)
  beta.nestdata[i] <- eta.y[i]
  }

  #hyperparameters for random effect
  tau.y <- 1/(pow(sigma.y,2))
  sigma.y ~ dunif(0,50)
  
  #survival model
  for(i in 1:n){
  #daily survival estimate is on logit scale
  logit(S[i]) <- alpha.a + 
                    beta.nestdata[nestdata[i]]
  #success/failure on a given day is bernoulli trial of survival estimate
  surv[i] ~ dbern(S[i]^interval[i])
  }
    # x is estimated null daily survival
    x<-exp(alpha.a)/(exp(alpha.a)+1)
    # csurv is estimated nest success over 23 days
    csurv<-pow(x,23)

}
    ",fill = T)
sink()

#package data for analysis in JAGS
win.data.sc <- list(n = nrow(nestdata),    
                    interval = as.numeric(nestdata$interval),
                    surv = nestdata$Surv,
                    Site2 = as.numeric(nestdata$Site2))

#define function to draw initial values for MCMC chains
inits <- function() {list(alpha.n = rnorm(1, 0, 1),
                          sigma.y = rlnorm(1))}

#list parameters to monitor
params <- c("sigma.y","alpha","beta.nestdata",
            "alpha.a","x","csurv")

ni <- 50000
nb <- 20000
nt <- 3
nc <- 3

nullmodel.fit <- jags(win.data.sc, inits, params, "LogExp_model.txt", 
                      n.iter=ni, n.thin=nt, n.burnin=nb, n.chains=nc, parallel=TRUE)

This is similar to a previous model that I've run and that worked fine. I'm not sure what I did differently this time.

-Kama

Upvotes: 0

Views: 27

Answers (0)

Related Questions