thin_edges: Thinning of edges in a graphical model with a triangulated...

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

View source: R/thinning_edges.R

Description

Thinning of edges in a graphical model with a triangulated graph based on a likelihood ratio test for conditional independence.

Usage

1
thin_edges(cliques, separators, data, alpha = 0.05, ...)

Arguments

cliques

A list containing the cliques of the triangulated graph, which should be thinned.

separators

A list containing the separators of the junction tree of the triangulated graph, which should be thinned.

data

Data with realisations of the variables in the graph.

alpha

Significance level used in the conditional independece test.

...

Additional arguments passed to cond_independence_test

Details

The edges in the graph are removed one by one if the respective conditional independence test cannot be rejected. An edge is only considered if its removal results in a new triangulated graph, i.e. the edge is in one clique only.

Value

A list containing the following components:

Author(s)

Katrine Kirkeby, enir_tak@hotmail.com

Maria Knudsen, mariaknudsen@hotmail.dk

Ninna Vihrs, ninnavihrs@hotmail.dk

See Also

cond_independence_test for the test used.

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"))

thin_edges(cliques, separators, data = data, alpha = 0.1,
               smooth = 0.1)

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