A Function That Writes, Saves, and Exports Syntax for Fitting Latent Actor-Partner Interdependence Models (APIMs)
Source:R/scriptAPIM.R
scriptAPIM.Rd
This function takes the outputted object from scrapeVarCross() and automatically writes, returns, and exports (.txt) lavaan() syntax for specifying Actor-Partner Interdependence Models (APIMs). Users can also invoke configural, loading, and/or intercept invariant measurement models, and particular types of structural comparisons.
Usage
scriptAPIM(
dvn,
scaleset = "FF",
lvxname,
lvyname,
constr_dy_x_meas = c("loadings", "intercepts", "residuals"),
constr_dy_x_struct = c("variances", "means"),
constr_dy_y_meas = c("loadings", "intercepts", "residuals"),
constr_dy_y_struct = c("variances", "means"),
constr_dy_xy_struct = c("actors", "partners"),
model = lifecycle::deprecated(),
equate = lifecycle::deprecated(),
est_k = FALSE,
writeTo = NULL,
fileName = NULL
)
Arguments
- dvn
input dvn list from scrapeVarCross
- scaleset
input character to specify how to set the scale of the latent variable(s). Default is "FF" (fixed-factor; see Details for rationale), but user can specify "MV" (Marker Variable)
- lvxname
input character to (arbitrarily) name LV X in lavaan syntax
- lvyname
input character to (arbitrarily) name LV Y in lavaan syntax
- constr_dy_x_meas
input character vector detailing which measurement model parameters to constrain across dyad members for latent X. Default is c("loadings", "intercepts", "residuals"), but user can specify any combination of "loadings", "intercepts", and "residuals", #or "none" to specify an otherwise unconstrained dyadic configural invariance model
- constr_dy_x_struct
input character vector detailing which structural model parameters to constrain across dyad members for latent X. Default is c("variances", "means"), but user can specify any combination of "variances" and "means", or "none".
- constr_dy_y_meas
input character vector detailing which measurement model parameters to constrain across dyad members for latent X. Default is c("loadings", "intercepts", "residuals"), but user can specify any combination of "loadings", "intercepts", and "residuals", #or "none" to specify an otherwise unconstrained dyadic configural invariance model
- constr_dy_y_struct
input character vector detailing which structural model parameters to constrain across dyad members for latent X. Default is c("variances", "means"), but user can specify any combination of "variances" and "means", or "none".
- constr_dy_xy_struct
input character vector detailing which structural model parameters to constrain for modeling the predictive association(s) between partners' latent x and y. Default is c("actors", "partners"), but users can also specify "all", "actors_zero", "partners_zero", or "none".
- model
Deprecated input character used to specify which level of invariance is modeled. Users should rely upon constr_dy_x_meas/constr_dy_y_meas and constr_dy_x_struct/constr_dy_y_struct instead, for making constraints to the measurement and/or structural portions of the model for latent x and y.
- equate
Deprecated input character to specify which type of structural parameters are constrained to equivalency between partners. Users should rely upon constr_dy_xy_struct for making constraints to the structural portion of the model for associative relationship between latent x and y.
- est_k
input logical for whether Kenny & Ledermann's (2010) k parameter should be calculated to characterize the dyadic pattern in the APIM. Defaults FALSE, and requires at least a loading-invariant model to be specified, otherwise a warning is returned.
- writeTo
A character string specifying a directory path to where a .txt file of the resulting lavaan script should be written. If set to “.”, the .txt file will be written to the current working directory. The default is NULL, and examples use a temporary directory created by tempdir().
- fileName
A character string specifying a desired base name for the .txt output file. The default is NULL. The specified name will be automatically appended with the .txt file extension. If a file with the same name already exists in the user's chosen directory, it will be overwritten.
Value
character object of lavaan script that can be passed immediately to lavaan functions. Users will receive message if structural comparisons are specified when the recommended level of invariance is not also specified. If user supplies dvn with containing X or Y variables, they are alerted to respecify the dvn object.
See also
scrapeVarCross
which this function relies on
Other script-writing functions:
scriptBiDy()
,
scriptCFA()
,
scriptCFM()
,
scriptDyEFA()
,
scriptINULL()
,
scriptISAT()
,
scriptMIM()
Examples
dvn <- scrapeVarCross(dat = commitmentQ, x_order = "spi", x_stem = "sat.g", x_delim1 = ".",
x_delim2="_", distinguish_1="1", distinguish_2="2",
y_order="spi", y_stem="com", y_delim1 = ".", y_delim2="_")
apim.script.indist <- scriptAPIM(dvn, lvxname = "Sat", lvyname = "Com", est_k = TRUE,
writeTo = tempdir(),
fileName = "latAPIM_indist")