Issue with redefining nodes

Help
2013-12-13
2013-12-13
  • Dean Castillo
    Dean Castillo
    2013-12-13

    I have been working on a model where I want to estimate precision parameters separately for Npop number of populations, as well as mean difference between populations.
    I thought that I indexed the precision parameters correctly to avoid treating them as local variables (based on other posts to the forum), but I am still receiving the "Attempt to redefine node t.male[1]"
    error. My goal was to have t.male, t.female, and t.int be vectors containing Npop estimates

    Here is my model code

        #Likelihood
    for (i in 1:Ntotal){ #loop through all observations
        y[i]~dnorm(mu[i],tau)
        mu[i]<-mup[pop[i]]+male[m[i],pop[i]]+female[f[i],pop[i]]
    }   
    #Prior on error
    tau ~dnorm( 0.0, 1.0E-04)
    #Prior for population level effects
    for (j in 1:Npop){
        mup[j]~dnorm(mu0,tau.pop) #should give diff mean for each pop?
        male[j,1]<-0.0 #this is my corner constraint?
        for (a in 2:LM){
            male[j,a]~dnorm(0.0,t.male[j])
            t.male[j]~dt(0,1,1)I(0,) #half cauchy
        }
        female[j,1]<-0.0
        for (b in 2:LF){
            female[j,b]~dnorm(0,t.fem[j])
            t.fem[j]~dt(0,1,1)I(0,)
        }
    

    Any help would be greatly appreciated

     
  • Matt Denwood
    Matt Denwood
    2013-12-13

    Hi Dean

    From a very quick look at your model you can solve that error by moving the 't.male[j] ~ etc' and 't.fem[j] ~ etc' lines outside the for loop for a/b - i.e. just after the curly brace below each line. Remember that each variable can only be assigned once - at the moment you are trying to assign each element of t.male LM-1 times (and the same thing for t.fem).

    Hope that helps,

    Matt

     
  • Dean Castillo
    Dean Castillo
    2013-12-13

    Thanks Matt, that was indeed helpful.
    I thought providing the [j] subscript would supersede the smaller loop but now I see why that is incorrect
    I also realized I did not provide priors for mu0 and tau.pop which was causing some issues. I still have some other errors I have not fixed, but I believe your correction has helped

    Dean