gibbs_stcos: Gibbs Sampler for STCOS Model

Description Usage Arguments Details Value Examples

View source: R/gibbs_stcos.R

Description

Gibbs Sampler for STCOS Model

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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 \bm{K}^{-1} of the random coefficient \bm{η}

R

Number of MCMC reps.

report_period

Gibbs sampler will report progress each time this many iterations are completed.

burn

Number of the R draws to discard at the beginning of the chain.

thin

After burn-in period, save one out of every thin draws.

init

A list containing the following initial values for the MCMC: sig2mu, sig2xi, sig2K, muB, eta, xi. Any values which are not specified are set to arbitrary choices.

fixed

A list specifying which parameters to keep fixed in the MCMC. This can normally be left blank. If elements sig2mu, sig2xi, or sig2K are specified they should be boolean, where TRUE means fixed (i.e. not drawn). If elements muB, eta, or xi are specified, they should each be a vector of indicies; the specified indices are to be treated as fixed (i.e. not drawn).

hyper

A list containing the following hyperparameter values: a_sig2mu, a_sig2K, a_sig2xi, b_sig2mu, b_sig2K, b_sig2xi. Any hyperparameters which are not specified are set to a default value of 2.

object

A result from gibbs_stcos.

...

Additional arguments.

x

A result from gibbs_stcos.

Details

Fits the model

\bm{Z} = \bm{H} \bm{μ}_B + \bm{S} \bm{η} + \bm{ξ} + \bm{\varepsilon}, \quad \bm{\varepsilon} \sim \textrm{N}(0, \bm{V}),

\bm{η} \sim \textrm{N}(\bm{0}, σ_K^2 \bm{K}), \quad \bm{ξ} \sim \textrm{N}(0, σ_{ξ}^2 \bm{I}),

\bm{μ}_B \sim \textrm{N}(\bm{0}, σ_μ^2 \bm{I}), \quad σ_μ^2 \sim \textrm{IG}(a_μ, b_μ),

σ_K^2 \sim \textrm{IG}(a_K, b_K), \quad σ_ξ^2 \sim \textrm{IG}(a_ξ, b_ξ),

using a Gibbs sampler with closed-form draws.

Helper functions produce the following outputs:

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## 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)

stcos documentation built on July 1, 2020, 10:42 p.m.

Related to gibbs_stcos in stcos...