Announcement

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

  • wsanova to anova command

    I'm trying to reproduce what I have in SPSS, in Stata.

    It works when I run wsanova but I want to be able to run marginal effects, which appears to require I run it as anova.

    Unfortunately I can't provide any of my data since it would violate our ethics protocols. But just looking to see if anyone can compare my wsanova and anova syntax and tell me what I'm doing wrong:

    wsanova DRS data_point if unique_ID, id(unique_ID) bet (LTCH Sex LTCH*Sex)

    anova DRS LTCH##Sex/unique_ID|LTCH#Sex data_point##LTCH##Sex, repeated(data_point) bseunit(unique_ID)


    DV = DRS
    IVs= Sex and LTCH
    time variable= data_point

    The within subject factor is data_point
    the between subject factors are Sex, and LTCH and I want to know the results for Sex, LTCH and Sex*LTCH

    Both Sex and LTCH are categorical and have 3 options each.
    DRS is continuous scale


    When I run the anova the within subject factor (data_point) is correct, and the interaction of Sex*LTCH is correct but Pre_LTCH and Sex_AA2's F-value, partial SS and significance are not correct.

  • #2
    I haven't used SPSS in about forty years and so won't be able to help you there, but, based upon your description of the data, the ANOVA model in Stata would look something like this:
    Code:
    anova DRS LTCH Sex LTCH#Sex / unique_ID|LTCH#Sex data_point LTCH#data_point Sex#data_point LTCH#Sex#data_point
    You should provide a dataset, but there is no need to violate patient confidentiality obligations to do so: just return to your conception of the phenomenon that you are trying to model in order to create a fictitious dataset for illustration of the modeling problem.

    .ÿ
    .ÿversionÿ16.0

    .ÿ
    .ÿclearÿ*

    .ÿ
    .ÿsetÿseedÿ`=strreverse("1516132")'

    .ÿquietlyÿsetÿobsÿ18

    .ÿgenerateÿbyteÿpidÿ=ÿ_n

    .ÿgenerateÿdoubleÿpid_uÿ=ÿrnormal()

    .ÿ
    .ÿ//ÿSexÿandÿLCTH
    .ÿgenerateÿbyteÿsexÿ=ÿmod(_n,ÿ2)

    .ÿgenerateÿbyteÿlctÿ=ÿmod(_n,ÿ3)

    .ÿ
    .ÿ//ÿRepeatedÿmeasurement
    .ÿquietlyÿexpandÿ5

    .ÿbysortÿpid:ÿgenerateÿbyteÿtimÿ=ÿ_n

    .ÿ
    .ÿgenerateÿdoubleÿdrsÿ=ÿ0ÿ+ÿpid_uÿ+ÿrnormal()

    .ÿ
    .ÿ*
    .ÿ*ÿBeginÿhere
    .ÿ*
    .ÿanovaÿdrsÿsexÿlctÿsex#lctÿ/ÿpid|sex#lctÿtimÿsex#timÿlct#timÿsex#lct#timÿ//,ÿrepeated(tim)

    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿobsÿ=ÿÿÿÿÿÿÿÿÿ90ÿÿÿÿR-squaredÿÿÿÿÿ=ÿÿ0.5652
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿRootÿMSEÿÿÿÿÿÿ=ÿÿÿÿ1.15863ÿÿÿÿAdjÿR-squaredÿ=ÿÿ0.1939

    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿSourceÿ|ÿPartialÿSSÿÿÿÿÿÿÿÿÿdfÿÿÿÿÿÿÿÿÿMSÿÿÿÿÿÿÿÿFÿÿÿÿProb>F
    ÿÿÿÿÿÿÿÿÿÿÿÿÿ------------+----------------------------------------------------
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿModelÿ|ÿÿ83.775045ÿÿÿÿÿÿÿÿÿ41ÿÿÿ2.0432938ÿÿÿÿÿÿ1.52ÿÿ0.0808
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿsexÿ|ÿÿ13.073721ÿÿÿÿÿÿÿÿÿÿ1ÿÿÿ13.073721ÿÿÿÿÿÿ6.41ÿÿ0.0263
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿlctÿ|ÿÿ7.8864072ÿÿÿÿÿÿÿÿÿÿ2ÿÿÿ3.9432036ÿÿÿÿÿÿ1.93ÿÿ0.1870
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿsex#lctÿ|ÿÿÿ13.87811ÿÿÿÿÿÿÿÿÿÿ2ÿÿÿ6.9390552ÿÿÿÿÿÿ3.40ÿÿ0.0675
    ÿÿÿÿÿÿÿÿÿÿÿÿÿpid|sex#lctÿ|ÿÿÿ24.46256ÿÿÿÿÿÿÿÿÿ12ÿÿÿ2.0385467ÿÿ
    ÿÿÿÿÿÿÿÿÿÿÿÿÿ------------+----------------------------------------------------
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿtimÿ|ÿÿ1.7148373ÿÿÿÿÿÿÿÿÿÿ4ÿÿÿ.42870933ÿÿÿÿÿÿ0.32ÿÿ0.8636
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿsex#timÿ|ÿÿ5.9644582ÿÿÿÿÿÿÿÿÿÿ4ÿÿÿ1.4911145ÿÿÿÿÿÿ1.11ÿÿ0.3624
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿlct#timÿ|ÿÿ8.9420922ÿÿÿÿÿÿÿÿÿÿ8ÿÿÿ1.1177615ÿÿÿÿÿÿ0.83ÿÿ0.5785
    ÿÿÿÿÿÿÿÿÿÿÿÿÿsex#lct#timÿ|ÿÿ7.8528582ÿÿÿÿÿÿÿÿÿÿ8ÿÿÿ.98160727ÿÿÿÿÿÿ0.73ÿÿ0.6634
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿResidualÿ|ÿÿ64.435997ÿÿÿÿÿÿÿÿÿ48ÿÿÿ1.3424166ÿÿ
    ÿÿÿÿÿÿÿÿÿÿÿÿÿ------------+----------------------------------------------------
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿTotalÿ|ÿÿ148.21104ÿÿÿÿÿÿÿÿÿ89ÿÿÿ1.6652926ÿÿ

    .ÿ
    .ÿ/*ÿmixedÿdrsÿi.(sex##lct##tim)ÿ||ÿpid:ÿ,ÿremlÿdfmethod(satterthwaite)ÿnolrtestÿnolog
    >ÿ
    >ÿcontrastÿsexÿlctÿsex#lct,ÿdf(12)
    >ÿcontrastÿtimÿsex#timÿlct#timÿsex#lct#tim,ÿdf(48)ÿ*/
    .ÿ
    .ÿexit

    endÿofÿdo-file


    .
    Last edited by Joseph Coveney; 12 Sep 2019, 17:22.

    Comment


    • #3
      I created some dummy data.



      Code:
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input double(data_point LTCH Sex DRS) float unique_ID
      1 3 0 12  1
      2 3 0  4  1
      3 3 0  1  1
      4 3 0  6  1
      1 1 0  7  2
      2 1 0  1  2
      3 1 0  6  2
      4 1 0 12  2
      1 3 0  6  3
      2 3 0 12  3
      3 3 0  4  3
      4 3 0  2  3
      1 1 0  2  4
      2 1 0  8  4
      3 1 0  0  4
      4 1 0  4  4
      1 2 0  0  5
      2 2 0  6  5
      3 2 0  0  5
      4 2 0  4  5
      1 3 0  3  6
      2 3 0  4  6
      3 3 0  4  6
      4 3 0  2  6
      1 1 0  3  7
      2 1 0  4  7
      3 1 0  0  7
      4 1 0  3  7
      1 3 0  4  8
      2 3 0  4  8
      3 3 0  2  8
      4 3 0  4  8
      1 1 0  6  9
      2 1 0  3  9
      3 1 0  3  9
      4 1 0  2  9
      1 3 0  3 10
      2 3 0  3 10
      3 3 0  4 10
      4 3 0  4 10
      1 3 0  1 11
      2 3 0  4 11
      3 3 0  0 11
      4 3 0  4 11
      1 3 1  2 12
      2 3 1  9 12
      3 3 1  0 12
      4 3 1  7 12
      1 3 1  4 13
      2 3 1  0 13
      3 3 1  4 13
      4 3 1  9 13
      1 1 1  0 14
      2 1 1  7 14
      3 1 1  0 14
      4 1 1  9 14
      1 2 1  8 15
      2 2 1  6 15
      3 2 1  3 15
      4 2 1  9 15
      1 2 1  9 16
      2 2 1  0 16
      3 2 1  0 16
      4 2 1  0 16
      1 2 1  0 17
      2 2 1  1 17
      3 2 1  4 17
      4 2 1  0 17
      1 2 1  0 18
      2 2 1  8 18
      3 2 1  9 18
      4 2 1  9 18
      1 1 1  9 19
      2 1 1  0 19
      3 1 1  2 19
      4 1 1  0 19
      1 3 1  7 20
      2 3 1  0 20
      3 3 1  7 20
      4 3 1  7 20
      1 2 1  9 21
      2 2 1  0 21
      3 2 1  0 21
      4 2 1  1 21
      1 3 1  4 22
      2 3 1  1 22
      3 3 1  7 22
      4 3 1 10 22
      1 2 1  2 23
      2 2 1  1 23
      3 2 1  2 23
      4 2 1  4 23
      1 1 1  1 24
      2 1 1  3 24
      3 1 1  3 24
      4 1 1  9 24
      end
      label values Sex Sex_AA2
      label def Sex_AA2 0 "Male", modify
      label def Sex_AA2 1 "Female", modify
      When I run
      anova DRS LTCH Sex LTCH#Sex / unique_ID|LTCH#Sex data_point LTCH#data_point Sex#data_point LTCH#Sex#data_point vs the wsanova code above, I still get slightly different outputs for my Sex and LTCH variables. My actual file has about 1200 cases and the differences is larger. Here's what I get when I run it on the dummy data: . anova DRS LTCH Sex LTCH#Sex / unique_ID|LTCH#Sex data_point LTCH#data_point Sex#data_point LTCH#Sex#data_point Number of obs = 96 R-squared = 0.3925 Root MSE = 3.43772 Adj R-squared = -0.0687 Source | Partial SS df MS F Prob>F --------------------+---------------------------------------------------- Model | 412.32292 41 10.056657 0.85 0.7027 | LTCH | 22.80756 2 11.40378 1.04 0.3746 Sex | 3.8340656 1 3.8340656 0.35 0.5621 LTCH#Sex | 7.7586207 2 3.8793103 0.35 0.7074 unique_ID|LTCH#Sex | 197.83333 18 10.990741 --------------------+---------------------------------------------------- data_point | 68.362179 3 22.787393 1.93 0.1360 LTCH#data_point | 16.438424 6 2.7397373 0.23 0.9644 Sex#data_point | 41.836538 3 13.945513 1.18 0.3260 LTCH#Sex#data_point | 51.059113 6 8.5098522 0.72 0.6351 | Residual | 638.16667 54 11.817901 --------------------+---------------------------------------------------- Total | 1050.4896 95 11.057785 . wsanova DRS data_point if unique_ID, id(unique_ID) bet (LTCH Sex LTCH*Sex) Number of obs = 96 R-squared = 0.3925 Root MSE = 3.43772 Adj R-squared = -0.0687 Source | Partial SS df MS F Prob > F -----------+---------------------------------------------------- Between subjects: | 27.90625 5 5.58125 0.51 0.7667 LTCH | 22.3760263 2 11.1880131 1.02 0.3812 Sex | 3.92628205 1 3.92628205 0.36 0.5575 LTCH*Sex | 7.75862069 2 3.87931034 0.35 0.7074 unique_ID*LTCH*Sex | 197.833333 18 10.9907407 | Within subjects: | 186.583333 18 10.3657407 0.88 0.6063 data_point | 68.3621795 3 22.7873932 1.93 0.1360 data_point*LTCH | 16.4384236 6 2.73973727 0.23 0.9644 data_point*Sex | 41.8365385 3 13.9455128 1.18 0.3260 data_point*LTCH*Sex | 51.0591133 6 8.50985222 0.72 0.6351 Residual | 638.166667 54 11.8179012 -----------+---------------------------------------------------- Total | 1050.48958 95 11.0577851 Thanks!





      Originally posted by Joseph Coveney View Post
      I haven't used SPSS in about forty years and so won't be able to help you there, but, based upon your description of the data, the ANOVA model in Stata would look something like this:
      Code:
      anova DRS LTCH Sex LTCH#Sex / unique_ID|LTCH#Sex data_point LTCH#data_point Sex#data_point LTCH#Sex#data_point
      You should provide a dataset, but there is no need to violate patient confidentiality obligations to do so: just return to your conception of the phenomenon that you are trying to model in order to create a fictitious dataset for illustration of the modeling problem.

      .ÿ
      .ÿversionÿ16.0

      .ÿ
      .ÿclearÿ*

      .ÿ
      .ÿsetÿseedÿ`=strreverse("1516132")'

      .ÿquietlyÿsetÿobsÿ18

      .ÿgenerateÿbyteÿpidÿ=ÿ_n

      .ÿgenerateÿdoubleÿpid_uÿ=ÿrnormal()

      .ÿ
      .ÿ//ÿSexÿandÿLCTH
      .ÿgenerateÿbyteÿsexÿ=ÿmod(_n,ÿ2)

      .ÿgenerateÿbyteÿlctÿ=ÿmod(_n,ÿ3)

      .ÿ
      .ÿ//ÿRepeatedÿmeasurement
      .ÿquietlyÿexpandÿ5

      .ÿbysortÿpid:ÿgenerateÿbyteÿtimÿ=ÿ_n

      .ÿ
      .ÿgenerateÿdoubleÿdrsÿ=ÿ0ÿ+ÿpid_uÿ+ÿrnormal()

      .ÿ
      .ÿ*
      .ÿ*ÿBeginÿhere
      .ÿ*
      .ÿanovaÿdrsÿsexÿlctÿsex#lctÿ/ÿpid|sex#lctÿtimÿsex#timÿlct#timÿsex#lct#timÿ//,ÿrepeated(tim)

      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿobsÿ=ÿÿÿÿÿÿÿÿÿ90ÿÿÿÿR-squaredÿÿÿÿÿ=ÿÿ0.5652
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿRootÿMSEÿÿÿÿÿÿ=ÿÿÿÿ1.15863ÿÿÿÿAdjÿR-squaredÿ=ÿÿ0.1939

      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿSourceÿ|ÿPartialÿSSÿÿÿÿÿÿÿÿÿdfÿÿÿÿÿÿÿÿÿMSÿÿÿÿÿÿÿÿFÿÿÿÿProb>F
      ÿÿÿÿÿÿÿÿÿÿÿÿÿ------------+----------------------------------------------------
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿModelÿ|ÿÿ83.775045ÿÿÿÿÿÿÿÿÿ41ÿÿÿ2.0432938ÿÿÿÿÿÿ1.52ÿÿ0.0808
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿsexÿ|ÿÿ13.073721ÿÿÿÿÿÿÿÿÿÿ1ÿÿÿ13.073721ÿÿÿÿÿÿ6.41ÿÿ0.0263
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿlctÿ|ÿÿ7.8864072ÿÿÿÿÿÿÿÿÿÿ2ÿÿÿ3.9432036ÿÿÿÿÿÿ1.93ÿÿ0.1870
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿsex#lctÿ|ÿÿÿ13.87811ÿÿÿÿÿÿÿÿÿÿ2ÿÿÿ6.9390552ÿÿÿÿÿÿ3.40ÿÿ0.0675
      ÿÿÿÿÿÿÿÿÿÿÿÿÿpid|sex#lctÿ|ÿÿÿ24.46256ÿÿÿÿÿÿÿÿÿ12ÿÿÿ2.0385467ÿÿ
      ÿÿÿÿÿÿÿÿÿÿÿÿÿ------------+----------------------------------------------------
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿtimÿ|ÿÿ1.7148373ÿÿÿÿÿÿÿÿÿÿ4ÿÿÿ.42870933ÿÿÿÿÿÿ0.32ÿÿ0.8636
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿsex#timÿ|ÿÿ5.9644582ÿÿÿÿÿÿÿÿÿÿ4ÿÿÿ1.4911145ÿÿÿÿÿÿ1.11ÿÿ0.3624
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿlct#timÿ|ÿÿ8.9420922ÿÿÿÿÿÿÿÿÿÿ8ÿÿÿ1.1177615ÿÿÿÿÿÿ0.83ÿÿ0.5785
      ÿÿÿÿÿÿÿÿÿÿÿÿÿsex#lct#timÿ|ÿÿ7.8528582ÿÿÿÿÿÿÿÿÿÿ8ÿÿÿ.98160727ÿÿÿÿÿÿ0.73ÿÿ0.6634
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿResidualÿ|ÿÿ64.435997ÿÿÿÿÿÿÿÿÿ48ÿÿÿ1.3424166ÿÿ
      ÿÿÿÿÿÿÿÿÿÿÿÿÿ------------+----------------------------------------------------
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿTotalÿ|ÿÿ148.21104ÿÿÿÿÿÿÿÿÿ89ÿÿÿ1.6652926ÿÿ

      .ÿ
      .ÿ/*ÿmixedÿdrsÿi.(sex##lct##tim)ÿ||ÿpid:ÿ,ÿremlÿdfmethod(satterthwaite)ÿnolrtestÿnolog
      >ÿ
      >ÿcontrastÿsexÿlctÿsex#lct,ÿdf(12)
      >ÿcontrastÿtimÿsex#timÿlct#timÿsex#lct#tim,ÿdf(48)ÿ*/
      .ÿ
      .ÿexit

      endÿofÿdo-file


      .

      Comment


      • #4
        First, a point of order. I didn't realize that -wsanova- was a Stata command. Apparently it's a user-written command. I recommend that you take a moment to read the forum's FAQ about this and about its suggestion to make output readable.

        Second, I assume that the lack of balance in the between-patient factors in your fake dataset reflects a similar imbalance in your real dataset.

        .ÿ
        .ÿversionÿ16.0

        .ÿ
        .ÿclearÿ*

        .ÿ
        .ÿquietlyÿinputÿdouble(data_pointÿLTCHÿSexÿDRS)ÿfloatÿunique_ID

        .ÿ/*ÿlabelÿvaluesÿSexÿSex_AA2
        >ÿlabelÿdefÿSex_AA2ÿ0ÿ"Male",ÿmodify
        >ÿlabelÿdefÿSex_AA2ÿ1ÿ"Female",ÿmodifyÿ*/
        .ÿ
        .ÿquietlyÿcompress

        .ÿrenameÿ*,ÿlower

        .ÿrenameÿunique_idÿpid

        .ÿrenameÿltchÿltc

        .ÿrenameÿdata_pointÿtim

        .ÿ
        .ÿbysortÿpidÿ(tim):ÿassertÿsexÿ==ÿsex[1]

        .ÿbyÿpid:ÿassertÿltcÿ==ÿltc[1]

        .ÿquietlyÿcountÿifÿpidÿ==ÿpid[1]

        .ÿbyÿpid:ÿassertÿ_Nÿ==ÿr(N)

        .ÿ
        .ÿsummarizeÿtim,ÿmeanonly

        .ÿtabulateÿltcÿsexÿifÿtimÿ==ÿr(max)

        ÿÿÿÿÿÿÿÿÿÿÿ|ÿÿÿÿÿÿÿÿÿÿsex
        ÿÿÿÿÿÿÿltcÿ|ÿÿÿÿÿÿÿÿÿ0ÿÿÿÿÿÿÿÿÿÿ1ÿ|ÿÿÿÿÿTotal
        -----------+----------------------+----------
        ÿÿÿÿÿÿÿÿÿ1ÿ|ÿÿÿÿÿÿÿÿÿ4ÿÿÿÿÿÿÿÿÿÿ3ÿ|ÿÿÿÿÿÿÿÿÿ7ÿ
        ÿÿÿÿÿÿÿÿÿ2ÿ|ÿÿÿÿÿÿÿÿÿ1ÿÿÿÿÿÿÿÿÿÿ6ÿ|ÿÿÿÿÿÿÿÿÿ7ÿ
        ÿÿÿÿÿÿÿÿÿ3ÿ|ÿÿÿÿÿÿÿÿÿ6ÿÿÿÿÿÿÿÿÿÿ4ÿ|ÿÿÿÿÿÿÿÿ10ÿ
        -----------+----------------------+----------
        ÿÿÿÿÿTotalÿ|ÿÿÿÿÿÿÿÿ11ÿÿÿÿÿÿÿÿÿ13ÿ|ÿÿÿÿÿÿÿÿ24ÿ

        .ÿ
        .ÿ/*ÿanovaÿdrsÿsexÿltcÿsex#ltcÿ/ÿpid|sex#ltcÿtimÿsex#timÿltc#timÿsex#ltc#tim,ÿsequential
        >ÿanovaÿdrsÿltcÿsexÿsex#ltcÿ/ÿpid|sex#ltcÿtimÿsex#timÿltc#timÿsex#ltc#tim,ÿsequentialÿ*/
        .ÿ
        .ÿexit

        endÿofÿdo-file


        .


        Last, I don't know what -wsanova- (and SPSS) are doing, but you'll benefit by taking a look at some of what's brought up by this Internet search. (The commented-out -anova- commands above are worth considering if you find the Sex × LTCH interaction unimpressive.)

        Comment


        • #5
          Re the Google search Joseph Coveney suggested (i.e., Type I vs Type III SS), I imagine that Elyse used GLM-Repeated Measures in SPSS. It uses Type III SS by default. Stata's -anova- command has partial and sequential sum of squares options. I believe those correspond to Type III and Type 1 respectively.

          Code:
              options                  Description
              -----------------------------------------------------------------------------------------------
              Model
                repeated(varlist)      variables in terms that are repeated-measures variables
                partial                use partial (or marginal) sums of squares
                sequential             use sequential sums of squares
          --
          Bruce Weaver
          Email: [email protected]
          Web: http://sites.google.com/a/lakeheadu.ca/bweaver/
          Version: Stata/MP 18.0 (Windows)

          Comment


          • #6
            anova and wsanova both say they're using Partial (and you are correct, I used the GLM Repeated Measures model in SPSS which used Type III).



            Originally posted by Bruce Weaver View Post
            Re the Google search Joseph Coveney suggested (i.e., Type I vs Type III SS), I imagine that Elyse used GLM-Repeated Measures in SPSS. It uses Type III SS by default. Stata's -anova- command has partial and sequential sum of squares options. I believe those correspond to Type III and Type 1 respectively.

            Code:
             options Description
            -----------------------------------------------------------------------------------------------
            Model
            repeated(varlist) variables in terms that are repeated-measures variables
            partial use partial (or marginal) sums of squares
            sequential use sequential sums of squares

            Comment


            • #7
              Your problem, the discrepancy between -anova- and -wsanova-, is noted and briefly discussed in the repeated-measures ANOVA FAQ on the company's website.

              Scroll down to the header Two between-subjects factors example from wsanova STB article:
              "If you look closely, you will find a difference in the results for the drug and the depleted terms between anova and wsanova. This is due to the imbalance in the data . . ."
              "The wsanova command actually performs its work with two separate calls to anova instead of getting the whole ANOVA table at one time. . . . In the presence of imbalanced data, this method can sometimes make a difference in the results. In these cases, I recommend using the anova command."
              and finally
              "This example does point out that for models with imbalance there can sometimes be a difference between wsanova and anova in the reported ANOVA table for some of the terms. In these cases, you should rely on the anova command."
              As recommended in some of the citations from the Internet search that I point to above, you might want to consider using Type II sums of squares (the second factors in the two ANOVA models that I commented out above) in unbalanced factorial ANOVA where you are interested in the main effects in the absence of remarkable interaction.

              Comment


              • #8
                Thank you I'll look into Type II sums of squares!


                Originally posted by Joseph Coveney View Post
                Your problem, the discrepancy between -anova- and -wsanova-, is noted and briefly discussed in the repeated-measures ANOVA FAQ on the company's website.

                Scroll down to the header Two between-subjects factors example from wsanova STB article:
                "If you look closely, you will find a difference in the results for the drug and the depleted terms between anova and wsanova. This is due to the imbalance in the data . . ."
                "The wsanova command actually performs its work with two separate calls to anova instead of getting the whole ANOVA table at one time. . . . In the presence of imbalanced data, this method can sometimes make a difference in the results. In these cases, I recommend using the anova command."
                and finally
                "This example does point out that for models with imbalance there can sometimes be a difference between wsanova and anova in the reported ANOVA table for some of the terms. In these cases, you should rely on the anova command."
                As recommended in some of the citations from the Internet search that I point to above, you might want to consider using Type II sums of squares (the second factors in the two ANOVA models that I commented out above) in unbalanced factorial ANOVA where you are interested in the main effects in the absence of remarkable interaction.

                Comment


                • #9
                  Originally posted by Joseph Coveney View Post
                  As recommended in some of the citations from the Internet search that I point to above, you might want to consider using Type II sums of squares (the second factors in the two ANOVA models that I commented out above) in unbalanced factorial ANOVA where you are interested in the main effects in the absence of remarkable interaction.
                  This thread from 2016 might be helpful. Is the method shown in #3 of that thread really the easiest way to obtain Type II SS? If so, I think I'll suggest that an option for Type II SS be added to -anova- in the Wish List thread. (And while they're at it, they could add Type IV for good measure.)
                  --
                  Bruce Weaver
                  Email: [email protected]
                  Web: http://sites.google.com/a/lakeheadu.ca/bweaver/
                  Version: Stata/MP 18.0 (Windows)

                  Comment


                  • #10
                    I think that it's the only way, if you're going to use -anova-.

                    Comment

                    Working...
                    X