# principles and practice of sem, 5th ed. # rex b. kline, guilford press, 2023 # chapter 6, table 6.3, analysis 2 # identification of direct and total (i.e., indirect) # effects for the roth et al. (1989) nonparametric # path model of illness # to avoid the problem that some R packages share the same name # for different functions, all functions are specified next as # package::function # which prevents masking, or the default hiding of # a function with a redundant name from a package used next date() v <- R.Version() print(paste0(v$language, " version ", v$major, ".", v$minor, " (", v$year, "-", v$month, "-", v$day, ")")) library(dagitty) # get citation information citation("dagitty", auto = TRUE) # specify model in dagitty rothdag <- dagitty::dagitty("dag{ exercise <-> hardy; exercise -> fitness; hardy -> stress; fitness -> illness; stress -> illness}") # minimally sufficient adjustment sets of covariates # direct effects (also total effects) dagitty::adjustmentSets(rothdag, "exercise", "fitness", effect = "direct") dagitty::adjustmentSets(rothdag, "hardy", "stress", effect = "direct") dagitty::adjustmentSets(rothdag, "fitness", "illness", effect = "direct") dagitty::adjustmentSets(rothdag, "stress", "illness", effect = "direct") # indirect effects (also total effects) dagitty::adjustmentSets(rothdag, "exercise", "illness", effect = "total") dagitty::adjustmentSets(rothdag, "hardy", "illness", effect = "total") # instrumental variables # direct effects (also total effects) dagitty::instrumentalVariables(rothdag, "exercise", "fitness") dagitty::instrumentalVariables(rothdag, "hardy", "stress") dagitty::instrumentalVariables(rothdag, "fitness", "illness") dagitty::instrumentalVariables(rothdag, "stress", "illness") # indirect effects (also total effects) dagitty::instrumentalVariables(rothdag, "exercise", "illness") dagitty::instrumentalVariables(rothdag, "hardy", "illness")