# NOT RUN {
model <- make_model('X -> Y') %>%
set_confound(list('X <-> Y'))
get_parameters(model)
# }
# NOT RUN {
# In this case we notionally place a distribution but in fact Y has degenerate support
make_model('X -> Y -> Z') %>%
set_restrictions(c(increasing('X', 'Y')), keep = TRUE) %>%
set_confound(list('X <-> Y')) %>%
get_parameter_matrix()
# X nodes assigned conditional on Y
make_model('X -> Y') %>%
set_confound(list(X = 'Y')) %>%
get_parameter_matrix()
# Y nodes assigned conditional on X
make_model('X -> Y') %>%
set_confound(list(Y = 'X')) %>%
get_parameter_matrix()
model <- make_model('X -> Y') %>%
set_confound(list(X = '(Y[X=1]>Y[X=0])', X = '(Y[X=1]<Y[X=0])', X = '(Y[X=1]==Y[X=0])'))
model <- make_model('X -> M -> Y') %>%
set_confound (list(X = '(Y[X=1]>Y[X=0])',
M = 'Y',
X = '(Y[X=1]<Y[X=0])'))
confound = list(A = '(D[A=., B=1, C=1]>D[A=., B=0, C=0])')
model <- make_model('A -> B -> C -> D; B -> D') %>%
set_confound(confound = confound)
# Example where two parents are confounded
model <- make_model('A -> B <- C') %>%
set_confound(list(A = 'C==1')) %>%
set_parameters(c(0,1,1,0, .5, .5, rep(.0625, 16)))
cor(simulate_data(model, n = 20))
model <- make_model('X -> Y')
confound <- list(X = '(Y[X=1] > Y[X=0])', X = '(Y[X=1] == 1)')
model <- set_confound(model = model, confound = confound)
model <- make_model('X -> Y <- S; S -> W') %>%
set_restrictions(c(
increasing('X', 'Y'), increasing('S', 'W'),
increasing('S', 'Y'), decreasing('S', 'Y')))
model1 <- set_confound(model, list(X = 'S==1', S = 'W[S=1]==1'), add_confounds_df = TRUE)
model1$confounds_df
model2 <- set_confound(model, list(S = 'X==1', S = 'W[S=1]==1'), add_confounds_df = TRUE)
model2$confounds_df
# }
Run the code above in your browser using DataLab