updateStats | R Documentation |
When the student model of a StudentRecord
changes, because the function updateSM
has been run, the
statistics need to be recalculated. The function updateStats
recalculates the statistics. The function announceStats
lets
the listeners know that new statistics are available for this user.
updateStats(eng, rec, debug = 0)
announceStats(eng, rec)
eng |
A |
rec |
A |
debug |
An integer flag. If the value is greater than 1, there
will be a call |
The BNEngine
contains a number of
Statistic
objects. Every time the student model
(sm
) of the StudentRecord
changes,
the stats
of the record need to be updated as well.
The function updateStats
simply loops through the statistic
collection and calculates the new values. The corresponding field of
the student record is then updated.
The function announceStats
takes the new statistic values and
generates a P4Message
containing the new
statistics. This is sent to all of the Listener
objects in the ListenerSet
attached to the
engine.
The function stats
returns the latest statistics from
the student record.
The function updateStats
returns the updates
StudentRecord
object.
The function announceStats
is called for its side effects. Its
return value should not be used.
Russell Almond
Almond, Mislevy, Steinberg, Yan and Williamson (2015). Bayesian Networks in Educational Assessment. Springer. Especially Chapters 5 and 13.
Classes:
BNEngine
, ListenerSet
StudentRecord
, Statistic
,
P4Message
Functions in EABN:
accumulateEvidence
, updateHist
,
updateSM
, stats
Peanut Functions:
calcStat
Proc4Functions
notifyListeners
## Requires PNetica
library(PNetica) ## Must load to setup Netica DLL
app <- "ecd://epls.coe.fsu.edu/EITest"
sess <- RNetica::NeticaSession()
RNetica::startSession(sess)
config.dir <- file.path(library(help="Peanut")$path, "auxdata")
net.dir <- file.path(library(help="PNetica")$path,"testnets")
netman <- read.csv(file.path(config.dir, "Mini-PP-Nets.csv"),
row.names=1, stringsAsFactors=FALSE)
stattab <- read.csv(file.path(config.dir, "Mini-PP-Statistics.csv"),
as.is=TRUE)
Nethouse <- PNetica::BNWarehouse(netman,session=sess,
address=net.dir)
cl <- new("CaptureListener")
listeners <- list("cl"=cl)
ls <- ListenerSet(sender= paste("EAEngine[",app,"]"),
db=MongoDB(noMongo=TRUE), listeners=listeners)
eng <- newBNEngineNDB(app=app,warehouse=Nethouse,
listenerSet=ls,manifest=netman,
profModel="miniPP_CM",
histNodes="Physics",
statmat=stattab,
activeTest="EAActive.txt")
## Standard initialization methods.
loadManifest(eng,netman)
eng$setHistNodes("Physics")
configStats(eng,stattab)
setupDefaultSR(eng)
sr0 <- getRecordForUser(eng,"S1")
eap0 <- stat(sr0,"Physics_EAP")
e1 <- EvidenceSet(uid="S1",app="Test",context="PPcompEM",
obs=list("CompensatoryObs"="Right"))
sr1 <- updateRecord(sr0,e1)
sr1 <- updateSM(eng,sr1,e1)
sr1 <- updateStats(eng,sr1)
eap1 <- stat(sr1,"Physics_EAP")
## This should have changed.
stopifnot(abs(eap1-eap0) > .001)
announceStats(eng,sr1)
## Look at the resulting message.
cl$lastMessage()
details(cl$lastMessage())
stopifnot(uid(cl$lastMessage())=="S1",context(cl$lastMessage())=="PPcompEM")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.