View source: R/10-comparison-functions.R
compare_stages | R Documentation |
Compare two staged event trees, return the differences of the stages structure and plot the difference tree. Three different methods to compute the difference tree are available (see Details).
compare_stages( object1, object2, method = "naive", return_tree = FALSE, plot = FALSE, ... ) hamming_stages(object1, object2, return_tree = FALSE) diff_stages(object1, object2)
object1 |
an object of class |
object2 |
an object of class |
method |
character, method to compare staged event trees.
One of: |
return_tree |
logical, if |
plot |
logical. |
... |
additional parameters to be passed to |
compare_stages
tests if the stage structure of two sevt
objects
is the same.
Three methods are available:
naive
first applies stndnaming
to both
objects and then simply compares the resulting stage names.
hamming
uses the hamming_stages
function that finds
a minimal subset of nodes which stages
must be changed to obtain the same structure.
stages
uses the diff_stages
function that compares
stages to check whether the same stage structure is present in both models.
Setting return_tree = TRUE
will return the stages
difference obtained with the selected method.
The stages difference is a list of numerical vectors with same
lengths and structure as stages(object1)
or stages(object2)
,
where values are 1 if the corresponding node has different
(with respect to the selected method
) associated stage, and
0 otherwise.
With plot = TRUE
the plot of the difference tree is displayed.
If return_tree = FALSE
and plot = FALSE
the logical output is the same for the
three methods and thus the naive
method should be used
since it is computationally faster.
hamming_stages
finds a minimal set of nodes for which the associated stages
should be changed to obtain equivalent structures. To do that, a maximum-weight bipartite
matching problem between the stages of the two staged trees is solved using the
Hungarian method implemented in the solve_LSAP
function of the clue
package.
hamming_stages
requires the package clue
.
compare_stages
: if return_tree = FALSE
, logical: TRUE
if the two
models are exactly equal, otherwise FALSE
.
Else if return_tree = TRUE
, the differences between
the two trees, according to the selected method
.
hamming_stages
: if return_tree = FALSE
, integer, the minimum
number of situations where the stage should be changed to obtain the same
models. If return_tree = TRUE
a stages-like structure showing which
situations should be modified to obtain the same models.
diff_stages
: a stages-like structure marking the situations belonging
to stages which are not the exactly equal.
data("Asym") mod1 <- stages_bhc(full(Asym, lambda = 1)) mod2 <- stages_fbhc(full(Asym, lambda = 1)) compare_stages(mod1, mod2) ########## m0 <- full(PhDArticles[, 1:4], lambda = 0) m1 <- stages_bhc(m0) m2 <- stages_bj(m0, distance = "totvar", thr = 0.25) diff_stages(m1, m2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.