sevt_fit {stagedtrees} | R Documentation |
Fit a staged event tree
Description
Estimate transition probabilities in a staged event tree from data. Probabilities are estimated with the relative frequencies plus, eventually, an additive (Laplace) smoothing.
Usage
sevt_fit(
object,
data = NULL,
lambda = NULL,
scope = NULL,
compute_logLik = TRUE
)
Arguments
object |
an object of class |
data |
data.frame or contingency table with observations of
the variables in |
lambda |
smoothing parameter or pseudocount. Default (NULL) to
lambda value stored in |
scope |
which variable should be fitted. Default (NULL) to
all variables in the model. A partial re-fit is
possible only for model which are already fitted and in
that case the provided |
compute_logLik |
logical value. If |
Details
The data in form of contingency tables and the
log-likelihood of the model is (eventually)
stored in the returned staged event tree.
Partial re-fit of a model can be performed
with the scope
argument.
Partial re-fit can only be done over a
fully fitted model, e.g. when changing
the stages structure of one of the variables.
In case of a partial re-fit, the data
and lambda
arguments
will be ignored and the data and lambda value stored in the
sevt object will be used (a warning is issued if such arguments are
supplied).
Value
A fitted staged event tree,
that is an object of class sevt
with ctables
and prob
components.
Additionally the chosen lambda
is stored in the returned object
and eventually the log-likelihood of the model is saved in
the ll
field.
Examples
#########
model <- sevt(list(
X = c("good", "bad"),
Y = c("high", "low")
))
D <- data.frame(
X = c("good", "good", "bad"),
Y = c("high", "low", "low")
)
model.fit <- sevt_fit(model, data = D, lambda = 1)