## MeanU qchisq0951 [1 00527

Observe the use of the "for" loop. The indexing variable, to the left of the word "in" inside the brackets, sequentially obtains as a value the components of the vector to the right of that word. The expression following the brackets is evaluated for each value of the indexing variable. Several expressions may be grouped together by placing them between curly brackets. In this example we compute the test statistic 10,000 times. In each iteration x values are generated according to the binomial distribution. The phenotypes are generated according to the normal distribution with mean equal to 15 and standard deviation of 3. The test statistic is formed by squaring the correlation coefficient and multiplying the result by the sample size. The result is stored in the vector U. The function qchisq computes the quantile of the chi-square distribution. The simulated significance level is approximately equal to the target value of 5%.

A more comprehensive description of the distribution of the test statistic under the null distribution is given in Fig. 1.5. The solid black line represents the theoretical cumulative distribution function of the chi-square distribution, which is appropriate since we are computing the square of test statistic. The solid gray line represents the empirical distribution function of the simulated U statistic. The broken black line represents the empirical distribution function of the statistic when it is simulated under the alternative hypothesis. Note that the simulated solid gray line and the theoretical solid black line are practically identical. These two lines were formed using the code:

## Post a comment