Description Usage Arguments Value Examples
Creates a database of possible data from a data strategy.
Users can gather additional data on variables specified via vars
for any possible cases in the model ("any"). Or they can
gather data in all cases within a given dataset ("within"). Or they can specify the subset of cases for which within-case data should be collected (e.g. "Y == 1").
1 2 |
model |
A causal model as created by |
given |
A data frame in compact form with first column indicating event type and second column indicating number of events of that type. |
N |
Number of variables to seek |
within |
logical Whether to seek variables within existing data |
condition |
A list of character strings indicating for which cases data should be gathered. Options are: (i) to gather additional data on variables specified via |
vars |
Variables to be sought or NA. If NA |
A dataset
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | library(dplyr)
model <- make_model("X->M->Y") %>%
set_restrictions(causal_type_restrict = "Y[M=1]<Y[M=0] | M[X=1]<M[X=0] ") %>%
set_parameter_matrix()
df <- data.frame(X = c(0,0,0,1,1,1), M = NA, Y = c(0,0,1,0,1,1))
given <- summarize_data(model, df)[, -2]
# Look for data on M for all possible cases in the given data
make_possible_data_single(model, N = 2)
make_possible_data_single(model, given = given, vars = "M", within = TRUE, N = 2)
make_possible_data_single(model, given = given,
within = TRUE, vars = "M",
N = 2,
condition = "X==1 & Y==1")
model <- make_model("X -> M -> Y <- K") %>%
set_restrictions(causal_type_restrict = "(Y[M=1, K= .]<Y[M=0, K= .]) | M[X=1]<M[X=0] ") %>%
set_parameter_matrix()
given <- data.frame(X = c(0,0,0,1,1,1), K = NA, M = NA, Y = c(0,0,1,0,1,1)) %>%
collapse_data(model = model)
make_possible_data_single(model, given = given,
within = TRUE,
N = 2,
condition = "X==1",
vars = "M")
make_possible_data_single(model, given = given,
within = TRUE,
N = 2,
condition = "X==1 & Y==1",
vars = c("M", "K"))
model <- make_model("X->M->Y") %>%
set_restrictions(causal_type_restrict = "Y[M=1]<Y[M=0] | M[X=1]<M[X=0]") %>%
set_parameter_matrix()
given <- data.frame(X = c(0,0,0,1,1,1), M = NA, Y = c(0,0,1,0,1,1)) %>%
collapse_data(model)
make_possible_data_single(model,
given = given,
within = TRUE,
vars = "M",
N = 1,
condition = "X==1 & Y==1")
make_possible_data_single(model,
given = given,
within = TRUE,
vars = "M",
N = 1,
condition = "X==1")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.