biips_model: Create a biips model object described in BUGS language.

Description Usage Arguments Value See Also Examples

View source: R/biips_model.r

Description

Create a biips model object described in BUGS language.

Usage

1
2
biips_model(file, data = parent.frame(), sample_data = TRUE,
  quiet = FALSE, seed = get_seed())

Arguments

file

string. path of the BUGS file which defines the stochastic model. Alternatively, file can be a readable text-mode connection, or a complete URL.

data

either a list or environment containing constants and observed values or a character vector containing names of variables existing in the workspace. Any numeric objects in data corresponding to node arrays used in file are taken to represent the values of observed nodes in the model.

sample_data

logical. Toggle the evaluation of the 'data' block of the BUGS model that generates or transforms data. (default = TRUE).

quiet

logical. Deactivate verbosity. (default = FALSE).

seed

int. RNG seed used for data generation if sample_data is true. Randomly generated by default.

Value

An object of class biips which can be used to generate samples from the posterior distribution of the parameters.

An object of class biips is a list of functions that share a common environment. The functions can be used to query information on the model.

ptr()

Get an external pointer to the compiled model object.

file()

Get a string. filename of the BUGS model.

data()

Get a named list of the original data of the model.

model()

Get a character vector. BUGS language definition of the model.

recompile()

Recompile the model using the original data set.

See Also

biips_variable_names, biips_nodes, biips_print_dot, biips_add_function, biips_add_distribution

Examples

 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
30
31
32
33
34
modelfile <- system.file('extdata', 'hmm.bug', package = 'rbiips')
stopifnot(nchar(modelfile) > 0)
cat(readLines(modelfile), sep = '\n')

data <- list(tmax = 10, p = c(.5, .5), logtau_true = log(1), logtau = log(1))
model <- biips_model(modelfile, data, sample_data = TRUE)

## Not run: 
tmax <- 10
p <- c(.5, .5)
logtau_true <- log(1)
logtau <- logtau_true

datanames <- c('tmax', 'p', 'logtau_true', 'logtau')
model <- biips_model(modelfile, datanames, sample_data = TRUE)

## End(Not run)

is.biips(model)
print(model)

model$data()

variable.names(model)
biips_variable_names(model)

biips_nodes(model)

## Not run: 
dotfile <- 'hmm.dot'
biips_print_dot(model, dotfile)
cat(readLines(dotfile), sep = '\n')

## End(Not run)

biips/rbiips documentation built on Nov. 28, 2020, 2:12 p.m.