# CRcompare: Confidence interval for the distance between two response... In OptimaRegion: Confidence Regions for Optima

## Description

Computes bootstrapped confidence intervals for the mean and median distance between the optima of two response surface models. Models can be thin plate splines or quadratic polynomials \insertCiteDelCastilloCROptimaRegion.

## Usage

 ```1 2 3 4 5 6 7 8 9``` ```CRcompare(X1, y1, X2, y2, responseType = "TPS", lambda = 0.04, nosim1and2 = 200, alpha = 0.05, LB1, LB2, UB1, UB2, triangularRegion1 = FALSE, vertex11 = NULL, vertex21 = NULL, triangularRegion2 = FALSE, vertex12 = NULL, vertex22 = NULL, maximization1 = TRUE, maximization2 = TRUE, xlab1and2 = "Protein eaten (mg)", ylab1and2 = "Carbohydrates eaten (mg)", outputPDFFile1 = "CR_plot1.pdf", outputOptimaFile1 = "Optima1.txt", outputPDFFile2 = "CR_plot2.pdf", outputOptimaFile2 = "Optima2.txt") ```

## Arguments

 `X1` nx2 matrix with the values of the 2 regressors (experimental factors) corresponding to the first response. Note: can have replicates. They will be eliminated by the program and the corresponding y-values averaged `y1` nx1 vector of values for the first response corresponding to X1 `X2` nx2 matrix with the values of the 2 regressors (experimental factors) corresponding to the second response. Note: can have replicates. They will be eliminated by the program and the corresponding y-values averaged `y2` nx1 vector of values for the second response corresponding to X2 `responseType` use 'TPS' if fitting thin plate spline responses, 'Quad' if fitting quadratic polynomials `lambda` psmoothing penalty if a TPS model is selected (default=0.04) `nosim1and2` number of simulations(default = 200) used to find each of the two confidence regions of optima `alpha` confidence level (0 < alpha < 1; default = 0.05) `LB1` vector of lower bounds for x (2x1 vector) above which the optimum is sought for the first response `LB2` vector of lower bounds for x (2x1 vector) above which the optimum is sought for the second response `UB1` vector of upper bounds for x (2x1 vector) below which the optimum is sought for the first response `UB2` vector of upper bounds for x (2x1 vector) below which the optimum is sought for the second response `triangularRegion1` logical: if TRUE it will constrain the maximum points of response 1 to lie inside a triangle defined by the coordinates (0,0), and those in "vertex11", and "vertex21", see below (in addition to being constrained to lie inside the region defined by LB1 and UB1). NOTE: use TRUE when the treatments form a triangular experimental region in shape. If FALSE, optima will only be constrained to lie inside the rectangular region defined by LB1 and UB1. Default is FALSE. `vertex11` 2 times 1 vector with coordinates defining one of the 3 vertices of the triangular region where the first response is being optimized. Must be provided if triangularRegion1 is TRUE (NOTE: vertices numbered clockwise, with vertex0 fixed to (0,0)) `vertex21` 2 times 1 vector with coordinates defining a second vertex of a triangular region where the first response is being optimized. Must be provided if triangularRegion1 is TRUE `triangularRegion2` logical: if TRUE it will constrain the maximum points of response 2 to lie inside a triangle defined by the coordinates (0,0), and those in "vertex12", and "vertex22", see below (in addition to being constrained to lie inside the region defined by LB2 and UB2).NOTE: use TRUE when the treatments form a triangular experimental region in shape. If FALSE, optima will only be constrained to lie inside the rectangular region defined by LB2 and UB2. Default is FALSE. `vertex12` 2 times 1 vector with coordinates defining one of the 3 vertices of the triangular region where the second response is being optimized. Must be provided if triangularRegion2 is TRUE (NOTE: vertices numbered clockwise, with vertex0 fixed to (0,0)) `vertex22` 2 times 1 vector with coordinates defining a second vertex of a triangular region where the second response is being optimized. Must be provided if triangularRegion2 is TRUE `maximization1` logical: if TRUE (default) it maximizes response 1, if FALSE it minimizes it `maximization2` logical: if TRUE (default) it maximizes response 2, if FALSE it minimizes it `xlab1and2` text label for x axis in both confidence region plots (default: "Protein eaten (mg)") `ylab1and2` text label for y axis in both confidence region plots (default: "Carbohydrates eaten (mg)") `outputPDFFile1` name of the PDF file where the CR plot of the first response is saved (default: "CR_plot.pdf") `outputOptimaFile1` name of the text file containing the coordinates of all the simulated optima of the first response `outputPDFFile2` name of the PDF file where the CR plot of the second response is saved (default: "CR_plot.pdf") `outputOptimaFile2` name of the text file containing the coordinates of all the simulated optima of the second response

## Details

Computes distribution-free bootstrapped confidence intervals on the mean and median distance between the optima of two different responses. The responses can be Thin Plate Spline models or Quadratic polynomial models. Program calls each response, next computes all pairwise distances between points in each CR, and finally bootstraps the distances to compute bca bootstrapped confidence intervals for the mean and median distance.

## Value

Upon completion, two PDF files with the CR plots and two text files with the coordinates of each set of optima are created, and the function also returns a list consisting of the following 5 components:

dist

vector of distances between pairs of points taken from each set of optima

mean

mean of dist

median

median of dist

ciMean

95 bca bootstrapping; it is a vector with 5 columns, containing the signicance level, the next two containing the indices of the order statistics used in the calculations and the final two the calculated endpoints of the CI's.

ciMEdian

95 using bca bootstrapping; it is a vector with 5 columns, containing the signicance level, the next two containing the indices of the order statistics used in the calculations and the final two the calculated endpoints of the CI's.

## Author(s)

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

\insertAllCited

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14``` ```## Not run: # Example: two randomly generated data sets, quadratic polynomial responses. X1 <- cbind(runif(100, -2, 2), runif(100, -2, 2)) y1 <- as.matrix(72 - 11.78 * X1[, 1] + 0.74 * X1[, 2] - 7.25 * X1[, 1]^2 - 7.55 * X1[, 2]^2 - 4.85 * X1[, 1] * X1[, 2] + rnorm(100, 0, 8)) X2 <- cbind(runif(100, -2, 2), runif(100, -2, 2)) y2 <- as.matrix(72 - 11.78 * X2[, 1] + 0.74 * X2[, 2] - 7.25 * X2[, 1]^2 - 7.55 * X2[, 2]^2 - 4.85 * X2[, 1] * X2[, 2] + rnorm(100, 0, 8)) out <- CRcompare( X1 = X1, y1 = y1, X2 = X2, y2 = y2, responseType = "Quad", nosim1and2 = 200, alpha = 0.05, LB1 = c(-2, -2), UB1 = c(2, 2), LB2 = c(-2, -2), UB2 = c(2, 2) ) ## End(Not run) ```

OptimaRegion documentation built on July 3, 2019, 1:04 a.m.