| BestVCGsize | R Documentation |
The function tries out different sizes of VCG and searches for the smallest distance.
BestVCGsize(formula, data = data, plot = TRUE)
formula |
A formula specifying the treated and covariates, e.g., 'treated ~ cov1 + cov2 | stratum'. The treated variable must be binary (0=pool, 1=treated) |
data |
A data frame containing the variables specified in the formula. |
plot |
Logical. If 'TRUE', returns a ggplot2 plot. Default: TRUE |
It is only intended for exploratory purposes, as the VCG size is normally given. But it can be used to see how well the given size fits. The recommendation for VCG size is based solely on distance and does not take into account other aspects such as power or validity.
If 'plot = TRUE', returns a list with:
optimal_n |
The estimated optimal VCG size (integer). |
plot |
A ggplot2 object visualizing the energy distance curve and plateau. |
set.seed(2342)
dat <- data.frame(
treat = rep(0:1, c(50, 30)),
cov1 = c(rnorm(50, 11, 2), rnorm(30, 10, 1)),
cov2 = c(rnorm(50, 12, 2), rnorm(30, 10, 1)),
cov3 = c(rnorm(50, 9, 2), rnorm(30, 10, 1))
)
BestVCGsize(treat ~ cov1 + cov2 + cov3, data=dat)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.