Git Product home page Git Product logo

sem-analysis-for-psychologists's Introduction

Structural Equation Modelling for Psychologists

Last updated 2023-11-16.

This GitHub repository contains R code for conducting Structural Equation Modeling (SEM) with a focus on latent variables, specifically tailored for psychologists. The analysis includes a two-mediator serial mediation model that I applied in my MSc research on work addiction. As serial mediation studies are rare in Psychology literature, I'm uploading my code which may be of use to someone as a starting point which will hopefully give you the basic tools to construct, evaluate and compare Structural Equation Models (SEM; w/plots), using lavaan.

๐Ÿ”ญ Overview

The repository is organised into the following sections:

๐Ÿ“œ Notes

This repository assumes basic competence in R (importing, structural equation, modelling, mediation, plotting, etc) and contains only materials relating to Structural Equation Modelling in R. So the focus will be generally on the application and not on the theory.

๐Ÿ› ๏ธ Setup

To run the code, you will need:

  1. A dataset relating to one independent variable, two mediator variables and one dependent variable.

  2. A fresh installation of R (preferably version 4.3.1 or above).

  3. RStudio IDE (optional but recommended).

  4. Install the required packages by running:

    # in alphabetical order:
    pkgs <- c(
      "careless", "dplyr", "knitr", "lavaan", "lavaanPlot", "mvnormalTest",
      "psych", "pwr", "semPlot", "tidyr"
    )
    
    install.packages(pkgs, repos = c("https://easystats.r-universe.dev", getOption("repos")))
    
Package Versions

Run on Windows 11 x64 (build 22621), with R version 4.3.1.

The packages used here:

  • careless 1.2.2(CRAN)
  • dplyr 1.1.3 (CRAN)
  • knitr 1.45 (CRAN)
  • lavaan 0.6-16 (CRAN)
  • lavaanPlot 0.6.2 (CRAN)
  • mvnormalTest 1.0.0 (CRAN)
  • psych 2.3.9 (CRAN)
  • pwr 1.3-0 (CRAN)
  • semPlot 1.1.6 (CRAN)
  • tidyr 1.3.0 (CRAN)

Feel free to adjust this based on your preferences and specific details about your code and setup.

sem-analysis-for-psychologists's People

Contributors

stephtowch avatar

Watchers

 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.