-
samuelsmock authoredsamuelsmock authored
output: github_document
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
simulateDCE
The goal of simulateDCE is to make it easy to simulate choice experiment datasets using designs from NGENE or spdesign
. You have to store the design file in a subfolder and need to specify certain parameters and the utility functions for the data generating process. The package is useful for:
-
Test different designs in terms of statistical power, efficiency and unbiasedness
-
To test the effects of deviations from RUM, e.g. heuristics, on model performance for different designs.
-
In teaching, using simulated data is useful, if you want to know the data generating process. It helps to demonstrate Maximum likelihood and choice models, knowing exactly what you should expect.
-
You can use simulation in pre-registration to justify your sample size and design choice.
-
Before data collection, you can use simulated data to estimate the models you plan to use in the actual analysis. You can thus make sure, you can estimate all effects for given sample sizes.
Installation
You can install the development version of simulateDCE from gitlab. You need to install the remotes
package first. The current version is alpha and there is no version on cran:
install.packages("remotes")
remotes::install_gitlab(repo = "dj44vuri/simulateDCE" , host = "https://git.idiv.de")
Example
This is a basic example for a simulation:
rm(list=ls())
library(simulateDCE)
library(rlang)
library(formula.tools)
library(rlang)
designpath<- system.file("extdata","SE_DRIVE" ,package = "simulateDCE")
resps =120 # number of respondents
nosim= 2 # number of simulations to run (about 500 is minimum)
# bcoeff <- list(
# bpreis = -0.036,
# blade = -0.034,
# bwarte = -0.049)
decisiongroups=c(0,0.7,1)
# wrong parameters
# place b coefficients into an r list:
bcoeff = list(
bpreis = -0.01,
blade = -0.07,
bwarte = 0.02)
manipulations = list(alt1.x2= expr(alt1.x2/10),
alt1.x3= expr(alt1.x3/10),
alt2.x2= expr(alt2.x2/10),
alt2.x3= expr(alt2.x3/10)
)
#place your utility functions here
ul<-list( u1 =
list(
v1 =V.1~ bpreis * alt1.x1 + blade*alt1.x2 + bwarte*alt1.x3 ,
v2 =V.2~ bpreis * alt2.x1 + blade*alt2.x2 + bwarte*alt2.x3
)
,
u2 = list( v1 =V.1~ bpreis * alt1.x1 ,
v2 =V.2~ bpreis * alt2.x1)
)
destype="ngene"
sedrive <- sim_all(nosim = nosim, resps=resps, destype = destype,
designpath = designpath, u=ul, bcoeff = bcoeff)