R: learn a dynamic network (structure and parameters) of a BN...

learn.dynamic.network {bnstruct} | R Documentation

## learn a dynamic network (structure and parameters) of a BN from a BNDataset.

### Description

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.

### Usage

    learn.dynamic.network(x, ...)

    ## S4 method for signature '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 signature '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,
      ...
    )

### Arguments

`x` | can be a `BN` or a `BNDataset`. If `x` is a `BN`, then also the `dataset` parameter must be given.
`...` | potential further arguments for methods.
`y` | a `BNDataset` object, to be provided only if `x` is a `BN`.
`num.time.steps` | the number of time steps to be represented in the dynamic BN.
`algo` | 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).
`scoring.func` | the scoring function to use. Currently, one among `BDeu`, `AIC`, `BIC`.
`initial.network` | 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.
`alpha` | confidence threshold (only for `mmhc`).
`ess` | Equivalent Sample Size value.
`bootstrap` | `TRUE` to use bootstrap samples.
`layering` | vector containing the layers each node belongs to.
`max.fanin` | maximum number of parents for each node (only for `hc`, `mmhc`).
`max.fanin.layers` | matrix of available parents in each layer (only for `sm` – DEPRECATED, use `max.parents.layers` instead).
`max.parents` | maximum number of parents for each node (for `sm`, `hc`, `mmhc`).
`max.parents.layers` | matrix of available parents in each layer (only for `sm`).
`layer.struct` | `0/1` matrix for indicating which layers can contain parent nodes for nodes in a layer (only for `mmhc`, `mmpc`).
`cont.nodes` | vector containing the index of continuous variables.
`use.imputed.data` | `TRUE` to learn the structure from the imputed dataset (if available, a check is performed). Default is to use raw dataset
`use.cpc` | (when using `mmhc`) compute Candidate Parent-and-Children sets instead of starting the Hill Climbing from an empty graph.
`mandatory.edges` | 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.

### Details

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.

### Value

new `BN` object with structure (DAG) and conditional probabilities as learnt from the given dataset.

### See Also

learn.network learn.structure learn.params

### Examples

    ## Not run:
    mydataset <- BNDataset("data.file", "header.file")

    net <- learn.dynamic.network(mydataset, num.time.steps=2)

    ## End(Not run)

[Package bnstruct version 1.0.9 Index]