make_data | R Documentation |
Make data
make_data(
model,
n = NULL,
parameters = NULL,
param_type = NULL,
nodes = NULL,
n_steps = NULL,
probs = NULL,
subsets = TRUE,
complete_data = NULL,
given = NULL,
verbose = TRUE,
...
)
model |
A |
n |
Non negative integer. Number of observations. If not provided it is inferred from the largest n_step. |
parameters |
A vector of real numbers in [0,1]. Values of parameters to
specify (optional). By default, parameters is drawn from
|
param_type |
A character. String specifying type of parameters to
make ("flat", "prior_mean", "posterior_mean", "prior_draw",
"posterior_draw", "define"). With param_type set to |
nodes |
A |
n_steps |
A |
probs |
A |
subsets |
A |
complete_data |
A |
given |
A string specifying known values on nodes, e.g. "X==1 & Y==1" |
verbose |
Logical. If TRUE prints step schedule. |
... |
additional arguments that can be passed to
|
Note that default behavior is not to take account of whether a node has already been observed when determining whether to select or not. One can however specifically request observation of nodes that have not been previously observed.
A data.frame
with simulated data.
# Simple draws
model <- make_model("X -> M -> Y")
make_data(model)
make_data(model, n = 3, nodes = c("X","Y"))
make_data(model, n = 3, param_type = "prior_draw")
make_data(model, n = 10, param_type = "define", parameters = 0:9)
# Data Strategies
# A strategy in which X, Y are observed for sure and M is observed
# with 50% probability for X=1, Y=0 cases
model <- make_model("X -> M -> Y")
make_data(
model,
n = 8,
nodes = list(c("X", "Y"), "M"),
probs = list(1, .5),
subsets = list(TRUE, "X==1 & Y==0"))
# n not provided but inferred from largest n_step (not from sum of n_steps)
make_data(
model,
nodes = list(c("X", "Y"), "M"),
n_steps = list(5, 2))
# Wide then deep
make_data(
model,
n = 8,
nodes = list(c("X", "Y"), "M"),
subsets = list(TRUE, "!is.na(X) & !is.na(Y)"),
n_steps = list(6, 2))
make_data(
model,
n = 8,
nodes = list(c("X", "Y"), c("X", "M")),
subsets = list(TRUE, "is.na(X)"),
n_steps = list(3, 2))
# Example with probabilities at each step
make_data(
model,
n = 8,
nodes = list(c("X", "Y"), c("X", "M")),
subsets = list(TRUE, "is.na(X)"),
probs = list(.5, .2))
# Example with given data
make_data(model, given = "X==1 & Y==1", n = 5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.