View source: R/buildWeatherGenerator.R
buildWeatherGenerator | R Documentation |
Builds a discrete weather generator Bayesian network model, using
bnlearn. Data should be discretized prior to calling
the function by the user. The Bayesian network will approximate the Joint Probability
Distribution of the dataset y
considering the temporal order specified in epochs
.
buildWeatherGenerator(
y,
x = NULL,
structure.learning.algorithm = "tabu",
structure.learning.args.list = list(),
param.learning.method = "bayes",
epochs = 2,
force.DD = NULL,
forbid.GG = FALSE,
forbid.DD = FALSE,
forbid.DtoG = FALSE,
force.closest.GD = NULL,
closest.GD.direction = NULL,
forbid.GD = FALSE,
structure.learning.steps = 1,
fix.intermediate = TRUE,
structure.learning.algorithm2 = NULL,
structure.learning.args.list2 = list(),
structure.learning.algorithm3 = NULL,
structure.learning.args.list3 = list(),
keep.dynamic.distance = TRUE,
remove.past.G = TRUE,
forbid.backwards = FALSE,
forbid.past.dynamic.GD = TRUE,
forbid.dynamic.GG = FALSE,
forbid.past.DD = FALSE,
return.intermediate = FALSE,
compile.junction = FALSE,
parallelize = FALSE,
n.cores = NULL,
cluster.type = "FORK"
)
y |
Stations dataset, as output by |
x |
By default |
structure.learning.algorithm |
Algorithm used to perform structure learning, with name
as text. Supports all the score-based, constraint-based and hybrid bayesian network structure
learning algorithms from |
structure.learning.args.list |
List of arguments passed to structure.learning.algorithm,
in particular distance argument if local learning is used. Note that other arguments, e.g.
|
param.learning.method |
Either "bayes", for bayesian estimation; or "mle", for Maximum Likelihood Estimation. |
epochs |
Number of epochs to consider for Dynamic Bayesian Networks. |
force.DD |
If set to "-", the final DAG will be force to have a link between each station and its past. If set to "->" the arc will be forced from past to present, and from present to past if set to "<-". |
forbid.GG |
If set to TRUE, arcs between grid or G nodes will be forbidden. |
forbid.DD |
If set to TRUE, arcs between local, i.e. station or D nodes, will be forbidden. |
forbid.DtoG |
If set to TRUE, arcs from D nodes to G nodes will be forbidden. |
force.closest.GD |
Expects a positive integer or |
closest.GD.direction |
Either |
forbid.GD |
If set to TRUE, arcs between G and D nodes will be forbidden. See
|
structure.learning.steps |
It is used to perform structure learning in up to three steps.
Note that
Note that only first two options are valid when |
fix.intermediate |
Set to TRUE to forbid the creation of new arcs in the next steps
for already built DAGs. See |
structure.learning.algorithm2 |
Same as structure.learning.algorithm for the second
step if |
structure.learning.args.list2 |
Same as structure.learning.args.list for the second
step if |
structure.learning.algorithm3 |
Same as structure.learning.algorithm for the third
step if |
structure.learning.args.list3 |
Same as structure.learning.args.list for the third step
if |
keep.dynamic.distance |
When |
remove.past.G |
When |
forbid.backwards |
When |
forbid.past.dynamic.GD |
When |
forbid.dynamic.GG |
When |
forbid.past.DD |
When |
return.intermediate |
Add the intermediate DAGs to the output, as $intermediateDBN1 and
$intermediateDBN2 (if any) if |
compile.junction |
Compile the junction tree from BN.fit to compute probabilities. Can be set to FALSE. Compiling the junction tree is necessary for using exact inference at the simulating stage. |
parallelize |
Set to |
n.cores |
When |
cluster.type |
Either "PSOCK" or "FORK". Use the former under Windows systems,
refer to |
buildWeatherGenerator() can be used with just a stations dataset. A Grid dataset may be specified
by either using parameter x
or using a "pp.forBN" class object (as output from
preparePredictorsBN()
) for parameter y
. If none is specified the Bayesian
Network may be used as a naive weather generator.
Structure Learning Algorithms
Use structure.learning.algorithm
to specify the algorithm for the structure (DAG) learning
process.
Currently it DOES NOT support local discovery algorithms, expect malfuncion if used.
List of supported algorithms:
"hc"
, "tabu"
(score-based), "gs"
, "iamb"
, "fast.iamb"
,
"inter.iamb"
(constraint-based),
"mmhc"
, "rsmax2"
(hybrid).
Check their corresponding parameters in bnlearn
, arguments may be
passed to the algorithm through
the parameter structure.learning.args.list. Do not forget to set the distance argument
in structure.learning.args.list
for
local learning.
Two or Three Step Learning
structure.learning.steps
allows to build separate DAGs for each set of nodes.
Note that by employing the three structure.learning.algorithm
,
structure.learning.algorithm2
, structure.learning.algorithm3
arguments and their
corresponding structure.learning.args.list*
counterparts, many different configurations
can be used for the structure learning process, e.g. by using grow-shrink for D nodes with
distance set to 1, then injecting the left nodes using hill-climbing without distance
restriction.
fix.intermediate
, if set to TRUE
, will forbid the creation of new arcs
between nodes that were present in the previous learning step. E.g. if
structure.learning.steps = c("local", "global\-past")
, no new arcs between D nodes
will be created in the second step, as the first DAG will be considered finished.
If set to FALSE
, the previous step DAG will be kept, but the next
learning algorithm could create new arcs between D nodes over the first one.
Forbidding or Forcing Arcs
force.DD
, forbid.GG
, forbid.DD
, forbid.DtoG
, force.closest.GD
,
forbid.GD
, fix.intermediate
, structure.learning.steps
allow for
introducing constraints to the structure learning algorithm. The user might also combine them
with structure.learning.args.list$whitelist
and
structure.learning.args.list$blacklist
. As whitelist
has priority over
blacklist
, i.e. an arc placed in both will always be present in the DAG, they provide
maximum flexibility. Bearing the priority of the whitelist
, force.closest.GD = TRUE
and forbid.GD = TRUE
will, for example, forbid the placement of aditional
arcs beyond those specified as the closest G-D.
When manually specifying a whitelist or blacklist through structure.learning.args.list
,
beware of the naming convention. It overrides the names and marks them as either "D.X" or "G.X",
predictand and predictor nodes, respectivelly. A plot of a dummy network using plotDBN()
is may help.
An object of type CBN which contains the learnt Bayesian Network.
Mikel N. Legasa
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.