# \donttest{
# note: iter = 250 for demonstrative purposes
# data
Y <- bfi
###############################
#### example 1: continuous ####
###############################
# males
Ymale <- subset(Y, gender == 1,
select = -c(education,
gender))[,1:5]
# females
Yfemale <- subset(Y, gender == 2,
select = -c(education,
gender))[,1:5]
# exhaustive
hypothesis <- c("g1_A1--A2 > g2_A1--A2;
g1_A1--A2 < g2_A1--A2;
g1_A1--A2 = g2_A1--A2")
# test hyp
test <- ggm_compare_confirm(Ymale, Yfemale,
hypothesis = hypothesis,
iter = 250,
progress = FALSE)
# print (evidence not strong)
test
#########################################
#### example 2: sensitivity to prior ####
#########################################
# continued from example 1
# decrease prior SD
test <- ggm_compare_confirm(Ymale,
Yfemale,
prior_sd = 0.1,
hypothesis = hypothesis,
iter = 250,
progress = FALSE)
# print
test
# indecrease prior SD
test <- ggm_compare_confirm(Ymale,
Yfemale,
prior_sd = 0.28,
hypothesis = hypothesis,
iter = 250,
progress = FALSE)
# print
test
################################
#### example 3: mixed data #####
################################
hypothesis <- c("g1_A1--A2 > g2_A1--A2;
g1_A1--A2 < g2_A1--A2;
g1_A1--A2 = g2_A1--A2")
# test (1000 for example)
test <- ggm_compare_confirm(Ymale,
Yfemale,
type = "mixed",
hypothesis = hypothesis,
iter = 250,
progress = FALSE)
# print
test
##############################
##### example 4: control #####
##############################
# control for education
# data
Y <- bfi
# males
Ymale <- subset(Y, gender == 1,
select = -c(gender))[,c(1:5, 26)]
# females
Yfemale <- subset(Y, gender == 2,
select = -c(gender))[,c(1:5, 26)]
# test
test <- ggm_compare_confirm(Ymale,
Yfemale,
formula = ~ education,
hypothesis = hypothesis,
iter = 250,
progress = FALSE)
# print
test
#####################################
##### example 5: many relations #####
#####################################
# data
Y <- bfi
hypothesis <- c("g1_A1--A2 > g2_A1--A2 & g1_A1--A3 = g2_A1--A3;
g1_A1--A2 = g2_A1--A2 & g1_A1--A3 = g2_A1--A3;
g1_A1--A2 = g2_A1--A2 = g1_A1--A3 = g2_A1--A3")
Ymale <- subset(Y, gender == 1,
select = -c(education,
gender))[,1:5]
# females
Yfemale <- subset(Y, gender == 2,
select = -c(education,
gender))[,1:5]
test <- ggm_compare_confirm(Ymale,
Yfemale,
hypothesis = hypothesis,
iter = 250,
progress = FALSE)
# print
test
# }
Run the code above in your browser using DataLab