Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

grapes-twiddle-twiddle-grapes

Correlated error operator


Description

Specifies correlated errors among predictors

Usage

e1 %~~% e2

Arguments

e1

one variable to be correlated

e2

the other variable to be correlated

Details

For use in psem to identify correlated sets of variables.

Author(s)

Jon Lefcheck <lefcheckj@si.edu>

See Also

Examples

# Generate example data
dat <- data.frame(x1 = runif(50),
  x2 = runif(50), y1 = runif(50),
    y2 = runif(50))

# Create list of structural equations
sem <- psem(
  lm(y1 ~ x1 + x2, dat),
  lm(y2 ~ y1 + x1, dat)
)

# Look at correlated error between x1 and x2
# (exogenous)
cerror(x1 %~~% x2, sem, dat)

# Same as cor.test
with(dat, cor.test(x1, x2))

# Look at correlatde error between x1 and y1
# (endogenous)
cerror(y1 %~~% x1, sem, dat)

# Not the same as cor.test
# (accounts for influence of x1 and x2 on y1)
with(dat, cor.test(y1, x1))

# Specify in psem
sem <- update(sem, x1 %~~% y1)

coefs(sem)

piecewiseSEM

Piecewise Structural Equation Modeling

v2.1.2
GPL-3
Authors
Jon Lefcheck [aut, cre], Jarrett Byrnes [aut], James Grace [aut]
Initial release
2020-12-09

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.