Announcement

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

  • Loop with chi2 distribution in MATA

    Hello, I'm trying to create 200 samples of a chi2 distribution with 20 degree freedom. And I stared with this:

    set more off
    clear mata
    mata
    x=1000
    do
    {
    rchi2(x,1,20)
    } while (x>=1000)
    end

    x is the number of observations and I decided that x starts in 1000, the problem with this is that the loops goes on forever and I don't know how tell it to does it just 200 times.

    I'm totally new in stata mata
    Thank you

  • #2
    You can do this in one line:

    Code:
    mata: A= rchi2(1000, 200, 20)

    Comment


    • #3
      Thank you Scott

      Comment

      Working...
      X