|
R demos
Back to all R demos
Tests for population mean
You can try out the function I used in lecture 17 to visualise basic ideas of testing hypotheses.
- Download this file: test.mean.R to your computer, and save it (as test.mean.R)
- Start up R in the usual way
- In R, using the Source R code command (on the File menu), navigate to the appropriate folder, and select the file test.mean.R
- The function visualises a test for the population mean of a normal distribution with known variance, based on the sample mean, as in section 8.5
- Run the demonstration by typing test.mean()
- You can control the simulation and display with the mouse and pointer
- If you click in the main part of the figure, the observed value of the sample mean, or the critical value of the test, respectively, is moved to the x coordinate where you click
- If you click in the menu:
- You can switch between the 'p-value' view of the test and the 'critical region' view
- You can change the sample size
- You can specify a significance level
- You can alter the alternative hypothesis
- If you are interested in seeing how this is all done in R, and perhaps even modifying the actions, you can view the function by simply typing its name (without the () afterwards)
|