Hi All,
Thanks for the help! I've got an occupancy model with p and Psi covariates that I set up using matrices rather than vectors for convenience.
Most sites have 3 visits per year in each of three years, so I have a response variable array of:
y[1:n_sites , 1:n_species , 1:2 (years), 1:3 (surveys per year)]
However, some sites (e.g. 5%) were only surveyed twice in a given year, and a few (3%) were only surveyed in one or two (rather than all three) years. I think all of the NAs in those years are giving me problems though I can't pinpoint exactly where/why. For example, I'm not getting estimates of my covariate coefficients (they are stuck at initial values).
So my main question is how I should be dealing with those missing values. One solution I tried (in for the formula below) is to index year and survey numbers for each site. For years I do this with a years-per-site vector (yrs), and for surveys per year I do this with a matrix of k[1:n_sites,1:n years] that shows how many visits there were.
This should prevent the model from ever encountering the missing data, but then the parameter matrices that it is estimating are not 'full', and I assume that is causing the model to fail (as it does when using the code below).
Note: this model also involves some latent variables, which you can ignore
#Psi model
for (yr in 1:(yrs[j])) {
eta[j,i,yr] <- inprod(u.b[i,1:Vocc], Xocc[j, ,yr]) + inprod(lv.coef[i,1:nlv],LV[j,1:nlv])
u[j,i,yr] ~ dnorm(eta[j,i,yr],1/(1-sum(lv.coef[i,1:nlv]^2)))
z[j,i,yr] <- step(u[j,i,yr])
}
#p model
for (yr in 1:(yrs[j])) {
for (kv in 1:(k[j,yr])) {
logit(p[j,i,yr,kv]) <- inprod(v.b[i,1:Vobs], Xobs[j, ,yr,kv])
mu.p[j,i,yr,kv] <- p[j,i,yr,kv]*z[j,i,yr]
y[j,i,yr,kv] ~ dbern(mu.p[j,i,yr,kv])
}
}
Is there a better way to deal with these missing surveys and years at some sites? Or am I stuck using a vector setup of this model?
The answer to the above question may also answer my other question, but I occasionally have missing p and Psi covariates as well. I don't care about estimates for these values except to the extent that Nimble needs them to get estimates for the parameters of interest for those sites. If I need to specify priors for those values can I ask the model to estimate mean and sd of each covariate column to create a prior? And do I need to give a formula in the model that is 'solved' for those missing values (which would be annoying for models with many covariates and a few missing values in each)? Or can Nimble use the information it already has (equations containing those covariates) to infer their values?
Thank you!