run: Run a Markov-chain Monte Carlo algorithm to sample from the...

Description Usage Arguments Value See Also Examples

Description

Run a Markov-chain Monte Carlo algorithm to sample from the log posterior density.

Usage

1
run(spec, data = NULL, writeDir = tempdir(), ...)

Arguments

data

A named list with the dataset.

writeDir

An optional character string with the path where the Stan file should be written. Useful to inspect and modify the Stan code manually. It defaults to a temporary directory.

...

Arguments to be passed to rstan's stan.

Value

An object of S4 class stanfit with some additional attributes (the dataset data, the name of the Stan code file filename, and the Specification object spec). This object is completely compatible with all other functions.

See Also

See rstan's sampling for further details on tunning the MCMC algorithm.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
## Not run: 
y <- rnorm(1000) # Assume this is your dataset

mySpec   <- hmm(
  K = 2, R = 1,
  observation = Gaussian(
    mu    = Gaussian(0, 10),
    sigma = Student(
      mu = 0, sigma = 10, nu = 1, bounds = list(0, NULL)
    )
  ),
  initial     = Dirichlet(alpha = c(1, 1)),
  transition  = Dirichlet(alpha = c(1, 1)),
  name = "Univariate Gaussian Hidden Markov Model"
)

myModel <- compile(mySpec)

myFit   <- draw_samples(myModel, y = y, chains = 2, iter = 500)

## End(Not run)

luisdamiano/BayesHMM documentation built on May 20, 2019, 2:59 p.m.