Create a list containing the data to be passed to 'stan
Arguments
- model
A
causal_model
. A model object generated bymake_model
.- data
A
data.frame
. Data of nodes that can take three values: 0, 1, and NA. In long form as generated bymake_events
Examples
# \donttest{
model <- make_model('X->Y')
data <- collapse_data(make_data(model, n = 6), model)
CausalQueries:::prep_stan_data(model, data)
#> $parmap
#> X0Y0 X1Y0 X0Y1 X1Y1
#> X.0 1 0 1 0
#> X.1 0 1 0 1
#> Y.00 1 1 0 0
#> Y.10 0 1 1 0
#> Y.01 1 0 0 1
#> Y.11 0 0 1 1
#> attr(,"map")
#> X0Y0 X1Y0 X0Y1 X1Y1
#> X0Y0 1 0 0 0
#> X1Y0 0 1 0 0
#> X0Y1 0 0 1 0
#> X1Y1 0 0 0 1
#>
#> $map
#> X0Y0 X1Y0 X0Y1 X1Y1
#> X0Y0 1 0 0 0
#> X1Y0 0 1 0 0
#> X0Y1 0 0 1 0
#> X1Y1 0 0 0 1
#>
#> $n_paths
#> [1] 4
#>
#> $n_params
#> [1] 6
#>
#> $n_param_sets
#> [1] 2
#>
#> $n_param_each
#> X Y
#> 2 4
#>
#> $l_starts
#> X Y
#> 1 3
#>
#> $l_ends
#> X Y
#> 2 6
#>
#> $node_starts
#> X Y
#> 1 3
#>
#> $node_ends
#> X Y
#> 2 6
#>
#> $n_nodes
#> [1] 2
#>
#> $lambdas_prior
#> X.0 X.1 Y.00 Y.10 Y.01 Y.11
#> 1 1 1 1 1 1
#>
#> $n_data
#> [1] 4
#>
#> $n_events
#> [1] 4
#>
#> $n_strategies
#> [1] 1
#>
#> $strategy_starts
#> [1] 1
#>
#> $strategy_ends
#> [1] 4
#>
#> $keep_type_distribution
#> [1] 1
#>
#> $E
#> X0Y0 X1Y0 X0Y1 X1Y1
#> X0Y0 1 0 0 0
#> X1Y0 0 1 0 0
#> X0Y1 0 0 1 0
#> X1Y1 0 0 0 1
#>
#> $Y
#> [1] 1 1 0 4
#>
#> $P
#> X0.Y00 X1.Y00 X0.Y10 X1.Y10 X0.Y01 X1.Y01 X0.Y11 X1.Y11
#> X.0 1 0 1 0 1 0 1 0
#> X.1 0 1 0 1 0 1 0 1
#> Y.00 1 1 0 0 0 0 0 0
#> Y.10 0 0 1 1 0 0 0 0
#> Y.01 0 0 0 0 1 1 0 0
#> Y.11 0 0 0 0 0 0 1 1
#>
#> $n_types
#> [1] 8
#>
model <- make_model('X->Y') |>
set_confound(list(X = 'Y[X=1]>Y[X=0]'))
data <- collapse_data(make_data(model, n = 6), model)
CausalQueries:::prep_stan_data(model, data)
#> $parmap
#> X0Y0 X1Y0 X0Y1 X1Y1
#> Y.00 1 1 0 0
#> Y.10 0 1 1 0
#> Y.01 1 0 0 1
#> Y.11 0 0 1 1
#> attr(,"map")
#> X0Y0 X1Y0 X0Y1 X1Y1
#> X0Y0 1 0 0 0
#> X1Y0 0 1 0 0
#> X0Y1 0 0 1 0
#> X1Y1 0 0 0 1
#>
#> $map
#> X0Y0 X1Y0 X0Y1 X1Y1
#> X0Y0 1 0 0 0
#> X1Y0 0 1 0 0
#> X0Y1 0 0 1 0
#> X1Y1 0 0 0 1
#>
#> $n_paths
#> [1] 4
#>
#> $n_params
#> [1] 4
#>
#> $n_param_sets
#> [1] 1
#>
#> $n_param_each
#> Y
#> 4
#>
#> $l_starts
#> Y
#> 1
#>
#> $l_ends
#> Y
#> 4
#>
#> $node_starts
#> Y
#> 1
#>
#> $node_ends
#> Y
#> 4
#>
#> $n_nodes
#> [1] 1
#>
#> $lambdas_prior
#> Y.00 Y.10 Y.01 Y.11
#> 1 1 1 1
#>
#> $n_data
#> [1] 4
#>
#> $n_events
#> [1] 4
#>
#> $n_strategies
#> [1] 1
#>
#> $strategy_starts
#> [1] 1
#>
#> $strategy_ends
#> [1] 4
#>
#> $keep_type_distribution
#> [1] 1
#>
#> $E
#> X0Y0 X1Y0 X0Y1 X1Y1
#> X0Y0 1 0 0 0
#> X1Y0 0 1 0 0
#> X0Y1 0 0 1 0
#> X1Y1 0 0 0 1
#>
#> $Y
#> [1] 2 0 3 1
#>
#> $P
#> X0.Y00 X1.Y00 X0.Y10 X1.Y10 X0.Y01 X1.Y01 X0.Y11 X1.Y11
#> Y.00 1 1 0 0 0 0 0 0
#> Y.10 0 0 1 1 0 0 0 0
#> Y.01 0 0 0 0 1 1 0 0
#> Y.11 0 0 0 0 0 0 1 1
#>
#> $n_types
#> [1] 8
#>
# }