extract_grf_args: Recover the GRF arguments used inside a forestsearch run

View source: R/grf_args.R

extract_grf_argsR Documentation

Recover the GRF arguments used inside a forestsearch run

Description

Returns the exact list of arguments that forestsearch() passed to its inner GRF subgroup-identification call (grf.subg.harm.survival() for survival outcomes, grf.subg.harm.glm() for binary, continuous, and count outcomes). The result is suitable for do.call(grf.subg.harm.glm, args) or do.call(grf.subg.harm.survival, args) to reproduce the standalone GRF run with identical settings.

Usage

extract_grf_args(fs)

Arguments

fs

A fitted forestsearch object.

Details

Typical uses:

  • Sensitivity analyses: modify one or two arguments and re-fit GRF without re-running the full forestsearch pipeline, e.g. do.call(grf.subg.harm.glm, modifyList(extract_grf_args(fs), list(maxdepth = 3L))).

  • Reproducibility audits: confirm what the inner GRF saw.

  • Independent variable-importance or policy-tree extraction from a forest fit with the same configuration.

This function reads from fs$args_call_all (populated by forestsearch() via mget() of its formals) and from fs$outcome_type. It is the user-facing complement to the internal builders that the forestsearch() call sites use.

Value

A named list of arguments. For survival outcomes the list targets grf.subg.harm.survival; for binary, continuous, or count outcomes it targets grf.subg.harm.glm. The list carries an attribute "grf_function" holding the target function name as a character string.

See Also

forestsearch, grf.subg.harm.glm, grf.subg.harm.survival.

Examples

## Not run: 
# Reproduce the inner GRF run
args <- extract_grf_args(fs)
fn   <- match.fun(attr(args, "grf_function"))
grf_standalone <- do.call(fn, args)

# Sensitivity: deeper trees, everything else unchanged
args_deep <- modifyList(args, list(maxdepth = 3L))
grf_deep  <- do.call(fn, args_deep)

## End(Not run)


forestsearch documentation built on Nov. 15, 2026, 9:06 a.m.