Announcement

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

  • How do I graph a parameter t distribution

    Dear Statalisters,

    I have a regression coefficient x2=.2227885 with a SE=.056563 and a 95% Conf. Interval =(.1005915; .3449856); n=15. How do I graph the t density distribution for the coefficient showing zero is not within the 95% Conf. Interval?

    For this classical regression beginners exercise, I tried the tden function but it puts zero in the center of the graph, not the coefficient value (x2=.2227885)

    . twoway function y = tden(13,.x)

    Any help would be greatly appreciated.

  • #2
    Try this
    Code:
    local x2=.2227885
    twoway function y=tden(13,x-`x2')

    Comment


    • #3
      it returns
      error in expression: tden(13,x-)
      r(198);

      Comment


      • #4
        Moises Rosas, post #3: odd. It works for me (Stata 16.1)
        Are you copy, pasting? It seems that if you are typing, you are not getting the ` character right.

        Comment


        • #5
          I copied and pasted twice, finally the command line worked, but:

          local x2=.2227885
          twoway function y = tden(13,x-`x2'), range(-5 5) dropline(-1.96 1.96)

          and

          twoway function y = tden(13,x), range(-5 5) dropline(-1.96 1.96)

          returned exactly the same graph, with zero at the center of the distribution

          Comment


          • #6
            Try adding xline(0) as an option. When I do this (Stata 16.1 on a Mac) it is evident that the first distribution is not centered on 0 but the second one is.

            Comment


            • #7
              #5: both do not put zero at the centre. To see this add the value 0 to dropline in the two cases
              This is clear from the length of the vertical lines at -1.96 and 1.96
              To see it more clearly add the value of zero to dropline and the option xlabel(0 .2227895, angle(vert))
              The "angle" is just to make it readable.

              Comment


              • #8
                #6: I'm confused: tden(df,x) should be centered on zero for any degrees of freedom, as t(df) a symmetric distribution with mode=median=0.
                Code:
                twoway function y = tden(13,x), range(-5 5) dropline(-1.96 0 1.96)
                appears to show this when I issue the command.

                Comment


                • #9
                  #8 (John Mullahy): of course, you're right. my mind was elsewhere when I posted #7 and led astray. My post makes no sense

                  Comment


                  • #10
                    Thank you so much for your great advice. It allowed me to finish this classical exercise as shown below:

                    local x2=4.06
                    twoway (function y = tden(12,x), range(-5 10) dropline(-2.1788128 0 2.1788128 4.06)) (function y = tden(12,x-`x2'), range(-5 10) dropline(1.8811872 0 6.2388128 4.06) color(red) legend(off))

                    Moses

                    Comment

                    Working...
                    X