effectLite {EffectLiteR} | R Documentation |
Estimate average and conditional effects
Description
This function is the main function of the package and can be used to estimate average and conditional effects of a treatment variable on an outcome variable, taking into account any number of continuous and categorical covariates. It automatically generates lavaan syntax for a multi-group structural equation model, runs the model using lavaan, and extracts various average and conditional effects of interest.
Usage
effectLite(
y,
x,
k = NULL,
z = NULL,
data,
method = "sem",
control = "default",
measurement = character(),
fixed.cell = "default",
fixed.z = "default",
missing = "default",
se = "default",
syntax.only = FALSE,
interactions = "all",
homoscedasticity = "default",
test.stat = "default",
propscore = NULL,
ids = ~0,
weights = NULL,
add = character(),
...
)
Arguments
y |
Dependent variable (character string). Can be the name of a manifest variable or of a latent variable. |
x |
Treatment variable (character string) treated as categorical variable. |
k |
Vector of manifest variables treated as categorical covariates (character vector). |
z |
Vector of continuous covariates (character vector). Names of both manifest and latent variables are allowed. |
data |
A data frame. |
method |
Can be one of |
control |
Value of |
measurement |
Measurement model. The measurement model is lavaan syntax (character string), that will be appended before the automatically generated lavaan input. It can be used to specify a measurement for a latent outcome variable and/or latent covariates. See also the example and |
fixed.cell |
logical. If |
fixed.z |
logical. If |
missing |
Missing data handling. Will be passed on to |
se |
Type of standard errors. Will be
passed on to |
syntax.only |
logical. If |
interactions |
character. Indicates the type of interaction. Can be one of |
homoscedasticity |
logical. If |
test.stat |
character. Can be one of |
propscore |
Vector of covariates (character vector) that will be used to compute (multiple) propensity scores based on a multinomial regression without interactions. Alternatively, the user can specify a formula with the treatment variable as dependent variable for more control over the propensity score model. |
ids |
Formula specifying cluster ID variables. Will be passed on to |
weights |
Formula to specify sampling weights. Currently only one weight variable is supported. Will be passed on to |
add |
Character string that will be pasted at the end of the generated lavaan syntax. Can for example be used to add additional (in-) equality constraints or to compute user-defined conditional effects. |
... |
Further arguments passed to |
Value
Object of class effectlite.
References
Mayer, A., Dietzfelbinger, L., Rosseel, Y. & Steyer, R. (2016). The EffectLiteR approach for analyzing average and conditional effects. Multivariate Behavioral Research, 51, 374-391.
Examples
## Example with one categorical covariate
m1 <- effectLite(y="y", x="x", k="z", control="0", data=nonortho)
print(m1)
## Example with one categorical and one continuous covariate
m1 <- effectLite(y="dv", x="x", k=c("k1"), z=c("z1"), control="control", data=example01)
print(m1)
## Example with latent outcome and latent covariate
measurement <- '
eta2 =~ 1*CPM12 + 1*CPM22
eta1 =~ 1*CPM11 + 1*CPM21
CPM11 + CPM12 ~ 0*1
CPM21 ~ c(m,m)*1
CPM22 ~ c(p,p)*1'
m1 <- effectLite(y="eta2", x="x", z=c("eta1"), control="0",
measurement=measurement, data=example02lv)
print(m1)
## Not run:
## Example with cluster variable and sampling weights
m1 <- effectLite(y="y", x="x", z="z", fixed.cell=TRUE, control="0",
syntax.only=F, data=example_multilevel,
ids=~cid, weights=~weights)
print(m1)
## End(Not run)