woe {RNetica}R Documentation

Calculates the weight of evidence for a hypothesis

Description

Calculates the weight of evidence provided by the current findings for the specified hypothesis. A hypothesis consists of a statement that a particular set of nodes (hnodes) will fall in a specified set of states (hstatelists).

Usage

woe(enodes, estates, hnodes, hstatelists)

Arguments

enodes

A list of NeticaNodes which are providing evidence. As a special case, a single NeticaNode is treated as a list of length one.

estates

A list of character vectors the same length as enodes corresponding to the observed or hypothesized state of the evidence nodes and representing states of the corresponding node. As a special case, a character vector is turned into a list of length one.

hnodes

A list of NeticaNodes whose values are of interest. As a special case, a single NeticaNode is treated as a list of length one.

hstatelists

A list of character vectors the same length as hnodes corresponding to the hypothesized state of the nodes and representing states of the corresponding node. As a special case, a character vector is turned into a list of length one.

Details

Good (1985) defines the weight of evidence E for a hypothesis H as

W(H:E) = log \frac{P(E|H)}{P(E|\not H)} = log \frac{P(H|E)}{P(\not H|E)} - log \frac{P(H)}{P(\not H)}.

Author(s)

Russell Almond

Examples

##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (hnodes, hstatelists) 
{
    if (!is.list(hnodes)) 
        hnodes <- list(hnodes)
    if (!is.list(hstatelistss)) 
        hstatelists <- list(hstatelists)
    if (!all(sapply(hnodes, is.NeticaNode))) {
        stop("Expected a list of Netica nodes, got ", hnodes)
    }
    if (length(hstatelists) > length(hnodes)) {
        stop("More statelists than nodes.")
    }
    net <- NodeNetwork(hnodes[[1]])
    hlikes <- mapply(function(hnode, hstatelist) {
        stnames <- NodeStateNames(hnode)
        hlike <- rep(0, length(stnames))
        names(hlike) <- stnames
        hlike[hstatelist] <- 1
        hlike
    }, hnodes, hstatelists, SIMPLIFY = FALSE)
    tryCatch({
        for (i in 1:length(hnodes)) {
            RetractNodeFinding(hnodes[[i]])
            NodeLikelihood(hnodes[[i]]) <- hlike[[i]]
        }
        p_Htrue <- FindingsProbability(net)
        for (i in 1:length(hnodes)) {
            RetractNodeFinding(hnodes[[i]])
            NodeLikelihood(hnodes[[i]]) <- 1 - hlike[[i]]
        }
        p_Hfalse <- FindingsProbability(net)
        100 * log10(p_Htrue/p_Hfalse)
    }, finally = sapply(hnodes, RetractNodeFinding))
  }

[Package RNetica version 0.5-4 Index]