experiment_compose: Compose experiment

View source: R/experiment_compose.R

experiment_composeR Documentation

Compose experiment

Description

This function simulates the data preparation step for an experiment. The function performs coupling between X (population) and Z (experimental_design) datasets.

Usage

experiment_compose(population, experimental_design, seed = NULL)

Arguments

population

A 'population' object.

experimental_design

An 'experimental_desing' object.

seed

The desired seed to be set before data generation. No seed is set by default ('seed = NULL').

Value

data.frame A complete experimental dataset XZ

Examples

# Generate individual profile and population
ind3 <- individual$new()
ind3$add_characteristics(Age = rnorm(mean = 50, sd = 4), Salary = runif(min = 1, max = 5))
drule <- decision_rule$new()
drule$add_noise(rnorm(), rnorm(sd = 2))
drule$add_formulas(Age + 2 * Quality, 1.5 * Age + Quality^2)
ind3$add_decision_rule(drule)
pop <- population$new(profiles = list(ind3), n = list(5))

# Create alternatives and regroup them into design
alt1 <- alternative$new()
alt1$add_attributes(Quality = runif(min = 0, max = 1), Price = rnorm(mean = 5))
alt2 <- alternative$new()
alt2$add_attributes(Size = runif(min = 0, max = 1), Price = rnorm(mean = 6))
edesign <- experimental_design$new(alternatives = list(alt1, alt2), n = 4)

# Compose dataset
XZ <- experiment_run(pop, edesign, seed = 10)

nikitagusarov/dcesimulatr documentation built on Jan. 7, 2023, 4:27 p.m.