make_parameters {CausalQueries}R Documentation

Make a 'true' parameter vector


A vector of 'true' parameters; possibly drawn from prior or posterior.


  parameters = NULL,
  param_type = NULL,
  warning = TRUE,
  normalize = TRUE,



A causal_model. A model object generated by make_model.


A vector of real numbers in [0,1]. Values of parameters to specify (optional). By default, parameters is drawn from model$parameters_df.


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.


Logical. Whether to warn about parameter renormalization.


Logical. If parameter given for a subset of a family the residual elements are normalized so that parameters in param_set sum to 1 and provided params are unaltered.


Options passed onto make_priors.


A vector of draws from the prior or distribution of parameters

See Also

Other parameters: get_parameters(), set_parameters()


# Simple examples
model <- make_model('X -> Y')
data  <- simulate_data(model, n = 2)
model <- update_model(model, data)
make_parameters(model, parameters = c(.25, .75, 1.25,.25, .25, .25))
make_parameters(model, param_type = 'flat')
make_parameters(model, param_type = 'prior_draw')
make_parameters(model, param_type = 'prior_mean')
make_parameters(model, param_type = 'posterior_draw')
make_parameters(model, param_type = 'posterior_mean')

# Harder examples, using \code{define} and priors arguments to define
# specific parameters using causal syntax

# Using labels: Two values for two nodes with the same label
make_model('X -> M -> Y') %>% make_parameters(label = "01", parameters = c(0,1))

# Using statement:
make_model('X -> Y') %>%
   make_parameters(statement = c('Y[X=1]==Y[X=0]'), parameters = c(.2,0))
make_model('X -> Y') %>%
   make_parameters(statement = c('Y[X=1]>Y[X=0]', 'Y[X=1]<Y[X=0]'), parameters = c(.2,0))

# Normalize renormalizes values not set so that value set is not renomalized
make_parameters(make_model('X -> Y'),
               statement = 'Y[X=1]>Y[X=0]', parameters = .5)
make_parameters(make_model('X -> Y'),
               statement = 'Y[X=1]>Y[X=0]', parameters = .5, normalize = FALSE)

# May be built up
make_model('X -> Y') %>%
  set_confound(list(X = 'Y[X=1]>Y[X=0]'))  %>%
  set_parameters(confound   = list(X='Y[X=1]>Y[X=0]', X='Y[X=1]<=Y[X=0]'),
                 parameters = list(c(.2, .8), c(.8, .2))) %>%
  set_parameters(statement  = 'Y[X=1]>Y[X=0]', parameters = .5) %>%

[Package CausalQueries version 0.0.3 Index]