STDMED Function

computes the standard deviation of a sample median.

Syntax

STDMED(n)

where n is the sample size.

Description

The STDMED function gives the standard deviation of the median of a normally distributed sample with a mean of 0 and a variance of 1. This function gives the standard error used to determine the width of the control limits for charts produced by the MCHART and MRCHART statements in PROC SHEWHART.

Let n represent the sample size and $X_{(i)}$ represent the ith order statistic. Then, when n is odd, the STDMED function calculates $\sqrt { \mbox{Var}(X_{((n+1)/2)}) }$, where

\[  \mbox{Var}(X_{((n+1)/2)}) = \frac{1}{\mbox{B}\left( \frac{n+1}{2},\frac{n+1}{2} \right) } \displaystyle \int _{-\infty }^\infty x^2 [\Phi (x)]^{(n-1)/2} [1-\Phi (x)]^{(n-1)/2} \,  \phi (x) \,  dx  \]

where B$(a,b)= \Gamma (a)\Gamma (b)/\Gamma (a+b)$ and $\Gamma (\cdot )$ is the gamma function, $\Phi (\cdot )$ is the standard normal cumulative distribution function, and $\phi (\cdot )$ is the corresponding density function.

If n is even, the function calculates the square root of the following:

\[  \mbox{Var} \left[ \frac{ X_{(n/2)} + X_{((n/2)+1)} }{2} \right] = \]
\[  \mbox{} (1/4) \left[ \mbox{E}(X_{(n/2)}^2) +\mbox{E}(X_{((n/2)+1)}^2) + 2\mbox{E}(X_{(n/2)}X_{((n/2)+1)}) \right]  \]

where

\[  \mbox{E}(X_{(n/2)}^2) = \frac{2}{\mbox{B}\left( \frac{n}{2},\frac{n}{2} \right) } \displaystyle \int _{-\infty }^\infty x^2 [\Phi (x)]^{(n/2)-1} [1-\Phi (x)]^{n/2} \,  \phi (x) \,  dx  \]
\[  \mbox{E}(X_{((n/2)+1)}^2) = \frac{2}{\mbox{B}\left( \frac{n}{2},\frac{n}{2} \right) } \displaystyle \int _{-\infty }^\infty x^2 [\Phi (x)]^{n/2} [1-\Phi (x)]^{(n/2)-1} \,  \phi (x) \,  dx  \]
\[  \mbox{E}(X_{(n/2)}X_{((n/2)+1)}) = \frac{n}{\mbox{B}\left( \frac{n}{2},\frac{n}{2} \right) } \displaystyle \int _{-\infty }^\infty \int _{-\infty }^ y xy [\Phi (x)]^{(n/2)-1} [1-\Phi (y)]^{(n/2)-1} \,  \phi (x) \,  \phi (y) \,  dx \, dy  \]

For more details, refer to David (1981), Kendall and Stuart; 1977, p. 252, and Sarhan and Greenberg (1962).

Examples

These statements use a loop to calculate the standard deviation of the median for sample sizes from 6 to 12:

data;
   do n=6 to 12;
      s=stdmed(n);
      put s;
      output;
   end;
run;

The statements produce these values:

0.4634033519
0.4587448763
0.410098592
0.4075552495
0.3719226208
0.3703544701
0.3428063408