Skip to contents

Fits y = b0 + sum b_i x_i + sum b_ii x_i^2 + sum b_ij x_i x_j and returns the stationary point if the quadratic matrix B is invertible.

Usage

mrm_response_surface(data, response_col, factor_cols)

Arguments

data

data.frame.

response_col

Response column.

factor_cols

Character vector of factor columns.

Value

Named list with coefficients, stationary_point, stationary_y, stationary_nature, eigenvalues, n, interpretation.

Examples

# Central composite design on (x1, x2) with quadratic response.
set.seed(2026)
df <- expand.grid(
  x1 = c(-1.4, -1, 0, 1, 1.4),
  x2 = c(-1.4, -1, 0, 1, 1.4)
)
df$y <- 10 + 2 * df$x1 + 1.5 * df$x2 -
  df$x1^2 - 1.2 * df$x2^2 + rnorm(nrow(df), 0, 0.2)
res <- mrm_response_surface(df,
  response_col = "y",
  factor_cols = c("x1", "x2")
)
res$stationary_point
#> $x1
#> [1] 0.9917
#> 
#> $x2
#> [1] 0.6773
#> 
res$stationary_nature
#> [1] "maximum"