Announcement

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

  • Replicate R's pnorm function

    Hi Statalist,

    I'm porting a couple R scripts to Stata and have hit a roadblock. I have been unable to replicate R's pnorm() function in Stata. I've searched this forum, Stata documentation, and the Web to no avail.

    R has a dnorm() function that “returns the value of the probability density function (pdf) of the normal distribution” and appears to be the same as Stata’s normalden()
    Example:
    R: dnorm(-0.2231436, -0.1682927, 0.1931885) returns 1.983462
    Stata: normalden(-0.2231436, -0.1682927, 0.1931885) returns 1.9834621

    R’s pnorm() function “returns the value of the cumulative density function (cdf) of the normal distribution” and I haven't found a way to replicate it in Stata.
    Using the same value, mean, and SD as above…
    R: pnorm(-0.2231436, -0.1682927, 0.1931885) returns 0.3882342
    Stata: I’ve had no luck.

    Do any Statalisters know how to find the value of the CDF of the normal distribution?

    Thank you,
    Marc Peterson

  • #2
    Stata's cumulative distribution function for the normal distribution is -normal()-. But you cannot give it three arguments the way you can with -normalden()-. You have to convert your x, m, and s into a z-score, z = (x-m)/s, and that becomes the argument.

    Code:
    . display normal((-0.2231436-(-0.1682927))/0.1931885)
    .38823422

    Comment


    • #3
      Fantastic! Thank you, Clyde!

      Comment

      Working...
      X