Description Usage Arguments Value Author(s) See Also Examples
Computes the posterior distribution of the standard deviations for the structured (random) effects in an INLA model, starting from the default output based on the precisions
1 | inla.contrib.sd(model, nsamples=1000)
|
model |
An INLA model, fitted calling the |
nsamples |
The number of simulations from the posterior distribution of the standard deviations used to compute the summary statistics |
inla.contrib.sd
returns a matrix samples
including the simulated values from the
posterior distributions as well as a summary table hyper
reporting
the mean, sd and 95% credible interval for the posterior distributions of each random effect.
Gianluca Baio gianluca@stats.ucl.ac.uk
1 2 3 4 5 6 7 8 9 10 11 12 13 | # Data generation
n=12
Ntrials = sample(c(80:100), size=n, replace=TRUE)
eta = rnorm(n,0,0.5)
prob = exp(eta)/(1 + exp(eta))
y = rbinom(n, size=Ntrials, prob = prob)
data=data.frame(y=y,z=1:n)
formula=y~f(z,model="iid")
m=inla(formula,data=data,family="binomial",Ntrials=Ntrials)
summary(m)
s=inla.contrib.sd(m)
s$hyper
hist(s$samples,xlab="standard deviation for z",main="")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.