Announcement

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

  • ttest using a null hypothesis other than zero

    I would like to run one-sided ttest (either paired or independent samples) with the null hypothesis set to values other than zero. One possible application for this might be to set the null hypothesis to either a superiority margin or inferiority margin to test for a clinically important difference; however, for that type of application, I would typically calculate the confidence interval and see if it crosses the margin. Unfortunately, I need the actual p-values. My intent is create a graph of p-values by variable difference by setting the null hypothesis to a range of values. This would be similar to a p-value function graph. Does the ttest (or other command) allow me to set the null hypothesis to a specific value or variable list? Thanks.

  • #2
    Howard:
    welcome to this forum.
    You can use .ttesti- and set the reference mean at whatever value you want, as in the following toy-example (N=100; sample mean=5; sample std.dev.:2; Ho: mean=4).
    Code:
    . ttesti 100 5 2 4
    
    One-sample t test
    ------------------------------------------------------------------------------
             |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
    ---------+--------------------------------------------------------------------
           x |     100           5          .2           2    4.603157    5.396843
    ------------------------------------------------------------------------------
        mean = mean(x)                                                t =   5.0000
    Ho: mean = 4                                     degrees of freedom =       99
    
        Ha: mean < 4                 Ha: mean != 4                 Ha: mean > 4
     Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000
    
    .
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Originally posted by Howard Smithline View Post
      My intent is create a graph of p-values by variable difference by setting the null hypothesis to a range of values. This would be similar to a p-value function graph.
      I don't know what a p-value function graph is, but for plotting the quantiles of the Student's t-distribution in the context of a two-sided alternative hypothesis, and a given mean difference, standard error of the difference and degrees of freedom, you could do something like the following (substitute in your particular values for the placeholder values used below).
      Code:
      local control_mean 4
      local se_difference 0.5
      local df 7
      
      graph twoway function p = 2 * ttail(`df', abs(x - `control_mean') / `se_difference'), range(2 6) ///
          ylabel( , angle(horizontal) format(%04.2f) nogrid) xtitle("Experimental mean") yline(0.05)

      Comment


      • #4
        Very interesting, thanks Joseph Coveney
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment


        • #5
          Oh, for a range of specified nonzero null hypotheses, you'd modify the code above to
          Code:
          local control_mean 4
          local experimental_mean 2
          local se_difference 0.5
          local df 7
          
          graph twoway function p = 2 * ttail(`df', abs(`experimental_mean' - `control_mean' - x) / `se_difference'), range(-4 0) ///
              ylabel( , angle(horizontal) format(%04.2f) nogrid) xtitle("Null hypothesis of mean difference") yline(0.05)

          Comment

          Working...
          X