Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Wald and LM test with structural equational modeling (SEM)

    Hey Everyone

    Actually am doing an SEM analysis and i need to run a Wald Test and LM test to adjust a better model fit. The model is as following:

    sem( inadopc <- perfexpc effexpc socinflc facilcc hedonc pricec changec cognitcorrc change_cognition extravc agreec conscc neurotc openc)( perfexpc <- changec cognitcorrc change_cognition extravc agreec conscc neurotc openc)( effexpc <- changec cognitcorrc change_cognition extravc agreec conscc neurotc openc)(changec <- extravc agreec conscc neurotc openc)( cognitcorrc <- extravc agreec conscc neurotc openc)

    Thus can anyone help me with how to code in the command of stata 14 to run the wald and LM test for this model.

    Regards

    Ashraf Hilal

  • #2
    For the Wald test you can use the test command. The score test has not been implemented in Stata.
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment


    • #3
      Note that commands like estat gof and estat mindices can help you to assess model fit, e.g. the modification indices might suggest that a variable that is not in some equation should be in there. You can also do LR tests to contrast nested models.
      -------------------------------------------
      Richard Williams, Notre Dame Dept of Sociology
      StataNow Version: 19.5 MP (2 processor)

      EMAIL: [email protected]
      WWW: https://www3.nd.edu/~rwilliam

      Comment


      • #4
        I am not sure that the TEST command can be used and applied for SEM models ? !!!

        Regards

        Comment


        • #5
          Yeah Sr. Richard

          The thing is that i have conducted the fit model using estat gof, (all) and then estat mindices to see what can be modified, but now am in charged of running the wald test for this SEM model to insure what can be drooped out from the model to improve the fit indices found in the estat gof, (all) test.

          The issue is that how to run the wald test for this SEM function ?

          Regards

          Comment


          • #6
            Originally posted by Ashraf Hilal View Post
            I am not sure that the TEST command can be used and applied for SEM models ?
            Why are you not sure?
            ---------------------------------
            Maarten L. Buis
            University of Konstanz
            Department of history and sociology
            box 40
            78457 Konstanz
            Germany
            http://www.maartenbuis.nl
            ---------------------------------

            Comment


            • #7
              Since with SEM the way of analysis is different from normal models and regressions. Test if am not missing is used with normal variables while different commands are used form SEM functions

              Comment


              • #8
                My own inclination would be to run the model that has all the parameters in it, store the results, then run the model with fewer parameters, store the results, and then use lrtest.

                But, another alternative is to run the model with all the parameters in it, probably adding the coeflegend option. Then, use test commands.

                Here is an example. In the following, I want to test whether black and female can be dropped from the weight equation. I can either use a test command or an LR test, which in this case yield almost identical results. I didn't have to use coeflegend but it made it easier for me the get the test command right.

                Code:
                . * estimate the unconstrained model
                
                . sem (female black -> height) (female black height -> weight), coefl nolog
                
                Endogenous variables
                
                Observed:  height weight
                
                Exogenous variables
                
                Observed:  female black
                
                Structural equation model                       Number of obs     =     10,337
                Estimation method  = ml
                Log likelihood     = -86090.901
                
                ------------------------------------------------------------------------------
                             |      Coef.  Legend
                -------------+----------------------------------------------------------------
                Structural   |
                  height <-  |
                      female |  -13.51765  _b[height:female]
                       black |   .3979381  _b[height:black]
                       _cons |   174.7076  _b[height:_cons]
                  -----------+----------------------------------------------------------------
                  weight <-  |
                      height |   .6624414  _b[weight:height]
                      female |  -2.664485  _b[weight:female]
                       black |   3.490113  _b[weight:black]
                       _cons |  -38.12579  _b[weight:_cons]
                -------------+----------------------------------------------------------------
                var(e.height)|    47.7417  _b[var(e.height):_cons]
                var(e.weight)|   179.9492  _b[var(e.weight):_cons]
                ------------------------------------------------------------------------------
                LR test of model vs. saturated: chi2(0)   =      0.00, Prob > chi2 =      .
                
                . est store unconstrained
                
                . test _b[weight:female] = _b[weight:black] = 0
                
                 ( 1)  [weight]female - [weight]black = 0
                 ( 2)  [weight]female = 0
                
                           chi2(  2) =  115.56
                         Prob > chi2 =    0.0000
                
                . * Now estimate the constrained model with female and black effects on weight = 0
                
                . sem (female black -> height) (height -> weight), coefl nolog
                
                Endogenous variables
                
                Observed:  height weight
                
                Exogenous variables
                
                Observed:  female black
                
                Structural equation model                       Number of obs     =     10,337
                Estimation method  = ml
                Log likelihood     = -86148.362
                
                ------------------------------------------------------------------------------
                             |      Coef.  Legend
                -------------+----------------------------------------------------------------
                Structural   |
                  height <-  |
                      female |  -13.51765  _b[height:female]
                       black |   .3979381  _b[height:black]
                       _cons |   174.7076  _b[height:_cons]
                  -----------+----------------------------------------------------------------
                  weight <-  |
                      height |   .7593137  _b[weight:height]
                       _cons |  -55.39901  _b[weight:_cons]
                -------------+----------------------------------------------------------------
                var(e.height)|    47.7417  _b[var(e.height):_cons]
                var(e.weight)|    181.961  _b[var(e.weight):_cons]
                ------------------------------------------------------------------------------
                LR test of model vs. saturated: chi2(2)   =    114.92, Prob > chi2 = 0.0000
                
                . est store constrained
                
                . lrtest constrained unconstrained
                
                Likelihood-ratio test                                 LR chi2(2)  =    114.92
                (Assumption: constrained nested in unconstrained)     Prob > chi2 =    0.0000
                -------------------------------------------
                Richard Williams, Notre Dame Dept of Sociology
                StataNow Version: 19.5 MP (2 processor)

                EMAIL: [email protected]
                WWW: https://www3.nd.edu/~rwilliam

                Comment


                • #9
                  test is listed as a post-estimation command for sem, as is lrtest. Sure, it is always possible that a violation of this or that assumption makes something invalid in a specific instance, but it isn't a universal thing. See

                  help sem postestimation
                  -------------------------------------------
                  Richard Williams, Notre Dame Dept of Sociology
                  StataNow Version: 19.5 MP (2 processor)

                  EMAIL: [email protected]
                  WWW: https://www3.nd.edu/~rwilliam

                  Comment


                  • #10
                    Originally posted by Ashraf Hilal View Post
                    Since with SEM the way of analysis is different from normal models and regressions. Test if am not missing is used with normal variables while different commands are used form SEM functions
                    That is incorrect, the Wald test is definitely not limited to models for normally distributed variables. It is perfectly fine for SEMs.
                    ​​​​​
                    ---------------------------------
                    Maarten L. Buis
                    University of Konstanz
                    Department of history and sociology
                    box 40
                    78457 Konstanz
                    Germany
                    http://www.maartenbuis.nl
                    ---------------------------------

                    Comment


                    • #11
                      Thanks for you all. Well appreciated Sir. Richard and again thanks sir Maarten. I already noticed that Wald test is not limited to models but the way of executing it differs (supposed to be so). Thus executing it with the Test command is not correct, it must be executed using estat eqtest or as sir. Richard indicated for linear equations.

                      Regards

                      Comment


                      • #12
                        estat eqtest has its uses but I am not sure how it fits in with your goal "to insure what can be drooped out from the model to improve the fit indices found in the estat gof, (all) test. " It is just going to test whether all coefficients equal zero. estat eqtest "Equation-level test that all coefficients are zero." Even if the results are highly significant, it doesn't tell you whether specific effects should be dropped or added.
                        -------------------------------------------
                        Richard Williams, Notre Dame Dept of Sociology
                        StataNow Version: 19.5 MP (2 processor)

                        EMAIL: [email protected]
                        WWW: https://www3.nd.edu/~rwilliam

                        Comment


                        • #13
                          Perfectly explained. But in case to add some variables to better fit the model we shell run score test no ? and as maarten said score test are not implemented yet in stata so what shell we perform ?

                          Comment


                          • #14
                            I am not sure what you don't like about the ideas already tossed out, e.g. run constrained and unconstrained models and then contrast them. I will note that "estat scoretests displays score tests (Lagrangian multiplier tests) for each of the user-specified linear constraints imposed on the model when it was fit." But, that may not apply to what you are doing unless you are imposing constraints when running your model.
                            -------------------------------------------
                            Richard Williams, Notre Dame Dept of Sociology
                            StataNow Version: 19.5 MP (2 processor)

                            EMAIL: [email protected]
                            WWW: https://www3.nd.edu/~rwilliam

                            Comment


                            • #15
                              Appreciated Thanks

                              Comment

                              Working...
                              X