11.1 Introduction

This chapter has several purposes. One is to convey the basics of writing your own functions in R. The second is to show you, in a simple case, how you could simulate the data from an experiment before performing it, and why this would be useful. The third is to discuss statistical power in more detail. leads on to a discussion of power analysis, and how to choose and justify your sample size.