{"id":23477160,"url":"https://github.com/kss2k/modsem","last_synced_at":"2026-01-25T21:25:55.479Z","repository":{"id":204895025,"uuid":"709859763","full_name":"Kss2k/modsem","owner":"Kss2k","description":"An R package for estimating interaction effects in structural equation modeling (SEM), and lavaan.","archived":false,"fork":false,"pushed_at":"2024-04-13T14:51:30.000Z","size":8586,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-04-14T02:41:41.458Z","etag":null,"topics":["interaction-effect","interaction-effects","lavaan-syntax","r","rlang","rlanguage","sem","structural-equation-modeling","structural-equation-models"],"latest_commit_sha":null,"homepage":"","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Kss2k.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-10-25T14:36:58.000Z","updated_at":"2024-04-15T09:30:56.118Z","dependencies_parsed_at":"2024-01-03T22:23:29.808Z","dependency_job_id":"db3a115d-e0fb-417b-9acb-cef77e1d8ac8","html_url":"https://github.com/Kss2k/modsem","commit_stats":null,"previous_names":["kss2k/modsem"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kss2k%2Fmodsem","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kss2k%2Fmodsem/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kss2k%2Fmodsem/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kss2k%2Fmodsem/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Kss2k","download_url":"https://codeload.github.com/Kss2k/modsem/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248710435,"owners_count":21149188,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["interaction-effect","interaction-effects","lavaan-syntax","r","rlang","rlanguage","sem","structural-equation-modeling","structural-equation-models"],"created_at":"2024-12-24T18:17:02.624Z","updated_at":"2026-01-25T21:25:55.473Z","avatar_url":"https://github.com/Kss2k.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `modsem` \u003cimg src=\"man/figures/modsem.png\" alt=\"Logo\" align = \"right\" height=\"139\" class=\"logo\"\u003e\n\u003c!-- badges: start --\u003e\n[![R-CMD-check](https://github.com/kss2k/modsem/actions/workflows/checks.yml/badge.svg)](https://github.com/kss2k/modsem/actions/workflows/checks.yml)\n[![Tests](https://github.com/kss2k/modsem/actions/workflows/tests.yml/badge.svg)](https://github.com/kss2k/modsem/actions/workflows/tests.yml)\n[![CRAN](https://www.r-pkg.org/badges/version/modsem)](https://cran.r-project.org/package=modsem)\n[![PKGDOWN-Build](https://github.com/kss2k/modsem/actions/workflows/pkgdown.yml/badge.svg)](https://github.com/kss2k/modsem/actions/workflows/pkgdown.yml)\n[![](https://cranlogs.r-pkg.org/badges/grand-total/modsem)](https://cran.r-project.org/package=modsem)\n[![GitHub Clones](https://img.shields.io/badge/dynamic/json?color=success\u0026label=Clone\u0026query=count\u0026url=https://gist.githubusercontent.com/Kss2k/131dd94e938508da4f039ec2a4ecb256/raw/clone.json\u0026logo=github)](https://github.com/MShawon/github-clone-count-badge)\n\n\u003c!-- badges: end --\u003e\n`modsem` is an `R`-package for estimating interaction (i.e., moderation) effects between latent variables\nin structural equation models (SEMs). See https://www.modsem.org for a tutorial.\n\n# Installation\n`modsem` is available on `CRAN` and `GitHub`, and can be installed as follows:\n\n```R\n# From CRAN \ninstall.packages(\"modsem\")\n\n# Latest version from GitHub\ninstall.packages(\"devtools\")\ndevtools::install_github(\"kss2k/modsem\", build_vignettes = TRUE)\n```\n**Note**: The package needs to be compiled from source on `macOS` (if installing via `GitHub`) and `Linux`.\nIf you have issues installing the package on `macOS`, you might need to install the `gfortran` compiler.\nA `C++` compiler is also required, but should be installed by default on most systems.\nSee the [R for macOs](https://cran.r-project.org/bin/macosx/tools/) page for more information.\n\nIf you're using `Windows`, consider installing [`OpenBLAS in R for Windows`](https://github.com/david-cortes/R-openblas-in-windows) \nfor better perfmance. If you're using a `Linux` distribution, consider installing\nthe [`ropenblas` package](https://CRAN.R-project.org/package=ropenblas)\n\n# Methods/Approaches\n\nThere are a number of approaches for estimating interaction effects in SEM. \nIn `modsem()`, the `method = \"method\"` argument allows you to choose which to use.\nDifferent approaches can be categorized into two groups: \nProduct Indicator (PI) and Distribution Analytic (DA) approaches.\n\n## Product Indicator (PI) Approaches:\n- `\"ca\"` = constrained approach (Algina \u0026 Moulder, 2001)\n    - Note that constraints can become quite complicated for complex models, \n      particularly when there is an interaction including enodgenous variables.\n      The method can therefore be quite slow. \n- `\"uca\"` = unconstrained approach (Marsh, 2004)\n- `\"rca\"` = residual centering approach (Little et al., 2006)\n- `\"dblcent\"` = double centering approach (Marsh., 2013)\n  - default \n- `\"pind\"` = basic product indicator approach (not recommended)\n\n## Distribution Analytic (DA) Approaches\n- `\"lms\"` = The Latent Moderated Structural equations (LMS) approach, see the [vignette](https://modsem.org/articles/lms_qml.html)\n- `\"qml\"` = The Quasi Maximum Likelihood (QML) approach, see the [vignette](https://modsem.org/articles/lms_qml.html)\n- `\"mplus\"` = `Mplus`\n  - estimates model through `Mplus`, if it is installed\n\n# Examples \n\n## Elementary Interaction Model (Kenny \u0026 Judd, 1984; Jaccard \u0026 Wan, 1995)\n```R\nlibrary(modsem)\n\nm1 \u003c- '\n  # Outer Model\n  X =~ x1 + x2 + x3\n  Y =~ y1 + y2 + y3\n  Z =~ z1 + z2 + z3\n  \n  # Inner model\n  Y ~ X + Z + X:Z \n'\n\n# Double centering approach\nest1_dca \u003c- modsem(m1, oneInt)\nsummary(est1_dca)\n\n# Constrained approach\nest1_ca \u003c- modsem(m1, oneInt, method = \"ca\")\nsummary(est1_ca)\n\n# QML approach \nest1_qml \u003c- modsem(m1, oneInt, method = \"qml\")\nsummary(est1_qml, standardized = TRUE) \n\n# LMS approach \nest1_lms \u003c- modsem(m1, oneInt, method = \"lms\") \nsummary(est1_lms)\n```\n\n## Theory Of Planned Behavior\n```R\ntpb \u003c- \"\n# Outer Model (Based on Hagger et al., 2007)\n  ATT =~ att1 + att2 + att3 + att4 + att5\n  SN =~ sn1 + sn2\n  PBC =~ pbc1 + pbc2 + pbc3\n  INT =~ int1 + int2 + int3\n  BEH =~ b1 + b2\n\n# Inner Model (Based on Steinmetz et al., 2011)\n  INT ~ ATT + SN + PBC\n  BEH ~ INT + PBC\n  BEH ~ PBC:INT\n\"\n\n# double centering approach\nest_tpb_dca \u003c- modsem(tpb, data = TPB, method = \"dblcent\")\nsummary(est_tpb_dca)\n\n# Constrained approach using Wrigths path tracing rules for generating\n# the appropriate constraints\nest_tpb_ca \u003c- modsem(tpb, data = TPB, method = \"ca\") \nsummary(est_tpb_ca)\n\n# LMS approach \nest_tpb_lms \u003c- modsem(tpb, data = TPB, method = \"lms\")\nsummary(est_tpb_lms, standardized = TRUE) \n\n# QML approach \nest_tpb_qml \u003c- modsem(tpb, data = TPB, method = \"qml\") \nsummary(est_tpb_qml, standardized = TRUE)\n```\n## Interactions between two observed variables\n```R\nest2 \u003c- modsem('y1 ~ x1 + z1 + x1:z1', data = oneInt, method = \"dblcent\")\nsummary(est2)\n```\n\n## Interaction between an obsereved and a latent variable \n```R\nm3 \u003c- '\n  # Outer Model\n  X =~ x1 + x2 + x3\n  Y =~ y1 + y2 + y3\n  \n  # Inner model\n  Y ~ X + z1 + X:z1\n'\n\nest3 \u003c- modsem(m3, oneInt, method = \"dblcent\", \n               res.cov.method = \"none\") # res.cov.method = \"simple\" will lead\n                                        # to an unidentifiable model. Instead we\n                                        # constrain them to zero\nsummary(est3)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkss2k%2Fmodsem","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkss2k%2Fmodsem","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkss2k%2Fmodsem/lists"}