Announcement

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

  • Cross-lagged panel models with binary and continuous outcome variables: gsem or sem (?) + other questions

    Greetings,

    I'm running Stata 15.1 on OSX and working with yearly panel data. My hypothesis predicts that social media activity (a continuous variable) at t-2 and t-1 will predict agreement with a statement (a binary variable) at t-1 and t. I also aim to test if there's any evidence of a causal relationship, which would, for instance, mean that the effects of social media activity at t-2 on agreement at t-1 are significantly stronger than the effects of agreement at t-2 on social media activity at t-1. In other words, I'd like to test a cross-lagged model. The question relates to the fact that the two variables are measured along different scales--one continuous and the other binary. I'm aware that -sem- only allows for continuous outcome variables, while -gsem- allows for both. If I estimate the model with -gsem-, however, how would I be able to test for equality of coefficients? If I were to instead use -sem-, this issue could be rectified by standardizing the coefficients (i.e. estat stdize: test coefficient1 vs. coefficient2). However, the parameter estimates obtained from using -sem- might be unreliable given the disparately-measured outcome variables. As such, I'm not quite sure how to proceed. Is it possible to standardize and test the equality of coefficients with gsem? If not, should I simply treat the binary variable as continuous and stick to SEM (while leaving open the possibility that the estimates are unreliable?). I would greatly appreciate any advice you might have for approaching this issue.

    Here is some sample data:

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float(sma sma_lag1 sma_lag2) byte whpa float(whpa_lag1 whpa_lag2)    double    caseid    float(time    year)
    -.15783915          .          . 0 . . 100197 1 2016
    .18903075 -.15783915          . 0 0 . 100197 2 2017
    -.13314976  .18903075 -.15783915 1 0 0 100197 3 2018
    -.13009462          .          . 0 . . 100252 1 2016
    0 -.13009462          . 0 0 . 100252 2 2017
    0          0 -.13009462 . 0 0 100252 3 2018
    -.15783915          .          . 0 . . 100260 1 2016
    -.15783915 -.15783915          . 0 0 . 100260 2 2017
    -.13314976 -.15783915 -.15783915 0 0 0 100260 3 2018
    -.06436194          .          . 0 . . 100314 1 2016
    -.06436194 -.06436194          . 0 0 . 100314 2 2017
    -.02402338 -.06436194 -.06436194 0 0 0 100314 3 2018
    .02230732          .          . 0 . . 100363 1 2016
    .56018245  .02230732          . 0 0 . 100363 2 2017
    -.13314976  .56018245  .02230732 0 0 0 100363 3 2018
    0          .          . . . . 100413 1 2016
    0          0          . . . . 100413 2 2017
    0          0          0 . . . 100413 3 2018
    -.15783915          .          . 0 . . 100446 1 2016
    -.06436194 -.15783915          . 0 0 . 100446 2 2017
    -.02402338 -.06436194 -.15783915 0 0 0 100446 3 2018
    -.15783915          .          . 0 . . 100514 1 2016
    -.06436194 -.15783915          . 0 0 . 100514 2 2017
    0 -.06436194 -.15783915 . 0 0 100514 3 2018
    .02230732          .          . 0 . . 100588 1 2016
    .02230732  .02230732          . 1 0 . 100588 2 2017
    .27179015  .02230732  .02230732 1 1 0 100588 3 2018
    -.06436194          .          . 0 . . 100598 1 2016
    -.06436194 -.06436194          . 0 0 . 100598 2 2017
    -.02402338 -.06436194 -.06436194 0 0 0 100598 3 2018
    -.13009462          .          . 0 . . 100604 1 2016
    -.06436194 -.13009462          . 0 0 . 100604 2 2017
    -.02402338 -.06436194 -.13009462 0 0 0 100604 3 2018
    -.13009462          .          . 0 . . 100637 1 2016
    -.15783915 -.13009462          . 0 0 . 100637 2 2017
    -.13314976 -.15783915 -.13009462 0 0 0 100637 3 2018
    .09993055          .          . 0 . . 100734 1 2016
    .11578453  .09993055          . 0 0 . 100734 2 2017
    -.02402338  .11578453  .09993055 0 0 0 100734 3 2018
    -.15783915          .          . 0 . . 100803 1 2016
    -.15783915 -.15783915          . 0 0 . 100803 2 2017
    -.13314976 -.15783915 -.15783915 0 0 0 100803 3 2018
    0          .          . . . . 100866 1 2016
    0          0          . . . . 100866 2 2017
    0          0          0 . . . 100866 3 2018
    0          .          . . . . 100982 1 2016
    0          0          . . . . 100982 2 2017
    0          0          0 . . . 100982 3 2018
    -.15783915          .          . 0 . . 101224 1 2016
    -.15783915 -.15783915          . 0 0 . 101224 2 2017
    -.13314976 -.15783915 -.15783915 0 0 0 101224 3 2018
    -.15783915          .          . 0 . . 101322 1 2016
    -.15783915 -.15783915          . 0 0 . 101322 2 2017
    -.13314976 -.15783915 -.15783915 0 0 0 101322 3 2018
    0          .          . . . . 101368 1 2016
    0          0          . . . . 101368 2 2017
    0          0          0 . . . 101368 3 2018
    .25423202          .          . 0 . . 101400 1 2016
    0  .25423202          . . 0 . 101400 2 2017
    .3809165          0  .25423202 . . 0 101400 3 2018
    -.15783915          .          . 0 . . 101437 1 2016
    -.15783915 -.15783915          . 0 0 . 101437 2 2017
    -.13314976 -.15783915 -.15783915 0 0 0 101437 3 2018
    -.13009462          .          . 0 . . 101443 1 2016
    0 -.13009462          . . 0 . 101443 2 2017
    0          0 -.13009462 . . 0 101443 3 2018
    .28250796          .          . 0 . . 101472 1 2016
    .28250796  .28250796          . 0 0 . 101472 2 2017
    .27179015  .28250796  .28250796 0 0 0 101472 3 2018
    .4626544          .          . 0 . . 101485 1 2016
    .4626544   .4626544          . 0 0 . 101485 2 2017
    .3809165   .4626544   .4626544 0 0 0 101485 3 2018
    -.15783915          .          . 0 . . 101493 1 2016
    .3967137 -.15783915          . 0 0 . 101493 2 2017
    .27179015   .3967137 -.15783915 0 0 0 101493 3 2018
    0          .          . . . . 101495 1 2016
    0          0          . . . . 101495 2 2017
    0          0          0 . . . 101495 3 2018
    0          .          . . . . 101712 1 2016
    0          0          . . . . 101712 2 2017
    0          0          0 . . . 101712 3 2018
    -.15783915          .          . 0 . . 102009 1 2016
    .11578453 -.15783915          . 1 0 . 102009 2 2017
    -.13314976  .11578453 -.15783915 1 1 0 102009 3 2018
    0          .          . . . . 102130 1 2016
    0          0          . 1 . . 102130 2 2017
    0          0          0 . 1 . 102130 3 2018
    .02230732          .          . 0 . . 102198 1 2016
    .02230732  .02230732          . 0 0 . 102198 2 2017
    -.13314976  .02230732  .02230732 0 0 0 102198 3 2018
    -.13009462          .          . . . . 102351 1 2016
    0 -.13009462          . 0 . . 102351 2 2017
    0          0 -.13009462 . 0 . 102351 3 2018
    .380036          .          . 0 . . 102352 1 2016
    0    .380036          . . 0 . 102352 2 2017
    0          0    .380036 . . 0 102352 3 2018
    0          .          . . . . 102400 1 2016
    0          0          . . . . 102400 2 2017
    0          0          0 . . . 102400 3 2018
    -.15783915          .          . 0 . . 102584 1 2016
    end
    Thanks in advance!

    -Zach

  • #2
    Sample data appears to be misaligned (not sure if that matters). Let me try again:

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float(sma sma_lag1 sma_lag2) byte whpa float(whpa_lag1 whpa_lag2) double caseid float(time year)
    -.15783915          .          . 0 . . 100197 1 2016
     .18903075 -.15783915          . 0 0 . 100197 2 2017
    -.13314976  .18903075 -.15783915 1 0 0 100197 3 2018
    -.13009462          .          . 0 . . 100252 1 2016
             0 -.13009462          . 0 0 . 100252 2 2017
             0          0 -.13009462 . 0 0 100252 3 2018
    -.15783915          .          . 0 . . 100260 1 2016
    -.15783915 -.15783915          . 0 0 . 100260 2 2017
    -.13314976 -.15783915 -.15783915 0 0 0 100260 3 2018
    -.06436194          .          . 0 . . 100314 1 2016
    -.06436194 -.06436194          . 0 0 . 100314 2 2017
    -.02402338 -.06436194 -.06436194 0 0 0 100314 3 2018
     .02230732          .          . 0 . . 100363 1 2016
     .56018245  .02230732          . 0 0 . 100363 2 2017
    -.13314976  .56018245  .02230732 0 0 0 100363 3 2018
             0          .          . . . . 100413 1 2016
             0          0          . . . . 100413 2 2017
             0          0          0 . . . 100413 3 2018
    -.15783915          .          . 0 . . 100446 1 2016
    -.06436194 -.15783915          . 0 0 . 100446 2 2017
    -.02402338 -.06436194 -.15783915 0 0 0 100446 3 2018
    -.15783915          .          . 0 . . 100514 1 2016
    -.06436194 -.15783915          . 0 0 . 100514 2 2017
             0 -.06436194 -.15783915 . 0 0 100514 3 2018
     .02230732          .          . 0 . . 100588 1 2016
     .02230732  .02230732          . 1 0 . 100588 2 2017
     .27179015  .02230732  .02230732 1 1 0 100588 3 2018
    -.06436194          .          . 0 . . 100598 1 2016
    -.06436194 -.06436194          . 0 0 . 100598 2 2017
    -.02402338 -.06436194 -.06436194 0 0 0 100598 3 2018
    -.13009462          .          . 0 . . 100604 1 2016
    -.06436194 -.13009462          . 0 0 . 100604 2 2017
    -.02402338 -.06436194 -.13009462 0 0 0 100604 3 2018
    -.13009462          .          . 0 . . 100637 1 2016
    -.15783915 -.13009462          . 0 0 . 100637 2 2017
    -.13314976 -.15783915 -.13009462 0 0 0 100637 3 2018
     .09993055          .          . 0 . . 100734 1 2016
     .11578453  .09993055          . 0 0 . 100734 2 2017
    -.02402338  .11578453  .09993055 0 0 0 100734 3 2018
    -.15783915          .          . 0 . . 100803 1 2016
    -.15783915 -.15783915          . 0 0 . 100803 2 2017
    -.13314976 -.15783915 -.15783915 0 0 0 100803 3 2018
             0          .          . . . . 100866 1 2016
             0          0          . . . . 100866 2 2017
             0          0          0 . . . 100866 3 2018
             0          .          . . . . 100982 1 2016
             0          0          . . . . 100982 2 2017
             0          0          0 . . . 100982 3 2018
    -.15783915          .          . 0 . . 101224 1 2016
    -.15783915 -.15783915          . 0 0 . 101224 2 2017
    -.13314976 -.15783915 -.15783915 0 0 0 101224 3 2018
    -.15783915          .          . 0 . . 101322 1 2016
    -.15783915 -.15783915          . 0 0 . 101322 2 2017
    -.13314976 -.15783915 -.15783915 0 0 0 101322 3 2018
             0          .          . . . . 101368 1 2016
             0          0          . . . . 101368 2 2017
             0          0          0 . . . 101368 3 2018
     .25423202          .          . 0 . . 101400 1 2016
             0  .25423202          . . 0 . 101400 2 2017
      .3809165          0  .25423202 . . 0 101400 3 2018
    -.15783915          .          . 0 . . 101437 1 2016
    -.15783915 -.15783915          . 0 0 . 101437 2 2017
    -.13314976 -.15783915 -.15783915 0 0 0 101437 3 2018
    -.13009462          .          . 0 . . 101443 1 2016
             0 -.13009462          . . 0 . 101443 2 2017
             0          0 -.13009462 . . 0 101443 3 2018
     .28250796          .          . 0 . . 101472 1 2016
     .28250796  .28250796          . 0 0 . 101472 2 2017
     .27179015  .28250796  .28250796 0 0 0 101472 3 2018
      .4626544          .          . 0 . . 101485 1 2016
      .4626544   .4626544          . 0 0 . 101485 2 2017
      .3809165   .4626544   .4626544 0 0 0 101485 3 2018
    -.15783915          .          . 0 . . 101493 1 2016
      .3967137 -.15783915          . 0 0 . 101493 2 2017
     .27179015   .3967137 -.15783915 0 0 0 101493 3 2018
             0          .          . . . . 101495 1 2016
             0          0          . . . . 101495 2 2017
             0          0          0 . . . 101495 3 2018
             0          .          . . . . 101712 1 2016
             0          0          . . . . 101712 2 2017
             0          0          0 . . . 101712 3 2018
    -.15783915          .          . 0 . . 102009 1 2016
     .11578453 -.15783915          . 1 0 . 102009 2 2017
    -.13314976  .11578453 -.15783915 1 1 0 102009 3 2018
             0          .          . . . . 102130 1 2016
             0          0          . 1 . . 102130 2 2017
             0          0          0 . 1 . 102130 3 2018
     .02230732          .          . 0 . . 102198 1 2016
     .02230732  .02230732          . 0 0 . 102198 2 2017
    -.13314976  .02230732  .02230732 0 0 0 102198 3 2018
    -.13009462          .          . . . . 102351 1 2016
             0 -.13009462          . 0 . . 102351 2 2017
             0          0 -.13009462 . 0 . 102351 3 2018
       .380036          .          . 0 . . 102352 1 2016
             0    .380036          . . 0 . 102352 2 2017
             0          0    .380036 . . 0 102352 3 2018
             0          .          . . . . 102400 1 2016
             0          0          . . . . 102400 2 2017
             0          0          0 . . . 102400 3 2018
    -.15783915          .          . 0 . . 102584 1 2016
    end

    Comment


    • #3
      Still no response. Was my question unclear perhaps?

      Comment

      Working...
      X