This function performs the sample size calculation for a linear mixed model with random slope.

1 2 3 |

`n` |
sample size per group |

`delta` |
group difference in slopes |

`t` |
the observation times |

`sig2.s` |
variance of random slope |

`sig2.e` |
residual variance |

`sig.level` |
type one error |

`power` |
power |

`alternative` |
one- or two-sided test |

`tol` |
numerical tolerance used in root finding. |

This function will also provide sample size estimates for linear mixed
models with random intercept only simply by setting `sig2.s = 0`

The number of subject required per arm to attain the specified
`power`

given `sig.level`

and the other parameter estimates.

Michael C. Donohue, Steven D. Edland

Edland, S.D. (2009) Which MRI measure is best for Alzheimer's
disease prevention trials: Statistical considerations of power and sample
size. *Joint Stat Meeting Proceedings*. 4996-4999.

`lmmpower`

, `diggle.linear.power`

,
`liu.liang.linear.power`

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | ```
## Not run:
browseVignettes(package = "longpower")
## End(Not run)
# Reproduces the table on page 29 of Diggle et al
n = 3
t = c(0,2,5)
rho = c(0.2, 0.5, 0.8)
sigma2 = c(100, 200, 300)
tab = outer(rho, sigma2,
Vectorize(function(rho, sigma2){
ceiling(edland.linear.power(
delta=0.5,
t=t,
sig2.e=sigma2*(1-rho),
alternative="one.sided",
power=0.80)$n)}))
colnames(tab) = paste("sigma2 =", sigma2)
rownames(tab) = paste("rho =", rho)
tab
# An Alzheimer's Disease example using ADAS-cog pilot estimates
t = seq(0,1.5,0.25)
n = length(t)
edland.linear.power(delta=1.5, t=t, sig2.s = 24, sig2.e = 10, sig.level=0.05, power = 0.80)
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

All documentation is copyright its authors; we didn't write any of that.