Skip to contents

Generate full dataset

Usage

make_data_single(
  model,
  n = 1,
  parameters = NULL,
  param_type = NULL,
  given = NULL,
  w = NULL,
  P = NULL,
  A = NULL
)

Arguments

model

A causal_model. A model object generated by make_model.

n

An integer. Number of observations.

parameters

A numeric vector. Values of parameters may be specified. By default, parameters is drawn from priors.

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 define use arguments to be passed to make_priors; otherwise flat sets equal probabilities on each nodal type in each parameter set; prior_mean, prior_draw, posterior_mean, posterior_draw take parameters as the means or as draws from the prior or posterior.

given

A string specifying known values on nodes, e.g. "X==1 & Y==1"

w

Vector of event probabilities can be provided directly. This is useful for speed for repeated data draws.

P

A matrix. Parameter matrix that can be used to generate w if w is not provided

A

A matrix. Ambiguity matrix that can be used to generate w if w is not provided

Value

A data.frame of simulated data.

See also

Other data_generation: data_helpers, get_all_data_types(), observe_data()

Examples


model <- make_model("X -> Y")

# Simplest behavior uses by default the parameter vector contained in model
CausalQueries:::make_data_single(model, n = 5)
#>   X Y
#> 1 0 0
#> 2 0 1
#> 3 1 1
#> 4 1 1
#> 5 1 1

CausalQueries:::make_data_single(model, n = 5, param_type = "prior_draw")
#>   X Y
#> 1 1 0
#> 2 1 0
#> 3 1 0
#> 4 1 1
#> 5 1 1

# Simulate multiple datasets. This is fastest if
# event probabilities (w) are  provided
w <- get_event_probabilities(model)
replicate(5, CausalQueries:::make_data_single(model, n = 5, w = w))
#>   [,1]      [,2]      [,3]      [,4]      [,5]     
#> X numeric,5 numeric,5 numeric,5 numeric,5 numeric,5
#> Y numeric,5 numeric,5 numeric,5 numeric,5 numeric,5