*! version 1.0.0 4sept2020
help spnorm

Title

spnorm - Shaded Percentiles of Normal Distributions

Syntax

spnorm
[mean#1 sd#1] [mean#2 sd#2] ...
[ , fcolor(string) xtitle(string) ytitle(string) title(string) saving(filename) ]

Description

spnorm graphs the probability density function of normal distributions upon specification of one or more sets of means and standard deviations. The command is taking advantage of the Stata 16/python interaction. The following packages need to be installed: matplotlib, numpy, scipy, statistics available at https://pypi.org/.

Options

Options

fcolor(string) specifies the color of the distribution. The default is blue. Otherwise, specify as many colours as the specified sets of means and standard deviations. Named colors are listed in https://matplotlib.org.

xtitle(string) specifies the title for the x-axis. Latex is allowed within dollar signs.

ytitle(string) specifies the title for the y-axis. Latex is allowed within dollar signs.

title(string) specifies the title for the figure. Latex is allowed within dollar signs.

saving(filename) saves the graph to disk. Supported formats: PNG (.png), JPEG (.jpg), PDF (.pdf), BMP (.bmp), TIFF (.tif), EPS (.eps), and KML (.kml).
The default file format is PNG (.png).

Examples

// Graph the probability density function of a standard normal distribution

spnorm

// Overlay two (theoretical) sampling distributions of a sample proportion (n=100) under two data generating mechanisms (theta=0.1 and theta=0.2)

spnorm .1 .03 .2 .04, fcolor(aqua lime)

// Add some explanations to the figure

spnorm .1 .03 .2 .04, fc(aqua lime) yt(Sampling distribution) xt(Sample proportions $\hat\theta$ under $\theta=[0.1, 0.2]$) t($ \hat \theta \sim \mathcal(\theta,\, \sqrt{\frac{\theta(1-\theta)}})$)

// Save the figure as pdf in the working directory

spnorm .1 .03 .2 .04, fc(aqua lime) y(Sampling distribution) xt(Sample proportions $\hat\theta$ under $\theta=[0.1, 0.2]$) t($\hat\theta\sim\mathcal(\theta,\, \sqrt{\frac{\theta(1-\theta)}})$) sav(fig.pdf)

// Overlay 9 sampling distributions of a sample proportion (n=100) under a data generating mechanisms where theta = [.1, .2, ..., .9]

spnorm .1 0.030 .2 0.040 .3 0.046 .4 0.049 .5 0.050 .6 0.049 .7 0.046 .8 0.040 .9 0.030, fc(navy blue darkviolet pink gold orange red sienna green)

Author

Nicola Orsini, Biostatistics Team,
Department of Global Public Health, Karolinska Institutet, Sweden

Support

http://www.stats4life.se

nicola.orsini@ki.se