# Use linear regression with an "error" on the SIR dataset.
ranges <- list(aSI = c(0.1, 0.8), aIR = c(0, 0.5), aSR = c(0, 0.05))
targets <- SIREmulators$targets
lms <- purrr::map(names(targets),
~step(lm(data = SIRSample$training[,c(names(ranges), .)],
formula = as.formula(paste0(., "~(",
paste0(names(ranges), collapse = "+"),
")^2"
))
), trace = 0))
# Set up the proto emulators
proto_ems <- purrr::map(seq_along(lms), function(l) {
Proto_emulator$new(
ranges,
names(targets)[l],
function(x) predict(lms[[l]], x),
function(x) predict(lms[[l]], x, se.fit = TRUE)$se.fit^2 +
predict(lms[[l]], x, se.fit = TRUE)$residual.scale^2,
print_func = function() print(summary(lms[[l]]))
)
}) |> setNames(names(targets))
# Test with some hmer functions
nth_implausible(proto_ems, SIRSample$validation, targets)
emulator_plot(proto_ems)
emulator_plot(proto_ems, 'imp', targets = targets)
validation_diagnostics(proto_ems, targets, SIRSample$validation)
new_points <- generate_new_design(proto_ems, 100, targets)
Run the code above in your browser using DataLab