*! version 1.0.0 01Dec2023

Title

norm dist -- normal and inverse normal distribution functions with added mean and standard deviation

Syntax

The inverse cumulative standard normal distribution function using data stored in memory

invnorm newvarname [if] [in] , p(varname) [ mean(varname) sd(varname) ]

Immediate form of invnorm

invnormi p [, mean(#) sd(#) ]

where p represents the significance level

The cumulative standard normal distribution using data stored in memory

normd newvarname [if] [in] , z(varname) [ mean(varname) sd(varname) ]

Immediate form of norm

normi z [, mean(#) sd(#) ]

where z represents the z score

normd
z(varname) variable containing the z scores; required

mean(varname) variable containing the distribution means; default is means set at 0

sd(varname) variable containing the distribution standard deviations; default is sds set at 1

invnorm
p(varname) variable containing the p values; required

mean(varname) variable containing the distribution means; default is to set the means at 0

sd(varname) variable containing the distribution standard deviations; default is to set the sds at 1

normi and invnormi
mean(#) specify the mean of the distribution; default is mean(0)

sd(#) specify the standard deviation of the distribution; default is sd(1)

Description

invnorm computes the inverse cumulative standard normal distribution function and normd computes the cumulative standard normal distribution, allowing
the user to specify the means and standard deviations. This extends official Stata's invnormal and normal functions that assume
a mean of 0 and a standard deviation of 1. invnorm is equivalent to R's qnorm function and normd is equivalent to R's pnorm function
(see https://stat.ethz.ch/R-manual/R-devel/library/stats/html/Normal.html).

invnormi and normi are the immediate forms of invnorm and normd, respectively; see immed.

Examples

invnorm using data stored in memory

set-up

. clear

. set obs 1000

. gen p = runiform()

. gen mean = rnormal(2,4)

. gen sd = rnormal(4,2)

generate z scores using defaults (means=0, sds=1)

. invnorm zval, p(p)

generate z scores specifying means and sds

. invnorm zval2, p(p) mean(mean) sd(sd)

invnormi to specify values manually

using defaults; mean = 0 and sd = 1

. invnormi 0.05

specifying values for mean and sd

. invnormi 0.05, m(2) s(4)

normd using data stored in memory

set-up

. clear

. set obs 1000

. gen z = rnormal(0,1)

. gen mean = rnormal(2,4)

. gen sd = rnormal(4,2)

generate p values using defaults (means=0, sds=1)

. normd pval, z(z)

generate p values specifying means and sds

. normd pval2, z(z) mean(mean) sd(sd)

normi to specify values manually

using defaults; mean = 0 and sd = 1

. normi -1.6448536

specifying values for mean and sd

. normi -1.6448536, m(2) s(4)

Stored results

invnormi and normi store the following in r(), respectively:

Scalars

r(invnorm) inverse cumulative standard normal distribution

r(normd) cumulative standard normal distribution

Citation of norm dist

norm dist is not an official Stata command. It is a free contribution
to the research community, like a paper. Please cite it as such:

Linden, Ariel (2023). NORM DIST: Stata module for computing normal and inverse normal distribution functions with added mean and standard deviation

Author

Ariel Linden

President, Linden Consulting Group, LLC

alinden@lindenconsulting.org

http://www.lindenconsulting.org

Also see

Online: invnormal, normal