biips-object: Manipulate biips model objects.

Description Usage Arguments Value See Also Examples

Description

A biips object is returned by function biips_model. It represents a Bayesian graphical model described in BUGS language.

The method biips_build_sampler assigns a sampler to each node of the graph. In order to specify the proposal used by the SMC algorithm, this function has to be called before biips_smc_samples. Otherwise, it will be automatically called by biips_smc_samples with the default parameters.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
is.biips(object)

## S3 method for class 'biips'
print(x, ...)

## S3 method for class 'biips'
biips_variable_names(object, ...)

## S3 method for class 'biips'
variable.names(object, ...)

## S3 method for class 'biips'
biips_nodes(object, type, observed, ...)

## S3 method for class 'biips'
biips_print_dot(object, file, ...)

## S3 method for class 'biips'
biips_build_sampler(object, proposal = "auto", ...)

Arguments

object, x

biips model object as returned by biips_model.

...

Additional arguments to be passed to default methods.

type

string. Return only a specific type of node. Possible values are 'const', 'logic' or 'stoch'. Default returns all types of nodes.

observed

logical. Return only observed or unobserved nodes. Default returns all.

file

string. Path of the output file.

proposal

string. The type of proposal used by the SMC algorithm. Possible values are 'auto' and 'prior'. 'auto' selects the best sampler among available ones automatically. 'prior' forces assignment of the prior sampler to every node. 'prior' switches off lots of instructions and can speed up the startup of the SMC for large models. (default = 'auto').

Value

The function is.biips returns TRUE if the object is of class biips.

The method biips_variable_names returns a character vector. Names of node arrays used in the model.

The method variable.names is an alias for biips_variable_names.

The method biips_nodes returns a data.frame with a row for each node of the graphical model sorted in a topological order with the following columns:

id

integer. node ids.

name

string. node names.

type

string. node types ('const', 'logic' or 'stoch').

observed

logical. TRUE if the node is observed.

discrete

logical. TRUE if the node is discrete.

If the function is called after the sampler is built (by calling biips_build_sampler or biips_smc_samples), it will also contain the additional variables:

iteration

integer. node sampling iteration of unobserved nodes, starting at 0. NA if the node if observed.

sampler

string. node sampler name for stochastic unobserved nodes. An empty string for other types of nodes.

The method biips_print_dot prints the graph in a file in dot format.

The method biips_build_sampler returns NULL.

See Also

biips_model

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
35
36
37
38
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)

#\dontrun{
#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)
#}

is.biips(model)
print(model)

model$data()

variable.names(model)
biips_variable_names(model)

biips_nodes(model)

#\dontrun{
#dotfile <- 'hmm.dot'
#biips_print_dot(model, dotfile)
#cat(readLines(dotfile), sep = '\n')
#}

biips_build_sampler(model, proposal = 'prior')
biips_nodes(model, type = 'stoch', observed = FALSE)

biips_build_sampler(model, proposal = 'auto')
biips_nodes(model, type = 'stoch', observed = FALSE)

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