Skip to contents

Validate an omnibus fit by leaving out one group

Usage

validate_omnibus_leave_one_out(object, group_value, level = 0, ...)

Arguments

object

A predmicror_omnibus_fit object.

group_value

Group value to leave out.

level

Prediction level. Defaults to 0 for population-level prediction of the left-out group.

...

Additional arguments passed to fit_omnibus() during refitting.

Value

A list with the refitted model, validation data, predictions, residuals, bias factor, and accuracy factor.

Examples

set.seed(1)
dat <- do.call(rbind, lapply(1:4, function(g) {
  Time <- c(1, 2, 4, 6, 8, 10)
  sigma <- 5 + 0.4 * g
  data.frame(
    Condition = g,
    Time = Time,
    Temp = 55 + g,
    logN = WeibullM(Time, Y0 = 7, sigma = sigma, alpha = 1.1) +
      rnorm(length(Time), 0, 0.03)
  )
}))
fit <- fit_omnibus_inactivation(
  dat, primary = "WeibullM", time = "Time", response = "logN",
  group = "Condition", secondary = list(sigma = ~ Temp), random = Y0 ~ 1,
  start = c(Y0 = 7, sigma = 1, sigma.Temp = 0.08, alpha = 1)
)
validate_omnibus_leave_one_out(fit, group_value = 1)
#> $group
#> [1] 1
#> 
#> $fit
#> predmicror omnibus fit
#>   type: inactivation
#>   primary: WeibullM
#>   response: logN (log10N)
#>   group: Condition
#>   formula: logN ~ WeibullM(Time, Y0, sigma, alpha)
#> 
#> Nonlinear mixed-effects model fit by maximum likelihood
#>   Model: logN ~ WeibullM(Time, Y0, sigma, alpha) 
#>   Data: structure(list(Condition = structure(c(2L, 2L, 2L, 2L, 2L, 2L,  1L, 1L, 1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L), levels = c("3",  "2", "4"), class = c("ordered", "factor")), Time = c(1, 2, 4,  6, 8, 10, 1, 2, 4, 6, 8, 10, 1, 2, 4, 6, 8, 10), Temp = c(57,  57, 57, 57, 57, 57, 58, 58, 58, 58, 58, 58, 59, 59, 59, 59, 59,  59), logN = c(6.68162236376677, 6.30834752659853, 5.48720489842949,  4.60076476835948, 3.76557971644166, 2.81946728291791, 6.67191681320917,  6.2702470472557, 5.61190762362015, 4.77763845418162, 3.95173288068617,  3.13262114209126, 6.73575671288993, 6.39858936905395, 5.7002257519511,  4.95006102960119, 4.15701372323355, 3.30353668937129)), row.names = 7:24, class = c("nfnGroupedData",  "nfGroupedData", "groupedData", "data.frame"), formula = logN ~      Time | Condition, FUN = function (x)  max(x, na.rm = TRUE), order.groups = TRUE) 
#>   Log-likelihood: 39.58223
#>   Fixed: list(Y0 = Y0 ~ 1, sigma = sigma ~ Temp, alpha = alpha ~ 1) 
#>                Y0 sigma.(Intercept)        sigma.Temp             alpha 
#>         6.9879709       -15.3486585         0.3724932         1.1162938 
#> 
#> Random effects:
#>  Formula: Y0 ~ 1 | Condition
#>                   Y0  Residual
#> StdDev: 7.311083e-07 0.0268376
#> 
#> Number of Observations: 18
#> Number of Groups: 3 
#> 
#> $data
#>   Condition Time Temp     logN .predicted      .resid
#> 1         1    1   56 6.620974   6.645370 -0.02439589
#> 2         1    2   56 6.233335   6.245249 -0.01191414
#> 3         1    4   56 5.319739   5.377828 -0.05808998
#> 4         1    6   56 4.462332   4.456145  0.00618752
#> 5         1    8   56 3.461902   3.497354 -0.03545161
#> 6         1   10   56 2.440331   2.509990 -0.06965871
#> 
#> $observed
#> [1] 6.620974 6.233335 5.319739 4.462332 3.461902 2.440331
#> 
#> $predicted
#> [1] 6.645370 6.245249 5.377828 4.456145 3.497354 2.509990
#> 
#> $residuals
#> [1] -0.02439589 -0.01191414 -0.05808998  0.00618752 -0.03545161 -0.06965871
#> 
#> $bias_factor
#> [1] 1.008939
#> 
#> $accuracy_factor
#> [1] 1.009405
#>