Learn R Programming

CausalQueries (version 0.0.3)

make_par_values: make_par_values

Description

This is the one step function for make_priors and make_parameters. See make_priors for more help.

Usage

make_par_values(
  model,
  y = get_priors(model),
  x = NA,
  distribution = NA,
  node = NA,
  label = NA,
  statement = NA,
  confound = NA,
  nodal_type = NA,
  param_names = NA,
  param_set = NA,
  normalize = FALSE
)

Arguments

model

A model created with make_model

y

Vector of real non negative values to be changed

x

Vector of real non negative values to be substituted into y

distribution

String indicating a common prior distribution (uniform, jeffreys or certainty)

node

A string indicating nodes for which priors are to be altered

label

String. Label for nodal type indicating nodal types for which priors are to be altered

statement

A causal query that determines nodal types for which priors are to be altered

confound

A confound statement that restricts nodal types for which priors are to be altered

nodal_type

String. Label for nodal type indicating nodal types for which priors are to be altered

param_names

String. The name of specific parameter in the form of, for example, 'X.1', 'Y.01'

param_set

String. Indicates the name of the set of parameters to be modified (useful when setting confounds)

normalize

Logical. If TRUE normalizes such that param set probabilities sum to 1.

Details

Forbidden statements include:

  • Setting distribution and values at the same time.

  • Setting a distribution other than uniform, jeffreys or certainty.

  • Setting negative values.

See Also

Other priors: get_priors(), make_par_values_multiple(), make_priors(), make_values_task_list(), set_priors()

Examples

Run this code
# NOT RUN {
model <- make_model('X -> M -> Y; X -> Y')

CausalQueries:::make_par_values(model, distribution = 'jeffreys')

CausalQueries:::make_par_values(model, x = 3)

# Selecting subsets:

# By node
CausalQueries:::make_par_values(model, node = 'M', x = 8)

# By nodal type statement
CausalQueries:::make_par_values(model,
        statement = '(Y[X=1, M = .] > Y[X=0, M = .])', x = 2)

# By nodal type label (safest to provide node also)
CausalQueries:::make_par_values(model, node = 'X', label = '0', x = 9)

# By confound query: Applies only to types that are involved in confounding
# Only alters named node in confound, even if other nodes are listed in 'nodes'
confounds <- list(X = 'Y[X=1] > Y[X=0]', X = 'Y[X=1] < Y[X=0]')
model     <- make_model('X->Y') %>% set_confound(confounds)
CausalQueries:::make_par_values(model, confound = confounds[1], x = 3)
CausalQueries:::make_par_values(model, node = 'Y', confound = confounds[1], x = 3)

# A residual  confound condition can also be defined
CausalQueries:::make_par_values(model,
                                confound = list(X = '!(Y[X=1] > Y[X=0])'),
                                x = 3)
CausalQueries:::make_par_values(model,
                                confound = list(X = '(Y[X=1] == Y[X=0])'),
                                x = 3)

# make_par_values can also be used for some vector valued statements
model <- make_model('X -> M -> Y')
CausalQueries:::make_par_values(model, node = c('X', 'Y'), x = 2)
CausalQueries:::make_par_values(model, label = c('1', '01'), x = 2)

# Incompatible conditions produce no change
CausalQueries:::make_par_values(model, node = 'X', label = '01', x = 2)

# If statement not satisfied by any cases then no change
model <- make_model("X->Y")
CausalQueries:::make_par_values(model, statement = '(Y[X=1] == 2)', x = .1)

# Normalization: Take in a parameter vector and output is renormalized
model <- make_model("X->Y")
CausalQueries:::make_par_values(model,
                                y = get_parameters(model),
                                label = '01',
                                x = .1,
                                normalize = TRUE)
CausalQueries:::make_par_values(model,
                                y = get_parameters(model),
                                statement = '(Y[X=1] == Y[X=0])',
                                x = .1,
                                normalize = TRUE)

# Problematic examples
# }
# NOT RUN {
CausalQueries:::make_par_values(model, x = 1:2)
CausalQueries:::make_par_values(model,
                                y = get_parameters(model),
                                label = '01',
                                x = 2,
                                normalize = TRUE)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab