make_confounds_df {CausalQueries}R Documentation

Make a confounds dataframe

Description

Identifies confounded nodal types.

Usage

make_confounds_df(model)

Arguments

model

A causal_model. A model object generated by make_model.

Value

A data.frame indicating which nodes are confounded

Examples


model <- make_model('X -> Y') %>%
set_confound('X <-> Y', add_confounds_df  = FALSE)
make_confounds_df(model)

model <- make_model('X -> M -> Y; X <-> Y') %>%
set_restrictions(c('M[X=1] == M[X=0]', 'Y[M=1]==Y[M=0]'))
make_confounds_df(model)

model <- make_model('X -> M -> Y; X <-> M; M <-> Y') %>%
set_restrictions(c('M[X=1] == M[X=0]', 'Y[M=1]==Y[M=0]'))
make_confounds_df(model)

# The implied confounding is between X and M and also between X and Y
model <- make_model('X -> M -> Y') %>%
  set_confound(list(X = 'Y[X=1] > Y[X=0]'), add_confounds_df = FALSE)
make_confounds_df(model)

model <- make_model('X -> M -> Y')
make_confounds_df(model)

# Bad case
## Not run: 
model <- make_model('X -> Y') %>%
  set_confound(list(X = 'X==1'))

## End(Not run)

# Complex confounding 1
model <- make_model('A -> X <- B ; A <-> X; B <-> X')
model$confounds_df

# Complex confounding 2
model <- make_model('A <- X -> B; A <-> X; B <-> X') %>%
set_restrictions(c('A[X=0] == A[X=1]', 'B[X=0] == B[X=1]'))
table(model$parameters_df$param_set)
model$confounds_df

# Full confounding: X, A|X, B|A,X with 7 degrees of freedom
model <- make_model('A <- X -> B; A <-> X; B <-> X; A<->B') %>%
set_restrictions(c('A[X=0] == A[X=1]', 'B[X=0] == B[X=1]'))
table(model$parameters_df$param_set)
model$confounds_df

[Package CausalQueries version 0.0.3 Index]