Learn R Programming

nlmixr2auto (version 1.0.0)

generate_neighbors_df: Generate neighbor models

Description

Generates a set of neighbor models from a given current model code. The neighborhood is defined as all single-variable changes (1-bit modifications).

Usage

generate_neighbors_df(
  current_string,
  search.space = c("ivbase", "oralbase"),
  nsize = NULL
)

Value

A list with two components:

original

Neighbors generated by single-variable flips, before validation.

validated

Neighbors after validation, representing feasible models.

Arguments

current_string

A named numeric vector representing the current model code. Names correspond to model features (e.g. "no.cmpt", "eta.vc", "rv"), and values to their current states.

search.space

Character, one of "ivbase" or "oralbase". Default is "ivbase".

nsize

Integer (optional). Maximum number of neighbors to return. If NULL (default), the full neighborhood is returned. If specified, a random subset of this size is sampled.

Author

Zhonghui Huang

Details

For each neighbor, both the original (pre-validation) and the validated (post-validation) codes are retained. This allows downstream functions (e.g. detect_move()) to distinguish between the intended primary modification and any secondary adjustments introduced by validation.

Optionally, the function can restrict the number of neighbors by random sampling (candidate list strategy).

Examples

Run this code
current_string <- c(no.cmpt = 2, eta.km = 0, eta.vc = 1,
                    eta.vp = 0, eta.vp2 = 0, eta.q = 1,
                    eta.q2 = 0, mm = 0, mcorr = 1, rv = 2)
neighbors <- generate_neighbors_df(current_string, search.space = "ivbase")
head(neighbors$original)   # raw neighbors (pre-validation)
head(neighbors$validated)  # validated neighbors (post-validation)

Run the code above in your browser using DataLab