# Assignment 1 - example report

## Sample Size Requirements for Asthma Study

While it is necessary to follow subjects over time to ensure that
treatments maintain their effectiveness, there is also a statistical
advantage in that taking the mean of repeated measurements provides an
outcome variable with smaller variance, thus requiring a smaller sample
size.  

Our calculations are based on the assumption that the overall standard
deviation (SD) for a single FEV% measurement is 15% and that a absolute
reduction of 5% in mean FEV% is an appropriate target.  Applying the
usual sample size calculation for a two sample t-test, assuming a type I
error rate of .05 and power of 80%, yields a requirement of 142 subjects per group.  

Given that the estimated SD for repeat FEV% measurements is 10%, we
obtain a reliability coefficient of .56 for repeat observations.  The
somewhat low value of reliability indicates that savings may be achieved
through with additional follow-up visits, as indicated in the following
table.

```{r,echo=FALSE,message=FALSE,results='hide'}
sd1 <- 15
sd2 <- 10
diff <- 5
ks <- 1:6
rho <- 125/225
varRed <- (1 + (ks-1)*rho)/ks
sds <- sd1 * sqrt(varRed)
ss <- NULL
for (ki in ks) ss[ki] <-  power.t.test(delta=5,sd=sds[ki],power=.8,type="two.sample")$n
tb <- cbind(ks,round(ss),round(100*varRed,1))
dimnames(tb)[[2]] <-
c("Followups","Sample Size", "Percent Reduction")
```

```{r,echo=FALSE,message=FALSE,results='raw'}
kable(tb)
```

As we can see, there is a "law of diminishing returns", since there is
little gain beyond 4 to 5 follow-up visits.

### Knitr is Easy and Fun

Tables are easily included (see above) and so are graphics.

```{r,echo=FALSE,message=FALSE,results='markup',fig.height=4, fig.width=5,fig.show="asis"}
plot(ks,ss,xlab="Number of Follow-ups",
	  ylab="Sample Size",type="l")
```

Latex equations.  The variance reduction factor is $\frac{1 + ( m -1)\rho}{m}$ where $m$ is the number of follow-up visits.

