Pnet2Omega | R Documentation |
An Omega matrix (represented as a data frame) is a structure which
describes a Bayesian network as a series of regressions from the
parent nodes to the child nodes. It actually contains two matrixes,
one giving the structure and the other the regression coefficients.
If the parameters have not yet been added to nodes, then the function
will use the supplied default values allowing the parameters to later
be defined through the use of the function Pnet2Omega
.
Pnet2Omega(net, prof, defaultRule = "Compensatory", defaultLink = "normalLink",
defaultAlpha = 1, defaultBeta = 0, defaultLinkScale = 1, debug = FALSE)
net |
A |
prof |
A list of |
defaultRule |
This should be a character scalar giving the name
of a CPTtools combination rule (see
|
defaultLink |
This should be a character scalar giving the name
of a CPTtools link function (see |
defaultAlpha |
A numeric scalar giving the default value for slope parameters. |
defaultBeta |
A numeric scalar giving the default value for difficulty (negative intercept) parameters. |
defaultLinkScale |
A positive number which gives the default value for the link scale parameter. |
debug |
A logical value. If true, extra information will be printed during process of building the Omega matrix. |
Whittaker (1990) noted that a normal Bayesian network (one in which all nodes followed a standard normal distribution) could be described using the inverse of the covariance matrix, often denoted Omega. In particular, zeros in the inverse covariance matrix represented variables which were conditionally independent, and therefore reducing the matrix to one with positive and zero values could provide the structure for a graphical model. Almond (2010) proposed using this as the basis for specifying discrete Bayesian networks for the proficiency model in educational assessments (especially as correlation matrixes among latent variables are a possible output of a factor analysis).
The Omega matrix is represented with a data.frame
object which contains two square submatrixes and a couple of auxiliary
columns. The first column should be named “Node” and contains
the names of the nodes. This defines a collection of nodes
which are defined in the Omega matrix. Let J
be the number of
nodes (rows in the data frame). The next J
columns should
have the names the nodes. Their values give the structural
component of the matrix. The following two columns are “Link”
and “Rules” these give the name of the combination rule and
link function to use for this row. Next follows another series J
“A” columns, each should have a name of the form
“A.node”. This defines a matrix A
containing
regression coefficients. Finally, there should be two additional
columns, “Intercept” and “PriorWeight”.
Let Q
be the logical matrix formed by the J
columns after the
first and let A
be the matrix of coefficients. The matrix
Q
gives the structure of the graph with Q[i,j]
being true
when Node j
is a parent of node i. By convention,
Q[j,j]=1
. Note that unlike the inverse covariance matrix from
which it gets its name, this matrix is not symmetric. It instead
reflects the (possibly arbitrary) directions assigned to the edges.
Except for the main diagonal, Q[i,j]
and Q[j,i]
will not
both be 1. Note also, that A[i,j]
should be positive only when
Q[i,j]=1
. This provides an additional check that structures
were correctly entered if the Omega matrix is being used for data
entry.
When the link function is set to normalLink
and the
rules is set of Compensatory
the model is described as a
series of regressions. Consider Node j
which has K
parents. Let \theta_j
be a real value corresponding to that
node and let \theta_k
be a real (standard normal)
value representing Parent Node k
a_k
represent the
corresponding coefficient from the A
-table. Let \sigma_j =
a_{j,j}
that is the diagonal element of the A
-table
corresponding to the variable under consideration. Let b_j
be
the value of the intercept column for Node j
. Then the model
specifies that theta_j
has a normal distribution with mean
\frac{1}{\sqrt{K}}\sum a_k\theta_k + b_j,
and standard
deviation \sigma_j
. The regression is discretized to calculate
the conditional probability table (see
normalLink
for details).
Note that the parameters are deliberately chosen to look like a
regression model. In particular, b_j
is a normal intercept and
not a difficulty parameter, so that in general
PnodeBetas
applied to the corresponding node will have
the opposite sign. The 1/\sqrt{K}
term is a variance
stabilization parameter so that the variance of \theta_j
will
not be affected by number of parents of Node j
. The multiple
R-squared for the regression model is
\frac{1/K \sum a_k^2}{ 1/K \sum a_k^2 + \sigma_j^2} .
This is often a more convenient parameter to elicit than
\sigma_j
.
The function Pnet2Omega
builds an Omega matrix from an existing
Pnet
. Only the nodes specified in the prof
argument are included in the matrix, each row corresponding to a node.
The values in the “Node” column are taken from
PnodeName(node)
. The values in the structural
part of the matrix are taken from the graphical structure,
specifically PnodeParents(node)
. The
“Link” and “Rules” columns are taken from
PnodeLink(node)
and
PnodeRules(node)
. The off-diagonal elements of the
A-matrix are taken from the values of
PnodeAlphas(node)
and the diagonal elements from
PnodeLinkScale(node)
. The values in the
“Intercept” column are the negatives of the values
PnodeBetas(node)
. Finally, the values in the
“PriorWeight” column correspond to the values of
PnodePriorWeight(node)
; note that a value of
NA
indicates that the prior weight should be taken from the
Pnet
.
If the nodes do not yet have the various parameters set, then this
function will create a blank Omega matrix, with default values
(set from various optional arguments) for entries where the parameters
have not yet been set. This matrix can then be edited and read back
in with Omega2Pnet
as a way of setting the parameters of
the network.
An object of class (OmegaMat
,data.frame
)
with number of rows equal to the number of nodes. Throughout let
node stand for the name of a node.
Node |
The name of the node described in this column. |
node |
One column for each node. The value in this column should be 1 if the node in the column is regarded as a parent of the node referenced in the row. |
Link |
The name of a link function. Currently, “normalLink” is the only value supported. |
Rules |
The name of the combination rule to use. Currently, “Compensatory” is recommended. |
A.node |
One column for each node. This should be a positive value if the corresponding node column has a 1. This gives the regression coefficient. If node corresponds to the current row, this is the residual standard deviation rather than a regression coefficient. See details. |
Intercept |
A numeric value giving the change in prevalence for the two variables (see details). |
PriorWeight |
The amount of weight which should be given to the
current values when learning conditional probability tables. See
|
While the Omega matrix allows the user to specify both link function
and combination rule, the description of the Bayesian network as a
series of regressions only really makes sense when the link function
is normalLink
and the combination rule is
Compensatory
. These are included for future exapnsion.
The representation, using a single row of the data frame for each node
in the graph, only works well with the normal link function. In
particular, both the partial credit and graded response links require
the ability to specify different intercepts for different states of
the variable, something which is not supported in the Omega matrix.
Furthermore, the OffsetConjunctive
rule requires
multiple intercepts. Presumable the Conjunctive
rule
could be used, but the interpretation of the slope parameters is then
unclear. If the variables need a model other than the compensatory
normal model, it might be better to use a Q-matrix (see
Pnet2Qmat
to describe the variable.
Russell Almond
Whittaker, J. (1990). Graphical Models in Applied Multivariate Statistics. Wiley.
Almond, R. G. (2010). ‘I can name that Bayesian network in two matrixes.’ International Journal of Approximate Reasoning. 51, 167-178.
Almond, R. G. (presented 2017, August). Tabular views of Bayesian networks. In John-Mark Agosta and Tomas Singlair (Chair), Bayeisan Modeling Application Workshop 2017. Symposium conducted at the meeting of Association for Uncertainty in Artificial Intelligence, Sydney, Australia. (International) Retrieved from http://bmaw2017.azurewebsites.net/
The inverse operation is Omega2Pnet
.
See normalLink
and
Compensatory
for more
information about the mathematical model.
The node functions from which the Omega matrix is populated includes:
PnodeParents(node)
,
PnodeLink(node)
,
PnodeLinkScale(node)
,
PnodeRules(node)
,
PnodeAlphas(node)
,
PnodeBetas(node)
, and
PnodePriorWeight(node)
## Sample Omega matrix.
omegamat <- read.csv(system.file("auxdata", "miniPP-omega.csv",
package="Peanut"),
row.names=1,stringsAsFactors=FALSE)
## Not run:
library(PNetica) ## Needs PNetica
sess <- NeticaSession()
startSession(sess)
curd <- getwd()
netman1 <- read.csv(system.file("auxdata", "Mini-PP-Nets.csv",
package="Peanut"),
row.names=1,stringsAsFactors=FALSE)
nodeman1 <- read.csv(system.file("auxdata", "Mini-PP-Nodes.csv",
package="Peanut"),
row.names=1,stringsAsFactors=FALSE)
## Insures we are building nets from scratch
setwd(tempdir())
## Network and node warehouse, to create networks and nodes on demand.
Nethouse <- BNWarehouse(manifest=netman1,session=sess,key="Name")
Nodehouse <- NNWarehouse(manifest=nodeman1,
key=c("Model","NodeName"),
session=sess)
CM <- WarehouseSupply(Nethouse,"miniPP_CM")
CM1 <- Omega2Pnet(omegamat,CM,Nodehouse,override=TRUE,debug=TRUE)
Om2 <- Pnet2Omega(CM1,NetworkAllNodes(CM1))
class(omegamat) <- c("OmegMat","data.frame") # To match Pnet2Omega output.
omegamat$PriorWeight <- rep("10",nrow(omegamat))
stopifnot(all.equal(omegamat,Om2))
DeleteNetwork(CM)
stopSession(sess)
setwd(curd)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.