inferMM targets a common enzyme-kinetic workflow: fit a
Michaelis-Menten curve, compare plausible working variance functions,
and summarize inference in a way that is less sensitive to
heteroscedasticity than ordinary nonlinear least squares alone. The same
interface also supports clustered assay layouts in which repeated
measurements within a core, plate, or sample may be correlated.
library(inferMM)
one_curve <- subset(sdl_demo, enzyme == "1111")
nrow(one_curve) # 32 rates: eight concentrations, four reactions each
#> [1] 32
fit <- fit_mm(
x = one_curve$s_uM,
y = one_curve$v_uM_per_min
)
fit
#> Call:
#> fit_mm(x = one_curve$s_uM, y = one_curve$v_uM_per_min)
#>
#> Method: profile-score
#> Working variance: Var = gamma S^(1/2)
#>
#> Variance-model screening:
#>
#> model quasi_aic quasi_bic selected success
#> sqrt -60.71156 -56.31436 TRUE 1
#> cuberoot -56.26105 -51.86384 FALSE 1
#> log -53.98475 -49.58754 FALSE 1
#> constant -43.10122 -38.70401 FALSE 1
#>
#> Selected model: sqrt (minimum quasi-AIC)
#>
#> Estimate Std. Error Lower CI Upper CI
#> Vmax 6.44520 0.08348 6.28158 6.60883
#> Km 76.96398 2.22408 72.60486 81.32309
#>
#> Quasi-AIC:-60.71156 Quasi-BIC:-56.31436 RMSE:0.11267
#>
#> Intervals condition on the selected variance model; model-selection uncertainty is not included.
fit$screen_table[, c("model", "quasi_aic", "quasi_bic", "selected")]
#> model quasi_aic quasi_bic selected
#> 1 sqrt -60.71156 -56.31436 TRUE
#> 2 cuberoot -56.26105 -51.86384 FALSE
#> 3 log -53.98475 -49.58754 FALSE
#> 4 constant -43.10122 -38.70401 FALSE
summary(fit)
#> Call:
#> fit_mm(x = one_curve$s_uM, y = one_curve$v_uM_per_min)
#>
#> Method: profile-score
#> Working variance: Var = gamma S^(1/2)
#>
#> Variance-model screening:
#>
#> model quasi_aic quasi_bic selected success
#> sqrt -60.71156 -56.31436 TRUE 1
#> cuberoot -56.26105 -51.86384 FALSE 1
#> log -53.98475 -49.58754 FALSE 1
#> constant -43.10122 -38.70401 FALSE 1
#>
#> Selected model: sqrt (minimum quasi-AIC)
#>
#> CI method: wald
#>
#> Estimate Std. Error Lower CI Upper CI
#> Vmax 6.44520 0.08348 6.28158 6.60883
#> Km 76.96398 2.22408 72.60486 81.32309
#>
#> Scale:0.0011 RMSE:0.11267 Weighted RSS:32
#> Quasi-AIC:-60.71156 Quasi-BIC:-56.31436
#>
#> Intervals condition on the selected variance model; model-selection uncertainty is not included.When variance is omitted, fit_mm() compares
constant, log, sqrt and
cuberoot, then returns the lowest quasi-AIC fit as an
ordinary fit_mm object. The printed fit and summary include
the candidate comparison and selected model; the fitting call itself is
quiet. This SDL example selects sqrt. All four candidates
estimate three parameters on the same observations, so their AIC and BIC
rankings agree. power_selection = "quasi_bic" can select by
quasi-BIC instead.
An explicit shape bypasses this screen. For example,
variance = "log" preserves the former default, and
variance = "sqrt" fits that shape directly. The separate
variance = "auto" option still compares
log(S + 1) with a grid of fixed power shapes:
sqrt_fit <- fit_mm(one_curve$s_uM, one_curve$v_uM_per_min, variance = "sqrt")
fit_auto <- fit_mm(
x = one_curve$s_uM,
y = one_curve$v_uM_per_min,
variance = "auto",
power_selection = "quasi_aic"
)
summary(fit_auto)
#> Call:
#> fit_mm(x = one_curve$s_uM, y = one_curve$v_uM_per_min, variance = "auto",
#> power_selection = "quasi_aic")
#>
#> Method: profile-score
#> Working variance: Var = gamma S^1 (selected by quasi-AIC from log/power candidates)
#>
#> CI method: wald
#>
#> Estimate Std. Error Lower CI Upper CI
#> Vmax 6.55883 0.11109 6.34111 6.77656
#> Km 80.15368 2.30266 75.64056 84.66680
#>
#> Scale:0.00014 RMSE:0.11838 Weighted RSS:32
#> Quasi-AIC:-66.28789 Quasi-BIC:-61.89068The fitted object supports extraction of coefficients, Wald confidence intervals, bootstrap confidence intervals, and predictions. For the default four-shape screen, intervals condition on the selected shape, and bootstrap refits keep that shape fixed. These intervals omit model-selection uncertainty.
coef(fit)
#> Vmax Km
#> 6.445201 76.963978
confint(fit)
#> lower upper
#> Vmax 6.281577 6.608825
#> Km 72.604863 81.323094
set.seed(1)
confint(fit, method = "bootstrap", B = 99)
#> lower upper
#> Vmax 6.218953 6.655811
#> Km 71.408873 82.011496
#> attr(,"bootstrap_draws")
#> Vmax Km
#> [1,] 6.634191 80.59446
#> [2,] 6.624140 79.02914
#> [3,] 6.381217 75.47213
#> [4,] 6.579378 79.06645
#> [5,] 6.459370 75.13569
#> [6,] 6.514508 76.85696
#> [7,] 6.431241 78.51044
#> [8,] 6.333733 76.77147
#> [9,] 6.429045 77.71514
#> [10,] 6.430622 75.90861
#> [11,] 6.437842 77.99273
#> [12,] 6.470516 78.80971
#> [13,] 6.435140 78.41032
#> [14,] 6.452888 76.32602
#> [15,] 6.596845 80.60650
#> [16,] 6.505647 80.42294
#> [17,] 6.336328 72.54563
#> [18,] 6.414559 76.67374
#> [19,] 6.383144 75.31857
#> [20,] 6.395584 75.41049
#> [21,] 6.460867 78.69901
#> [22,] 6.470352 77.74889
#> [23,] 6.600720 81.49759
#> [24,] 6.461286 76.85821
#> [25,] 6.440780 75.36456
#> [26,] 6.402931 74.83632
#> [27,] 6.507135 79.54802
#> [28,] 6.472693 77.05218
#> [29,] 6.377078 76.29782
#> [30,] 6.595221 80.72817
#> [31,] 6.657488 81.33797
#> [32,] 6.369616 75.06435
#> [33,] 6.286213 74.35536
#> [34,] 6.390055 77.24934
#> [35,] 6.382849 76.30863
#> [36,] 6.663777 83.42949
#> [37,] 6.377339 75.71846
#> [38,] 6.446631 78.61387
#> [39,] 6.506397 77.23510
#> [40,] 6.339345 74.84123
#> [41,] 6.358060 75.53405
#> [42,] 6.383473 75.47787
#> [43,] 6.430971 74.04655
#> [44,] 6.350545 75.25444
#> [45,] 6.287727 73.89329
#> [46,] 6.443948 76.14249
#> [47,] 6.246904 72.56499
#> [48,] 6.488523 78.66055
#> [49,] 6.312024 72.69961
#> [50,] 6.461288 79.41380
#> [51,] 6.222701 69.86802
#> [52,] 6.474113 77.61923
#> [53,] 6.551880 78.00878
#> [54,] 6.412938 76.32565
#> [55,] 6.459186 76.70207
#> [56,] 6.518784 79.07483
#> [57,] 6.269093 71.43075
#> [58,] 6.412737 75.39622
#> [59,] 6.512970 78.51215
#> [60,] 6.351575 74.15987
#> [61,] 6.418711 74.28195
#> [62,] 6.366252 74.88653
#> [63,] 6.630996 80.55090
#> [64,] 6.606226 80.62509
#> [65,] 6.494857 78.59812
#> [66,] 6.516707 78.72867
#> [67,] 6.573915 79.52274
#> [68,] 6.586221 77.68386
#> [69,] 6.562137 79.14919
#> [70,] 6.503000 77.94425
#> [71,] 6.302027 73.91930
#> [72,] 6.331200 74.05489
#> [73,] 6.608421 82.09916
#> [74,] 6.366502 76.02285
#> [75,] 6.460894 78.05847
#> [76,] 6.650756 81.05350
#> [77,] 6.396678 76.00004
#> [78,] 6.669725 83.21845
#> [79,] 6.489937 76.85727
#> [80,] 6.345179 73.72578
#> [81,] 6.584875 78.15796
#> [82,] 6.446954 75.10896
#> [83,] 6.626282 81.83550
#> [84,] 6.342474 75.86291
#> [85,] 6.384315 76.69524
#> [86,] 6.650091 82.22226
#> [87,] 6.421994 76.52620
#> [88,] 6.387825 74.87713
#> [89,] 6.640525 82.16426
#> [90,] 6.566582 79.04441
#> [91,] 6.430336 75.28110
#> [92,] 6.413305 77.23437
#> [93,] 6.576082 80.55578
#> [94,] 6.514148 79.55891
#> [95,] 6.470357 79.07521
#> [96,] 6.514918 79.52686
#> [97,] 6.460935 78.60717
#> [98,] 6.418221 77.74893
#> [99,] 6.443695 75.74933
#> attr(,"bootstrap_draws")attr(,"requested_B")
#> [1] 99
#> attr(,"bootstrap_draws")attr(,"successful_B")
#> [1] 99
#> attr(,"bootstrap_draws")attr(,"bootstrap_type")
#> [1] "wild"
#> attr(,"bootstrap_draws")attr(,"wild_weights")
#> [1] "mammen"
#> attr(,"bootstrap_draws")attr(,"se_draws")
#> Vmax Km
#> [1,] 0.07896411 2.125631
#> [2,] 0.09955738 2.639596
#> [3,] 0.07422150 1.964063
#> [4,] 0.07742805 2.067672
#> [5,] 0.08614270 2.243363
#> [6,] 0.08668986 2.282228
#> [7,] 0.07637235 2.073948
#> [8,] 0.06823357 1.845857
#> [9,] 0.05893586 1.587156
#> [10,] 0.05867326 1.548303
#> [11,] 0.07800671 2.104257
#> [12,] 0.06530358 1.768328
#> [13,] 0.10173770 2.758088
#> [14,] 0.06575182 1.737225
#> [15,] 0.07425155 2.010344
#> [16,] 0.08935296 2.448370
#> [17,] 0.08548524 2.202375
#> [18,] 0.07582336 2.023130
#> [19,] 0.11999732 3.168914
#> [20,] 0.06549757 1.728109
#> [21,] 0.07427692 2.011905
#> [22,] 0.08322917 2.227897
#> [23,] 0.08428093 2.301975
#> [24,] 0.06044840 1.604516
#> [25,] 0.08932149 2.338932
#> [26,] 0.09664879 2.530503
#> [27,] 0.07552568 2.049836
#> [28,] 0.07533591 2.000458
#> [29,] 0.09040235 2.416147
#> [30,] 0.08725155 2.365933
#> [31,] 0.07671611 2.074028
#> [32,] 0.09902239 2.612996
#> [33,] 0.06141988 1.628978
#> [34,] 0.07803186 2.103424
#> [35,] 0.06562838 1.752649
#> [36,] 0.08256394 2.278650
#> [37,] 0.07772661 2.063804
#> [38,] 0.07727156 2.095708
#> [39,] 0.08872766 2.348603
#> [40,] 0.07752139 2.050175
#> [41,] 0.06387544 1.697629
#> [42,] 0.07191683 1.902528
#> [43,] 0.07888983 2.037952
#> [44,] 0.06299732 1.670969
#> [45,] 0.06242575 1.646455
#> [46,] 0.06508498 1.718456
#> [47,] 0.06257440 1.635569
#> [48,] 0.09850419 2.655659
#> [49,] 0.09907482 2.566971
#> [50,] 0.07085873 1.934034
#> [51,] 0.08819083 2.240165
#> [52,] 0.05810949 1.552373
#> [53,] 0.11045249 2.928147
#> [54,] 0.06817661 1.812504
#> [55,] 0.06925145 1.835590
#> [56,] 0.08225971 2.217318
#> [57,] 0.08665545 2.226723
#> [58,] 0.10421884 2.741945
#> [59,] 0.08618070 2.310976
#> [60,] 0.07488379 1.961209
#> [61,] 0.09262671 2.403903
#> [62,] 0.06261360 1.649769
#> [63,] 0.10723445 2.886701
#> [64,] 0.07839217 2.119853
#> [65,] 0.08597096 2.313939
#> [66,] 0.08657301 2.325617
#> [67,] 0.09205711 2.472465
#> [68,] 0.09127409 2.398549
#> [69,] 0.11554587 3.096451
#> [70,] 0.05606194 1.496343
#> [71,] 0.06626550 1.744286
#> [72,] 0.09364000 2.457348
#> [73,] 0.08854864 2.430871
#> [74,] 0.07842500 2.093052
#> [75,] 0.06958700 1.871779
#> [76,] 0.10809603 2.916642
#> [77,] 0.07211093 1.914969
#> [78,] 0.07797229 2.145389
#> [79,] 0.09018659 2.383281
#> [80,] 0.09668719 2.522096
#> [81,] 0.10157380 2.683644
#> [82,] 0.08808659 2.297706
#> [83,] 0.08240701 2.250011
#> [84,] 0.06953957 1.859596
#> [85,] 0.07823252 2.097802
#> [86,] 0.07419646 2.026685
#> [87,] 0.06077816 1.617153
#> [88,] 0.09364166 2.458713
#> [89,] 0.07994559 2.185559
#> [90,] 0.10719265 2.867415
#> [91,] 0.06086198 1.594782
#> [92,] 0.08183798 2.197661
#> [93,] 0.08437865 2.290519
#> [94,] 0.09318334 2.526653
#> [95,] 0.06158949 1.672582
#> [96,] 0.09116752 2.470855
#> [97,] 0.07118991 1.926350
#> [98,] 0.09350869 2.523393
#> [99,] 0.08867746 2.331137
#> attr(,"bootstrap_draws")attr(,"bootstrap_ci")
#> [1] "studentized"
head(predict(fit, newdata = seq(0, 80, length.out = 6), interval = "prediction"))
#> x fit se.fit working_variance lwr upr
#> 1 0 0.000000 0.00000000 1.095100e-11 -6.485970e-06 6.485970e-06
#> 2 16 1.109281 0.01583297 4.380399e-03 9.759019e-01 1.242661e+00
#> 3 32 1.892795 0.02130898 6.194819e-03 1.732978e+00 2.052612e+00
#> 4 48 2.475671 0.02288928 7.587073e-03 2.299154e+00 2.652187e+00
#> 5 64 2.926229 0.02321708 8.760797e-03 2.737219e+00 3.115239e+00
#> 6 80 3.284933 0.02342394 9.794869e-03 3.085598e+00 3.484267e+00For a one-step console summary plus a 95% confidence band, use:
The default fit_mm() call combines the four-shape
comparison and selected fit. The standalone screen_mm()
function also supports expanded sets of fixed power exponents and
user-defined functions, and retains all successful candidate fits:
screen <- screen_mm(
x = one_curve$s_uM,
y = one_curve$v_uM_per_min,
power_values = c(0.4, 0.6),
include_auto = TRUE,
quiet = TRUE
)
screen$table[, c("model", "selected_model", "quasi_aic", "quasi_bic", "rmse")]
#> model selected_model quasi_aic quasi_bic rmse
#> 1 auto(quasi_aic) power(1) -66.28789 -61.89068 0.1183823
#> 2 power(0.6) power(0.6) -62.69370 -58.29649 0.1130041
#> 3 sqrt sqrt -60.71156 -56.31436 0.1126654
#> 4 power(0.4) power(0.4) -58.21667 -53.81946 0.1124840
#> 5 cuberoot cuberoot -56.26105 -51.86384 0.1124182
#> 6 log log -53.98475 -49.58754 0.1124352
#> 7 constant constant -43.10122 -38.70401 0.1123490The screening table is ordered by quasi-AIC, with quasi-BIC and RMSE reported as secondary summaries.
For a single curve, a function can replace a built-in variance name.
It defines the shape h(S) in
Var(Y | S) = gamma h(S), not the standard deviation.
h <- variance_function(function(S) 1 + S / 20,
label = "Var = gamma (1 + S/20)")
custom_fit <- fit_mm(one_curve$s_uM, one_curve$v_uM_per_min, variance = h)
summary(custom_fit)
#> Call:
#> fit_mm(x = one_curve$s_uM, y = one_curve$v_uM_per_min, variance = h)
#>
#> Method: profile-score
#> Working variance: Var = gamma (1 + S/20)
#>
#> CI method: wald
#>
#> Estimate Std. Error Lower CI Upper CI
#> Vmax 6.46149 0.09705 6.27128 6.65169
#> Km 77.17994 2.27530 72.72043 81.63946
#>
#> Scale:0.00173 RMSE:0.11297 Weighted RSS:32
#> Quasi-AIC:-61.54838 Quasi-BIC:-57.15118
confint(custom_fit)
#> lower upper
#> Vmax 6.271282 6.651694
#> Km 72.720428 81.639456
predict(custom_fit, newdata = c(0, 10, 40), interval = "prediction")
#> x fit se.fit working_variance lwr upr
#> 1 0 0.0000000 0.00000000 0.001730356 -0.08152969 0.08152969
#> 2 10 0.7411668 0.01062502 0.002595534 0.63916534 0.84316831
#> 3 40 2.2056635 0.01983918 0.005191067 2.05919426 2.35213278
custom_shapes <- list(
linear_floor = function(S) 1 + S / 20,
saturation = function(S) 1 + 9 * S / (20 + S)
)
custom_screen <- screen_mm(
one_curve$s_uM, one_curve$v_uM_per_min,
variance_models = c("constant", "sqrt"),
variance_functions = custom_shapes, quiet = TRUE
)
custom_screen$table[, c("model", "quasi_aic", "quasi_bic", "success")]
#> model quasi_aic quasi_bic success
#> 1 linear_floor -61.54838 -57.15118 1
#> 2 sqrt -60.71156 -56.31436 1
#> 3 saturation -53.66595 -49.26874 1
#> 4 constant -43.10122 -38.70401 1The function must be deterministic, vectorized, and pointwise,
returning one finite strictly positive numeric value for each input
concentration, including zero if used. Values must not depend on the
other concentrations in the vector. For example, a constant shape should
return rep(1, length(S)), not a scalar. Invalid values or
lengths cause errors; screening records candidate-specific errors and
continues with the remaining candidates. Names must be unique and must
not duplicate built-in candidates. For custom-only screening, specify
variance_models = character(0).
Only Km requires numerical search for a fixed shape. Vmax and gamma retain their closed-form updates, and the function is reused for prediction and bootstrap refits. Internal scaling preserves the supplied variance model. The reported gamma is relative to the original shape, so its value changes inversely when the shape is multiplied by a positive constant.
The constants 20 and 9 above are fixed, not estimated. Extra shape parameters, functions of unknown mean parameters, and data-adaptive nuisance estimation are not fitted by this interface. Intervals and information criteria condition on the supplied shape and omit external shape-estimation or selection uncertainty; prediction bands still use the working-normal approximation. User-defined variance shapes are not higher-moment efficient scores and do not imply smaller variance than identically weighted WNLS. They are currently supported for independent curves, not the clustered routine.
The user-defined variance shape above does not by itself incorporate
asymmetry into the estimating equations. Version 0.1.1 adds the separate
fit_mm_moments() estimator, based on the conditional-moment
construction of Kim and Ma (2012), Section 3 (doi:10.1007/s10463-011-0332-y). It does not require a
fully specified error density.
set.seed(19)
skew_dat <- simulate_mm_data(n = 200, error = "skewed", skew_shape = 4)
assay_shape <- function(S) 1 + 9 * S / (20 + S)
fit_hm <- fit_mm_moments(skew_dat$x, skew_dat$y, variance = assay_shape)
summary(fit_hm)
#> Call:
#> fit_mm_moments(x = skew_dat$x, y = skew_dat$y, variance = assay_shape)
#>
#> Method: higher-moment estimating equations
#> Working variance: Var = gamma h(S) (user-defined)
#> Working moments: estimate
#> Covariance: model
#> CI method: wald
#>
#> Estimate Std. Error Lower CI Upper CI
#> Vmax 99.32847 0.58349 98.18485 100.47210
#> Km 19.60062 0.36175 18.89160 20.30965
#>
#> Variance scale: 0.9439 RMSE: 2.476
#> Scaled score norm: 8.5468e-10
confint(fit_hm)
#> lower upper
#> Vmax 98.18485 100.47210
#> Km 18.89160 20.30965
fit_hm$vcov_joint
#> Vmax Km gamma
#> Vmax 0.34046250 0.186485439 0.012018354
#> Km 0.18648544 0.130864749 -0.005169235
#> gamma 0.01201835 -0.005169235 0.020383201
fit_gamma <- fit_mm_moments(
skew_dat$x, skew_dat$y, variance = assay_shape,
moments = "gamma", shape = 4
)
coef(fit_gamma)
#> Vmax Km
#> 99.40513 19.64990
predict(fit_gamma, c(10, 20, 80), interval = "confidence")
#> x fit se.fit working_variance lwr upr
#> 1 10 33.52629 0.2499221 3.771718 33.03645 34.01613
#> 2 20 50.14142 0.2391705 5.186112 49.67266 50.61019
#> 3 80 79.80349 0.2502522 7.732022 79.31301 80.29398The default estimates constant standardized skewness and kurtosis
from the profile pilot’s residuals. The gamma option supplies fixed
working moments of centered gamma errors; it does not
fit a gamma density. Student-t working moments use
moments = "student_t", df = 10. Custom standardized moment
functions can be passed with moments = "custom",
skewness, and kurtosis; the latter is raw
kurtosis, not excess kurtosis.
For residual \(r_i\) and variance \(v_i=\gamma h(S_i)\), let \(u_i=(r_i,r_i^2-v_i)^\top\). The conditional moment covariance is
\[ \Omega_i=\begin{pmatrix} v_i & s_i v_i^{3/2}\\ s_i v_i^{3/2} & (k_i-1)v_i^2 \end{pmatrix}, \]
where \(s_i\) and \(k_i\) are working skewness and kurtosis. With \(g_i\) the MM mean gradient and \(D_i=\begin{pmatrix}g_{i1}&g_{i2}&0\\0&0&h(S_i)\end{pmatrix}\), the joint equation is \(\sum_i D_i^\top\Omega_i^{-1}u_i=0\). Positive definiteness requires \(k_i-1-s_i^2>0\).
Unlike the default profile route, the higher-moment fit solves
jointly for \(V_{\max},K_m,\gamma\)
numerically. Its default covariance = "model" uses joint
inverse working information, with the mean covariance extracted after
allowing for the estimated scale. This interpretation requires
appropriate conditional third and fourth moments. Optional
covariance = "sandwich" uses the complete three-parameter
equations. Wald intervals use a normal cutoff for the estimator, not an
assumption that the individual errors are normal.
Normal moments recover the original mean/variance equations. Constant symmetric Student-t moments recover the same point estimates; heavy tails alone do not give an efficiency improvement in this conditional-moment model. Under asymmetry, appropriate third/fourth moments can improve asymptotic efficiency, but pilot moment estimation can inflate finite-sample variance. Incorrect variance shapes can bias the new estimator, and a sandwich does not remove that bias. Neither exact 95% coverage nor uniform improvement is guaranteed.
set.seed(20)
confint(fit_hm, method = "bootstrap", B = 399) # pairs only
report_mm(fit_hm, interval_type = "confidence")Pairs bootstrap repeats the pilot and higher-moment estimation. Prediction bands are not supplied because a few moments do not identify predictive quantiles; mean-confidence bands are pointwise. Quasi-AIC/BIC are omitted for these non-likelihood roots. This opt-in estimator is not yet connected to grouped selection or clustered fitting; those workflows below retain their original estimators.
Version 0.1.2 restores the lowest 3.90625 micromolar reactions:
sdl_demo contains 192 rates, 32 per enzyme. The
replicate column is the source-column occurrence ordinal
within each concentration, not a verified sample, plate, run or batch
identifier across concentrations. The source fluorescence CSV and
data-preparation helper are included; the source package’s
inst/data-raw/README.md gives the regeneration command and
calibration.
group_mm() fits separate curves with distinct
parameters, not a common-mean cluster model. Within each curve, its
model-based intervals assume conditional independence and adequate
working variance. Shared sample, experimental batch or calibration
variation is not automatically included in those intervals. These
assumptions cannot be verified from ordinal replicate labels alone.
For real enzyme panels we often fit many curves at once and then compare the best model within each group.
grouped <- group_mm(
data = sdl_demo,
s = "s_uM",
v = "v_uM_per_min",
groups = "enzyme",
variance_models = c("constant", "log", "sqrt", "cuberoot"),
power_values = c(0.4, 0.6),
include_auto = TRUE,
variance_functions = custom_shapes,
quiet = TRUE
)
head(grouped$comparison$best_by_group[, c("group_label", "model", "selected_model", "quasi_aic", "quasi_bic", "rmse")])
#> group_label model selected_model quasi_aic quasi_bic rmse
#> 1 enzyme=1111 auto(quasi_aic) power(1) -66.28789 -61.89068 0.11838230
#> 2 enzyme=2222 auto(quasi_aic) power(1) -136.62452 -132.22731 0.05696519
#> 3 enzyme=3333 auto(quasi_aic) power(1) -125.32709 -120.92988 0.07538179
#> 4 enzyme=4444 auto(quasi_aic) power(1) -126.72010 -122.32290 0.05922529
#> 5 enzyme=5555 auto(quasi_aic) power(0.95) -92.50700 -88.10980 0.08460185
#> 6 enzyme=6666 auto(quasi_aic) power(1) -54.67627 -50.27906 0.14448024To visualize the current best model for each group, use the grouped plotting method.
By default, cluster_mm() uses a rank-one working
covariance with a random effect on Vmax and a
low-dimensional residual variance function. The bundled
alves_demo data illustrate the interface on a small
soil-enzyme panel.
cluster_fit <- cluster_mm(
data = subset(alves_demo, enzyme == "BG"),
s = "substrate_conc",
v = "activity",
cluster = "core",
variance = "sqrt"
)
summary(cluster_fit)
#> Call:
#> cluster_mm(data = subset(alves_demo, enzyme == "BG"), s = "substrate_conc",
#> v = "activity", cluster = "core", variance = "sqrt")
#>
#> Method: clustered-profile-score
#> Clusters: 3
#> Initialization: pooled single-curve profile-score fit
#> Converged: yes Iterations: 4
#> Residual working variance: Var = gamma S^(1/2)
#>
#> CI method: disabled by default for sparse clustered fits
#>
#> Estimate
#> Vmax 1435.43759
#> Km 34.29102
#>
#> Interval inference is disabled by default for sparse clustered fits (3 clusters, 7 distinct substrate concentrations). Default interval reporting requires at least 4 clusters and at least 6 distinct concentrations.
#>
#> Tau^2:242368 Gamma:1303.433 RMSE:362.7108
#> Quasi-AIC:1136.631 Quasi-BIC:1146.109
confint(cluster_fit)
#> Warning: Small-cluster warning: this fit uses 3 clusters across 7 distinct
#> substrate concentrations. Default interval reporting is disabled below 4
#> clusters or below 6 distinct concentrations because coverage may be unstable.
#> Use these intervals only as a sensitivity analysis.
#> lower upper
#> Vmax 874.21368 1996.6615
#> Km 29.34983 39.2322
head(predict(cluster_fit, newdata = seq(0, 700, length.out = 6),
interval = "confidence"))
#> x fit se.fit working_variance marginal_variance lwr upr
#> 1 0 0.000 0.0000 1.303433e-05 1.303433e-05 0.0000 0.000
#> 2 140 1153.021 228.8684 1.542243e+04 1.718025e+05 704.4475 1601.595
#> 3 280 1278.823 254.2365 2.181061e+04 2.141763e+05 780.5285 1777.117
#> 4 420 1327.087 264.0631 2.671244e+04 2.338723e+05 809.5330 1844.641
#> 5 560 1352.612 269.2834 3.084487e+04 2.460502e+05 824.8260 1880.398
#> 6 700 1368.403 272.5217 3.448561e+04 2.547453e+05 834.2708 1902.536Because the bundled example contains only three cores, the printed summary reports point estimates by default and treats interval output as an explicit sensitivity analysis.
An optional method = "projected" uses an MM-specific
adaptation of Ma and Genton (2010, Section 3.2), https://doi.org/10.1111/j.1467-9868.2010.00741.x. It
leaves the random-effect density unspecified while retaining
conditionally independent Gaussian residuals with a correct fixed
variance shape. The identity-instrument projected score does not
generally attain the semiparametric efficiency bound. Standard errors
use a stacked independent-cluster sandwich, and only mean-confidence
bands are returned. At least five clusters and two readings per cluster
are required; this path is therefore not applied to the three-core
example above. The package README provides a reproducible
skewed-random-effect example. This is distinct from non-Gaussian
independent residual estimation.
Projected failures report a numerical stage, reason and available
diagnostics in inferMM_cluster_projected_error; no estimate
or interval is returned and no automatic method switch occurs. An
incomplete numerical search can retain a verified interior root but
warns explicitly. Inspect fit$convergence, especially the
scaled joint score norm and search diagnostics. A non-positive
variance-component moment has a separate reporting warning. For the
default profile method, an iteration-limit warning marks
converged = FALSE; such results should not be interpreted
as converged fits.
set.seed(100)
sim_dat <- simulate_mm_data(variance_shape = "hill", error = "skewed")
head(sim_dat)
#> x y true_mean true_variance error
#> 1 1 4.065991 4.761905 1.022444 -0.6882333
#> 2 2 7.609953 9.090909 1.089109 -1.4190785
#> 3 3 13.785376 13.043478 1.198044 0.6778096
#> 4 4 16.505541 16.666667 1.346154 -0.1388731
#> 5 5 20.075119 20.000000 1.529412 0.0607418
#> 6 6 22.084203 23.076923 1.743119 -0.7519053The package is intentionally lightweight: it relies only on base and recommended R packages, while keeping the workflow close to the heteroscedastic and clustered Michaelis-Menten analyses used in the companion methodology paper.
sdl_demo is derived from the fluorescence traces in
Supplementary Data 4, worksheet Michaelis-Menten_data, of
Rapp, J. T., Bremer, B. J., and Romero, P. A. (2024), Self-driving
laboratories to autonomously navigate the protein fitness
landscape, Nature Chemical Engineering 1, 97–107.
https://doi.org/10.1038/s44286-023-00002-4.
alves_demo is the prepared 0–10 cm, 10°C subset of the
soil exoenzyme activity data underlying Alves, R. J. E., et al. (2021),
Kinetic Properties of Microbial Exoenzymes Vary With Soil Depth but
Have Similar Temperature Sensitivities Through the Soil Profile,
Frontiers in Microbiology 12, 735282. https://doi.org/10.3389/fmicb.2021.735282. The study
data and code are supplied in Supplementary Material, Data Sheet 2
(ZIP); the corrected activity table is
enzymeActivity_corr.csv. Positive concentration/activity
records at the selected depth and temperature are retained.
The data help pages ?sdl_demo and
?alves_demo, also included in the PDF reference manual,
give complete bibliographic references and data preparation details.
Generated simulation examples are distinct from these observed data.