make_model: Make a model

Description Usage Arguments Value Examples

View source: R/make_models.R

Description

make_model uses dagitty syntax and functionality to specify nodes and edges of a graph. Implied causal types are calculated and default priors are provided under the assumption of no confounding. Models can be updated with specification of a parameter matrix, P, by providing restrictions on causal types, and/or by providing informative priors on parameters. The default setting for a causal model have flat (uniform) priors and parameters putting equal weight on each parameter within each parameter set. These can be adjust with set_priors and set_parameters

Usage

1
make_model(statement, add_causal_types = TRUE)

Arguments

statement

A character. Statement describing causal relations using dagitty syntax. Only directed relations are permitted. For instance "X -> Y" or "X1 -> Y <- X2; X1 -> X2".

add_causal_types

Logical. Whether to create and attach causal types to model. Defaults to 'TRUE'.

Value

An object of class causal_model.

An object of class "causal_model" is a list containing at least the following components:

dag

A data.frame with columns 'parent'and 'children' indicating how nodes relate to each other.

node

A named list with the nodes in the model

statement

A character vector of the statement that defines the model

nodal_types

A named list with the nodal types in the model

parameters_df

A data.frame with descriptive information of the parameters in the model

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
make_model(statement = "X -> Y")
modelXKY <- make_model("X -> K -> Y; X -> Y")

# Example where cyclicaly dag attempted
## Not run: 
 modelXKX <- make_model("X -> K -> X")

## End(Not run)

# Examples with confounding
model <- make_model("X->Y; X <-> Y")
model$P
model <- make_model("Y2 <- X -> Y1; X <-> Y1; X <-> Y2")
model$P
model$confounds_df
dim(model$P)
model$P
model <- make_model("X1 -> Y <- X2; X1 <-> Y; X2 <-> Y")
dim(model$P)
model$parameters_df

# A single node graph is also possible
model <- make_model("X")
plot(model)

# Unconnected nodes cannot
## Not run: 
 model <- make_model("X <-> Y")
 plot(model)

## End(Not run)

CausalQueries documentation built on July 1, 2020, 7:46 p.m.