postsynth_to_roadmap: Convert a incompletely synthesized 'postsynth' into a new...

View source: R/reset_postsynth.R

postsynth_to_roadmapR Documentation

Convert a incompletely synthesized postsynth into a new roadmap using the same roadmap settings from the incomplete synthesis.

Description

In the new roadmap, start_data will now include the initial starting data along with the previously synthesized variables. The visit_sequence will consist of, in the same order as the original visit sequence, all unsynthesized variables. The schema will reflect the original schema but with an updated set of synth_vars. The constraints will be similar to those initially inputted, but all rows in the constraints data frames for already synthesized variables will be excluded.

Usage

postsynth_to_roadmap(postsynth)

Arguments

postsynth

A postsynth object generated with keep_workflows == TRUE

Details

To update components of the roadmap use the ⁠reset_*⁠ and ⁠add_*⁠ functions. For example, to change the visit_sequence which by default follows the same order as the initial visit sequence, apply reset_visit_sequence() and then ⁠add_sequence_*()⁠ to the newly created roadmap.

Value

A roadmap object.

Examples


# create roadmap
rm <- roadmap(
  conf_data = acs_conf_nw,
  start_data = acs_start_nw
) 

rpart_mod_reg <- parsnip::decision_tree() |>
  parsnip::set_engine(engine = "rpart") |>
  parsnip::set_mode(mode = "regression")

rpart_mod_class <- parsnip::decision_tree() |>
  parsnip::set_engine(engine = "rpart") |>
  parsnip::set_mode(mode = "classification")

synth_spec1 <- synth_spec(
  default_regression_model = rpart_mod_reg,
  default_regression_sampler = sample_rpart,
  default_classification_model = rpart_mod_class,
  default_classification_sampler = sample_rpart
)

# create a presynth object
# use defaults for noise, constraints, and replicates
presynth1 <- presynth(
  roadmap = rm,
  synth_spec = synth_spec1
)

# synthesize with keep_workflows = TRUE
set.seed(1)
postsynth1 <- synthesize(
  presynth = presynth1, 
  keep_workflows = TRUE
)

# return roadmap (will return original roadmap if synthesis completes).
new_rmap <- postsynth_to_roadmap(postsynth1)


tidysynthesis documentation built on March 17, 2026, 1:06 a.m.