Giter VIP home page Giter VIP logo

minvariance's Introduction

minvariance

The goal of minvariance is to aid the understanding of longitudinal measurement invariance and see which parts of this method could be automated in R. The vignettes on the website of this package aim to replicate some examples found online. If you have any questions, ideas, or comments please get in touch.

Installation

You can install the released version of minvariance from GitHub with:

# install.packages("devtools")
devtools::install_github("milanwiedemann/minvariance")
library(tidyverse)
#> ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.0 ──
#> ✓ ggplot2 3.3.3     ✓ purrr   0.3.4
#> ✓ tibble  3.1.0     ✓ dplyr   1.0.5
#> ✓ tidyr   1.1.3     ✓ stringr 1.4.0
#> ✓ readr   1.4.0     ✓ forcats 0.5.1
#> ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
#> x dplyr::filter() masks stats::filter()
#> x dplyr::lag()    masks stats::lag()
library(minvariance)

# Specify list of variables 
# Generate lavaan syntax
long_minvariance_syntax(var_list = list(t1 = c("i1_t1", "i2_t1", "i3_t1"), 
                                        t2 = c("i1_t2", "i1_t2", "i1_t2")), 
                        model = "configural") %>% 
  cat()
#> Configural Invariance Model (Pattern Invariance)
#> #### CONFIGURAL INVARIANCE MODEL ####
#> # Specify Latent Factors ----
#> eta1 =~ NA * i1_t1 + lambda1 * i1_t1 + i2_t1 + i3_t1
#> eta2 =~ NA * i1_t2 + lambda1 * i1_t2 + i1_t2 + i1_t2
#> # Specify Latent Variable Means ----
#> eta1 ~ 0 * 1 
#> eta2 ~ 1 
#> # Specify Latent Variable Variances ----
#> eta1 ~~ 1 * eta1
#> eta2 ~~ eta2
#> # Specify Latent Variable Covariances ----
#> eta1 ~~ eta2
#> # Specify Observed Variable Intercepts ----
#> i1_t1 ~ tau1 * 1 
#> i2_t1 ~ 1 
#> i3_t1 ~ 1 
#> i1_t2 ~ tau1 * 1 
#> i1_t2 ~ 1 
#> i1_t2 ~ 1 
#> # Specify Unique Variances ----
#> i1_t1 ~~ i1_t1 
#> i2_t1 ~~ i2_t1 
#> i3_t1 ~~ i3_t1 
#> i1_t2 ~~ i1_t2 
#> i1_t2 ~~ i1_t2 
#> i1_t2 ~~ i1_t2 
#> # Specify Unique Covariances ----
#> i1_t1 ~~ i1_t2
#> i2_t1 ~~ i1_t2
#> i3_t1 ~~ i1_t2

Here’s another example with different variable names

# Generate lavaan syntax
long_minvariance_syntax(var_list = list(t1 = c("a1", "b1", "c1"), 
                                        t2 = c("a2", "b2", "c2")), 
                        model = "strong") %>% 
  cat()
#> Strong Invariance Model (Scalar Invariance, Intercept Invariance)
#> #### STRONG INVARIANCE MODEL ####
#> # Specify Latent Factors ----
#> eta1 =~ NA * a1 + lambda1 * a1 + lambda2 * b1 + lambda3 * c1
#> eta2 =~ NA * a2 + lambda1 * a2 + lambda2 * b2 + lambda3 * c2
#> # Specify Latent Variable Means ----
#> eta1 ~ 0 * 1 
#> eta2 ~ 1 
#> # Specify Latent Variable Variances ----
#> eta1 ~~ 1 * eta1
#> eta2 ~~ eta2
#> # Specify Latent Variable Covariances ----
#> eta1 ~~ eta2
#> # Specify Observed Variable Intercepts ----
#> a1 ~ tau1 * 1 
#> b1 ~ tau2 * 1 
#> c1 ~ tau3 * 1 
#> a2 ~ tau1 * 1 
#> b2 ~ tau2 * 1 
#> c2 ~ tau3 * 1 
#> # Specify Unique Variances ----
#> a1 ~~ a1 
#> b1 ~~ b1 
#> c1 ~~ c1 
#> a2 ~~ a2 
#> b2 ~~ b2 
#> c2 ~~ c2 
#> # Specify Unique Covariances ----
#> a1 ~~ a2
#> b1 ~~ b2
#> c1 ~~ c2

Resources and related work

R functions to test for longitudinal factorial/measurement invariance

minvariance's People

Contributors

milanwiedemann avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

minvariance's Issues

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.