Package 'optDesignSlopeInt'

Title: Optimal Designs for Estimating the Slope Divided by the Intercept
Description: Aids practitioners to optimally design experiments that measure the slope divided by the intercept and provides confidence intervals for the ratio.
Authors: Adam Kapelner [aut, cre] , Abba Krieger [rev], William J. Blanford [rev]
Maintainer: Adam Kapelner <[email protected]>
License: GPL-3
Version: 1.1.1
Built: 2024-11-25 05:44:52 UTC
Source: https://github.com/cran/optDesignSlopeInt

Help Index


A visualiation for comparing slope-divided-by-intercept estimates for a number of designs

Description

A visualiation for comparing slope-divided-by-intercept estimates for a number of designs

Usage

design_bakeoff(
  xmin,
  xmax,
  designs,
  gen_resp = function(xs) {
     1 + 2 * xs + rnorm(length(xs), 0, 1)
 },
  Nsim = 1000,
  l_quantile_display = 0.01,
  u_quantile_display = 0.99,
  error_est = function(est) {
     quantile(est, 0.99) - quantile(est, 0.01)
 },
  num_digits_round = 3,
  draw_theta_at = NULL,
  xlab_names = NULL,
  ...
)

Arguments

xmin

The minimum value of the independent variable.

xmax

The maximum value of the independent variable.

designs

A d x n matrix where each of the d rows is a design (the x values used to run the experiment).

gen_resp

A model for the response which takes the design as its parameter.

Nsim

The number of estimates per design. Default is 1000.

l_quantile_display

The lowest quantile of the simulation estimates displayed. Default is 0.025.

u_quantile_display

The highest quantile of the simulation estimates displayed. Default is 0.975.

error_est

The error metric for the estimates. The sample standard deviation (i.e. sd) is unstable at low sample sizes. The default is the 90 percentile minus the 10 percentile.

num_digits_round

The number of digits to round the error results. Default is 2.

draw_theta_at

If the user wishes to draw a horizontal line marking theta (to checked biasedness) it is specified here. The default is NULL with no line being drawn.

xlab_names

Text for the x-grid labels. This vector's size should equal lenth(designs).

...

Additional arguments passed to the boxplot function.

Value

A list with the simulated estimates and error estimates for each design.

Author(s)

Adam Kapelner

Examples

xmin = 5 / 15
xmax = 19 / 1
n = 10 #must be even for this demo
designs = rbind(
  c(rep(xmin, n / 2), rep(xmax, n / 2)),       #design A
  seq(from = xmin, to = xmax, length.out = n)  #design B
)
design_bakeoff_info = design_bakeoff(xmin, xmax, designs) #design A wins

Plots a standard error estimate of thetahat (slope over intercept) over a range of possible theta0 values in order to investigate robustness of the the initial theta0 guess.

Description

Plots a standard error estimate of thetahat (slope over intercept) over a range of possible theta0 values in order to investigate robustness of the the initial theta0 guess.

Usage

err_vs_theta0_plot_for_homo_design(
  n,
  xmin,
  xmax,
  theta,
  theta0_min,
  theta0_max,
  theta0 = NULL,
  beta0 = 1,
  sigma = 1,
  RES = 500,
  Nsim = 5000,
  error_est = function(est) {
     quantile(est, 0.99) - quantile(est, 0.01)
 },
  theta_logged = TRUE,
  error_pct = TRUE,
  plot_rhos = FALSE,
  ...
)

Arguments

n

The number of experimental runs.

xmin

The minimum value of the independent variable.

xmax

The maximum value of the independent variable.

theta

The putative true value. This is used to see how much efficiency given up by designing it for theta0.

theta0_min

Simulating over different guesses of theta0, this is the minimum guess.

theta0_max

Simulating over different guesses of theta0, this is the maximum guess.

theta0

The guess used to construct the experimental design. Specify only if you wish to see this value plotted. Default is NULL.

beta0

A guess to be used for the intercept. Defaults to 1.

sigma

A guess to be used for the homoskedastic variance of the measurement errors. If known accurately, then the standard errors (i.e. the y-axis on the plot) will be accurate. Otherwise, the standard errors are useful only when compared to each other in a relative sense. Defaults to 1.

RES

The number of points on the x-axis to simulate. Higher numbers will give smoother results. Default is 20.

Nsim

The number of models to be simulated for estimating the standard error at each value on the x-axis. Default is 1000.

error_est

The error metric for the estimates. The sample standard deviation (i.e. sd) is unstable at low sample sizes. The default is the 90 percentile minus the 10 percentile.

theta_logged

Should the values of theta be logged? Default is TRUE.

error_pct

Plot error as a percentage increase from minimum. Default is TRUE.

plot_rhos

Plot an additional graph of rho by theta0. Default is FALSE.

...

Additional arguments passed to the plot function.

Value

A list with original parameters as well as data from the simulation

Author(s)

Adam Kapelner

Examples

xmin = 5 / 15
xmax = 19 / 1
n = 10
theta0 = 0.053
plot_info = err_vs_theta0_plot_for_homo_design(
  n, xmin, xmax, theta0, theta0_min = 0.001, theta0_max = 1
)

Report the results of the experiment as well as confidence intervals.

Description

Report the results of the experiment as well as confidence intervals.

Usage

experimental_results(xs, ys, alpha = 0.05, B = 1000)

Arguments

xs

The design

ys

The measurements of the response

alpha

1 - alpha is the confidence of the computed intervals. Default is 0.05.

B

For the confidence interval methods with an embedded bootstrap (or resampling), the number of resamples (defaults to 1000).

Value

A list object containing the estimate as well as confidence intervals and parameters.

Author(s)

Adam Kapelner

Examples

n = 10 
xmin = 5 / 15
xmax = 19 / 1
xs = runif(n, xmin, xmax)
ys = 2 + 3 * xs + rnorm(n)
experimental_results_info = experimental_results(xs, ys)

This is data for the PRV measurement of the k_H of Napthalene in water. See Section 3 of our paper below for more information.

Description

This is data for the PRV measurement of the k_H of Napthalene in water. See Section 3 of our paper below for more information.

Usage

data(napth)

Format

A data frame with 100 rows and 2 variables

Author(s)

Adam Kapelner [email protected]

References

https://arxiv.org/abs/1604.03480


Create an optimal design for measuring the slope divided by the intercept

Description

Create an optimal design for measuring the slope divided by the intercept

Usage

oed_for_slope_over_intercept(
  n,
  xmin,
  xmax,
  theta0,
  f_hetero = NULL,
  MaxIter = 6000,
  MaxFunEvals = 6000,
  TolFun = 1e-06,
  NUM_RAND_STARTS = 50
)

Arguments

n

The number of experimental runs.

xmin

The minimum value of the independent variable.

xmax

The maximum value of the independent variable.

theta0

The guess of the true value of the slope / intercept.

f_hetero

Specification of heteroskedasticity: the h(x) which relates the value of the independent variable to the variance in the response around the line at that place or the proportional variance at that point. If NULL, homoskedasticity is assumed (this is the default behavior).

MaxIter

For the heteroskedastic design, a Nelder-Mead search is used (via the function fminbnd). This is the MaxIter value for the search. Default is 6000. Lower if n is high.

MaxFunEvals

For the heteroskedastic design, a Nelder-Mead search is used (via the function fminbnd). This is the MaxFunEvals value for the search. Default is 6000. Lower if n is high.

TolFun

For the heteroskedastic design, a Nelder-Mead search is used (via the function fminbnd). This is the TolFun value for the search. Default is 1e-6. Increase for faster execution.

NUM_RAND_STARTS

For the heteroskedastic design, a Nelder-Mead search is used (via the function fminbnd). The Nelder-Mead search must be given a starting location. Our implementation uses many starting locations. This parameter controls the number of additional random starting locations in the space [xmin, xmax]. Default is 50.

Value

An n-vector of x-values which specifies the optimal design

Author(s)

Adam Kapelner

Examples

xmin = 5 / 15
xmax = 19 / 1
n = 10
theta0 = 0.053
opt_homo_design = oed_for_slope_over_intercept(n, xmin, xmax, theta0)
table(opt_homo_design)

Optimal Designs for Estimating the Slope Divided by the Intercept

Description

Software which helps practitioners optimally design experiments that measure the slope divided by the intercept.

Author(s)

Adam Kapelner [email protected]