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 c("sem","lm") and indicates which function is used to fit the model.

control

Value of x that is used as control group. If "default", takes the first entry of as.factor(x).

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 generateMeasurementModel.

fixed.cell

logical. If FALSE, the group sizes are treated as stochastic rather than fixed. The default setting for method="sem" is FALSE and the default setting for method="lm" is TRUE.

fixed.z

logical. If FALSE, the continuous covariates are treated as stochastic rather than fixed. The default setting for method="sem" is FALSE and the default setting for method="lm" is TRUE.

missing

Missing data handling. Will be passed on to sem or ignored for method="lm".

se

Type of standard errors. Will be passed on to sem or ignored for method="lm".

syntax.only

logical. If TRUE, only syntax is returned and the model will not be estimated.

interactions

character. Indicates the type of interaction. Can be one of "all" (all interactions), "2-way" (only two-way interactions), "X:K,X:Z" (only X:K and X:Z interactions), "X:K" (only X:K interactions), "X:Z" (only X:Z interactions), "none" (no treatment by covariate interactions, but potentially interactions between categorical and continuous covariates), or "no" (no interactions at all).

homoscedasticity

logical. If TRUE, residual variances of the dependent variable are assumed to be homogeneous across cells. The default setting for method="sem" is FALSE and the default setting for method="lm" is TRUE.

test.stat

character. Can be one of c("default","Chisq","Ftest") and indicates the statistic used for the hypothesis tests. The tests are either based on the large sample Chi-Squared statistic (Wald tests) or the finite sample F statistic with approximate F distribution. The default setting for method="sem" is "Chisq" and the default setting for method="lm" is "Ftest".

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 lavaan.survey if lavaan.survey is installed. If not, the cluster argument in sem will be used. See svydesign for details.

weights

Formula to specify sampling weights. Currently only one weight variable is supported. Will be passed on to lavaan.survey if lavaan.survey is installed. If not, the sampling.weights argument in sem will be used. See svydesign for details. Note: Only use weights if you know what you are doing. For example, some conditional treatment effects may require different weights than average effects.

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 sem.

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)

[Package EffectLiteR version 0.4-6 Index]