-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME.Rmd
More file actions
108 lines (74 loc) · 2.93 KB
/
README.Rmd
File metadata and controls
108 lines (74 loc) · 2.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r options, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# simulateDCE
<!-- badges: start -->
[](https://CRAN.R-project.org/package=simulateDCE)
[](https://github.com/sagebiej/simulatedce/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->
The goal of simulateDCE is to make it easy to simulate choice experiment datasets using designs from NGENE, `idefix` or `spdesign`. You have to store the design file(s) in a subfolder and need to specify certain parameters and the utility functions for the data generating process. The package is useful for:
1. Test different designs in terms of statistical power, efficiency and unbiasedness
2. To test the effects of deviations from RUM, e.g. heuristics, on model performance for different designs.
3. 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.
4. You can use simulation in pre-registration to justify your sample size and design choice.
5. 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 simulateDCE directly from cran by
``` r
install.packages("simulateDCE")
```
For the latest development version use this:
``` r
install.packages("devtools")
devtools::install_git('https://github.com/sagebiej/simulateDCE', ref = "devel")
```
## Example
This is a basic example for a simulation:
```{r example}
rm(list = ls())
library(simulateDCE)
library(rlang)
library(formula.tools)
designpath <- system.file("extdata", "SE_DRIVE", package = "simulateDCE")
resps <- 120 # number of respondents
nosim <- 4 # number of simulations to run (about 500 is minimum)
decisiongroups <- c(0, 0.7, 1)
# 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, decisiongroups = decisiongroups
)
```