BestVCGsize: The function attempts to find the optimal size for VCG.

View source: R/BestVCGsize.R

BestVCGsizeR Documentation

The function attempts to find the optimal size for VCG.

Description

The function tries out different sizes of VCG and searches for the smallest distance.

Usage

BestVCGsize(formula, data = data, plot = TRUE)

Arguments

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

Details

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.

Value

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.

Examples


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)


eVCGsampler documentation built on March 10, 2026, 5:07 p.m.