RUMdataSimulator: RUMdataSimulator

RUMdataSimulatorR Documentation

RUMdataSimulator

Description

RUMdataSimulator provides convenient tools for generating experimental design from synthetic data for Random Utility Model. Below, please find a complete example of how to use the package RUMdataSimulator.

Author(s)

Antoine Dubois

Examples

library("RUMdataSimulator")
library("clusterGeneration") # This packages provides functions generating random covariance matrices
##############################
# Generation of synthetic dataset
##############################
DM_att_names <- list("S1", "S2", "S3") # the list of the decision makers' characteristics
AT_names <- list("good1", "good2", "good3", "good4") # the list of the alternatives' names
AT_att_names <- list("X1", "X2", "X3") # the list of the alternatives' attributes
groups <- c(10, 20) # the groups of decision makers
FD <- Experiment(DM_att_names=DM_att_names, AT_att_names=AT_att_names,
                 AT_names=AT_names,groups=groups, no_choice=TRUE) # creation of an instance of the call Experiment

################################################################################
# Example 1: step-by-step generation

#Generation of S whose components law's are different:
FD$gen_DM_attributes("empirical", data = data.frame(S1=c(0.5, 0, 12, 6, 7.3)), which = "S1") # the characteristics of S1 are drawn from a data set
FD$gen_DM_attributes("normal", which=c("S2", "S3"), group=1) # the characteristics S2 and S3 follow a standardized normal distribution within the group 1
FD$gen_DM_attributes("normal", mu=1, sd=2, which=c("S2","S3"), group=2) # the characteristics S2 and S3 follow a normal distribution with mean 1 and 2 standard deviation within the group 2
FD$S
FD$gen_DM_attributes(observation=~S1+S2+S3+I(S1*S2)) # observation of cross effects between the decision makers' characteristics
FD$S

#Generation of X whose components law's are identical:
sigma <- clusterGeneration::genPositiveDefMat(3)$sigma # generation of a random covariance matrix of size 3
FD$gen_AT_attributes(mu=c(-1,2,0), sd=sigma) # all the attributes are generated by a multivariate normal distribution of mean (-1, 2, 0) and covariance matrix sigma
FD$gen_AT_attributes(observation=~X1+X2+X3+I(X1^2)) # observation of cross effects between the alternatives' attributes
FD$X

#Generation of beta whose components law's are different:
FD$gen_preference_coefficients("student", heterogeneity=TRUE, location=-100,  scale=1, df=4, which=c(1:4), group=1) # generation of the variables from 1 to 4 of the alternatives within the group 1
FD$gen_preference_coefficients("student", heterogeneity=FALSE, location=100,  scale=1, df=4, which=c(1:4), group=2) # generation of the variables from 1 to 4 of the alternatives within the group 2
FD$gen_preference_coefficients("normal", heterogeneity=FALSE, mu=0, sd=2, which=5) # generation of the fifth variable within every group
FD$gen_preference_coefficients("discrete_uniform", heterogeneity=TRUE, a=1, b=5, which="X2") # rectification, the variable X2 follows a discrete uniform distribution
FD$gen_preference_coefficients(heterogeneity=TRUE, which=c("X3", "I(X1^2)")) # generation of the variable X3 and I(X1^2) according to the default distribution: the standardized normal distribution
FD$beta


#Generation of measurement error from different distributions:
FD$utility() # computation of the decision makers' utility according to the standardized Gumbel distribution
FD$utility("discrete_uniform") # computation of the decision makers' utility according to the discrete uniform distribution
FD$utility("normal", mu=0, sd=2) # It is possible to have correlation between alternatives preference (for both student and normal distributions)
FD$utility("student", location=0, scale=2, df=4)

FD$V
FD$Epsilon
FD$U
FD$choice_order

FD$choice

# Drawing a 3D preference mapping:
FD$map("X1", "X3") # Map representing the choice of the decision makers and the utility provided by this choice according to the value of X1 and X3
FD$map("S1", "X3")
FD$map("S1", "S2")

# Generation of designs:
FFD <- FD$design(choice_set_size=2, clustered=0) # generation of the full factorial design with row data
#by default, name="FuFD", choice_set_size = nb_alternatives
View(FFD)

FFD <- FD$design(name="FuFD",choice_set_size=2, clustered=1, nb_levels_DM=c(3, 3, 4, 2), nb_levels_AT=c(3, 2, 2, 4)) # generation of the full factorial design with glustered data
View(FFD)

FFD1 <- FD$design(choice_set_size=2, clustered=2, nb_levels_DM=c(2, 3, 4, 2), nb_levels_AT=c(2, 2, 2, 2)) # generation of the full factorial design with categorial data

View(FFD1)

FFD2 <- FD$design(name="FrFD", choice_set_size=2, clustered=2, nb_levels_DM=c(2, 3, 4, 2), nb_levels_AT=c(2, 2, 2, 2), nb_questions = 2) # Generation a a random fractional factorial design with categorial data
View(FFD2)

summary.Exepriment(FD) # a summary of the experimental design

################################################################################
#Example 2: Straightforward generation with default distributions
groups <- 10
DM_att_names <- list("S1", "S2", "S3")
AT_names <- list("good1", "good2", "good3")
AT_att_names <- list("X1", "X2", "X3")
no_choice <- TRUE
normalize <- FALSE
FD <- Experiment(DM_att_names=DM_att_names, AT_att_names=AT_att_names,
                      AT_names=AT_names,groups=groups, no_choice=no_choice, normalize=normalize)

FD$experiment()
FD$choice_order
FD$map("X1", "X3")

FFD <- FD$design(choice_set_size=2, clustered=1, nb_levels_DM=c(3,3,4), nb_levels_AT=c(3, 2, 2))
View(FFD)


AntoineDubois/sdcv2 documentation built on May 16, 2024, 3:23 p.m.