history: Retrieves node histories from a Student Record

historyR Documentation

Retrieves node histories from a Student Record

Description

A history is a data.frame whose rows correspond to EvidenceSet objects and whose columns correspond to the states of a Pnode. Each row is a probability distribution, and they show the changes to the probabilities over time.

The function history returns the history for a single node in a given StudentRecord. The function histNames returns the names of the nodes for which the record has history information.

Usage

history(sr, name)
histNames(sr)

Arguments

sr

A StudentRecord whose history is to be accessed.

name

The name of the node whose history is requested.

Details

When the student record is first initialized, the function baselineHist is called to setup “*BASELINE*” values for each of the history nodes identified by the BNEngine. These are data.frame objects giving the prior marginal distributions for each of the identified variables.

After the student model is updated in response to evidence (see handleEvidence, the updateHist function is called to add a new row to each of the data frames.

The histNames function returns the names of the history nodes being tracked by a student model. The history function returns the history for a node.

Value

The function histNames returns a list of node names. These are suitable for the name argument of the history function.

The function history returns a data frame with rows corresponding to evidence sets and columns corresponding to states of the variables. Each row is a marginal probability distribution.

Note

These are designed to work with the functions woeHist and woeBal in the CPTtools-package.

Author(s)

Russell Almond

See Also

StudentRecord for student records.

baselineHist and updateHist for history construction.

BNEngine for specifying the history nodes.

woeHist and woeBal for applications.

Examples


library(PNetica)

##Start with manifest
sess <- RNetica::NeticaSession()
RNetica::startSession(sess)

## BNWarehouse is the PNetica Net Warehouse.
## This provides an example network manifest.
config.dir <- file.path(library(help="Peanut")$path, "auxdata")
netman1 <- read.csv(file.path(config.dir,"Mini-PP-Nets.csv"),
                    row.names=1, stringsAsFactors=FALSE)
net.dir <- file.path(library(help="PNetica")$path, "testnets")
Nethouse <- PNetica::BNWarehouse(manifest=netman1,session=sess,key="Name",
                       address=net.dir)
dsr <- StudentRecord("*DEFAULT*",app="ecd://epls.coe.fsu.edu/P4Test",
                     context="*Baseline*")
sm(dsr) <- WarehouseSupply(Nethouse,"miniPP_CM")
PnetCompile(sm(dsr))
## dsr <- updateStats(eng,dsr)

statmat <- read.csv(file.path(config.dir,"Mini-PP-Statistics.csv"),
                    stringsAsFactors=FALSE)
rownames(statmat) <- statmat$Name
statlist <- sapply(statmat$Name,function (st)
    Statistic(statmat[st,"Fun"],statmat[st,"Node"],st))
names(statlist) <- statmat$Name 
dsr@stats <- lapply(statlist,
                    function (stat) calcStat(stat,sm(dsr)))
names(dsr@stats) <- names(statlist)
stat(dsr,"Physics_EAP")
stat(dsr,"Physics_Margin")

## dsr <- baselineHist(eng,dsr)

dsr@hist <- lapply(c("Physics"),
                     function (nd)
                     EABN:::uphist(sm(dsr),nd,NULL,"*Baseline*"))
names(dsr@hist) <- "Physics"
stopifnot(histNames(dsr)=="Physics")
history(dsr,"Physics")



ralmond/EABN documentation built on Aug. 30, 2023, 12:52 p.m.