readHistory | R Documentation |
In running a typical Bayes net engine, as each piece of
evidence comes in, updated marginal distributions for several
variables are output. This function reads a such a log,
expressed as a data frame, and creates a data structure
suitable for doing weight of evidence analyses. The
probabilities are in the pvec (parseProbVec
)
format.
readHistory(histdat, obscol = "Item", valcol = "Result",
probcol="Probability")
histdat |
A data frame which has columns corresponding to
|
.
obscol |
Name of the column with the name of the observable at each time point. |
valcol |
Name of the column with the value of the observable at each time point. |
probcol |
Name of the column with the probabity vectors. |
The assumption is that the histdat
data frame contains
a history of measurements on a latent variable. The
probcol column should contain a probability vector of
the form: [High:0.527,Medium:0.447,Low:0.025]
. This
function parses this column (see parseProbVec
) and
builds a matrix with columns corresponding to the states of the
latent variable.
The rows are given names of the form, <obscol>=<valcol>
,
where <obscol>
and <valcol>
are the values in
the respective columns.
A matrix whose column names are taken from the probability
vectors and row names are taken from the obscol
and
valcol
fields.
The previous version (a) directly read the CSV file, and (b) had the names of the columns hard coded. This version will break any code that relied on the old version. However, it is hopefully more generally useful.
Russell Almond
http://research.ets.org/~ralmond/StatShop/dataFormats.html
parseProbVec
, woeHist
testFiles <- system.file("testFiles",package="CPTtools")
allcorrect <- readHistory(read.csv(file.path(testFiles,
"CorrectSequence.csv"),as.is=TRUE),
probcol="Margin.sequences.")
woeHist(allcorrect,"High",c("Medium","Low"))
allincorrect <- readHistory(read.csv(file.path(testFiles,
"InCorrectSequence.csv"),as.is=TRUE),
probcol="Margin.sequences.")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.