Giter Club home page Giter Club logo

modsem's Introduction

ModSEM

This is a package which allows you to perform interactions between latent variables in CB-SEM. See https://bookdown.org/slupphaugkjell/quartomodsem/ for a tutorial.

To Install

install.packages("devtools")
devtools::install_github("kss2k/modsem")

Methods/Approaches

There are a number of approaches for estimating interaction effects in SEM. In modsem(), the method = "method" argument allows you to choose which to use.

  • "ca" = constrained approach (Algina & Moulder, 2001)
    • not recommended for cases where there is a main effect between variables in the interaction term, unless you know what you are doing.
    • e.g.,
    • use removeFromParTable = "X ~~ Z"
    • and addToParTable = "new formula for covariance, with label Cov_X_Z"
  • "uca" = unconstrained approach (Marsh, 2004)
    • not recommended for cases where there is a main effect between variables in the interaction term, unless you know what you are doing.
  • "rca" = residual centering approach (Little et al., 2006)
  • "dblcent" = double centering approach (Marsh., 2013)
    • default
  • "pind" = basic product indicator approach (not recommended)
  • "lms" = The latent moderated structural equations approach through the nlsem package
    • do qml = TRUE for the quasi maximum likelihood version
    • do optimize = TRUE for faster convergence (experimental feature)
    • note: can only be done if you have a single endogenous (dependent) variable.
  • "mplus"
    • estimates model through Mplus, if it is installed

Examples

One interaction

library(modsem)
m1 <- '
  # Outer Model
  X =~ x1 + x2 +x3
  Y =~ y1 + y2 + y3
  Z =~ z1 + z2 + z3
  
  # Inner model
  Y ~ X + Z + X:Z 
'

est1 <- modsem(m1, oneInt)
summary(est1)

Interactions between two observed variables

est2 <- modsem('y1 ~ x1 + z1 + x1:z1', data = oneInt, method = "pind")
summary(est2)

## Interaction between an obsereved and a latent variable 
m3 <- '
  # Outer Model
  X =~ x1 + x2 +x3
  Y =~ y1 + y2 + y3
  
  # Inner model
  Y ~ X + z1 + X:z1 
'

est3 <- modsem(m3, oneInt, method = "pind")
summary(est3)

Multiple interaction terms

m4 <- '
  # Outer Model
  X =~ x1 + x2 +x3
  Y =~ y1 + y2 + y3
  Z =~ z1 + z2 + z3
  G =~ g1 + g2 + g3
  H =~ h1 + h2 + h3
  
  # Inner model
  Y ~ X + Z + G + H + X:Z + G:H
'

est4 <- modsem(m4, twoInt)
summary(est4)

Interactionterms with more than two variables

m5 <- '
  # Outer Model
  X =~ x1 + x2 +x3
  Y =~ y1 + y2 + y3
  Z =~ z1 + z2 + z3
  G =~ g1 + g2 + g3
  
  # Inner model
  Y ~ X + Z + G + X:Z:G
'

est5 <- modsem(m5, tripleInt, standardizeData = TRUE)
summary(est5)

modsem's People

Contributors

kss2k avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.