## ----setup, include=FALSE----------------------------------------------------- knitr::opts_chunk$set(collapse = TRUE, comment = "#>") ## ----example, eval=requireNamespace("nnet", quietly=TRUE)--------------------- library(SynthesizerPlus) set.seed(204) input <- data.frame( age = rnorm(500, 35, 10), income = rgamma(500, shape = 4, scale = 1000) ) logits <- cbind(0, (input$age - 35)/15, log(input$income/4000)) p <- exp(logits - apply(logits, 1L, max)) p <- p/rowSums(p) classes <- c("bus", "car", "rail") input$transport <- factor(classes[apply(p, 1, function(q) sample.int(3, 1, prob = q))]) fit <- fit_synthesizer(input, nominal_target = "transport", seed = 11) synthetic <- generate(fit, n = 500, seed = 12) prop.table(table(synthetic$transport)) fit$pooled$nominal$selection # AIC of the spline and linear models