Confirmatory factor analysis in R (Jan. 2020)

Поділитися
Вставка
  • Опубліковано 25 чер 2024
  • This video walks you through basics of performing confirmatory factor analysis using R. I use the 'lavaan' package to perform the analyses.
    The data file used in this video can be downloaded here:
    drive.google.com/file/d/1Ow3T...
    The text file used in the video can be downloaded here:
    drive.google.com/file/d/12ey9...
    The article cited in the video can be accessed here (journals.plos.org/plosone/art....
    PLEASE VISIT THE FOLLOWING SITE FOR MORE EXAMPLES OF CFA AND SEM USING R, AMOS, STATA, AND OTHER PROGRAMS: sites.google.com/view/statist...

КОМЕНТАРІ • 52

  • @raoulio351996
    @raoulio351996 Рік тому +4

    I am needing to learn CFA from scratch for my master's thesis. I have some familiarity but feel completely overwhelmed looking at R. This video is such a fantastic explanation; I feel so much better about my ability to run these tests in R after watching it! Thank you so much.

    • @mikecrowson2462
      @mikecrowson2462  Рік тому

      thank you very much for your kind words, River! Good luck with your thesis!

  • @specfunctor
    @specfunctor Рік тому

    What an excellent exposition of the CFA and the lavaan package! Many thanks, Mike!

  • @FuryAntrax
    @FuryAntrax 3 роки тому

    Writing my thesis now, you are very helpful. Thanks a lot to you and your kind of people.

  • @henriquetakahasi
    @henriquetakahasi 4 роки тому +1

    Great video! Thanks! In CFA for categorical variables, which fit indexes should I use, the standard column or the robust one?

  • @SuFangEungKhaiNBTFan
    @SuFangEungKhaiNBTFan 3 роки тому

    Thank you so much!

  • @aungchan623
    @aungchan623 3 роки тому

    Hi Mike, thanks for your great demo, it helps me understanding CFA in R. But one thing I want to know is that how should we modified the model when fit indicators doesn't match the required level.
    In SPSS Amos, when running CFA, we have to reduce the items in order to improve the model fit.
    How should we do to improve the model fit in R?

  • @manjuharil232
    @manjuharil232 4 роки тому +1

    Thank for this video. Why you have taken these two variables ce3 and ce8 for correlation in the model( ce3 ~~ce8). What is the rationale behind the selection of variables here?

  • @rowansmeets2125
    @rowansmeets2125 2 роки тому +1

    Hi Mike, Could you refer me to some literature about when to use the standard fit indices and when to use the robust ones? Thanks!

  • @krisztinakopcso4392
    @krisztinakopcso4392 4 роки тому

    Dear Mike, thanks for you video, it helped me a lot! I have one question though. When I run CFA with categorical variables, should I report the standard, or the robust model fit values (CFI, TLI, RMSEA, SMRM)?

    • @mikecrowson2462
      @mikecrowson2462  4 роки тому

      Hi there. I would report on the robust model fit values, noting that they are robust fit statistics. Best wishes!

  • @laraflorence9156
    @laraflorence9156 3 роки тому

    My data is not normally distributed and has no intervallscale but ordinal. Can I combine the codes for the Santorra Bentler correction and the code to indicate ordinal variables? And how do I interpret? Could you also do a video with how to edit the path?

  • @94niru
    @94niru 4 роки тому

    @Mike Crowson, how did you decide that ce3 is correlated with ce8? was this based on the exploratory factor analysis? or did you simply find the correlations between each of the factors to see which ones are correlated?

    • @mikecrowson2462
      @mikecrowson2462  4 роки тому

      It's been awhile since I put this demo together, but in all likelihood I either (a) chose to correlate these errors at random simply to show you how to do this during cfa or (b) I was following from the article (you can download it at the plos one link I referenced). In real practice, folks may specify correlated errors based on substantive theoretical or measurement considerations, or in an exploratory fashion such as via use of modification indices.

    • @94niru
      @94niru 3 роки тому

      @@mikecrowson2462 Thank you for your input, it is much appreciated. I did notice the ModificationIndices() function. What are your thoughts on that? Should we be tweaking our models based on what corrections it suggests us to do. I'm under the impression that Chi-Square/df should be close to or below 2.5. From my understanding ModificationIndices() helps with reducing the Chi Square down a bit.

  • @vitorklein
    @vitorklein 4 роки тому +1

    Many thanks for the video, i was looking for a way to covariate 2 variables in order to increase the fit of the model. Many thanks from Brazil.

    • @mikecrowson2462
      @mikecrowson2462  4 роки тому

      You are very welcome. Thanks for visiting! cheers!

  • @BLooDy21HD
    @BLooDy21HD 3 роки тому

    Thanks for the video, totally saved me!
    One question, what is the difference between using "~~" and "~"?
    For example, what would change if instead typing
    "ce3~~ce8" you typed "ce3~ce8"?

    • @mikecrowson2462
      @mikecrowson2462  3 роки тому +1

      The single tilde is used when you are performing regression. For instance, y~x1+x2. The double tilde (~~) is used when you are correlating variables (or errors, as I did in the the example). Cheers!

  • @EdvanAguiarEA
    @EdvanAguiarEA 3 роки тому

    How to interpret the R2 of the indicators in a CFA with only 1 Latent Variable? In this example you do not use the 'rsquare' argument inside the cfa() function.

  • @mertgunes7085
    @mertgunes7085 3 роки тому

    Thanks for the video.
    In the ordered modeling case you used ce20 two times and didn't use c17. Why did you do the analysis like this?

    • @mikecrowson2462
      @mikecrowson2462  3 роки тому

      Hi Murat, it looks to be a typo. I meant to put ce17 in there in addition to ce20. Thanks for finding it :) Best wishes!

  • @philipdoyle9242
    @philipdoyle9242 3 роки тому

    Excellent tutorial Mike. Could you explain why you might need to stipulate covariance between specific items within the model? (i.e., where you have 'ce3~~ce8' in your script)

    • @mikecrowson2462
      @mikecrowson2462  3 роки тому

      Hi Phillip. The correlated error that I included here was basically to show you how you can do it if you needed to do it for some reason. But my decision was not based on theory or anything like that in the demo. One instance where a person might include a correlated error is if there is some type of wording or method artifact associated with the items that might result in the items being correlated not only as a result of the latent factor, but also some specific variation associated with them that is not modeled as a function of the factors on which the items are loaded. For example, if you thought that part of the specific variances associated with the items are attributable to some other common factor such as wording or other method factor you could add the correlated error to account for it. Hope this helps!

    • @philipdoyle9242
      @philipdoyle9242 3 роки тому

      @@mikecrowson2462 Super helpful. Thanks Mike, much appreciated

  • @prasadk6510
    @prasadk6510 3 місяці тому

    How to deal with missing values? Should we impute or discard the cases?

  • @siyisoy
    @siyisoy 4 роки тому

    Nice video Mike. I appreciate your efforts. I wonder why you use the ugly, insufficent R interface, while there are bunch of GUI alternatives like RStudio, the main player in this area?

    • @mikecrowson2462
      @mikecrowson2462  4 роки тому

      Hi there. Well, I guess I just learned R "old school". Maybe I'll transition over at some point in the future :) cheers!

    • @balnurskak4168
      @balnurskak4168 3 роки тому

      @@mikecrowson2462 i would prefer this old one too, simple and clear :)thanks foe the video!

  • @marvinrobot962
    @marvinrobot962 3 роки тому

    Please help. What happens if my survey data is full of missing values? Ok so lets say we find that the model is ok , what method do we use to aggregate the values? Do we use mean or median? We will lose the variation info.. How do we retain that? Thanks !

    • @mikecrowson2462
      @mikecrowson2462  3 роки тому

      If you have missing values, then you can invoke Full-information maximum likelihood by including the 'missing' argument and setting it to "ML" when using the cfa function. For example: cfa(model, data, missing="ML"). See more on this topic here: lavaan.ugent.be/tutorial/est.html . If you don't use this option, the program will utilize listwise deletion. Just an FYI, a lot of the options for lavaan are described in this article: www.jstatsoft.org/index.php/jss/article/view/v048i02/v48i02.pdf
      Cheers!

  • @mcheng1846
    @mcheng1846 3 роки тому

    Hi! Does the Ordered statement can also deal with dichotomous indicators (correct/incorrect items)? If not, what should be the correct statement for dealing with dichotomous ones? Thank you in advanced!

    • @mikecrowson2462
      @mikecrowson2462  3 роки тому

      Hi. Yes, it works for these items. It would also work with agree-disagree type of response format. Cheers!

    • @mcheng1846
      @mcheng1846 3 роки тому

      @@mikecrowson2462 Thank you so much for the quick reply! I am using the same codes as yours somehow it keeps popping out "Error: object 'model' not found". I wonder what might cause this issue? (my data is loading successfully & lavaan had been installed successfully. I also checked spelling everything looks good.)... Thank you!

    • @mikecrowson2462
      @mikecrowson2462  3 роки тому

      @@mcheng1846 The error says the object 'model' is not found. In my videos I name the object containing the code for the cfa model, 'model' (pretty bland, right?). If you changed the name to something else for the object containing the model specification, then that change in naming would need to be reflected in the code where you are using the CFA function. In other words, the cfa function cannot find your model information. Right now, that's the only thing I can think of.
      for example, using code from lavaan.ugent.be/tutorial/cfa.html
      HS.model

    • @mcheng1846
      @mcheng1846 3 роки тому

      @@mikecrowson2462 Thank you so much!!! OMG you are so kind & generous! I did fix that issue, however, the new error I have is
      Warning message: In lavaan::lavaan(model = model, data = pupil, ordered = c("CT1", : lavaan WARNING: the optimizer warns that a solution has NOT been found!
      Have no clue what it is...
      My codes are:
      pupil

  • @segunemmanuel2322
    @segunemmanuel2322 4 роки тому

    Please what software is this R and how can I get the software in one wanted to perform CFA using R. I will appreciate your prompt response

    • @mikecrowson2462
      @mikecrowson2462  4 роки тому

      Hi there. You can download R from this site: www.r-project.org/ . The package that was used in the analysis was 'lavaan'. If you download the text file underneath the video description, there are links to various lavaan resources.
      Best wishes!

  • @balnurskak4168
    @balnurskak4168 3 роки тому

    I am not sure about this part 'ce3~~ce8'', why only from ce3 to ce8? thanks in advance

    • @mikecrowson2462
      @mikecrowson2462  3 роки тому

      Hi there. I wasn't testing theory. I was just demonstrating how to set an error covariance between two measured endogenous variables. There likely are other error covariances that could be added. Cheers!

  • @m...7570
    @m...7570 Рік тому

    Thank you for this video. I followed the steps but I got an error message "covariance matrix of latent variables is not positive definite". There aren't any negative values in the covariance matrix though and also not in the correlation matrix. Grateful for any help to fix this issue.

    • @mikecrowson2462
      @mikecrowson2462  Рік тому

      Hello. The statement that the covariance matrix of latent variables is not positive definite does not have anything to do with negative values in the matrix. Oftentimes, this is the result of some type of linear dependency among the variables or perhaps other problems. Solving this problem is not always straightforward given the possible number of things that may contribute to this problem. I wish I could offer you more on this, but the best I can do is refer to you the following for more information: www3.nccu.edu.tw/~mnyu/2020%20Latent%20Variable%20Modeling/Not%20Positive%20Definite%20Matrices.pdf

  • @ilhanilkeralbulut6620
    @ilhanilkeralbulut6620 4 роки тому

    Error in cfa(model, data = a) : unused argument (data = a)
    > summary(fit,fit.measures=TRUE,standardized=TRUE)
    Error in summary(fit, fit.measures = TRUE, standardized = TRUE) :
    'fit' object cannot fine
    I am taking this error, Could you help me to solve it, Please ?

    • @ilhanilkeralbulut6620
      @ilhanilkeralbulut6620 4 роки тому

      cannot find*

    • @mikecrowson2462
      @mikecrowson2462  4 роки тому

      If there's an error in the cfa portion, then the fit object won't be created that contains the fit information. From there on, requesting summary information won't work because the cfa wasn't performed. It looks like the error says there's an 'unused argument(data=a)'. If your data frame (i.e., containing your data) is not 'a', then that may be the source of your problem. Make sure you are referencing the correct name of the data frame

  • @segunemmanuel2322
    @segunemmanuel2322 4 роки тому +1

    I think is lot easier to understand and operate than AMOS software. Please Mike Crowson, I will like to know which software is this and how to get it... Please kindly treat as urgent. Thanks

    • @mikecrowson2462
      @mikecrowson2462  4 роки тому

      Hi there. You can download R from this site: www.r-project.org/ . The package that was used in the analysis was 'lavaan'. If you download the text file underneath the video description, there are links to various lavaan resources.
      Best wishes!

  • @segunemmanuel2322
    @segunemmanuel2322 4 роки тому +1

    Please what software is this R and how can I get the software in one wanted to perform CFA using R. I will appreciate your prompt response