Announcement

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

  • Bayesian analysis: how to mirror a chi-squared test under the "bayes:" prefix

    Dear Forum Members,

    I believe Stata 15 provided a rather handy panoply of commands to perform Bayesian analysis under the - bayes: - prefix.

    With regards to inferential models, it became much easier to select several types of regression, including hierarchical models,

    That said, I wonder whether there is some sort of "equivalent" chi-squared test, at least some kind of simulation which would produce the couterpart of the traditional calculation proposed by Pearson.

    Below, for example, we see repair records were unexpectedly higher for foreign cars. To underline this aspect, we have the expected values, the Pearson chi2 contribution, p-values (Pearson's as well as Fisher's) and the Cramer's V.

    Code:
    . sysuse auto
    (1978 Automobile Data)
    
    . tabulate rep78 foreign, cchi2 chi2 column exact expected V
    
    +--------------------+
    | Key                |
    |--------------------|
    |     frequency      |
    | expected frequency |
    | chi2 contribution  |
    | column percentage  |
    +--------------------+
    
    Enumerating sample-space combinations:
    stage 5:  enumerations = 1
    stage 4:  enumerations = 3
    stage 3:  enumerations = 24
    stage 2:  enumerations = 203
    stage 1:  enumerations = 0
    
        Repair |
        Record |       Car type
          1978 |  Domestic    Foreign |     Total
    -----------+----------------------+----------
             1 |         2          0 |         2
               |       1.4        0.6 |       2.0
               |       0.3        0.6 |       0.9
               |      4.17       0.00 |      2.90
    -----------+----------------------+----------
             2 |         8          0 |         8
               |       5.6        2.4 |       8.0
               |       1.1        2.4 |       3.5
               |     16.67       0.00 |     11.59
    -----------+----------------------+----------
             3 |        27          3 |        30
               |      20.9        9.1 |      30.0
               |       1.8        4.1 |       5.9
               |     56.25      14.29 |     43.48
    -----------+----------------------+----------
             4 |         9          9 |        18
               |      12.5        5.5 |      18.0
               |       1.0        2.3 |       3.3
               |     18.75      42.86 |     26.09
    -----------+----------------------+----------
             5 |         2          9 |        11
               |       7.7        3.3 |      11.0
               |       4.2        9.5 |      13.7
               |      4.17      42.86 |     15.94
    -----------+----------------------+----------
         Total |        48         21 |        69
               |      48.0       21.0 |      69.0
               |       8.3       19.0 |      27.3
               |    100.00     100.00 |    100.00
    
              Pearson chi2(4) =  27.2640   Pr = 0.000
                   Cramér's V =   0.6286
               Fisher's exact =                 0.000
    
    .

    We see the association between foreign vehicles and repair records is "statistically significant" (sorry for the un-Bayesian sentence). What is more, the effect size is considerably strong.

    Now, my question: how could we elaborate a Bayesian couterpart in Stata?

    Indeed, the command - tabulate - is not supported by the bayes prefix. On top of that, I understand that, for some, this may raise eyebrows, since it would like bringing the frequentist mindset to a different realm.

    Anyway, I believe that such comparisons could be very helpful, particularly for those who have been working for a long time in a "non-Bayesian" world.

    As far as I tried, I didn't find any reference to this subject.

    Thank you in forward for any help!
    Last edited by Marcos Almeida; 13 May 2019, 14:51.
    Best regards,

    Marcos

  • #2
    This is just a gentle reminder, in case some fellow knows how to tackle this issue.

    As far as I could go, the chapter 22 of book "Doing Bayesian Data Analysis" (John Kruschke, 2010) suggests that a so-called 'Poisson exponential ANOVA" model could do the trick.

    I wonder whether it can be feasible in Stata.

    What is more, I would like to know whether there are a "Stataish" anologue to Pearson's chi-squared test.

    Thanks in advance.
    Best regards,

    Marcos

    Comment

    Working...
    X