compute_BIC_junction_tree: Calculates the BIC value

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/BIC_junction_tree.R

Description

Calculates the BIC value for a graphical model from a junction tree for the graph.

Usage

1
compute_BIC_junction_tree(cliques, separators, data, base_log = 2, ...)

Arguments

cliques

A list containing the cliques of the junction tree.

separators

A list containing the separators of the junction tree.

data

A data frame with observations of the variables.

base_log

The base to use for the logarithm.

...

Additional arguments passed to loglikelihood.

Details

The BIC is calculated as

loglik - (n_param / 2) * log(n_obs)

where loglik is the value of the log-likelihood function, n_param is the number of free parameters and n_obs is the number of observations in data. A high value of the BIC criterion is to be preferred.

Value

The BIC value.

Author(s)

Katrine Kirkeby, enir_tak@hotmail.com

Maria Knudsen, mariaknudsen@hotmail.dk

Ninna Vihrs, ninnavihrs@hotmail.dk

See Also

loglikelihood for calculating the log-likelihood value and n_params_junction_tree for determining the number of free parameters in the 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
set.seed(43)
var1 <- c(sample(c(1, 2), 100, replace = TRUE))
var2 <- var1 + c(sample(c(1, 2), 100, replace = TRUE))
var3 <- var1 + c(sample(c(0, 1), 100, replace = TRUE,
                        prob = c(0.9, 0.1)))
var4 <- c(sample(c(1, 2), 100, replace = TRUE))
var5 <- var2 + var3
var6 <- var1 - var4 + c(sample(c(1, 2), 100, replace = TRUE))
var7 <- c(sample(c(1, 2), 100, replace = TRUE))

data <- data.frame("var1" = as.character(var1),
                   "var2" = as.character(var2),
                   "var3" = as.character(var3),
                   "var4" = as.character(var4),
                   "var5" = as.character(var5),
                   "var6" = as.character(var6),
                   "var7" = as.character(var7))

cliques <- list(c("var1", "var2", "var3"),
                c("var2", "var3", "var5"),
                c("var5", "var6", "var7"),
                c("var1", "var4"),
                c("var2", "var5", "var6"))

separators <- list(c("var1"),
                   c("var2", "var3"),
                   c("var2", "var5"),
                   c("var5", "var6"))

# smooth is used to deal with zero probabilities.
compute_BIC_junction_tree(cliques, separators, data, smooth = 0.1)

nvihrs14/tcherry documentation built on Aug. 1, 2020, 6:25 p.m.