Questions tagged [r-lavaan]

A free, open-source `R` package for latent variable analysis. `lavaan` includes support for a large variety of multivariate statistical models which contain (or not) latent variables. It allows multilevel analysis, and as estimators that deal with missing values and categorical data. Some of the applications available are confirmatory factor analysis, full structural equation models, latent growth curve models, and path analysis.

A free, open-source R package for latent variable analysis. lavaan includes support for a large variety of multivariate statistical models which contain (or not) latent variables. It allows multilevel analysis, and as estimators that deal with missing values and categorical data. Some of the applications available are confirmatory factor analysis, full structural equation models, latent growth curve models, and path analysis.

Resources

Repositories

Related plotting packages

  • lavaanPlot - Visual analusis of lavaan models.
  • semPlot - visual analysis of various SEM packages' output, including lavaan.
308 questions
1
vote
1 answer

Fixed effect and random intercept models using "lavaan" in R: advice on coding

I´m trying to fit some path models (i.e. all variables are observed; no latent variables) using “lavaan” in R. I´ve been able to do this successfully for a model where the data are completely pooled (Model 1, below). But, the data are grouped and…
1
vote
0 answers

Problem with function/ replacement has length zero

I'm trying to run the following function proposed by Lai et al., 2021, that aims to compare fit differences in non-nested models with categorical AVs. The Models look like this: Mod1 <- ' # Measurement models # Predictor Variables …
Jan
  • 61
  • 1
  • 8
1
vote
0 answers

Stop lavaan's `sem()` function to print output

I am trying to run Monte Carlo simulations using R with the lavaan package and its function sem(). However, at every iteration, the output of sem() is showed, which is not very convenient. Is there a known way to stop that. Here is a minimal…
POC
  • 268
  • 1
  • 2
  • 7
1
vote
1 answer

Trouble Converging Bifactor model using lavaan

Title basically explains it but I'm trying to build a bifactor model with psychopathy as one factor and subtypes as the other. I believe that I have everything constrained properly but that might be the issue. Current code: BifactorModel <-…
Andrew
  • 25
  • 5
1
vote
1 answer

How can I add a value from a list or dataframe to the lavaan syntax?

When specifying a model in lavaan, it is possible to fixate certain variables. For example we can assume an monotonic increase in relationship of X (latent factor) from y1 (observation) through y5. This syntax would look as follows: model <- ' X =~…
HvG
  • 43
  • 8
1
vote
0 answers

Error related to ordering of factors while conducting Confirmatory Factor Analysis on lavaan

I am trying to run an R script using lavaan to conduct a Confirmatory Factor Analysis, but this ended up happening. Error in lav_data_full(data = data, group = group, cluster = cluster, : lavaan ERROR: unordered factor(s) detected; make them…
1
vote
0 answers

Comparing standardized factor loadings between non nested models

For my master thesis I am comparing Models using SEM (lavaan). I conducted an online survey to validate new scales to assess ict stress factors and resources. Since the questionnaire was quite long and I suspected there might be problems with…
Hans Ueli
  • 21
  • 2
1
vote
1 answer

How can I deal with the Lavaan error: "syntax error in lavaan model syntax"?

I am trying to do a CFA for the first time. Lavaan gives the following error. Error in lavParseModelString(model) : lavaan ERROR: syntax error in lavaan model syntax My code looks simplified like this: mycfa <- 'Construct =~ A + …
formatc
  • 35
  • 5
1
vote
0 answers

Discrete Choice modelling in Lavaan package - R

I am trying to use structural equation modelling (SEM) where I would have the final dependent variable which is nominal, thus requiring Choice modelling. Is there a way I can do this choice modelling in lavaan package in R or any other R package for…
snow
  • 31
  • 2
1
vote
1 answer

Model fit of SEM in Lavaan

What is the reason for CFI=0 in a sem model in Lavaan. Statistic values are attached
Stat009
  • 45
  • 1
  • 5
1
vote
0 answers

APIM: The Actor–Partner Interdependence Model

Does anyone here have experience with Kenny's APIM analysis, using the web app (https://apimsem.ugent.be/shiny/apim_sem/)? I want to control for two variables (age, gender) simultaneously in my APIM model, by including them both as mixed/within…
Kevin Liu
  • 11
  • 1
1
vote
1 answer

Extract error covariance matrix from lavaan

I want to extract the error covariance matrix from sem() but I don't know if I did it correctly. I used inspect("cov.ov") and for "cov.ov" the document says "The model-implied variance-covariance matrix". So is this the same as error covariance…
cliu
  • 933
  • 6
  • 13
1
vote
1 answer

SEM - Analysis of invariance to test regressions

Let's suppose we have a confirmatory factor analysis CFA with three latent variables (visual, textual, and speed) and that we want to add a regression where speed is the outcome and visual and textual are the explanatory variables (that is to say,…
Orlando Sabogal
  • 1,470
  • 7
  • 20
1
vote
0 answers

How to Adjust for Cronbach's Alpha Measurement Error in lavaan in R

Can anyone advise how best to account for measurement error (as measure by Cronbach's alpha) using the lavaan package in R? Below is a full example. The example attempts to predict the number of friends someone has based on their level of…
aspark2020
  • 341
  • 2
  • 17
1
vote
0 answers

Cross-lagged panel modelling in R using lavaan

I am exploring the bidirectional association between two variables over three timepoints (T1, T2, T3), and am considering using R's lavaan package to run a cross-lagged panel model. One of the dependent variables (DVs) is continuous and the other is…
Alice
  • 99
  • 1
  • 9