Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

  • vndesign_Dopt(): high-level interface for computing VN D-optimal designs.
  • virtual_noise_Dopt(): lower-level implementation of the Virtual Noise algorithm when Xchi and Sigma_chi are already available.
  • build_Xchi_grad(): builds the candidate regressor matrix from an analytical gradient.
  • build_Xchi_numeric(): builds the candidate regressor matrix using finite differences.
  • build_Sigma(): builds covariance matrices from one- or multi-dimensional candidate coordinates.
  • exact_design(): constructs an exact design from an approximate design measure.
  • plot_design_weights(), plot_convergence(), and plot_efficiency(): basic diagnostic plots.

Reproducible Examples

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

  • example_pazman2003_ex1.R: one-dimensional linear benchmark based on Pázman et al. 2003.
  • example_pazman2022_ex1.R: one-dimensional benchmark based on Pázman et al. 2022.
  • example_2D.R: self-contained two-dimensional example on a regular grid.

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.

About

❗ This is a read-only mirror of the CRAN R package repository. VNDesign — Virtual Noise Algorithm for Computing D-Optimal Designs with Correlated Observations

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages