The dySEM
helps automate the process of scripting,
fitting, and reporting on latent models of dyadic data via lavaan
. The package was
initially developed and used in the course of the research described in
Sakaluk, Fisher, and Kilshaw (2021), and has since undergone
considerable expansion.
The dySEM
logo was designed by Lowell Deranleau (for
logo design inquiries, email:
agangofwolves@gmail.com).
You can install the released version of dySEM from CRAN with:
install.packages("dySEM")
You can install the development version from GitHub with:
# install.packages("devtools")
::install_github("jsakaluk/dySEM") devtools
The package currently provides functionality regarding the following types of latent dyadic data models:
Additional features currently include:
Shorter-term development goals include:
Longer-term goals, meanwhile, include:
Please submit any feature requests via the dySEM
issues page, using
the “Wishlist for dySEM Package Development” tag.
If you are interested in collaborating on the development of
dySEM
, please contact Dr. Sakaluk.
A dySEM
workflow typically involves five steps, which
are covered in-depth in the Overview
vignette. Briefly, these steps include:
lavaan
There are additional optional functions, as well, that help users to calculate certain additional quantitative values (e.g., reliability, corrected model fit indexes in models with indistinguishable dyad members).
Structural equation modeling (SEM) programs like lavaan
require dyadic data to be in dyad structure data set, whereby each row
contains the data for one dyad, with separate columns for each
observation made for each member of the dyad. For example:
DRES#> # A tibble: 121 × 18
#> PRQC_1.1 PRQC_2.1 PRQC_3.1 PRQC_4.1 PRQC_5.1 PRQC_6.1 PRQC_7.1 PRQC_8.1
#> <int> <int> <int> <int> <int> <int> <int> <int>
#> 1 7 7 7 7 7 7 7 5
#> 2 6 6 6 7 7 6 5 5
#> 3 7 7 7 7 7 7 7 6
#> 4 6 6 6 7 7 6 5 6
#> 5 7 7 7 7 7 6 7 6
#> 6 6 6 6 6 6 3 6 5
#> 7 7 6 7 6 6 6 5 6
#> 8 6 7 7 7 7 6 5 6
#> 9 7 7 7 7 7 6 6 6
#> 10 6 6 6 7 7 7 4 4
#> # ℹ 111 more rows
#> # ℹ 10 more variables: PRQC_9.1 <int>, PRQC_1.2 <int>, PRQC_2.2 <int>,
#> # PRQC_3.2 <int>, PRQC_4.2 <int>, PRQC_5.2 <int>, PRQC_6.2 <int>,
#> # PRQC_7.2 <int>, PRQC_8.2 <int>, PRQC_9.2 <int>
The dySEM
scrapers consider appropriately repetitiously
named indicators as consisting of at least three distinct elements:
stem, item, and partner. Delimiter characters (e.g.,
“.”, “_“) are commonly–but not always–used to separate some/all of these
elements.dySEM
scrapers largely function by asking you to
specify in what order the elements of variable names are ordered.
<- scrapeVarCross(DRES, x_order = "sip", x_stem = "PRQC", x_delim1="_",x_delim2=".", distinguish_1="1", distinguish_2="2") dvn
Scripter functions like scriptCFA
typically require only three arguments to be specified:
dvn
object (e.g., from scrapeVarCross
)
to be used to script the model 1.arbitrary name(s) for the latent
variable(s) you are modeling<- scriptCFA(dvn, lvname = "Quality") qual.indist.script
This function returns a character object with lavaan
compliant syntax for your chosen model, as well as exporting a
reproducible .txt of the scripted model to a /scripts folder in your
working directory.
lavaan
You can immediately pass any script(s) returned from a
dySEM
scripter to your preferred lavaan
wrapper, with your estimator and missing data treatment of choice. For
example:
<- lavaan::cfa(qual.indist.script, data = DRES, std.lv = FALSE, auto.fix.first= FALSE, meanstructure = TRUE) qual.indist.fit
At this point, the full arsenal of lavaan
model-inspecting tools are at your disposal. For example:
summary(qual.indist.fit, fit.measures = TRUE, standardized = TRUE, rsquare = TRUE)
dySEM
also contains functionality to help you quickly,
correctly, and reproducibly generate output from your fitted model(s),
in the forms of path diagrams and/or tables of statistical values. By
default these save to a temporary directory, but you can specify a
directory of your choice by replacing tempdir()
(e.g., with
"."
, which will place it in your current working
directory).
outputParamTab(dvn, model = "cfa", fit = qual.indist.fit,
tabletype = "measurement", writeTo = tempdir(),
fileName = "cfa_indist")
outputParamFig(fit = qual.indist.fit, figtype = "standardized",
writeTo = tempdir(),
fileName = "cfa_indist")
Please note that the dySEM project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.
The development of dySEM
has been generously supported
by Internal Grants from Western University, including: