make_data | R Documentation |
Simulates data based on a model design and a parameter vector (p_vector
) by one of two methods:
Creating a fully crossed and balanced design specified by the design,
with number of trials per cell specified by the n_trials
argument
Using the design of a data frame supplied, which allows creation of unbalanced and other irregular designs, and replacing previous data with simulated data
make_data(
parameters,
design = NULL,
n_trials = NULL,
data = NULL,
expand = 1,
mapped_p = FALSE,
hyper = FALSE,
...
)
parameters |
parameter vector used to simulate data.
Can also be a matrix with one row per subject (with corresponding row names)
or an emc object with sampled parameters
(in which case posterior medians of |
design |
Design list created by |
n_trials |
Integer. If |
data |
Data frame. If supplied, the factors are taken from the data. Determines the number of trials per level of the design factors and can thus allow for unbalanced designs |
expand |
Integer. Replicates the |
mapped_p |
If |
hyper |
If |
... |
Additional optional arguments |
To create data for multiple subjects see ?make_random_effects()
.
A data frame with simulated data
# First create a design
design_DDMaE <- design(factors = list(S = c("left", "right"),
E = c("SPD", "ACC"),
subjects = 1:30),
Rlevels = c("left", "right"), model = DDM,
formula =list(v~0+S,a~E, t0~1, s~1, Z~1, sv~1, SZ~1),
constants=c(s=log(1)))
# Then create a p_vector:
parameters <- c(v_Sleft=-2,v_Sright=2,a=log(1),a_EACC=log(2), t0=log(.2),
Z=qnorm(.5),sv=log(.5),SZ=qnorm(.5))
# Now we can simulate data
data <- make_data(parameters, design_DDMaE, n_trials = 30)
# We can also simulate data based on a specific dataset
design_DDMaE <- design(data = forstmann,model=DDM,
formula =list(v~0+S,a~E, t0~1, s~1, Z~1, sv~1, SZ~1),
constants=c(s=log(1)))
parameters <- c(v_Sleft=-2,v_Sright=2,a=log(1),a_Eneutral=log(1.5),a_Eaccuracy=log(2),
t0=log(.2),Z=qnorm(.5),sv=log(.5),SZ=qnorm(.5))
data <- make_data(parameters, design_DDMaE, data = forstmann)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.