Hi Tim,
there are three issues in your call to inla:
1. The model you are fitting in inla has 4 variance components: one for each block and the residual variance which is always there by default, and is provoking some confounding. You can fix it to a high precision using control.family().
2. You are not estimating group-level means. The iid models are
centered at 0 by default. You could either remove this constraint
or add the group means as fixed effects
3. When you use blockA/B/C variables for (f, iid) it is assuming
that they are random effects with only two levels each (0 and 1).
And trying to estimate a variance from there! What I think you
wanted to do is to use id as a random effect weighted by
blockA/B/C.
In summary, I believe this works as you expected:
dat2 <- transform(dat2, id2 = id, id3 = id)
fit.inla <- inla(formula=y ~ 0 + block + f(id, blockA,
model="iid") +
f(id2, blockB, model="iid") +
f(id3, blockC, model="iid"),
control.family = list(
hyper = list(
prec = list(
initial = 10,
fixed = TRUE
)
)
),
data=dat2)
summary(fit.inla)
1/sqrt(fit.inla$summary.hyperpar[,"mean"])
Best regards,
ƒacu.-
--
You received this message because you are subscribed to the Google Groups "R-inla discussion group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to r-inla-discussion...@googlegroups.com.
To post to this group, send email to r-inla-disc...@googlegroups.com.
Visit this group at https://groups.google.com/group/r-inla-discussion-group.
For more options, visit https://groups.google.com/d/optout.