Announcement

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

  • How do conduct one-sided/tailed t-test in Stata?

    Can anyone tell me the code for conducting one-sided/tailed t-test on a coefficient in Stata?

  • #2
    Stata | FAQ: One-sided tests for coefficients
    https://www.kripfganz.de/stata/

    Comment


    • #3
      Thanks Sebastian,

      I have tried this, but get the following results from the test command.

      test age

      ( 1) age = 0

      chi2( 1) = 6.29
      Prob > chi2 = 0.0121

      These vary from the ones in the article and doesn't allow me to do the subsequent commands.

      Can you perhaps help me see why I get these results?

      Comment


      • #4
        Hi Amalie,

        Please read the FAQ, in particular #12.1, what to say about the the commands and your problem.

        The article that Sebastian posted does not involve an explicit hypothesis test of the age coefficient, so we cannot see exactly which commands you typed that led you to the -test age- statement. Please post the code that you used (using code delimeters, see FAQ).

        Comment


        • #5
          I am using the following code in STATA 15.1, in attempt to follow the guidelines in the article:
          • xtreg Y age X2 X3, re
          • test _b[age]=0
          ( 1) age = 0
          chi2( 1) = 3.40
          Prob > chi2 = 0.0653
          • return list
          scalars:
          r(drop) = 0
          r(chi2) = 3.398229583285744
          r(df) = 1
          r(p) = .0652664345916907
          • local sign_age = sign(_b[age])
          • display "Ho: coef <= 0 p-value = " ttail(r(df_r),`sign_age'*sqrt(r(F))
          • display "Ho: coef >= 0 p-value = " 1-ttail(r(df_r),`sign_age'*sqrt(r(F)))
          Ho: coef <= 0 p-value = .
          Ho: coef >= 0 p-value = .

          I believe there is a mistake in my code. Can you help identify the mistake so that I can correct it.

          Comment


          • #6
            Amalie:
            just replace -F- with -chi2- in your formulae calculi.
            Kind regards,
            Carlo
            (StataNow 18.5)

            Comment


            • #7
              I have changed the following and get the same results as above.
              • display "Ho: coef <= 0 p-value = " ttail(r(df_r),`sign_age'*sqrt(r(chi2))
              • display "Ho: coef >= 0 p-value = " 1-ttail(r(df_r),`sign_age'*sqrt(r(chi2)))
              Do you know how to change it?

              Comment


              • #8
                Amalie, go back to the link that Sebastian has shared in #2 and scroll down to z-tests, which is what xtreg with the re option performs.

                Best
                Daniel

                Comment


                • #9
                  Thanks a lot everyone, that solved my problem!

                  Comment

                  Working...
                  X