Stata Journal

Cluster randomized controlled trial analysis at the cluster level: The clan command
Thompson JA, Leurent B, Nash S, Moulton LH and Hayes RJ
In this article, we introduce a new command, clan, that conducts a cluster-level analysis of cluster randomized trials. The command simplifies adjusting for individual- and cluster-level covariates and can also account for a stratified design. It can be used to analyze a continuous, binary, or rate outcome.
artcat: Sample-size calculation for an ordered categorical outcome
White IR, Marley-Zagar E, Morris TP, Parmar MKB, Royston P and Babiker AG
We describe a new command, artcat, that calculates sample size or power for a randomized controlled trial or similar experiment with an ordered categorical outcome, where analysis is by the proportional-odds model. artcat implements the method of Whitehead (1993, 12: 2257-2271). We also propose and implement a new method that 1) allows the user to specify a treatment effect that does not obey the proportional-odds assumption, 2) offers greater accuracy for large treatment effects, and 3) allows for noninferiority trials. We illustrate the command and explore the value of an ordered categorical outcome over a binary outcome in various settings. We show by simulation that the methods perform well and that the new method is more accurate than Whitehead's method.
artbin: Extended sample size for randomized trials with binary outcomes
Marley-Zagar E, White IR, Royston P, Barthel FM, Parmar MKB and Babiker AG
We describe the command artbin, which offers various new facilities for the calculation of sample size for binary outcome variables that are not otherwise available in Stata. While artbin has been available since 2004, it has not been previously described in the . artbin has been recently updated to include new options for different statistical tests, methods and study designs, improved syntax, and better handling of noninferiority trials. In this article, we describe the updated version of artbin and detail the various formulas used within artbin in different settings.
power swgee: GEE-based power calculations in stepped wedge cluster randomized trials
Gallis JA, Wang X, Rathouz PJ, Preisser JS, Li F and Turner EL
Stepped wedge cluster randomized trials are increasingly being used to evaluate interventions in medical, public health, educational, and social science contexts. With the longitudinal and crossover nature of a SW-CRT, complex analysis techniques are often needed which makes appropriately powering SW-CRTs challenging. In this paper, we introduce a newly-developed SW-CRT power calculator, embedded within the power command in Stata. The power calculator assumes a marginal model (i.e., generalized estimating equations [GEE]) for the primary analysis of SW-CRTs, for which other currently available SW-CRT power calculators may not be suitable. The program accommodates complete cross-sectional and closed-cohort designs, and includes multilevel correlation structures appropriate for such designs. We discuss the methods and formulae underlying our SW-CRT calculator, and provide illustrative examples of the use of power swgee. We provide suggestions about the choice of parameters in power swgee, and conclude by discussing areas of future research which may improve the program.
Power and sample-size calculations for trials that compare slopes over time: Introducing the slopepower command
Nash S, Morgan KE, Frost C and Mulick A
Trials of interventions that aim to slow disease progression may analyze a continuous outcome by comparing its change over time-its slope-between the treated and the untreated group using a linear mixed model. To perform a sample-size calculation for such a trial, one must have estimates of the parameters that govern the between- and within-subject variability in the outcome, which are often unknown. The algebra needed for the sample-size calculation can also be complex for such trial designs. We have written a new user-friendly command, slopepower, that performs sample-size or power calculations for trials that compare slope outcomes. The package is based on linear mixed-model methodology, described for this setting by Frost, Kenward, and Fox (2008, Statistics in Medicine 27: 3717-3731). In the first stage of this approach, slopepower obtains estimates of mean slopes together with variances and covariances from a linear mixed model fit to previously collected user-supplied data. In the second stage, these estimates are combined with user input about the target effectiveness of the treatment and design of the future trial to give an estimate of either a sample size or a statistical power. In this article, we present the slopepower command, briefly explain the methodology behind it, and demonstrate how it can be used to help plan a trial and compare the sample sizes needed for different trial designs.
Calculating level-specific SEM fit indices for multilevel mediation analyses
Comulada WS
Stata's gsem command provides the ability to fit multilevel structural equation models (sem) and related multilevel models. A motivating example is provided by multilevel mediation analyses (ma) conducted on patient data from Methadone Maintenance Treatment clinics in China. Multilevel ma conducted through the gsem command examined the mediating effects of patients' treatment progression and rapport with counselors on their treatment satisfaction. Multilevel models accounted for the clustering of patient observations within clinics. sem fit indices, such as the comparative fit index and the root mean squared error of approximation, are commonly used in the sem model selection process. Multilevel models present challenges in constructing fit indices because there are multiple levels of hierarchy to account for in establishing goodness of fit. Level-specific fit indices have been proposed in the literature but have not been incorporated into the gsem command. I created the gsemgof command to fill this role. Model results from the gsem command are used to calculate the level-specific comparative fit index and root mean squared error of approximation fit indices. I illustrate the gsemgof command through multilevel ma applied to two-level Methadone Maintenance Treatment data.
xtgeebcv: A command for bias-corrected sandwich variance estimation for GEE analyses of cluster randomized trials
Gallis JA, Li F and Turner EL
Cluster randomized trials, where clusters (for example, schools or clinics) are randomized to comparison arms but measurements are taken on individuals, are commonly used to evaluate interventions in public health, education, and the social sciences. Analysis is often conducted on individual-level outcomes, and such analysis methods must consider that outcomes for members of the same cluster tend to be more similar than outcomes for members of other clusters. A popular individual-level analysis technique is generalized estimating equations (GEE). However, it is common to randomize a small number of clusters (for example, 30 or fewer), and in this case, the GEE standard errors obtained from the sandwich variance estimator will be biased, leading to inflated type I errors. Some bias-corrected standard errors have been proposed and studied to account for this finite-sample bias, but none has yet been implemented in Stata. In this article, we describe several popular bias corrections to the robust sandwich variance. We then introduce our newly created command, xtgeebcv, which will allow Stata users to easily apply finite-sample corrections to standard errors obtained from GEE models. We then provide examples to demonstrate the use of xtgeebcv. Finally, we discuss suggestions about which finite-sample corrections to use in which situations and consider areas of future research that may improve xtgeebcv.
swpermute: Permutation tests for Stepped-Wedge Cluster-Randomised Trials
Thompson J, Davey C, Hayes R, Hargreaves J and Fielding K
Permutation tests are useful in stepped-wedge trials to provide robust statistical tests of intervention-effect estimates. However, the Stata command permute does not produce valid tests in this setting because individual observations are not exchangeable. We introduce the swpermute command that permutes clusters to sequences to maintain exchangeability. The command provides additional functionality to aid users in performing analyses of stepped-wedge trials. In particular, we include the option "withinperiod" that performs the specified analysis separately in each period of the study with the resulting period-specific intervention-effect estimates combined as a weighted average. We also include functionality to test non-zero null hypotheses to aid the construction of confidence intervals. Examples of the application of swpermute are given using data from a trial testing the impact of a new tuberculosis diagnostic test on bacterial confirmation of a tuberculosis diagnosis.
kg_nchs: A command for Korn-Graubard confidence intervals and National Center for Health Statistics'
Ward BW
In August 2017 the National Center for Health Statistics (NCHS), part of the U.S. Federal Statistical System, published new standards for determining the reliability of proportions estimated using their data. These standards require an individual to take the Korn-Graubard confidence interval (CI), along with CI widths, sample size, and degrees of freedom, to assess reliability of a proportion and determine if it can be presented. The assessment itself involves determining if several conditions are met. This manuscript presents , a postestimation command that is used following . It allows Stata users to (a) calculate the Korn-Graubard CI and associated statistics used in applying the NCHS presentation standards for proportions, and (b) display a series of three dichotomous flags that show if the standards are met. The empirical examples provided show how can be used to easily apply the standards and prevent Stata users from needing to perform manual calculations. While developed for NCHS survey data, this command can also be used with data that stems from any survey with a complex sample design.
Calculations involving the multivariate normal and multivariate t distributions with and without truncation
Grayling MJ and Mander AP
In this article, we present a set of commands and Mata functions to evaluate different distributional quantities of the multivariate normal distribution and a particular type of noncentral multivariate distribution. Specifically, their densities, distribution functions, equicoordinate quantiles, and pseudo-random vectors can be computed efficiently, in either the absence or the presence of variable truncation.
Allowing for informative missingness in aggregate data meta-analysis with continuous or binary outcomes: Extensions to metamiss
Chaimani A, Mavridis D, Higgins JPT, Salanti G and White IR
Missing outcome data can invalidate the results of randomized trials and their meta-analysis. However, addressing missing data is often a challenging issue because it requires untestable assumptions. The impact of missing outcome data on the meta-analysis summary effect can be explored by assuming a relationship between the outcome in the observed and the missing participants via an informative missingness parameter. The informative missingness parameters cannot be estimated from the observed data, but they can be specified, with associated uncertainty, using evidence external to the meta-analysis, such as expert opinion. The use of informative missingness parameters in pairwise meta-analysis of aggregate data with binary outcomes has been previously implemented in Stata by the metamiss command. In this article, we present the new command metamiss2, which is an extension of metamiss for binary or continuous data in pairwise or network meta-analysis. The command can be used to explore the robustness of results to different assumptions about the missing data via sensitivity analysis.
cvcrand and cptest: Commands for efficient design and analysis of cluster randomized trials using constrained randomization and permutation tests
Gallis JA, Li F, Yu H and Turner EL
Cluster randomized trials (CRTs), where clusters (for example, schools or clinics) are randomized to comparison arms but measurements are taken on individuals, are commonly used to evaluate interventions in public health, education, and the social sciences. Because CRTs typically involve a small number of clusters (for example, fewer than 20), simple randomization frequently leads to baseline imbalance of cluster characteristics across study arms, threatening the internal validity of the trial. In CRTs with a small number of clusters, classic approaches to balancing baseline characteristics-such as matching and stratification-have several drawbacks, especially when the number of baseline characteristics the researcher desires to balance is large (Ivers et al., 2012, 13: 120). An alternative design approach is covariate-constrained randomization, whereby a randomization scheme is randomly selected from a subset of all possible randomization schemes based on the value of a balancing criterion (Raab and Butcher, 2001, 20: 351-365). Subsequently, a clustered permutation test can be used in the analysis, which provides increased power under constrained randomization compared with simple randomization (Li et al., 2016, 35: 1565-1579). In this article, we describe covariate-constrained randomization and the permutation test for the design and analysis of CRTs and provide an example to demonstrate the use of our new commands cvcrand and cptest to implement constrained randomization and the permutation test.
Group sequential clinical trial designs for normally distributed outcome variables
Grayling MJ, Wason JMS and Mander AP
In a group sequential clinical trial, accumulated data are analyzed at numerous time points to allow early decisions about a hypothesis of interest. These designs have historically been recommended for their ethical, administrative, and economic benefits. In this article, we first discuss a collection of new commands for computing the stopping boundaries and required group size of various classical group sequential designs, assuming a normally distributed outcome variable. Then, we demonstrate how the performance of several designs can be compared graphically.
Reconstructing time-to-event data from published Kaplan-Meier curves
Wei Y and Royston P
Hazard ratios can be approximated by data extracted from published Kaplan-Meier curves. Recently, this curve approach has been extended beyond hazard-ratio approximation with the capability of constructing time-to-event data at the individual level. In this article, we introduce a command, ipdfc, to implement the reconstruction method to convert Kaplan-Meier curves to time-to-event data. We give examples to illustrate how to use the command.
Model selection for univariable fractional polynomials
Royston P
Since Royston and Altman's 1994 publication ( 43: 429-467), fractional polynomials have steadily gained popularity as a tool for flexible parametric modeling of regression relationships. In this article, I present fp_select, a postestimation tool for fp that allows the user to select a parsimonious fractional polynomial model according to a closed test procedure called the fractional polynomial selection procedure or function selection procedure. I also give a brief introduction to fractional polynomial models and provide examples of using fp and fp_select to select such models with real data.
A combined test for a generalized treatment effect in clinical trials with a time-to-event outcome
Royston P
Most randomized controlled trials with a time-to-event outcome are designed and analyzed assuming proportional hazards of the treatment effect. The sample-size calculation is based on a log-rank test or the equivalent Cox test. Nonproportional hazards are seen increasingly in trials and are recognized as a potential threat to the power of the log-rank test. To address the issue, Royston and Parmar (2016, 16: 16) devised a new "combined test" of the global null hypothesis of identical survival curves in each trial arm. The test, which combines the conventional Cox test with a new formulation, is based on the maximal standardized difference in restricted mean survival time (rmst) between the arms. The test statistic is based on evaluations of rmst over several preselected time points. The combined test involves the minimum -value across the Cox and rmst-based tests, appropriately standardized to have the correct null distribution. In this article, I outline the combined test and introduce a command, stctest, that implements the combined test. I point the way to additional tools currently under development for power and sample-size calculation for the combined test.
The estimation and modelling of cause-specific cumulative incidence functions using time-dependent weights
Lambert PC
Competing risks occur in survival analysis when an individual is at risk of more than one type of event and the occurrence of one event precludes the occurrence of any other event. A measure of interest with competing risks data is the cause-specific cumulative incidence function (CIF) which gives the absolute (or crude) risk of having the event by time , accounting for the fact that it is impossible to have the event if a competing event is experienced first. The user written command, stcompet, calculates non-parametric estimates of the cause-specific CIF and the official Stata command, stcrreg, fits the Fine and Gray model for competing risks data. Geskus (2011) has recently shown that some of the key measures in competing risks can be estimated in standard software by restructuring the data and incorporating weights. This has a number of advantages as any tools developed for standard survival analysis can then be used for the analysis of competing risks data. This paper describes the stcrprep command that restructures the data and calculates the appropriate weights. After using stcrprep a number of standard Stata survival analysis commands can then be used for the analysis of competing risks. For example, sts graph, failure will give a plot of the cause-specific CIF and stcox will fit the Fine and Gray proportional subhazards model. Using stcrprep together with stcox is computationally much more efficient than using stcrreg. In addition, the use of stcrprep opens up new opportunities for competing risk models. This is illustrated by fitting flexible parametric survival models to the expanded data to directly model the cause-specific CIF.
Estimating inverse-probability weights for longitudinal data with dropout or truncation: The xtrccipw command
Daza EJ, Hudgens MG and Herring AH
Individuals may drop out of a longitudinal study, rendering their outcomes unobserved but still well defined. However, they may also undergo truncation (for example, death), beyond which their outcomes are no longer meaningful. Kurland and Heagerty (2005, 6: 241-258) developed a method to conduct regression conditioning on nontruncation, that is, regression conditioning on continuation (RCC), for longitudinal outcomes that are monotonically missing at random (for example, because of dropout). This method first estimates the probability of dropout among continuing individuals to construct inverse-probability weights (IPWs), then fits generalized estimating equations (GEE) with these IPWs. In this article, we present the xtrccipw command, which can both estimate the IPWs required by RCC and then use these IPWs in a GEE estimator by calling the glm command from within xtrccipw. In the absence of truncation, the xtrccipw command can also be used to run a weighted GEE analysis. We demonstrate the xtrccipw command by analyzing an example dataset and the original Kurland and Heagerty (2005) data. We also use xtrccipw to illustrate some empirical properties of RCC through a simulation study.
stpm2cr: A flexible parametric competing risks model using a direct likelihood approach for the cause-specific cumulative incidence function
Mozumder SI, Rutherford MJ and Lambert PC
In a competing risks analysis, interest lies in the cause-specific cumulative incidence function (CIF) which is usually obtained in a modelling framework by either (1) transforming on all of the cause-specific hazard (CSH) or (2) through its direct relationship with the subdistribution hazard (SDH) function. We expand on current competing risks methodology from within the flexible parametric survival modelling framework (FPM) and focus on approach (2). This models all cause-specific CIFs simultaneously and is more useful when prognostic related questions are to be answered. We propose the direct FPM approach for the cause-specific CIF which models the (log-cumulative) baseline hazard without the requirement of numerical integration leading to benefits in computational time. It is also easy to make out-of-sample predictions to estimate more useful measures and alternative link functions can be incorporated, for example, the logit link. To implement the methods, a new estimation command, stpm2cr, is introduced and useful predictions from the model are demonstrated through an illustrative Melanoma dataset.
Some utilities to help produce Rich Text Files from Stata
Gillman MS
Producing RTF files from Stata can be difficult and somewhat cryptic. Utilities are introduced to simplify this process; one builds up a table row-by-row, another inserts a PNG image file into an RTF document, and the others start and finish the RTF document.
emagnification: A tool for estimating effect-size magnification and performing design calculations in epidemiological studies
Miller DJ, Nguyen JT and Bottai M
Artificial effect-size magnification (ESM) may occur in underpowered studies, where effects are reported only because they or their associated -values have passed some threshold. Ioannidis (2008, 19: 640-648) and Gelman and Carlin (2014, 9: 641-651) have suggested that the plausibility of findings for a specific study can be evaluated by computation of ESM, which requires statistical simulation. In this article, we present a new command called emagnification that allows straightforward implementation of such simulations in Stata. The commands automate these simulations for epidemiological studies and enable the user to assess ESM routinely for published studies using user-selected, study-specific inputs that are commonly reported in published literature. The intention of the command is to allow a wider community to use ESMs as a tool for evaluating the reliability of reported effect sizes and to put an observed statistically significant effect size into a fuller context with respect to potential implications for study conclusions.