Title: | Optimal Regression Design under the Second-Order Least Squares Estimator |
Version: | 0.0.5 |
Description: | With given inputs that include number of points, discrete design space, a measure of skewness, models and parameter value, this package calculates the objective value, optimal designs and plot the equivalence theory under A- and D-optimal criteria under the second-order Least squares estimator. This package is based on the paper "Properties of optimal regression designs under the second-order least squares estimator" by Chi-Kuang Yeh and Julie Zhou (2021) <doi:10.1007/s00362-018-01076-6>. |
URL: | https://github.com/chikuang/SLSEdesign |
BugReports: | https://github.com/chikuang/SLSEdesign/issues |
License: | GPL-3 |
Encoding: | UTF-8 |
RoxygenNote: | 7.3.2 |
Imports: | CVXR |
Suggests: | knitr, rmarkdown |
VignetteBuilder: | knitr |
NeedsCompilation: | no |
Packaged: | 2025-06-04 17:17:18 UTC; chikuang |
Author: | Chi-Kuang Yeh |
Maintainer: | Chi-Kuang Yeh <chi-kuang.yeh@mail.mcgill.ca> |
Repository: | CRAN |
Date/Publication: | 2025-06-05 16:10:02 UTC |
Calculate the A-optimal design under the second-order Least squares estimator
Description
Calculate the A-optimal design under the second-order Least squares estimator
Usage
Aopt(N, u, tt, FUN, theta, num_iter = 1000)
Arguments
N |
The number of sample points in the design space. |
u |
The discretized design space. |
tt |
The level of skewness between 0 to 1 (inclusive). When tt=0, it is equivalent to compute the A-optimal design under the ordinary least squares estimator. |
FUN |
The function to calculate the derivative of the given model. |
theta |
The parameter value of the model. |
num_iter |
Maximum number of iteration. |
Details
This function calculates the A-optimal design and the loss function under the A-optimality. The loss function under A-optimality is defined as the trace of the inverse of the Fisher information matrix
Value
A list that contains 1. Value of the objective function at solution. 2. Status. 3. Optimal design
Examples
poly3 <- function(xi, theta){
matrix(c(1, xi, xi^2, xi^3), ncol = 1)
}
Npt <- 101
my_design <- Aopt(N = Npt, u = seq(-1, +1, length.out = Npt),
tt = 0, FUN = poly3, theta = rep(0,4), num_iter = 2000)
round(my_design$design, 3)
my_design$val
Calculate the D-optimal design under the SLSE
Description
Calculate the D-optimal design under the SLSE
Usage
Dopt(N, u, tt, FUN, theta, num_iter = 1000)
Arguments
N |
The number of sample points in the design space. |
u |
The discretized design space. |
tt |
The level of skewness. When tt=0, it is equivalent to compute the D-optimal design under the ordinary least squares estimator. |
FUN |
The function to calculate the derivative of the given model. |
theta |
The parameter value of the model. |
num_iter |
Maximum number of iteration. |
Details
This function calculates the D-optimal design and the loss function under the D-optimality. The loss function under D-optimality is defined as the log determinant of the inverse of the Fisher information matrix.
Value
A list that contains 1. Value of the objective function at solution. 2. Status. 3. Optimal design
Examples
poly3 <- function(xi, theta){
matrix(c(1, xi, xi^2, xi^3), ncol = 1)
}
Npt <- 101
my_design <- Dopt(N = Npt, u = seq(-1, +1, length.out = Npt),
tt = 0, FUN = poly3, theta = rep(0,4), num_iter = 2000)
round(my_design$design, 3)
my_design$val
Calculate the loss function of the A-, c- or D-optimal design
Description
Calculate the loss function of the A-, c- or D-optimal design
Usage
calc_phi(
design,
theta,
FUN,
tt,
A,
criterion = "D",
cVec = rep(0, length(theta))
)
Arguments
design |
The resulted design that contains the design points and the associated weights |
theta |
The parameter value of the model |
FUN |
The function to calculate the derivative of the given model. |
tt |
The level of skewness |
A |
The calculated covariance matrix |
criterion |
The criterion to be used for the design, either "D" for D-optimality or "A" for A-optimality. Default is "D". |
cVec |
c vector used to determine the combination of the parameters. This is only used in c-optimality |
Details
This function calculates the loss function of the design problem under the A- or D-optimality. The loss functions under A-, or D-optimality are defined as the trace and log determinant of the inverse of the Fisher information matrix
Value
The loss of the model at each design points
Examples
my_design <- data.frame(location = c(0, 180), weight = c(1/2, 1/2))
theta <- c(0.05, 0.5)
peleg <- function(xi, theta){
deno <- (theta[1] + xi * theta[2])^2
rbind(-xi/deno, -xi^2/deno)
}
A <- matrix(c(1, 0, 0, 0, 0.2116, 1.3116, 0, 1.3116, 15.462521), byrow = TRUE, ncol = 3)
res <- calc_phi(my_design, theta, peleg, 0, A, criterion = "A")
res
Calculate the c-optimal design under the SLSE with the given combination of the parameters
Description
Calculate the c-optimal design under the SLSE with the given combination of the parameters
Usage
copt(N, u, tt, FUN, theta, num_iter = 1000, cVec)
Arguments
N |
The number of sample points in the design space. |
u |
The discretized design space. |
tt |
The level of skewness. When tt=0, it is equivalent to compute the c-optimal design under the ordinary least squares estimator. |
FUN |
The function to calculate the derivative of the given model. |
theta |
The parameter value of the model. |
num_iter |
Maximum number of iteration. |
cVec |
c vector used to determine the combination of the parameters |
Details
This function calculates the c-optimal design and the loss function under the c-optimality. The loss function under c-optimality is defined as the log determinant of the inverse of the Fisher information matrix.
Value
A list that contains 1. Value of the objective function at solution. 2. Status. 3. Optimal design
Examples
poly3 <- function(xi, theta){
matrix(c(1, xi, xi^2, xi^3), ncol = 1)
}
Npt <- 101
my_design <- copt(N = Npt, u = seq(-1, +1, length.out = Npt),
tt = 0, FUN = poly3, theta = rep(0,4), num_iter = 2000,
cVec = c(0,1,1,1))
round(my_design$design, 3)
my_design$val
Verify the optimality condition for an optimal design (A-, c- or D-optimality)
Description
Verify the optimality condition for an optimal design (A-, c- or D-optimality)
Usage
plot_dispersion(
u,
design,
tt,
FUN,
theta,
criterion = "D",
cVec = rep(0, length(theta))
)
Arguments
u |
The discretized design points |
design |
The optimal design containing the design points and the associated weights |
tt |
The level of skewness |
FUN |
The function to calculate the derivative of the given model |
theta |
The parameter value of the model |
criterion |
The optimality criterion: one of "A", "c", or "D" |
cVec |
c vector used to determine the combination of the parameters. This is only used in c-optimality |
Details
This function visualizes the directional derivative under A-, c-, or D-optimality using the general equivalence theorem. For an optimal design, the directional derivative should not exceed the reference threshold
Value
A plot verifying the general equivalence condition for the specified optimal design
Examples
poly3 <- function(xi, theta){
matrix(c(1, xi, xi^2, xi^3), ncol = 1)
}
design_A <- data.frame(location = c(-1, -0.464, 0.464, 1),
weight = c(0.151, 0.349, 0.349, 0.151))
design_D = data.frame(location = c(-1, -0.447, 0.447, 1),
weight = rep(0.25, 4))
u <- seq(-1, 1, length.out = 201)
par(mfrow = c(2,2))
plot_dispersion(u, design_A, tt = 0, FUN = poly3, theta = rep(0, 4), criterion = "A")
plot_dispersion(u, design_A, tt = 0, FUN = poly3, theta = rep(0, 4), criterion = "D")
plot_dispersion(u, design_D, tt = 0, FUN = poly3, theta = rep(0, 4), criterion = "A")
plot_dispersion(u, design_D, tt = 0, FUN = poly3, theta = rep(0, 4), criterion = "D")
Plot the weight distribution of the optimal design for univaraite regression model
Description
Plot the weight distribution of the optimal design for univaraite regression model
Usage
plot_weight(design)
Arguments
design |
The resulted design that contains the design points and the associated weights |
Details
This functions produce a figure that contains the location and their associated weights of the resulted optimal design measures.
Value
The plot that shows the given optimal design
Examples
Des = list(location = c(-1, +1), weight = c(0.5, 0.5))
plot_weight(Des)