Announcement

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

  • fuction t-test

    Good morning, I'm new in this forum and I start recently to use Stata. What I have to do is compare the observations between companies that adopt a different accounting system. In particular, I have two accounting system (we can call them A and B) and companies are under A or B. For each companies i have like 10 variables and I have to compare variables of companies that use A with the variables of companies that use B. Someone knows how to do that?
    I try:.
    ttest Tot_Ass Tot_Rev if Acc_sys = "1" but it doesn't work

    I search online but I didn't find the answer, thanks to anyone who will answer me. I only knows that I must use the p-test function.
    Last edited by Matteo Amerio; 30 May 2023, 06:46.

  • #2
    Matteo:
    welcome to this forum.
    I'm not clear with what you have to compare:
    1) if you have one continuous variable only, (say turnover) and the only independent variable is company's accounting system, you can go -ttest- like:
    Code:
    . use "C:\Program Files\Stata17\ado\base\a\auto.dta"
    (1978 automobile data)
    
    . ttest mpg, by(foreign) unequal
    
    Two-sample t test with unequal variances
    ------------------------------------------------------------------------------
       Group |     Obs        Mean    Std. err.   Std. dev.   [95% conf. interval]
    ---------+--------------------------------------------------------------------
    Domestic |      52    19.82692     .657777    4.743297    18.50638    21.14747
     Foreign |      22    24.77273     1.40951    6.611187    21.84149    27.70396
    ---------+--------------------------------------------------------------------
    Combined |      74     21.2973    .6725511    5.785503     19.9569    22.63769
    ---------+--------------------------------------------------------------------
        diff |           -4.945804    1.555438               -8.120053   -1.771556
    ------------------------------------------------------------------------------
        diff = mean(Domestic) - mean(Foreign)                         t =  -3.1797
    H0: diff = 0                     Satterthwaite's degrees of freedom =  30.5463
    
        Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
     Pr(T < t) = 0.0017         Pr(|T| > |t|) = 0.0034          Pr(T > t) = 0.9983
    
    .
    2) if you have one continuous dependent variable and >1 independent variable, you can go -regress-, like:
    Code:
    . regress mpg price i.foreign
    
          Source |       SS           df       MS      Number of obs   =        74
    -------------+----------------------------------   F(2, 71)        =     23.01
           Model |  960.866305         2  480.433152   Prob > F        =    0.0000
        Residual |  1482.59315        71  20.8815937   R-squared       =    0.3932
    -------------+----------------------------------   Adj R-squared   =    0.3761
           Total |  2443.45946        73  33.4720474   Root MSE        =    4.5696
    
    ------------------------------------------------------------------------------
             mpg | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
    -------------+----------------------------------------------------------------
           price |   -.000959   .0001815    -5.28   0.000     -.001321    -.000597
                 |
         foreign |
        Foreign  |   5.245271   1.163592     4.51   0.000     2.925135    7.565407
           _cons |   25.65058   1.271581    20.17   0.000     23.11512    28.18605
    ------------------------------------------------------------------------------
    
    .
    3) if you have two or more continuous dependent variables and >1 independent variable you can go -mvreg-, like:
    Code:
    . mvreg mpg trunk=price i.foreign
    
    Equation             Obs   Parms        RMSE    "R-sq"          F      P>F
    --------------------------------------------------------------------------
    mpg                   74       3    4.569638    0.3932   23.00749   0.0000
    trunk                 74       3    3.782167    0.2396   11.18443   0.0001
    
    ------------------------------------------------------------------------------
                 | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
    -------------+----------------------------------------------------------------
    mpg          |
           price |   -.000959   .0001815    -5.28   0.000     -.001321    -.000597
                 |
         foreign |
        Foreign  |   5.245271   1.163592     4.51   0.000     2.925135    7.565407
           _cons |   25.65058   1.271581    20.17   0.000     23.11512    28.18605
    -------------+----------------------------------------------------------------
    trunk        |
           price |   .0004824   .0001503     3.21   0.002     .0001828     .000782
                 |
         foreign |
        Foreign  |  -3.491539   .9630738    -3.63   0.001    -5.411854   -1.571225
           _cons |   11.82073   1.052454    11.23   0.000     9.722197    13.91926
    ------------------------------------------------------------------------------
    
    .
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Thank you very much, I probably not understand well how to use ttest. I can't use it if I have to compare more dependent variable (like turnover, total assets, total debts...), am I right?

      Comment


      • #4
        Matteo:
        correct.
        I think you should go -regress-.
        As per FAQ, an example/excerpt of your dataset (that you can easily share via -dataex-) would help enormously. Thanks.
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment


        • #5
          The ttest command (not a function) would be legal starting

          Code:
          ttest Tot_Ass == Tot_Rev 
          and the qualifier

          Code:
          if Acc_sys == "1"
          would be legal if Acc_sys were a string variable. In general you need == when testing for equality. Exceptionally, ttest indulges

          Code:
          ttest Tot_Ass = Tot_Rev 
          -- but see help ttest for key options which are likely to be important.

          Comment


          • #6
            thank you very much for your answer, now I understand much better what to do

            Comment

            Working...
            X