buildRegressionTables | R Documentation |
Takes a description of a normal graphical model as a series of regressions and a description of the corresponding discrete variables and builds a series of conditional probability tables for the corresponding Bayesian network.
buildRegressionTables(regs, pvecs, mean = 0, std = 1)
regs |
A list with names corresponding to the variables in the model giving a series of regression coefficients (see Details). |
pvecs |
A list with names corresponding to the variables in the model giving a series of probability vectors in order from highest state to lowest state (see Details). |
mean |
A vector of means for the continuous variables. |
std |
A vector of standard deviations for the continuous variables. |
The regs
argument should be a list whose names are the names of
the variables. Each element should have the following fields:
A vector of slopes for the regression with names equal to the
names of the parent variables. Note that if there are no parents,
this should be numeric(0)
.
The intercept from the regression.
The residual standard deviation from the regression.
The function buildRegressions()
creates an appropriate list.
The pvecs
should be a list whose names are the names of the
variables. Each element should be a named vector of probabilities in
order from the Highest to the Lowest state, e.g.
c(High=.2,Med=.5,Low=.3)
.
The values mean
and std
should either be scalars or
vectors of the same length as the number of elements in regs
and pvecs
. If vectors, they should have names corresponding to
the variable names. Note that the order of the elements does not need
to be the same in all four arguments, but that the names of all four
arguments need to be identical (unless mean
or std
are
given as scalars, in which case they will be appropriately
replicated.)
A list of conditional probability tables whose names correspond to
regs
. Each conditional probability table is expressed as a
data frame whose columns correspond to either parent variables or
states of the child variable and whose rows correspond to
configurations of the parent variable.
Variables are given from highest to lowest state, for
example ‘High’, ‘Medium’, ‘Low’. This is the
order expected by StatShop. Note that pvecToCutpoints
expects probability vectors in the opposite order.
Russell Almond
Almond, R. G. (2010). ‘I can name that Bayesian network in two matrixes.’ International Journal of Approximate Reasoning. 51, 167-178.
Whittaker, J. (1990). Graphical Models in Applied Multivariate Statistics. Wiley.
buildRegressions
data(MathGrades)
pl <- buildParentList(structMatrix(MathGrades$var),"Algebra")
rt <- buildRegressions(MathGrades$var,MathGrades$means,pl)
tabs <- buildRegressionTables(rt, MathGrades$pvecs, MathGrades$means,
sqrt(diag(MathGrades$var)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.