Skip to contents

Add a parameter matrix to a model

Usage

set_parameter_matrix(model, P = NULL)

Arguments

model

A causal_model. A model object generated by make_model.

P

A data.frame. Parameter matrix. Not required but may be provided to avoid repeated computation for simulations. See inspect(model, "parameter_matrix").

Value

An object of class causal_model. It essentially returns a list containing the elements comprising a model (e.g. 'statement', 'nodal_types' and 'DAG') with the parameter matrix attached to it.

Examples

model <- make_model('X -> Y')
P <- diag(8)
colnames(P) <- inspect(model, "causal_types") |> rownames()
#> 
#> causal_types (Causal Types)
#> 
#> Cartesian product of nodal types
#>        X  Y
#> X0.Y00 0 00
#> X1.Y00 1 00
#> X0.Y10 0 10
#> X1.Y10 1 10
#> X0.Y01 0 01
#> X1.Y01 1 01
#> X0.Y11 0 11
#> X1.Y11 1 11
model <- set_parameter_matrix(model, P = P)