Announcement

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

  • Anova and interaction with ordinales variables

    Hello,

    I'm sorry, I'm new to this kind of analysis, but my boss asked me to analyze the interaction between two variables on a third one.

    So the two variables are categorical (wealth and work), and we have to see the impact on a third one which is ordinal categorical (never,..., always).

    The problem is that my boss really wants us to do a two-way anova.
    It seems to me that an anova is usable only if the Y is continuous, which is not the case.
    For me, to do this interaction I would have done a regression like that ologit y x1##x2


    My boss gave me an example of a type of anova he wants me to do, can you tell me if this is consistent? I have the impression that it's really bad but he insists a lot.

    (that's not my true data)

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input long(work wealth y)
    4 2 1
    1 3 2
    1 3 2
    2 3 2
    1 3 2
    3 1 3
    2 1 3
    4 1 3
    4 1 3
    4 1 3
    4 1 3
    4 1 3
    4 1 3
    3 1 3
    4 1 3
    4 1 3
    4 2 3
    1 2 3
    3 2 3
    1 2 3
    1 2 3
    1 2 3
    4 2 3
    1 2 3
    4 2 3
    3 3 3
    3 3 3
    2 3 3
    3 3 3
    1 3 3
    3 3 3
    1 3 3
    4 3 3
    1 3 3
    4 3 3
    1 3 3
    1 3 3
    1 3 3
    2 3 3
    3 1 4
    4 1 4
    4 1 4
    3 1 4
    2 1 4
    4 1 4
    4 1 4
    1 1 4
    3 1 4
    1 1 4
    2 1 4
    1 1 4
    1 1 4
    1 1 4
    2 1 4
    4 1 4
    1 1 4
    2 1 4
    1 1 4
    4 1 4
    4 1 4
    1 1 4
    4 1 4
    3 1 4
    1 1 4
    4 1 4
    2 2 4
    1 2 4
    4 2 4
    3 2 4
    4 2 4
    4 2 4
    3 2 4
    1 2 4
    1 2 4
    4 2 4
    1 2 4
    3 2 4
    1 2 4
    3 2 4
    4 2 4
    1 2 4
    3 2 4
    1 2 4
    1 2 4
    3 2 4
    1 3 4
    4 3 4
    1 3 4
    1 3 4
    1 3 4
    3 3 4
    2 3 4
    1 3 4
    1 3 4
    2 3 4
    3 3 4
    4 1 5
    4 1 5
    4 1 5
    4 1 5
    end
    label values work activite
    label def activite 1 "Engineer", modify
    label def activite 2 "Teacher", modify
    label def activite 3 "Reseacher", modify
    label def activite 4 "Tech", modify
    label values wealth village_groupe
    label def village_groupe 1 "Cat A", modify
    label def village_groupe 2 "Cat B", modify
    label def village_groupe 3 "Cat C", modify
    label values y peur
    label def peur 1 "never", modify
    label def peur 2 "rarely", modify
    label def peur 3 "sometimes", modify
    label def peur 4 "often", modify
    label def peur 5 "always", modify
    So here's my data, and here's what he wants me to do :

    Code:
    contract y work wealth, zero
    sort work wealth y
    replace _freq=_freq*y
    gen ln_freq=ln(_freq+1)/ln(10)
    anova ln_freq work wealth
    It's like if he wants to run anova on the logarithm of the number of observations of each category weighted by the variable y (*1 if y==1, *2 if y==2..). He told me he is doing that weight to make y continuous and the log+1 transformation for the homoscedasticity
    Is this something that makes sense?


    Sorry for this weird question,
    Thank you

  • #2
    Originally posted by Jul Herb View Post
    Is this something that makes sense?
    Not to me.

    You boss's method multiplies the values of the outcome variable by the marginal frequency of the predictor group. So, even if all of the work-activity groups have the identical distribution of fear scores--that is, even if engineers have an average score of 3 and teachers have the identical average score of 3 and researchers have the identical average score of 3 etc.)--then ANOVA will still declare a so-called statistically significant difference if there are many more engineers than teachers and researchers.

    However transformed (e.g., logarithm), an outcome for engineers that is Y × 37 (marginal total of engineers in your example dataset) will be seen by ANOVA as different from one for teachers that is Y × 11 (marginal total of teachers in your dataset), despite both work-activity groups' having the identical (Y) outcome score on average.

    I think that you can show this phenomenon to your boss by performing a simulation under the null hypothesis (identical average y, say, distributed uniformly from 1 to 5, using replace y = runiformint(1, 5) in each replication) with the observed marginal frequencies for work-activities and village-group categories.

    Comment


    • #3
      Actually, your boss is multiplying by the conditional (cell) frequencies and not the marginal frequencies, but I think that the same phenomenon would obtain: even if each cell's average outcome value is identical, but the cell counts vary, then the outcome variable will be distorted.

      Comment


      • #4
        Thanks a lot.

        Any ideas to show the interaction between work and wealth on Y ? I never worked with orderer y, an ologit is usable?

        Comment


        • #5
          Depending upon your sample size, you could go with what you show above with ologit. There are some assumptions, for example, proportional odds, but I wouldn't sweat that too much.

          With smallish sample sizes, you could consider a permutation test that is based upon the corresponding factorial ANOVA.

          I illustrate both below on your fake dataset. With your sample size (truncated by the default setting of dataex to 100 observations), both approaches give the same answer, viz., P = 0.8 for the interaction term.

          .ÿ
          .ÿversionÿ17.0

          .ÿ
          .ÿclearÿ*

          .ÿ
          .ÿ//ÿseedem
          .ÿsetÿseedÿ1605085412

          .ÿ
          .ÿquietlyÿinputÿbyte(workÿwealthÿy)

          .ÿ
          .ÿologitÿyÿi.work##i.wealth,ÿnolog

          OrderedÿlogisticÿregressionÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿobsÿ=ÿÿÿÿ100
          ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿLRÿchi2(11)ÿÿÿ=ÿÿ16.95
          ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿProbÿ>ÿchi2ÿÿÿ=ÿ0.1095
          Logÿlikelihoodÿ=ÿ-90.60301ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿPseudoÿR2ÿÿÿÿÿ=ÿ0.0855

          ------------------------------------------------------------------------------
          ÿÿÿÿÿÿÿÿÿÿÿyÿ|ÿCoefficientÿÿStd.ÿerr.ÿÿÿÿÿÿzÿÿÿÿP>|z|ÿÿÿÿÿ[95%ÿconf.ÿinterval]
          -------------+----------------------------------------------------------------
          ÿÿÿÿÿÿÿÿworkÿ|
          ÿÿÿÿÿÿÿÿÿÿ2ÿÿ|ÿÿ-.8556323ÿÿÿ1.205031ÿÿÿÿ-0.71ÿÿÿ0.478ÿÿÿÿ-3.217449ÿÿÿÿ1.506185
          ÿÿÿÿÿÿÿÿÿÿ3ÿÿ|ÿÿ-1.369716ÿÿÿ1.113499ÿÿÿÿ-1.23ÿÿÿ0.219ÿÿÿÿ-3.552133ÿÿÿÿ.8127014
          ÿÿÿÿÿÿÿÿÿÿ4ÿÿ|ÿÿ-.9753956ÿÿÿ.9072945ÿÿÿÿ-1.08ÿÿÿ0.282ÿÿÿÿÿ-2.75366ÿÿÿÿÿ.802869
          ÿÿÿÿÿÿÿÿÿÿÿÿÿ|
          ÿÿÿÿÿÿwealthÿ|
          ÿÿÿÿÿÿÿÿÿÿ2ÿÿ|ÿÿ-1.551978ÿÿÿ.9410824ÿÿÿÿ-1.65ÿÿÿ0.099ÿÿÿÿ-3.396466ÿÿÿÿ.2925095
          ÿÿÿÿÿÿÿÿÿÿ3ÿÿ|ÿÿ-2.695067ÿÿÿ.9470412ÿÿÿÿ-2.85ÿÿÿ0.004ÿÿÿÿ-4.551234ÿÿÿ-.8389002
          ÿÿÿÿÿÿÿÿÿÿÿÿÿ|
          ÿwork#wealthÿ|
          ÿÿÿÿÿÿÿÿ2ÿ2ÿÿ|ÿÿÿÿ2.40761ÿÿÿ2.590166ÿÿÿÿÿ0.93ÿÿÿ0.353ÿÿÿÿ-2.669022ÿÿÿÿ7.484243
          ÿÿÿÿÿÿÿÿ2ÿ3ÿÿ|ÿÿÿ.8556323ÿÿÿ1.591631ÿÿÿÿÿ0.54ÿÿÿ0.591ÿÿÿÿ-2.263908ÿÿÿÿ3.975173
          ÿÿÿÿÿÿÿÿ3ÿ2ÿÿ|ÿÿÿ2.305202ÿÿÿ1.502107ÿÿÿÿÿ1.53ÿÿÿ0.125ÿÿÿÿ-.6388737ÿÿÿÿ5.249278
          ÿÿÿÿÿÿÿÿ3ÿ3ÿÿ|ÿÿÿ1.605752ÿÿÿ1.439831ÿÿÿÿÿ1.12ÿÿÿ0.265ÿÿÿÿ-1.216265ÿÿÿÿÿ4.42777
          ÿÿÿÿÿÿÿÿ4ÿ2ÿÿ|ÿÿÿ.5601647ÿÿÿ1.243726ÿÿÿÿÿ0.45ÿÿÿ0.652ÿÿÿÿ-1.877493ÿÿÿÿ2.997823
          ÿÿÿÿÿÿÿÿ4ÿ3ÿÿ|ÿÿÿ1.211432ÿÿÿ1.489148ÿÿÿÿÿ0.81ÿÿÿ0.416ÿÿÿÿ-1.707244ÿÿÿÿ4.130109
          -------------+----------------------------------------------------------------
          ÿÿÿÿÿÿÿ/cut1ÿ|ÿÿ-6.452018ÿÿÿ1.281771ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ-8.964244ÿÿÿ-3.939793
          ÿÿÿÿÿÿÿ/cut2ÿ|ÿÿ-4.755205ÿÿÿÿ.914072ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ-6.546753ÿÿÿ-2.963657
          ÿÿÿÿÿÿÿ/cut3ÿ|ÿÿ-2.013954ÿÿÿ.7856569ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ-3.553813ÿÿÿ-.4740944
          ÿÿÿÿÿÿÿ/cut4ÿ|ÿÿÿ2.013954ÿÿÿ.7856569ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ.4740944ÿÿÿÿ3.553813
          ------------------------------------------------------------------------------

          .ÿtestparmÿi.work#i.wealth

          ÿ(ÿ1)ÿÿ[y]2.work#2.wealthÿ=ÿ0
          ÿ(ÿ2)ÿÿ[y]2.work#3.wealthÿ=ÿ0
          ÿ(ÿ3)ÿÿ[y]3.work#2.wealthÿ=ÿ0
          ÿ(ÿ4)ÿÿ[y]3.work#3.wealthÿ=ÿ0
          ÿ(ÿ5)ÿÿ[y]4.work#2.wealthÿ=ÿ0
          ÿ(ÿ6)ÿÿ[y]4.work#3.wealthÿ=ÿ0

          ÿÿÿÿÿÿÿÿÿÿÿchi2(ÿÿ6)ÿ=ÿÿÿÿ3.19
          ÿÿÿÿÿÿÿÿÿProbÿ>ÿchi2ÿ=ÿÿÿÿ0.7843

          .ÿ
          .ÿpermuteÿyÿFÿ=ÿe(F_3),ÿreps(3000)ÿnodots:ÿanovaÿyÿwork##wealth

          MonteÿCarloÿpermutationÿresultsÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿobservationsÿ=ÿÿÿ100
          Permutationÿvariable:ÿyÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿpermutationsÿ=ÿ3,000

          ÿÿÿÿÿÿCommand:ÿanovaÿyÿwork##wealth
          ÿÿÿÿÿÿÿÿÿÿÿÿF:ÿe(F_3)

          -------------------------------------------------------------------------------
          ÿÿÿÿÿÿÿÿÿÿÿÿÿ|ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿMonteÿCarloÿerror
          ÿÿÿÿÿÿÿÿÿÿÿÿÿ|ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ-------------------
          ÿÿÿÿÿÿÿÿÿÿÿTÿ|ÿÿÿÿT(obs)ÿÿÿÿÿÿÿTestÿÿÿÿÿÿÿcÿÿÿÿÿÿÿnÿÿÿÿÿÿpÿÿSE(p)ÿÿÿ[95%ÿCI(p)]
          -------------+-----------------------------------------------------------------
          ÿÿÿÿÿÿÿÿÿÿÿFÿ|ÿÿ.5479445ÿÿÿÿÿÿlowerÿÿÿÿÿ736ÿÿÿÿ3000ÿÿ.2453ÿÿ.0079ÿÿ.2300ÿÿ.2611
          ÿÿÿÿÿÿÿÿÿÿÿÿÿ|ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿupperÿÿÿÿ2264ÿÿÿÿ3000ÿÿ.7547ÿÿ.0079ÿÿ.7389ÿÿ.7700
          ÿÿÿÿÿÿÿÿÿÿÿÿÿ|ÿÿÿÿÿÿÿÿÿÿÿÿtwo-sidedÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ.4907ÿÿ.0091ÿÿ.4728ÿÿ.5086
          -------------------------------------------------------------------------------
          Notes:ÿForÿlowerÿone-sidedÿtest,ÿcÿ=ÿ#{Tÿ<=ÿT(obs)}ÿandÿpÿ=ÿp_lowerÿ=ÿc/n.
          ÿÿÿÿÿÿÿForÿupperÿone-sidedÿtest,ÿcÿ=ÿ#{Tÿ>=ÿT(obs)}ÿandÿpÿ=ÿp_upperÿ=ÿc/n.
          ÿÿÿÿÿÿÿForÿtwo-sidedÿtest,ÿpÿ=ÿ2*min(p_lower,ÿp_upper);ÿSEÿandÿCIÿapproximate.

          .ÿ
          .ÿexit

          endÿofÿdo-file


          .

          Comment


          • #6
            Thank you very much, this will help me a lot.
            I'm trying the first one (ologit), because i have more than 500 people in my database (i didn't know dataex was truncated at 100 observations).

            Comment

            Working...
            X