SWSamp is an `R` package designed to allow a wide range of simulation-based sample size calculations, specifically (but not exclusively!) for a Stepped Wedge Trial (SWT) and is based on the general framework described in Baio et al (2015). In its current version, SWSamp consists of 5 main functions: the first one (which is currently in fact specified by three different commands) performs the analytic sample size calculations using the method of Hussey and Hughes (2007). This can be used as a quick alternative for more standard designs or as a first-order approximation in the case of complicated designs (eg including multiple layers of correlation). The second function replicates the sample size calculations based on the (correct form of) the "design effect" specified by Woertman et al (2013). This too can be used very effectively in relatively standard cases, but is less efficient in cases of more complex designs. The core functions of `SWSamp` are `make.swt` , which can be used to simulate data as obtained by a reasonably wide range of possible SWTs and `sim.power` , which actually performs the simulation-based computation of the required sample size. More importantly, `sim.power` can be used to compute the sample size for other data generating processes (DGPs) or designs (ie not specifically for a SWT), which increases the applicability of SWSamp.In order to speed up the computation process (which can be intensive, under particularly complex designs), SWSamp is designed to take full advantage of `R` multi-core processing. For this reason, SWSamp "imports" the NAMESPACE of the R packages `foreach` , `doParallel` , `iterators` and `parallel` (technically, this means that these packages need to be installed on the user's local machine, for SWSamp to work). In addition to these, SWSamp formally "depends" on the `R` package `lme4` , which can be used to fit linear and generalized linear mixed-effects models. This is relevant when analysing a SWT (which invariably includes some form of clustering in the DGP). Other modelling strategies could be used instead, for example Generalised Estimating Equations (GEE, Zeger and Liang 1986) or a full Bayesian model, eg based on Integrated Nested Laplace Approximation (INLA, Rue et al, 2009). In the current release (version 0.3), the Bayesian approach based on INLA is implemented and can be used by setting the optional parameter `method="inla"` .There are two ways of installing install.packages("SWSamp", repos=c("http://www.statistica.it/gianluca/R", "https://cran.rstudio.org", "https://www.math.ntnu.no/inla/R/stable"), dependencies=TRUE ) Note that you need to specify a vector of repositories - the first one hosts To install from source (e.g. on a Linux machine), run install.packages("SWSamp", repos=c("http://www.statistica.it/gianluca/R", "https://cran.rstudio.org", "https://www.math.ntnu.no/inla/R/stable"), type="source", dependencies=TRUE The second way involves using the "development" version of pkgs <- c("foreach", "doParallel", "iterators", "parallel", "Matrix","lme4","INLA","Rtools","devtools") repos <- c("https://cran.rstudio.com", "https://www.math.ntnu.no/inla/R/stable") install.packages(pkgs,repos=repos,dependencies = "Depends") before installing the package using devtools::install_github("giabaio/SWSamp") Under Linux or MacOS, it is sufficient to install the package via install.packages("devtools"); devtools::install_github("giabaio/SWSamp") A full documentation guide available here, including a description of the methods specifically used for a SWT and some for more general data-generating processes. Current release: 0.3 (17 August 2016). |