random_sevt {stagedtrees} | R Documentation |
Generate a random (fitted) sevt
Description
Generate a random sevt
from a DAG or a tree.
Probabilities are also randomly generated.
Usage
random_sevt(x, q = 0.5, rfun = rexp)
## S3 method for class 'list'
random_sevt(x, q = 0.5, rfun = rexp)
## S3 method for class 'parentslist'
random_sevt(x, q = 0.5, rfun = rexp)
## S3 method for class 'sevt'
random_sevt(x, q = 0.5, rfun = rexp)
Arguments
x |
a |
q |
probability of joining stages. |
rfun |
a function which is used to generate random conditional probabilities associated to each stage. |
Details
The generated staged tree is obtained by randomly
joining stages with probability q
.
For random_sevt.list
, x
should be
a list representing an event tree, same format
as lists provided to sevt.list
.
The random generated sevt
will be
obtained by randomly joining stages starting from
a full staged event tree.
For random_sevt.parentslist
, x
should be
a parentslist
object
representing a DAG, this could be obtained with
as_parentslist
or with
random_parentslist
.
The random generated sevt
will be
obtained by randomly joining stages starting from
a the staged tree equivalent to the DAG.
For random_sevt.sevt
, x
should be
a sevt
.
The random generated sevt
will be
obtained by randomly joining stages starting
from the provided sevt object.
Stages (conditional) probabilities are sampled from the corresponding probability simplex by generating a vector with the user-defined function \code{rfun} and normalizing it to sum up to one. Absolute value is applied to assure non-negativity. The default \code{rfun = rexp} induces a uniform sampling from the probability simplex.
Value
A randomly generated fitted sevt
object.
Examples
model_gt <- random_sevt(list(
X = c("a", "b"), Y = c("c", "d", "e"),
Z = c("1", "2", "3"), W = c("yes", "no")
))
## sample data from model_gt and estimate a staged tree
data <- sample_from(model_gt, 100)
model_est <- stages_bhc(full(data))
## compare true and estimated model
hamming_stages(model_gt, model_est)
compare_stages(model_gt, model_est, method = "hamming", plot = TRUE)