extract: Extract list of synthetic data sets

View source: R/extract.R

extractR Documentation

Extract list of synthetic data sets

Description

Extracts a list of synthetic data sets from a synthetic data object.

Usage

extract(object, drop = TRUE)

Arguments

object

object of class robosynth as returned by synthesize.

drop

logical: if TRUE (the default), the masked copies are dropped from each data set.

Details

This function extracts a list of synthetic data sets from a synthetic data object as returned by synthesize. By default, the function drops the masked copies generated with mask.continuous and mask.categorical from the data set.

Value

An object of class robosynth.list (a list of data frames).

Author(s)

Simon Grund

See Also

synthesize, mask.categorical, mask.continuous

Examples

# create masked copies
sociosexuality <- within(sociosexuality, {

  m_sex <- mask.categorical(sex, probability = .80)
  m_sexpref <- mask.categorical(sexpref, probability = .60)
  m_age <- mask.continuous(age, reliability = .90)

})

# combine synthesis and masking models
models <- combine.models(

  synthesis.model(sex ~ 1, type = "binary"),
  synthesis.model(sexpref ~ 1 + sex, type = "categorical"),
  synthesis.model(age ~ 1 + sex + sexpref, type = "continuous"),

  masking.model(m_sex ~ sex, type = "binary"),
  masking.model(m_sexpref ~ sexpref, type = "categorical"),
  masking.model(m_age ~ age, type = "continuous"),

  data = sociosexuality

)

# run synthesis
syn <- synthesize(models = models, m = 5, iter = 5)

# * Example 1:

synlist <- extract(syn)

# * Example 2: keep masked copies

synlist <- extract(syn, drop = FALSE)

simongrund1/robosynth documentation built on March 20, 2022, 6:15 p.m.