**Bartomeus lab » Rstats**, and kindly contributed to R-bloggers)

This is a quick note that may be useful for some people. I was interested in knowing how many years of monitoring we need to detect a trend. This is a long term monitoring project, so we already have 7 years of data to play with. For a simple design, you can use the pwr library in R to answer your question, but for nested designs (i.e. random factors) things get hairy. In this and this paper they suggest building your own simulation and both has quite complex supplementary material with R code. I didn’t spent enough time to make sense of them. I also found thanks to @frod_san two packages that do it for you. The first, PAMM, is broken (lme4 keep evolving, while the package didn’t, so even the example they use don’t work*). The second (SimR) is not published yet, but is amazingly simple. All its code is in github and they are fast at fixing any bug you may detect (they fixed a small bug I found in no time). You can find a gist with an example of my question and how I calculate power here: https://gist.github.com/ibartomeus/e8eab8a32b57423341fb

*I fixed the function SSF to make it work with the updated lme4, but I am not posting it because I think makes no sense to use a not maintained package.

**leave a comment**for the author, please follow the link and comment on their blog:

**Bartomeus lab » Rstats**.

R-bloggers.com offers

**daily e-mail updates**about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...