[R] gen.inits error for non-linear hierarchical model using R2winBUGS

Dominik Jaskierniak dom1jaski at gmail.com
Mon Jun 22 07:20:44 CEST 2015


Hi,


I am relatively new to Bayesian statistics and am trying to apply a
non-linear hierarchical model using R2winBUGS on some tree stocking density
data. I am hoping someone may be able to help me find the reason why
R2winBUGS is giving me the following error:


*gen.inits cannot be executed (is greyed out)*


Even though I get this error, the code still produces output. For
parameters that converge, the model produces output that seem reasonable
but there are two parameters (mean_N0 sigma_N0 in below code) that are not
mixing well (not converging) when I use two chains.   The chains seem to
start around the initial value (i.e. mean_N0 starts at 4800.5 and 4799.5,
whereas sigma_N0 starts at 800.5 and 799.5) but don’t move far from those
values. The mean values for both parameters are about 0.5 off from the
initial values set. I am not sure whether the above error is causing this
convergence problem.


I have exhausted my investigations into this problem and am now hoping
someone may be able to see what is causing my problem in the below winBUGS
or R code.  I would greatly appreciate your time if you could help.


Kind Regards


Dom Jaskierniak



WINBUGS CODE

  model {

    ## loop over data for likelihood

    for(i in 1:Ntotal){

      N[i] <- log(N0[P_ID_Bug[i]] - 25)-(Age[i]/(Beta_0 + Beta_1*Age[i]))  #
LogSDen_Ha ~ log(N0 - 25)-(Age/(Beta_0 + Beta_1*Age))

      Y[i] ~ dnorm(N[i],tauY)

    }

    tauY ~ dgamma(1.0E-3, 1.0E-3)

    Beta_0 ~ dnorm(9,0.25)

    Beta_1 ~ dnorm(0.16,400)



## hierarchical model for each Plots intercept & slope

    for (p in 1:P_ID_Length) {

                N0[p] ~ dgamma(r_N0, lambda_N0)

    }

    mean_N0 ~ dnorm(5000,1.0E-6)

    sigma_N0 ~ dnorm(5000,0.25E-6)

    lambda_N0 <- mean_N0/(sigma_N0*sigma_N0)

    r_N0 <- mean_N0 * lambda_N0

  }



R CODE



data <- list(P_ID_Length = length(P_ID),

             P_ID_Bug = P_ID_Bug,

             Age=Grouped_SDen$Age,

             Y =Grouped_SDen$LogSDen_Ha,

             Ntotal=nrow(Grouped_SDen))



inits1 <- list(N0= rep(coef(NLS_SDen_Log_1)[[1]], P_ID_Length),

     Beta_0 = coef(NLS_SDen_Log_1)[[2]],

     Beta_1 = coef(NLS_SDen_Log_1)[[3]],

     tauY = 20,

     mean_N0 = 4800,

     sigma_N0 = 800

    )



inits2 <- list(N0= rep(coef(NLS_SDen_Log_1)[[1]], P_ID_Length),

     Beta_0 = coef(NLS_SDen_Log_1)[[2]],

     Beta_1 = coef(NLS_SDen_Log_1)[[3]],

     tauY = 20,

     mean_N0 = 4800,

     sigma_N0 = 800

    )

inits <- list(inits1, inits2)

parameters <- c("N0", "Beta_0", "Beta_1", "tauY", "mean_N0", "sigma_N0")

sims <- bugs(model.file=
"C:/WS/Post-Doc/TINNR/PAPER_4_WinBugs/Stocking_Growth.bug",

             data = data,

             parameters = parameters,

             inits = inits,

             n.chains = 2,

             n.iter = 1000,

             n.burnin = 500,

             n.thin = 2,

             debug=TRUE,

             bugs.directory = "C:/Program Files/WinBUGS14/")

	[[alternative HTML version deleted]]



More information about the R-help mailing list