Learn a dynamic network (structure and parameters) of a BN from a BNDataset (see the Details section).
This method is a wrapper for learn.network to simplify the learning of a dynamic network.
It provides an automated generation of the layering required to represent the set of time constraints
encoded in a dynamic network. In this function, it is assumed that the dataset contains the observations for each variable
in all the time steps:
V_1^{t_1}, V_2^{t_1}, V_n^{t_1}, V_1^{t_2}, ... , V_n^{t_k}.
Variables in time step j can be parents for any variable in time steps k>=j, but not for variables i<j.
If a layering is provided for a time step, it is valid in each time step, and not throughout the whole dynamic network;
a global layering can however be provided.
learn.dynamic.network(x, ...)# S4 method for BN
learn.dynamic.network(x, y = NULL,
num.time.steps = num.time.steps(y), algo = "mmhc",
scoring.func = "BDeu", initial.network = NULL, alpha = 0.05,
ess = 1, bootstrap = FALSE, layering = c(),
max.fanin = num.variables(y) - 1, max.fanin.layers = NULL,
max.parents = num.variables(y) - 1, max.parents.layers = NULL,
layer.struct = NULL, cont.nodes = c(), use.imputed.data = FALSE,
use.cpc = TRUE, mandatory.edges = NULL, ...)
# S4 method for BNDataset
learn.dynamic.network(x,
num.time.steps = num.time.steps(x), algo = "mmhc",
scoring.func = "BDeu", initial.network = NULL, alpha = 0.05,
ess = 1, bootstrap = FALSE, layering = c(),
max.fanin = num.variables(x) - 1, max.fanin.layers = NULL,
max.parents = num.variables(x) - 1, max.parents.layers = NULL,
layer.struct = NULL, cont.nodes = c(), use.imputed.data = FALSE,
use.cpc = TRUE, mandatory.edges = NULL, ...)
potential further arguments for methods.
the number of time steps to be represented in the dynamic BN.
the algorithm to use. Currently, one among sm (Silander-Myllymaki), mmpc
(Max-Min Parent-and-Children), mmhc (Max-Min Hill Climbing, default), hc
(Hill Climbing) and sem (Structural Expectation Maximization).
the scoring function to use. Currently, one among
BDeu, AIC, BIC.
network structure to be used as starting point for structure search.
Can take different values:
a BN object, a matrix containing the adjacency matrix of the structure of the network,
or the string random.chain to sample a random chain as starting point.
confidence threshold (only for mmhc).
Equivalent Sample Size value.
TRUE to use bootstrap samples.
vector containing the layers each node belongs to.
maximum number of parents for each node (only for hc, mmhc).
matrix of available parents in each layer (only for sm --
DEPRECATED, use max.parents.layers instead).
maximum number of parents for each node (for sm, hc, mmhc).
matrix of available parents in each layer (only for sm).
0/1 matrix for indicating which layers can contain parent nodes
for nodes in a layer (only for mmhc, mmpc).
vector containing the index of continuous variables.
TRUE to learn the structure from the imputed dataset
(if available, a check is performed). Default is to use raw dataset
(when using mmhc) compute Candidate Parent-and-Children sets instead of
starting the Hill Climbing from an empty graph.
binary matrix, where a 1 in cell [i,j]
indicates that an edge from node i to node j must be present
in the final network.
new BN object with structure (DAG) and conditional probabilities
as learnt from the given dataset.
The other parameters available are the ones of learn.network, refer to the documentation of that function
for more details. See also the documentation for learn.structure and learn.params for more informations.
learn.network learn.structure learn.params
# NOT RUN {
mydataset <- BNDataset("data.file", "header.file")
net <- learn.dynamic.network(mydataset, num.time.steps=2)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab