Announcement

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

  • Perplexing decimal issue with F test

    Hi all,

    I've been running ANOVAs and bonferroni posthocs and sometimes my mean table has decimal places...and sometimes it does not! I don't understand how this is the case since my data is all coming from the same file and I am using the same code. This is what it looks like:

    oneway sadness Chars, bonferroni tabulate

    Chars | Mean Std. Dev. Freq.
    ------------+------------------------------------
    1 | 5 2 50
    2 | 4 2 50
    3 | 5 2 50
    4 | 3 2 50
    ------------+------------------------------------


    But then I run the same code on a different variable and:

    oneway happiness Chars, bonferroni tabulate


    Chars | Mean Std. Dev. Freq.
    ------------+------------------------------------
    1 | 6.7333333 1.3336158 50
    2 | 5.75 1.5581932 50
    3 | 6.1166667 1.6060444 50
    4 | 5.11 1.5480989 50
    ------------+------------------------------------



    The same issue happens with my Bonferroni output table.
    What can I do to get all the decimals in each analysis? Thank you!

  • #2
    oneway is just trying to respect the display format of the outcome variable that you, or somebody else, assigned earlier. We can't see your data or their display formats, but this example should make the point clear.


    Code:
    . sysuse auto, clear
    (1978 Automobile Data)
    
    . d
    
    Contains data from C:\Program Files (x86)\Stata\ado\base/a/auto.dta
      obs:            74                          1978 Automobile Data
     vars:            12                          13 Apr 2018 17:45
                                                  (_dta has notes)
    -------------------------------------------------------------------------------------------------------------
                  storage   display    value
    variable name   type    format     label      variable label
    -------------------------------------------------------------------------------------------------------------
    make            str18   %-18s                 Make and Model
    price           int     %8.0gc                Price
    mpg             int     %8.0g                 Mileage (mpg)
    rep78           int     %8.0g                 Repair Record 1978
    headroom        float   %6.1f                 Headroom (in.)
    trunk           int     %8.0g                 Trunk space (cu. ft.)
    weight          int     %8.0gc                Weight (lbs.)
    length          int     %8.0g                 Length (in.)
    turn            int     %8.0g                 Turn Circle (ft.)
    displacement    int     %8.0g                 Displacement (cu. in.)
    gear_ratio      float   %6.2f                 Gear Ratio
    foreign         byte    %8.0g      origin     Car type
    -------------------------------------------------------------------------------------------------------------
    Sorted by: foreign
    
    . oneway gear_ratio foreign, means
    
                | Summary of
                | Gear Ratio
       Car type |        Mean
    ------------+------------
       Domestic |        2.81
        Foreign |        3.51
    ------------+------------
          Total |        3.01
    
                            Analysis of Variance
        Source              SS         df      MS            F     Prob > F
    ------------------------------------------------------------------------
    Between groups      7.59103509      1   7.59103509     71.84     0.0000
     Within groups      7.60741268     72   .105658509
    ------------------------------------------------------------------------
        Total           15.1984478     73   .208197915
    
    Bartlett's test for equal variances:  chi2(1) =   0.4305  Prob>chi2 = 0.512
    
    . oneway mpg foreign, means
    
                | Summary of
                |   Mileage
                |    (mpg)
       Car type |        Mean
    ------------+------------
       Domestic |   19.826923
        Foreign |   24.772727
    ------------+------------
          Total |   21.297297
    
                            Analysis of Variance
        Source              SS         df      MS            F     Prob > F
    ------------------------------------------------------------------------
    Between groups      378.153515      1   378.153515     13.18     0.0005
     Within groups      2065.30594     72   28.6848048
    ------------------------------------------------------------------------
        Total           2443.45946     73   33.4720474
    
    Bartlett's test for equal variances:  chi2(1) =   3.4818  Prob>chi2 = 0.062
    
    . format mpg %6.2f
    
    . oneway mpg foreign, means
    
                | Summary of
                |   Mileage
                |    (mpg)
       Car type |        Mean
    ------------+------------
       Domestic |       19.83
        Foreign |       24.77
    ------------+------------
          Total |       21.30
    
                            Analysis of Variance
        Source              SS         df      MS            F     Prob > F
    ------------------------------------------------------------------------
    Between groups      378.153515      1   378.153515     13.18     0.0005
     Within groups      2065.30594     72   28.6848048
    ------------------------------------------------------------------------
        Total           2443.45946     73   33.4720474
    
    Bartlett's test for equal variances:  chi2(1) =   3.4818  Prob>chi2 = 0.062
    So, to get consistent presentation, choose a display format that works well for all your outcome variables.

    Comment


    • #3
      Ohh! Thank you! I changed the display formats and it fixed the issue.

      Comment

      Working...
      X