update_model | R Documentation |
Takes a model and data and returns a model object with data attached and a posterior model
update_model(
model,
data = NULL,
data_type = NULL,
keep_type_distribution = TRUE,
keep_event_probabilities = FALSE,
keep_fit = FALSE,
censored_types = NULL,
...
)
model |
A |
data |
A |
data_type |
Either 'long' (as made by |
keep_type_distribution |
Logical. Whether to keep the (transformed) distribution of the causal types. Defaults to 'TRUE' |
keep_event_probabilities |
Logical. Whether to keep the (transformed) distribution of event probabilities. Defaults to 'FALSE' |
keep_fit |
Logical. Whether to keep the |
censored_types |
vector of data types that are selected out of
the data, e.g. |
... |
Options passed onto sampling call. For
details see |
An object of class causal_model
. The returned model is a
list containing the elements comprising a model
(e.g. 'statement', 'nodal_types' and 'DAG') with the
posterior_distribution
returned by stan
attached to it.
make_model
allows to create new model,
summary.causal_model
provides summary method for
output objects of class causal_model
model <- make_model('X->Y')
data_long <- simulate_data(model, n = 4)
data_short <- collapse_data(data_long, model)
model <- update_model(model, data_long)
model <- update_model(model, data_short)
## Not run:
# It is possible to implement updating without data, in which
# case the posterior is a stan object that reflects the prior
update_model(model)
data <- data.frame(X=rep(0:1, 10), Y=rep(0:1,10))
# Censored data types
# We update less than we might because we are aware of filtered data
uncensored <-
make_model("X->Y") |>
update_model(data) |>
query_model(te("X", "Y"), using = "posteriors")
censored <-
make_model("X->Y") |>
update_model(
data,
censored_types = c("X1Y0")) |>
query_model(te("X", "Y"), using = "posteriors")
# Censored data: We learn nothing because the data
# we see is the only data we could ever see
make_model("X->Y") |>
update_model(
data,
censored_types = c("X1Y0", "X0Y0", "X0Y1")) |>
query_model(te("X", "Y"), using = "posteriors")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.