OptRegionTps: Confidence region for optima of Thin Plate Spline Models (2...

View source: R/OptRegionTps.R

OptRegionTpsR Documentation

Confidence region for optima of Thin Plate Spline Models (2 regressors)

Description

Computes and displays an approximated (1 - alpha) confidence region (CR) for the linear-constrained maximum of a penalized Thin Plate Spline (TPS) model in 2 controllable factors \insertCiteDelCastilloCROptimaRegion. Generates a PDF file with a graph displaying the CR. Grey region on output plot is the approximate CR. The mean coordinates (centroid) of the optima is shown as a red point.

Usage

OptRegionTps(
  X,
  y,
  lambda = 0.04,
  nosim = 1000,
  alpha = 0.05,
  LB,
  UB,
  triangularRegion = FALSE,
  vertex1 = NULL,
  vertex2 = NULL,
  maximization = TRUE,
  xlab = "Protein eaten, mg",
  ylab = "Carbohydrate eaten, mg",
  outputPDFFile = "CRplot.pdf",
  outputOptimaFile = "Optima.txt"
)

Arguments

X

nx2 matrix with the values of the 2 regressors (experimental factors) in the n observations. Note: this can have replicates. They will be eliminated by the program and the corresponding y-values averaged

y

nx1 vector of response value observations, in the same order corresponding to the rows of X

lambda

penalization parameter (larger values implies more smoothing). Default is 0.04

nosim

number of simulations (default = 200)

alpha

confidence level (0 < alpha < 1; default = 0.05)

LB

vector of lower bounds for x (2x1 vector) above which the maximum is sought

UB

vector of upper bounds for x (2x1 vector) below which the maximum is sought

triangularRegion

logical: if TRUE it will constrain the maximum points to lie inside a triangle defined by the coordinates (0,0), and those in 'vertex1', and 'vertex2', see below (in addition to being constrained to lie inside the region defined by LB and UB). NOTE: use TRUE when the treatments form a triangular experimental region in shape. If FALSE, maxima will only be constrained to lie inside the rectangular region defined by LB and UB. Default is FALSE.

vertex1

2 times 1 vector with coordinates defining one of the 3 vertices of a triangular region. Must be provided if triangularRegion is TRUE (NOTE: vertices numbered clockwise)

vertex2

2 times 1 vector with coordinates defining a second vertex of a triangular region (third vertex is (0,0) by default). Must be provided if triangularRegion is TRUE (NOTE: vertices numbered clockwise)

maximization

logical: if TRUE (default) it maximizes it FALSE it minimizes

xlab

text label for x axis in confidence region plot (default: "Protein eaten (mg)")

ylab

text label for y axis in confidence region plot (default: "Carbohydrates eaten (mg)")

outputPDFFile

name of the PDF file where the CR plot is saved (default: "CR_plot.pdf")

outputOptimaFile

name of the text file containing the coordinates of all the optima found (same information as in output vector xin, see below)

Details

This program approximates the confidence region (CR) of the location of the optimum of a Thin Plate Spline (TPS) in 2 regressors x constrained inside a rectangular region defined by LB and UB. If triangularRegion=TRUE it will also contrain the optimum to lie inside the experimental region assumed to be well approximated by a triangle. The CR is generated pointwise by bootstrapping the residuals of a TPS fit to the given (X,y) data, refitting Tps models, and solving the corresponding constrained maximization (or minimization) problems. The confidence region is approximated by the convex hull of all the optimal solutions found. The CR computation is based on the "CS" bootstrapping approach for building a confidence set of a parametric function described in \insertCiteWoutersenHam2013;textualOptimaRegion. This version of the program uses nonparametric bootstrapping confidence regions to get the Confidence region of the Tps parameters,using the notion of data depth according to \insertCiteyeh1997balanced;textualOptimaRegion. Hence, this version does not rely on the normality assumption of the data. The TPS models are fit using the "fields" R package \insertCitefieldsPackageOptimaRegion and its "Tps" function.

Value

Upon completion, a PDF file containing the CR plot with name as set in ouputPDFFile is created and a text file with all xin values is created too. Also, the function returns a list containing the following 2 components:

meanPoint

a 2x1 vector with the coordinates of the mean optimum point (displayed as a red dot in the CR plot in output PDF file)

xin

an mx2 matrix with the x,y coordinates of all simulated points that belong to the confidence region (dim(m) is (1-alpha)*nosim)

Author(s)

Enrique del Castillo exd13@psu.edu, Peng Chen pfc5098@psu.edu, Adam Meyers akm5733@psu.edu, John Hunt J.Hunt@westernsydney.edu.au and James Rapkin jr297@exeter.ac.uk.

References

\insertAllCited

Examples

## Not run: 
# Example 1: randomly generated 2-variable response surface data
X <- cbind(runif(100, -2, 2), runif(100, -2, 2))
y <- as.matrix(72 - 11.78 * X[, 1] + 0.74 * X[, 2] - 7.25 * X[, 1]^2 - 
  7.55 * X[, 2]^2 - 4.85 * X[, 1] * X[, 2] + rnorm(100, 0, 8))
# Find a 95 percent confidence region for the maximum of a Thin Plate Spline
# model fitted to these data
out <- OptRegionTps(
  X = X, y = y, nosim = 200, LB = c(-2, -2), UB = c(2, 2),
  xlab = "X1", ylab = "X2"
)

# Example 2: a mixture-amount experiment in two components (Drug dataset) with
# non-normal data. Note triangular experimental region. Resulting 95p confidence
# region of the maxima of a TPS model has area > 0. Contrast with region for
# quadratic polynomial model. Note: 500 bootstrap iterations may take a few minutes.
out <- OptRegionTps(
  X = Drug[, 1:2], y = Drug[, 3], nosim = 500, lambda = 0.05, LB = c(0, 0),
  UB = c(0.08, 11), xlab = "Component 1 (mg.)", ylab = "Component 2 (mg.)",
  triangularRegion = TRUE, vertex1 = c(0.02, 11), vertex2 = c(0.08, 1.8),
  outputPDFFile = "Mixture_plot.pdf"
)

## End(Not run)

pfc5098/OptimaRegion documentation built on May 5, 2022, 4 p.m.