gibbs_stcos {stcos} | R Documentation |
Gibbs Sampler for STCOS Model
Description
Gibbs Sampler for STCOS Model
Usage
gibbs_stcos(
z,
v,
H,
S,
Kinv,
R,
report_period = R + 1,
burn = 0,
thin = 1,
init = NULL,
fixed = NULL,
hyper = NULL
)
## S3 method for class 'stcos_gibbs'
logLik(object, ...)
## S3 method for class 'stcos_gibbs'
DIC(object, ...)
## S3 method for class 'stcos_gibbs'
print(x, ...)
## S3 method for class 'stcos_gibbs'
fitted(object, H, S, ...)
## S3 method for class 'stcos_gibbs'
predict(object, H, S, ...)
Arguments
z |
Vector which represents the outcome; assumed to be direct estimates from the survey. |
v |
Vector which represents direct variance estimates from the survey. |
H |
Matrix of overlaps between source and fine-level supports. |
S |
Design matrix for basis decomposition. |
Kinv |
The precision matrix |
R |
Number of MCMC reps. |
report_period |
Gibbs sampler will report progress each time this many iterations are completed. |
burn |
Number of the |
thin |
After burn-in period, save one out of every |
init |
A list containing the following initial values for the MCMC:
|
fixed |
A list specifying which parameters to keep fixed in the MCMC.
This can normally be left blank. If elements |
hyper |
A list containing the following hyperparameter values:
|
object |
A result from |
... |
Additional arguments. |
x |
A result from |
Details
Fits the model
\bm{Z} = \bm{H} \bm{\mu}_B + \bm{S} \bm{\eta} + \bm{\xi} + \bm{\varepsilon}, \quad
\bm{\varepsilon} \sim \textrm{N}(0, \bm{V}),
\bm{\eta} \sim \textrm{N}(\bm{0}, \sigma_K^2 \bm{K}), \quad
\bm{\xi} \sim \textrm{N}(0, \sigma_{\xi}^2 \bm{I}),
\bm{\mu}_B \sim \textrm{N}(\bm{0}, \sigma_\mu^2 \bm{I}), \quad
\sigma_\mu^2 \sim \textrm{IG}(a_\mu, b_\mu),
\sigma_K^2 \sim \textrm{IG}(a_K, b_K), \quad
\sigma_\xi^2 \sim \textrm{IG}(a_\xi, b_\xi),
using a Gibbs sampler with closed-form draws.
Helper functions produce the following outputs:
-
logLik
computes the log-likelihood for each saved draw. -
DIC
computes the Deviance information criterion for each saved draw. -
print
displays a summary of the draws. -
fitted
computes the meanE(Y_i)
for each observationi = 1, \ldots, n
, for each saved draw. -
predict
drawsY_i
for each observationi = 1, \ldots, n
, using the parameter values for each saved Gibbs sampler draw.
Value
gibbs_stcos
returns an stcos
object which contains
draws from the sampler. Helper functions take this object as an input
and produce various outputs (see details).
Examples
## Not run:
demo = prepare_stcos_demo()
out = gibbs_stcos(demo$z, demo$v, demo$H, demo$S, solve(demo$K),
R = 100, burn = 0, thin = 1)
print(out)
logLik(out)
DIC(out)
fitted(out, demo$H, demo$S)
predict(out, demo$H, demo$S)
## End(Not run)