Description Usage Arguments Details Value Author(s) See Also Examples
View source: R/loglikelihood.R
Calculates the value of the log-likelihood function for a graphical model with the given junction tree after inserting estimated probabilities.
1 | loglikelihood(cliques, separators, data, ...)
|
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. |
... |
Additional arguments passed to |
Calculates the value as
n_obs * (weight - ∑ H(A))
where n_obs is the number of observations in data, weight is the estimated weight of the junction tree and H is the estimated entropy of the variable A. The sum is over all variables in data. All estimated probabilities are maximum likelihood estimates unless the smooth argument has been used to deal with zero probabilities.
The calculated log-likelihood value.
Katrine Kirkeby, enir_tak@hotmail.com
Maria Knudsen, mariaknudsen@hotmail.dk
Ninna Vihrs, ninnavihrs@hotmail.dk
weight_junction_tree
for calculating the weight
of a junction tree.
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.
loglikelihood(cliques, separators, data, smooth = 0.1)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.