graph.H2x2Factorial {H2x2Factorial} | R Documentation |
H2x2Factorial Plot
Description
The function graph.H2x2Factorial
plots the sample size estimations or combinations of mean cluster sizes and cluster numbers
under variable CV for a chosen test. Based on the desired test and power, the function produces a plot with mean cluster size on the x-axis and number of clusters on
the y-axis, with multiple lines representing the dynamic sample size constraints if a vector of CV is specified. The limits of the y-axis
will be automatically adjusted based on the extreme values calculated. A color-blind-friendly palette is set by default but it can be updated by users.
Usage
graph.H2x2Factorial(m_lower=10, m_upper=100, m_step=2,
CV=c(0,0.3,0.6,0.9),
palette=c("#0F2080","#85C0F9","#DDCC77","#F5793A","#A95AA1"),
line_width=rep(3,5), line_type=seq(1,5,1), title=NULL,
power=0.8, alpha=0.05,
pi_x=0.5, pi_z=0.5,
delta_x=0.25, delta_z=0.33, delta_xz=0.3, sigma2_y=1, rho=0,
estimand="controlled", test="cluster", correction=FALSE,
max_n=1e8, seed_mix=NULL, size_mix=1e4,
verbose=TRUE)
Arguments
m_lower |
a numeric value larger than 2 for the lower bound of the mean cluster sizes on the horizontal axis. Default is |
m_upper |
a numeric value larger than |
m_step |
a positive numeric value for the step size on the horizontal axis for plotting the sample size combinations. Default is |
CV |
a vector of positive numeric values for a series of coefficients of variation of the cluster sizes. The length of CV vector equals the number
of lines presented in the plot, so the CV vector with a length less or equal to 5 is suggested for making a clear-looking graph. Besides, a reasonable magnitude of CV is highly recommended to produce effective plots.
Default is |
palette |
a vector of character values to specify the color choices corresponding to the lines in the plot.
Default is |
line_width |
a vector of numeric values to specify the widths of the lines in the plot. Default is |
line_type |
a vector of numeric values to specify the line types of the lines in the plot. Default is |
title |
a user-defined title or caption for the plot. Default is |
power |
a numeric value between 0 and 1 as the desired power level for sample size estimation. Default is |
alpha |
a numeric value between 0 and 1 as the type I error rate. Default is |
pi_x |
a numeric value between 0 and 1 as the proportion of clusters randomized to the cluster-level treatment. Default is |
pi_z |
a numeric value between 0 and 1 as the proportion of individuals randomized to the individual-level treatment within each cluster. Default is |
delta_x |
a nonzero numeric value for the (unstandardized) effect size of the marginal cluster-level treatment effect. Default is |
delta_z |
a nonzero numeric value for the (unstandardized) effect size of the marginal individual-level treatment effect. Default is |
delta_xz |
a nonzero numeric value for the (unstandardized) effect size of the interaction effect of the two treatments. Default is |
sigma2_y |
a positive numeric value for the total variance of the continuous outcome. Default is |
rho |
a numeric value between 0 and 1 as the intraclass correlation coefficient characterizing the between-cluster variability. Default is |
estimand |
a character argument indicating the type of treatment effect estimand. Supported values include |
test |
a character argument indicating the type of hypothesis test of interest. Supported values include
|
correction |
a logical argument indicating whether a finite sample correction should be used. Default is |
max_n |
an optional setting of a maximum number of clusters, which is only functional under |
seed_mix |
an optional setting of a seed for conducting the simulation-based testing under a mixed distribution, which is only functional under |
size_mix |
a pre-specified size for the mixed distribution in the simulation-based procedure, which is only needed under |
verbose |
a logical argument indicating whether the parameter reiterations and supplementary messages should be presented or suppressed. Default is |
Value
graph.H2x2Factorial
returns a plot comparing the sample size requirements under different CV, with some suppressible messages.
Examples
#Make a plot under the test for marginal cluster-level treatment effect
graph.H2x2Factorial(power=0.9, estimand="controlled", test="cluster", rho=0.1, verbose=FALSE)