Announcement

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

  • chi-squared goodness-of-fit test

    Hello everybody,

    thank you for your time, my issue:

    +---------------------------------------+
    | p gpperc gpfreq mhfreq |
    |---------------------------------------|
    1. | consistent 26.3 26 12 |
    2. | equal 4 4 1 |
    3. | pr 69.7 69 29 |
    +---------------------------------------+

    csgof p, gpperc(26.3 4.0 69.7)




    => option gpperc() not allowed
    r(198);



    I would like to test if the change in frequency of PRs between Grether and Plott (1979) [gpfreq] and MacDonald and Huth (1989) [mhfreq] is significant at the 5% level. However, I receive a r(198) error.




    Best wishes,
    Daniel

  • #2
    More specifically, I would like to test the null hypothesis if both PR rates are equivalent at the 5% level.

    Comment


    • #3
      I am not familiar with this command (which, as you are asked in the FAQ to explain, is user-written), but the error message seems clear: you have made a typo; a quick look at the help file confirms that as "gpperc" should be "expperc"

      also, your table is very hard to read; please read the FAQ which explains how, and why, to use CODE blocks

      Comment


      • #4
        As Rich rightly underlined, csgof is user-written from http://www.ats.ucla.edu/stat/stata/ado/analysis -- as you are asked to explain. See http://www.statalist.org/forums/help#stata for protocol on citing user-written programs.

        For future questions, see also http://www.statalist.org/forums/help#references on why minimal name (date) references are deprecated.

        The syntax of csgof can be understood by expanding on its example. You feed it a categorical variable and expected percents from the null hypothesis.

        Code:
        . use http://www.ats.ucla.edu/stat/stata/notes/hsb2
        (highschool and beyond (200 cases))
        
        . tab race
        
                race |      Freq.     Percent        Cum.
        -------------+-----------------------------------
            hispanic |         24       12.00       12.00
               asian |         11        5.50       17.50
        african-amer |         20       10.00       27.50
               white |        145       72.50      100.00
        -------------+-----------------------------------
               Total |        200      100.00
        
        . csgof race, expperc(10 10 10 70)
        
          +--------------------------------------------+
          |         race   expperc   expfreq   obsfreq |
          |--------------------------------------------|
          |     hispanic        10        20        24 |
          |        asian        10        20        11 |
          | african-amer        10        20        20 |
          |        white        70       140       145 |
          +--------------------------------------------+
        
        chisq(3) is 5.03, p = .1697
        Now it becomes apparent what your immediate problem is. You specified an option gpperc() but there is no such option in the syntax. Stata is trying to tell you that.

        Here's another way of applying a chi-square test, using chitesti from tab_chi from SSC.

        Code:
        . ssc inst tab_chi 
        
        . chitesti 24 11 20 145 \ 200*0.1 200*0.1 200*0.1 200*0.7
        
        observed frequencies from keyboard; expected frequencies from keyboard
        
                 Pearson chi2(3) =   5.0286   Pr =  0.170
        likelihood-ratio chi2(3) =   5.7755   Pr =  0.123
        
          +-------------------------------------------+
          | observed   expected   obs - exp   Pearson |
          |-------------------------------------------|
          |       24     20.000       4.000     0.894 |
          |       11     20.000      -9.000    -2.012 |
          |       20     20.000       0.000     0.000 |
          |      145    140.000       5.000     0.423 |
          +-------------------------------------------+
        In your case, I can type in your observed frequencies and get a result:


        Code:
        . chitesti 12 1 29 \ 42*0.263 42*0.04 42*0.697
        
        observed frequencies from keyboard; expected frequencies from keyboard
        
                 Pearson chi2(2) =   0.3602   Pr =  0.835
        likelihood-ratio chi2(2) =   0.4051   Pr =  0.817
        
          +---------------------------------------------------+
          | observed   expected   notes   obs - exp   Pearson |
          |---------------------------------------------------|
          |       12     11.046               0.954     0.287 |
          |        1      1.680   *          -0.680    -0.525 |
          |       29     29.274              -0.274    -0.051 |
          +---------------------------------------------------+
        
        *  1 <= expected < 5
        Immodesty aside, chitesti does rather more than csgof. See also tabchi and tabchii in the same package

        Comment


        • #5
          Thank you Mr. Goldstein and Mr. Cox. I did not work with Stata for two years now and everything is a little bit complicated. I am writting my master's thesis in behavioral economics, so please do not fear that I will become an econometrician. However, thank you. I solved the issue such that I am exclusively focusing on the equvivalence of the incidences in both articles. So I did the following:



          Thus I get a p-value of p=0.199 and thus cannot reject the null hypothesis that the reversal rates are equivalent at the 5% level. Hence MacDonald and Huth have replicated Grether and Plott's result in this case. However, I will transcribe Mr. Cox approach.




          Best wishes,
          Daniel

          Comment


          • #6
            Sorry for this; I did the following:
            Attached Files

            Comment


            • #7
              Your cross-tabulation in #6 is utterly invalid as a test of any hypothesis. You have classes and class frequencies quite the wrong way round. It would be in your interests to revise your texts or lecture notes on that part of statistics as at Master's level this would be very alarming.

              Footnote. On #5 and in passing this comment from http://www.statalist.org/forums/foru...-does-not-work
              applies exactly to you too:

              First names are fine by Rich and me; otherwise you strip us of our hard-earned doctorates.

              Comment


              • #8
                Thank you Nick!

                Comment

                Working...
                X