## Preparation

1. Install RStudio: http://www.rstudio.com
2. If you are not familiar with R work thorugh this short online course: http://tryr.codeschool.com/
3. If you are not familiar with R markdown go throug this website: http://rmarkdown.rstudio.com/

The following exercise are taken from our textbook (Stanford library link).

## Exercises

### Exercise 1

Use the commands seq and rep create the following lists.

1. Even numbers less than 20
2. Odd numbers between 101 and 203
3. 1 3 1 3 1 3 1 3
4. 1 1 1 1 3 3 3 3

### Exercise 2

Calculate the mean and variance of the following.

1. First 100 integers.
2. Random sample of 50 normal random variates with mean 30 and standard deviation 5.

### Exercise 3

Simulate the sampling distribution of the mean of 10 tosses of a fair die.

### Exercise 4

Approximate the power of a $$t$$-test of $$H_0: \mu = 0$$ versus $$H_A: \mu > 0$$ when the true mean is $$\mu = 0.5$$. Assume a random sample of size $$n = 25$$ from a normal distribution with $$\sigma = 1$$. Assume $$\alpha = 0.05$$.

### Exercise 5

Use the commands dnorm, seq, and lines to create a plot of the pdf of a normal distribution with $$\mu = 50$$ and $$\sigma^2 = 10$$.

### Exercise 6

Write an R function which computes the sign analysis. For example, the following commands compute the statistic $$S^+$$, assuming that the sample is in the vector $$x$$.

xt <- x[x!=0]
nt <- length(xt)
ind <- rep(0,nt)
ind[xt > 0] <-1
splus <- sum(ind)

### Exercise 7

Calculate the sign test for the nursery school example, Example 2.3.1. Show that the $$p$$-value for the one-sided sign test is $$0.1445$$.