Computational Provenance & Reproducibility Record

RAISINS - R and AI Solutions for INferential Statistics · Online Statistical Analysis Platform for Agricultural Research

Computational Provenance & Reproducibility Record Response Surface Methodology · 10.5281/zenodo.23120291 · DOI 10.5281/zenodo.23120291

Computational Provenance & Reproducibility Record

RAISINS · Response Surface Methodology Module

This Computational Provenance Record documents the statistical computing environment, software dependencies, computational provenance, and bibliographic references associated with the RAISINS Response Surface Methodology module. It is intended to support computational reproducibility and software transparency. Detailed statistical methodology, mathematical derivations, and user guidance are provided separately in the official module documentation.

Any issues or updates required please comment here

Go to the App from here

1 Module Metadata

Parameter Specification
Module Response Surface Methodology
Module Version 1.0.0
DOI 10.5281/zenodo.23120291
Document Type Computational workflow
Statistical Engine R
R Version 4.5.2
Reproducibility Execution Environment: GCP · renv-locked

2 Statistical Dependency Manifest

Package Version Repository Core Statistical Functions
stats 4.5.2 Base R lm(), anova(), summary(), symnum(), pf(), qt(), predict(), optim(), optimize(), lm.fit(), as.formula(), coef(), sd()
rsm 2.10.6 CRAN rsm(), SO(), coded.data(), codings(), decode.data(), canonical(), canonical.path(), summary.rsm()
desirability 2.1 CRAN dMax(), dMin(), dTarget(), predict()

3 Statistical Function Registry

Analytical Role Primary Function(s)
Factor coding rsm::coded.data(data, x1 ~ (pred - centre)/half_width, ...)
Back-transformation rsm::decode.data()
Second-order model fitting rsm::rsm(response ~ [block +] SO(x1, ..., xk), data = coded_data)
Collinearity diagnostic Custom VIF loop over the SO design matrix via stats::lm.fit(), VIF = 1/(1 - R²ⱼ)
Per-response optimisation models rsm::rsm(response ~ SO(...)) fitted on the uncoded predictors
Individual desirability desirability::dMax(), dMin(), dTarget() + predict()
Overall desirability Geometric mean prod(d)^(1/n_resp)
Constrained optimum search stats::optim(method = "Nelder-Mead") and stats::optim(method = "L-BFGS-B"); stats::optimize() when a single factor is optimised

4 Default Methods & Parameters

Analysis Step / Parameter Default Method / Value
Factor coding
(rsm::coded.data())
Design type Central Composite Design (CCD) and Box-Behnken Design (BBD). The selection determines how the centre and half-width are detected from the data.
Centre & half-width - CCD Unique predictor levels are sorted descending; the centre is the 3rd value (axial-high, factorial-high, centre, factorial-low, axial-low) and the half-width is 2nd value − 3rd value. Requires at least 3 unique levels.
Centre & half-width - BBD Unique levels sorted descending; the centre is the 2nd value and the half-width is 1st value − 2nd value. Requires at least 2 unique levels.
Coding formula xi ~ (predictor_i − centre_i) / half_width_i, one per predictor, applied in the order the predictors were selected.
Predictor type Numeric Predictors.
Model fitting
(rsm::rsm())
Model order Full second order model: response ~ SO(x1, …, xk).
Blocking Optional. When a block column is chosen the formula becomes response ~ block + SO(x1, …, xk)
Multi-response optimisation
(desirability + optim())
Models optimised over One full second-order model per selected response, response ~ SO(all predictors), fitted with rsm::rsm() on the uncoded data
Goal per response Maximize (default), Minimize, or Target, mapped to dMax(low = A, high = B, tol = 0.01), dMin(low = A, high = B, tol = 0.01) and dTarget(low = A, target = T, high = B, tol = 0.01).
Overall desirability Unweighted geometric mean D = (∏ dᵢ)^(1/n_resp)

5 R Code for Key Analytical Steps

The code blocks below demonstrate the exact computation behind each reported result. A single dataset is used throughout, heli, which is loaded from the rsm package.

5.1 Dataset

rsm::heli is a blocked four-factor central composite design from a paper-helicopter experiment - 30 runs in 2 blocks, four geometry factors (A wing area, R wing-length ratio, W body width, L body length) and two responses, ave (mean flight time) and logSD (log of its standard deviation). Each factor carries the five levels of a CCD (axial-low, factorial-low, centre, factorial-high, axial-high).

The package stores heli already coded, so every block below starts from decode.data(heli) - the data in natural units, exactly as an uploaded file reaches the module. To check the same numbers in the app itself, write that table out and upload it:

write.csv(as.data.frame(rsm::decode.data(rsm::heli)), "heli.csv", row.names = FALSE)

5.2 Factor Coding and the Second-Order Fit

library(rsm)

# Data, response, predictors and block
data_raw   <- as.data.frame(decode.data(heli))
response   <- "ave"
predictors <- c("A", "R", "W", "L")
block      <- "block"

# Find the CCD centre and factorial half-width
A <- sort(unique(na.omit(data_raw$A)), decreasing = TRUE)
R <- sort(unique(na.omit(data_raw$R)), decreasing = TRUE)
W <- sort(unique(na.omit(data_raw$W)), decreasing = TRUE)
L <- sort(unique(na.omit(data_raw$L)), decreasing = TRUE)

A_centre <- A[3]; A_half <- A[2] - A[3]
R_centre <- R[3]; R_half <- R[2] - R[3]
W_centre <- W[3]; W_half <- W[2] - W[3]
L_centre <- L[3]; L_half <- L[2] - L[3]

coded_data <- coded.data(
  data_raw,
  x1 ~ (A - A_centre) / A_half,
  x2 ~ (R - R_centre) / R_half,
  x3 ~ (W - W_centre) / W_half,
  x4 ~ (L - L_centre) / L_half
)

data_raw$block <- as.numeric(data_raw$block)   # to match the app's intercept

model_fit <- rsm(ave ~ block + SO(x1, x2, x3, x4), data = coded_data)
summary(model_fit)

5.3 ANOVA - Partitioned and Term-Wise Views

# ---- Default view: partitioned ANOVA with lack of fit and pure error ----
summary(model_fit)$lof

# ---- Alternative view: term-wise sequential (Type I) ANOVA ----
lm_fit <- lm(ave ~ block + x1 + x2 + x3 + x4 +
               x1:x2 + x1:x3 + x1:x4 + x2:x3 + x2:x4 + x3:x4 +
               I(x1^2) + I(x2^2) + I(x3^2) + I(x4^2),
             data = coded_data)

anova_table <- anova(lm_fit)
anova_table

5.4 Ridge Analysis (Canonical Path)

# dist = seq(-5, 5, by = 0.5) 
canonical_result <- rsm::canonical.path(model_fit)

5.5 Multi-Response Desirability Optimisation

library(rsm)
library(desirability)

df <- as.data.frame(decode.data(heli))

# Fitting a second order model
fit_ave   <- rsm(ave   ~ SO(A, R, W, L), data = df)
fit_logSD <- rsm(logSD ~ SO(A, R, W, L), data = df)

p_ave   <- predict(fit_ave,   df)
p_logSD <- predict(fit_logSD, df)

# Turn each response into a 0-1 desirability score.
# low and high values are adjusted to the default values
d_ave   <- dMax(low = min(p_ave)   - 0.1 * diff(range(p_ave)),
                high = max(p_ave)   + 0.1 * diff(range(p_ave)),   tol = 0.01)
d_logSD <- dMin(low = min(p_logSD) - 0.1 * diff(range(p_logSD)),
                high = max(p_logSD) + 0.1 * diff(range(p_logSD)), tol = 0.01)

# 3. Overall desirability D at any setting = geometric mean of the two scores
overall_D <- function(x) {
  new_row <- data.frame(A = x[1], R = x[2], W = x[3], L = x[4])
  sqrt(predict(d_ave,   predict(fit_ave,   new_row)) *
       predict(d_logSD, predict(fit_logSD, new_row)))
}

# 4. Search for the settings with the highest D, staying inside the tested range
lower_b <- c(min(df$A), min(df$R), min(df$W), min(df$L))
upper_b <- c(max(df$A), max(df$R), max(df$W), max(df$L))
start   <- c(mean(df$A), mean(df$R), mean(df$W), mean(df$L))

best <- optim(start, overall_D, method = "L-BFGS-B",
              lower = lower_b, upper = upper_b,
              control = list(fnscale = -1))   # fnscale = -1 means MAXIMISE

# 5. Results
xopt    <- best$par
new_row <- data.frame(A = xopt[1], R = xopt[2], W = xopt[3], L = xopt[4])

xopt                                      # optimum settings
predict(fit_ave,   new_row)               # predicted ave there
predict(fit_logSD, new_row)               # predicted logSD there
best$value                              

Explore the entire Response Surface Methodology module in preview mode using our demo datasets. To submit suggestions or report a workflow issue, please use the discussion section below, or visit the official RAISINS website.

6 RAISINS Native Statistical Framework

RAISINS uses R for all its statistical computations. Every package used to generate major results is listed and demonstrated with examples, so results can be reproduced independently. These results are then organized and formatted on the RAISINS website along with visualisation to make them easier to use and interpret. RAISINS also has its own custom-built statistical tools for managing workflows, validating results, and generating reports. Details of these are not fully covered here, they’re shared with outside researchers only on request, and are subject to licensing terms.

7 Package References

R Core Team. (2025). R: A language and environment for statistical computing. R Foundation for Statistical Computing, Vienna, Austria. https://www.R-project.org/

Lenth, R. V. (2009). Response-surface methods in R, using rsm. Journal of Statistical Software, 32(7), 1-17. (R package version 2.10.6). https://doi.org/10.18637/jss.v032.i07

Kuhn, M. (2016). desirability: Function Optimization and Ranking via Desirability Functions (R package version 2.1). https://doi.org/10.32614/CRAN.package.desirability

Müller, K., & Wickham, H. (2023). tibble: Simple Data Frames (R package version 3.2.1). https://doi.org/10.32614/CRAN.package.tibble

Xie, Y. (2025). knitr: A General-Purpose Package for Dynamic Report Generation in R (R package version 1.51). https://yihui.org/knitr/

Zhu, H. (2024). kableExtra: Construct Complex Table with ‘kable’ and Pipe Syntax (R package version 1.4.0). https://doi.org/10.32614/CRAN.package.kableExtra

Box, G. E. P., & Wilson, K. B. (1951). On the experimental attainment of optimum conditions. Journal of the Royal Statistical Society: Series B, 13(1), 1-45. https://doi.org/10.1111/j.2517-6161.1951.tb00067.x

Box, G. E. P., & Behnken, D. W. (1960). Some new three level designs for the study of quantitative variables. Technometrics, 2(4), 455-475. https://doi.org/10.1080/00401706.1960.10489912

Nelder, J. A., & Mead, R. (1965). A simplex method for function minimization. The Computer Journal, 7(4), 308-313. https://doi.org/10.1093/comjnl/7.4.308

Harrington, E. C. (1965). The desirability function. Industrial Quality Control, 21(10), 494-498.

Derringer, G., & Suich, R. (1980). Simultaneous optimization of several response variables. Journal of Quality Technology, 12(4), 214-219. https://doi.org/10.1080/00224065.1980.11980968

Byrd, R. H., Lu, P., Nocedal, J., & Zhu, C. (1995). A limited memory algorithm for bound constrained optimization. SIAM Journal on Scientific Computing, 16(5), 1190-1208. https://doi.org/10.1137/0916069

Feedback & Discussion