Announcement

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

  • Significance t test of two scalars' difference

    Hi everyone!

    I want to test if the difference between two scalars is statistically significant at 10%, 5% or 1%, do you possibly know how to achieve that? The following is my code and data, but it didn't show up the t-statistics. Many thanks for your time in advance!


    ----------------------- copy starting from the next line -----------------------
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input long Name double(mean1 mean2)
    1  1.8383807419289167   1.7266930261427125
    2  .23570075560114517   .16440843279268563
    3  .17996988718763549   .20369058384697425
    4   5.620516515152281    5.805663871321566
    5  2.5813825628443197   2.6832247877277484
    6 -.06357658493897562 -.011365789056073154
    7  .18118794957284806   .17398404645983095
    8   5.286552811590096    5.824117617449302
    end
    ------------------ copy up to and including the previous line ------------------



    Code:
    ttest mean1== mean2 if Name== 8
    
    Paired t test
    ------------------------------------------------------------------------------
    Variable |     Obs        Mean    Std. err.   Std. dev.   [95% conf. interval]
    ---------+--------------------------------------------------------------------
     mean1|       1    5.286553           .           .           .           .
    mean2 |       1    5.824118           .           .           .           .
    ---------+--------------------------------------------------------------------
        diff |       1   -.5375648           .           .           .           .
    ------------------------------------------------------------------------------
         mean(diff) = mean(mean1- mean2)                     t =        .
     H0: mean(diff) = 0                              Degrees of freedom =        0
    
     Ha: mean(diff) < 0           Ha: mean(diff) != 0           Ha: mean(diff) > 0
     Pr(T < t) =      .         Pr(|T| > |t|) =      .          Pr(T > t) =      .
    Last edited by Jae Li; 22 Oct 2022, 09:55.

  • #2
    Jae:
    you're actually comparing two constants. No test in hell/heaven will ever do what you're after.

    The correct approach (that does not fullfil your oiu of reach research goals) is:
    Code:
    . ttest mean1 == mean2, unpaired unequal
    
    Two-sample t test with unequal variances
    ------------------------------------------------------------------------------
    Variable |     Obs        Mean    Std. err.   Std. dev.   [95% conf. interval]
    ---------+--------------------------------------------------------------------
       mean1 |       8    1.982514    .8265995    2.337976    .0279171    3.937112
       mean2 |       8    2.071302    .8822033    2.495248   -.0147771    4.157381
    ---------+--------------------------------------------------------------------
    Combined |      16    2.026908    .5840887    2.336355    .7819527    3.271864
    ---------+--------------------------------------------------------------------
        diff |           -.0887877    1.208946               -2.682747    2.505171
    ------------------------------------------------------------------------------
        diff = mean(mean1) - mean(mean2)                              t =  -0.0734
    H0: diff = 0                     Satterthwaite's degrees of freedom =  13.9411
    
        Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
     Pr(T < t) = 0.4712         Pr(|T| > |t|) = 0.9425          Pr(T > t) = 0.5288
    
    .
    Last edited by Carlo Lazzaro; 22 Oct 2022, 10:10.
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      A scalar is just a number, and if you want to know if they're different, just look at them. But that's not statistics or statistical inference. For that, you need to work with samples.

      Comment


      • #4
        @Carlo Lazzaro @Leonardo Guizzetti Hi Carlo and Leonardo, many thanks for your swift replies! I'll change the samples to fulfill it.

        Comment


        • #5
          Jae:
          I fail to get how drawing two different samples can fix the issue, if you still want to compare two scalars.
          Kind regards,
          Carlo
          (Stata 19.0)

          Comment

          Working...
          X