Announcement

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

  • Questions in doing sem

    Hi there! I want to conduct an SEM model to test the mediator. However, it shows 'factor-variable operators not allowed on latent variable I3a_7_0'.

    In this model, dependent variable is unsafe(continuous variable) , independent variable is techono (continuous) , the meditator is anti_behav(continuous). Others are control variables, I3a_7_0 (category) age I2_1(category) maritalstatus (category) Igender(category) i.I1_3_2(category) income

    The code is:
    sem (anti_behav<-techno i.I3a_7_0 age i.I2_1 i.maritalstatus i.Igender i.I1_3_2 income) (unsafe<-anti_behav techno i.I3a_7_0 age i.I2_1 i.maritalstatus i.Igender i.I1_3_2 income)

    Could anyone tell me where is wrong?

  • #2
    You’ve got a few problems.

    sem does not support factor variable notation. If you need dummy variables you need to compute them yourself,

    Variable names that start with a capital letter are assumed to be latent variables. Those vars that start with capital I therefore need to be renamed.
    -------------------------------------------
    Richard Williams, Notre Dame Dept of Sociology
    StataNow Version: 19.5 MP (2 processor)

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

    Comment


    • #3
      In -sem-, by default, any variable whose name begins with an upper case letter is assumed to be a latent variable. And in -sem- only continuous latent variables are allowed. So when Stata sees i.I3a_7_0, it thinks you are applying the factor operator i., which requires a discrete variable, to a latent, hence continuous variable. I see there are a number of other variables you have that begin with upper case I, and these will get you into trouble as well, because I do not believe from their names that you intend them to be latent variables. One solution is to rename those variables so they begin with lower case letters. Perhaps simpler in your situation is to use the -nocapslatent- option to -sem-, which overrides the default assumption. (In that case, if you have any variables you intend to be latent, you must list them in a -latent()- option.)

      There is another problem: -sem- does not support factor variable notation at all. So if your intent is that I3a_7_0 should be a categorical variable specified in the regression as a series of indicator ("dummy") variables, you either have to create those indicator variables yourself, or switch to -gsem-, which does support factor-variable notation. The drawback to using -gsem- in a mediation model analysis is that -gsem- does not have the -estat teffects- postestimation command that simplifies the interpretation of mediation models. Only -sem- has that.

      Added: Crossed with #2.

      Comment


      • #4
        Richard Williams Thank you very much!

        Comment

        Working...
        X