- Install RStudio: http://www.rstudio.com
- If you are not familiar with R work thorugh this short online course: http://tryr.codeschool.com/
- 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).

Use the commands `seq`

and `rep`

create the following lists.

- Even numbers less than 20
- Odd numbers between 101 and 203
`1 3 1 3 1 3 1 3`

`1 1 1 1 3 3 3 3`

Calculate the mean and variance of the following.

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

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

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\).

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\).

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)
```

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\).

Please email your solutions in the form of a Rmd file to Nan Bi and Lexi Guan.

This homework is due on Thursday, April 7th at 1:30 pm.

You are encouraged to work through this homework with your peers. But write your own code and explain the results in your own words.