Announcement

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

  • One sided t-test

    Hi,

    I would like to record the t-stat of the ttest of the following regression: w_H => w_L. The following command gives me the p-value but not the t-stat. I would like to record it in Excel with the command "putexcel". Who can I do that? Thanks.

    Code:
     sysuse auto, clear
    
    xtile weight_HL=weight, nquantiles(2)
    gen w_H=1 if weight_HL==2
    replace w_H=0 if weight_HL==1
    gen w_L=1 if weight_HL==1
    replace w_L=0 if weight_HL==2
    
    
    regress price w_H w_L weight length mpg, noconstant
    
    test _b[w_H] = _b[w_L]
    local sign_d_HL = sign(_b[w_H] - _b[w_L])
    display "Ho: coef (w_H-w_L) => 0  p-value = " 1-ttail(r(df_r),`sign_d_HL'*sqrt(r(F)))

  • #2
    Francois:
    I do hope that what follows might be helpful:
    Code:
    . display "Ho: coef (w_H-w_L) => 0  t= " invttail(r(df_r), 1-ttail(r(df_r),`sign_d_HL'*sqrt(r(F))))  " p-value = " 1-ttail(r(df_r),`sign_
    > d_HL'*sqrt(r(F)))
    Ho: coef (w_H-w_L) => 0  t= 3.1920331 p-value = .00106403
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      thanks a lot Carlo! Do you know how I could save that in excel with the "putexcel" command? Where can I see the results in memory?

      Comment


      • #4
        Francois:
        no, sorry.
        I'm not familiar with -putexcel-.
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment


        • #5
          Carlo,

          Thanks again for your code. I am currently running it with my data.

          Here is what I am getting:
          Code:
          . display "Ho: coef (w_H-w_L) => 0  t= " invttail(r(df_r), ttail(r(df_r),`sign_d_HL'*sqrt(r(F))))  " p-value = " ttail(r(df_r),
          > `sign_d_HL'*sqrt(r(F)))
          Ho: coef (w_H-w_L) => 0  t= 1.69504 p-value = .04552803
          The p-value is <5% and the t = 1.695. The t value (corresponding to the p-value) seems low. I may be wrong on that but I just want to check that everything is right... Can you confirm? Thanks

          Comment


          • #6
            Francois:
            the code seems right; I do not know your seemingly revised data (vs post#1), hence I cannot commen any further.
            Kind regards,
            Carlo
            (Stata 19.0)

            Comment


            • #7
              Remember, you specifically asked for a one-sided t-test, so the p-values will be lower than what you are accustomed to seeing in the more usual two-sided tests. With respect to your particular example, if the degrees of freedom is 35 or higher, then that t-statistic does indeed correspond to a p-values less than 0.05.

              Finally, let me also suggest you not make a fetish out of 0.05 significance. Your work will probably be more fruitful if you focus on the magnitude of the effect.

              Comment


              • #8
                Thanks Clyde

                Comment


                • #9
                  And of course, thanks a lot Carlo. Your code is right and very helpful!

                  Comment

                  Working...
                  X