Announcement

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

  • stata cannot display ttail results

    Hi -
    I want to generate a certain p-value after stata runs a model (instead of displaying all results), my code looks like this:

    qui xi: xtmixed pa_sum arm##trt || ProgNum:, variance reml
    dis 2*ttail(e(df_r), abs(_b[1.arm#1.trt]/_se[1.arm#1.trt]))

    I want to get the p value for the interaction term, but cannot get the output (I can display the coefficient and the se).
    Any idea?

    Thanks,
    Manqing

  • #2
    I don't know what version of Stata you are using (the FAQ asks you to tell us if you are not using the current version (which is 15)); there are a couple of clues that you are not using the current version ("xtmixed" rather than "mixed" and the use of -xi- when you would do better to use factor variable notation)

    at any rate, for several versions now, Stata has save what you want it the returned result "r(table)" and you can grab it from there

    added: if your version is new enough so that "r(table)" is included (just type
    Code:
    mat li r(table)
    after estimating your model

    Comment


    • #3
      Rich gives excellent advice to which I add that nothing in your example is reproducible by us as your dataset is not accessible. But minimally you want


      Code:
      2 * ttail(df, t) 
      where df and t are in your case numbers that you should be able to give us to see whether very large df or t are taking you into extreme territory.


      Comment


      • #4
        Hi - I use stata 14.

        r(table) is useful but if I only want to display one p value (so I can directly paste it in word), and really want to use the ttail function, what should I do to solve the issue?

        I can get the t - statistic which is 0.21, but cannot display the degree of freedom..

        dis _b[1.arm#1.trt]/_se[1.arm#1.trt]
        .21048453

        . dis abs(_b[1.arm#1.trt]/_se[1.arm#1.trt])
        .21048453

        . dis e(df_r)

        Code:
        . xi: xtmixed pa_sum arm##trt || ProgNum:, variance reml
        
        Performing EM optimization: 
        
        Performing gradient-based optimization: 
        
        Iteration 0:   log restricted-likelihood = -13042.244  
        Iteration 1:   log restricted-likelihood = -13042.243  
        Iteration 2:   log restricted-likelihood = -13042.243  
        
        Computing standard errors:
        
        Mixed-effects REML regression                   Number of obs     =      3,104
        Group variable: ProgNum                         Number of groups  =         61
        
                                                        Obs per group:
                                                                      min =          3
                                                                      avg =       50.9
                                                                      max =        115
        
                                                        Wald chi2(3)      =      19.80
        Log restricted-likelihood = -13042.243          Prob > chi2       =     0.0002
        
        ------------------------------------------------------------------------------
              pa_sum |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
        -------------+----------------------------------------------------------------
                 arm |
             1 FLEX  |   .1705617   1.015048     0.17   0.867    -1.818895    2.160018
                     |
                 trt |
               1 TR  |  -2.736016   .8364743    -3.27   0.001    -4.375475   -1.096556
                     |
             arm#trt |
        1 FLEX#1 TR  |   .2478312   1.177432     0.21   0.833    -2.059893    2.555555
                     |
               _cons |   27.07966   .7070088    38.30   0.000     25.69394    28.46537
        ------------------------------------------------------------------------------
        
        ------------------------------------------------------------------------------
          Random-effects Parameters  |   Estimate   Std. Err.     [95% Conf. Interval]
        -----------------------------+------------------------------------------------
        ProgNum: Identity            |
                          var(_cons) |   4.041388   1.843606       1.65283    9.881728
        -----------------------------+------------------------------------------------
                       var(Residual) |   259.1568   6.646303      246.4523    272.5163
        ------------------------------------------------------------------------------
        LR test vs. linear model: chibar2(01) = 11.35         Prob >= chibar2 = 0.0004
        .
        Last edited by Manqing Liu; 27 Sep 2017, 11:32.

        Comment


        • #5
          That should help someone. I'll reinforce Rich's comments that

          1. if you are using a previous version, you should always tell us what it is

          2. with Stata 14 xi: is not only unnecessary, it may even mess up what you get.

          What's clear to me is that if the degrees of freedom are missing, so also will be the P-value. Someone else may be able to explain why they are missing.

          Comment


          • #6
            Manqing, I see the problem. I should have spotted this before. -mixed- is an asymptotic estimator, and it produces z-statistics, not t-statistics. There is no e(df_r) in the model. (Notice that the output of -mixed- shows z, not t in the column headers. Notice also that your -display e(df_r)- command produces no output.) So you will have to calculate your pvalue differently:

            Code:
            display 2*normal(-abs(_b[1.arm#1.trt]/_se[1.arm#1.trt]))
            That said, I still think it wold be simpler to report
            Code:
            matrix M = r(table)
            display M[4,3]
            (The row subscript, 4, is where p-values are found in r(table). The column subscript, 3, is chosen because in your -mixed- command the interaction term you are interested in is the third one in the output.)

            Comment


            • #7
              Clyde - That helps a lot, thanks!!!

              Comment


              • #8
                thanks for picking that up Clyde Schechter - I also missed the t v. z

                I note that if Manqing wants to save the p-value in a local, there are ways to do that rather than just displaying; this is something that has been covered many times on this list

                Comment

                Working...
                X