JAGS model R problem with the results

HI guys,
I was starting few days ago to analyze this dataset https://www.kaggle.com/rashikrahmanpritom/heart-attack-analysis-prediction-dataset?select=heart.csv

I decide to use a model based on logistic regression:

# Writing model for jags
model <- function() {
  
  # Likelihood
  for (i in 1:N){
    y[i] ~ dbern(p[i])
    
    logit(p[i]) <- beta0 + beta[1]*x1[i] + beta[2]*x2[i] + beta[3]*x3[i] + beta[4]*x4[i] + beta[5]*x5[i] 
  }
  
  # Prior on constant term
  beta0 ~ dnorm(0, 1.0E-6) # intercept
  # Priors
  for(j in 1:Nvar){
    beta[j] ~ dnorm(0, 1.0E-6)
  }
  
}

In order to find the best coefficient that model my likelihood observations. But, when I'm doing the:

# Preparing data for JAGS
N <- nrow(dat) # number of obs
Nvar <- 5 # number of ind. variables, that are quantitative data

# Dependent Variable
y <- as.vector(dat$output) # Target variable, risks heart attack?

# Independent Variables
x1 <- as.vector(dat$age) # Age
x2 <- as.vector(dat$trtbps) # resting blood pressure (in mm Hg)
x3 <- as.vector(dat$chol) # cholestoral in mg/dl fetched via BMI sensor
x4 <- as.vector(dat$thalachh) # maximum heart rate achieved
x5 <- as.vector(dat$oldpeak) # Previous peak

data.jags <- list("y" = y, "N" = N, "Nvar" = Nvar,
                 "x1" = x1, "x2" = x2, "x3" = x3, "x4" = x4, "x5" = x5)

# Defining parameters of interest
mod.params <- c("beta0", "beta")

# Run JAGS
# set.seed(123)
n.chains <- 3
mod.fit <- jags(data = data.jags,                                               # DATA
                model.file = model,                                             # MODEL
                parameters.to.save = mod.params,                                # TRACKING
                n.chains = n.chains, n.iter = 10000, n.burnin = 1000, n.thin=10)       # MCMC

# Results -------------------------------------------------

mod.fit 
mod.fit$BUGSoutput$summary

the DIC information is around 300 and when i do the coda::heidel.diag(coda::as.mcmc(mod.fit)) one test about the x1, the age is failed.... so, what i should consider there is an error with my model, I should consider another model? What i should do ahah

sorry, but i'm new in this framework so I want to see what i should do!!

Best regards!

I don't know anything about jags, but model seems kind of weird. A function that doesn't seem to return any arguments being supplied to an input argument that seems to expect a file? Maybe I'm totally off base.

nono, is correct this is the syntax, however I changed sligthly the logit line and I avoid the intercept, now the tests are passed

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.