VNDesign

VNDesign implements the Virtual Noise algorithm for computing D-optimal experimental designs with correlated observations. It provides tools to build candidate regressor matrices, define covariance structures, compute approximate design measures, and construct exact designs from those measures.

The package is intended for linear and nonlinear regression models where the observations over the candidate set may be correlated.

Installation

Once available on CRAN, VNDesign can be installed with:

install.packages("VNDesign")

During development, it can be installed from the package source directory with:

# install.packages("devtools")
devtools::install_local(".")

Basic Workflow

A minimal one-dimensional example is:

library(VNDesign)

chi <- seq(-1, 1, length.out = 15)
theta <- c(0, 1)
kappa <- 0.99 / length(chi)

grad_fun <- function(x, theta) {
  c(1, x)
}

res <- vndesign_Dopt(
  chi = chi,
  theta = theta,
  grad_fun = grad_fun,
  kappa = kappa,
  max_iter = 20,
  verbose = FALSE,
  cov_type = "exp",
  range = 0.4,
  vn_alt = 3,
  vn_lambda = 2,
  return_components = TRUE
)

head(res$xi)
plot_design_weights(res, chi)

For the classical VN algorithm implemented here, kappa is used as a virtual-noise threshold and is typically chosen slightly below the initial uniform design weight. In the examples below, kappa = 0.99/N, where N is the number of candidate points.

An exact design can be obtained from the approximate VN design measure:

exact <- exact_design(
  res = res,
  Xchi = res$Xchi,
  Sigma_chi = res$Sigma_chi,
  chi = chi,
  n = 3,
  method = "quantile"
)

exact$points

Main Functions

Reproducible Examples

The package includes three reproducible example scripts in inst/examples/:

After installing the package, run an example with:

source(system.file("examples", "example_pazman2003_ex1.R", package = "VNDesign"))

From the source directory, run:

source("inst/examples/example_pazman2003_ex1.R")
source("inst/examples/example_pazman2022_ex1.R")
source("inst/examples/example_2D.R")

The examples are also introduced in the package vignette:

browseVignettes("VNDesign")

For quick checks of the longer examples, use:

Sys.setenv(VNDESIGN_EXAMPLE_MAX_ITER = "10000")
Sys.setenv(VNDESIGN_EXAMPLE_PLOTS = "false")

Development Checks

Run the unit tests with:

devtools::test()

Run a package check with:

devtools::check()

or from the terminal:

R CMD build .
R CMD check --no-manual VNDesign_0.0.0.1.tar.gz

References

Müller, W.G. and Pázman, A. (1999). An algorithm for the computation of optimum designs under a given covariance structure.

Müller, W.G. and Pázman, A. (2003). Measures for designs in experiments with correlated errors.

Pázman, A., Hainy, M. and Müller, W. G. (2022). A convex approach to optimum design of experiments with correlated observations.

López-Fidalgo, J. and Wong, W.K. (2025). Optimal Designs for Correlated Data.

License

MIT.