**Introduction**

A one-sample Wilcoxon signed rank test is applied when you are measuring values of a single variable that you are comparing to some test mean and when this variable is not normally distributed. In this blog entry, we’ll show you how to conduct a one-sample Wilcoxon signed rank test in Stata. You’ll also learn how to test for normalcy of distribution and create a **95% confidence interval graph** for your data.

**Create Data**

First, we’ll create mock data, then we’ll show you how to test their normality, conduct a one-sample Wilcoxon signed rank test in Stata, and generate a 95% CI plot. Let’s assume we’re measuring IQ for 1,000 subjects.

set obs 1000

gen subj = _n

label variable subj "Subject"

gen iq_a = runiform(90,140)

gen iq = round(iq_a)

drop iq_a

label variable iq "IQ"

list in 1/30

**Test for Normality**

We’ll use the Shapiro-Wilk test to assess normality of IQ distribution in the sample, then create a histogram:

swilk iq

hist iq, freq scheme(s1color)

The null hypothesis for the Shapiro-Wilk test is normal distribution. The null hypothesis is rejected, *W* = .95838, *p *< .00001, so we cannot assume normal distribution (if the distribution had been normal, we could have attempted a one-sample *t*-test). The histogram demonstrates the non-normality of the distribution as well:

We can use sktest to separately assess for normality of skewness, kurtosis, and skewness and kurtosis:

sktest iq

Skewness is normal, but kurtosis and joint kurtosis and skewness are not.

**The One-Sample Wilcoxon Signed Rank Test**

Now let’s run the one-sample Wilcoxon signed rank test. We want to check if the sample median differs significantly from 105, so we type:

signrank iq = 105

By the way, you can get the sample median through:

sum iq, det

Here’s what we get after the signrank command:

Note that you get the asymptotic *p* value because of the large sample size, so you can also try:

signrank iq = 105, exact

We reject the null hypothesis that 105 is not significantly different from the sample median of 115, *z* = 17.05, *p *< .0001.

**Graphic Support**

Finally, let’s illustrate the sample mean and 95% CI:

ciplot iq, scheme(s1color)

BridgeText can help you with all of your **statistical analysis needs**.