simdfhelp: Create a dataframe of a simulated outcome variable based on...

Usage Arguments Examples

Usage

1
simdf(variablespecification, effectspecifications, outcomespecification)

Arguments

variablespecification

A list of 'observed' variables to create a design specification. Must include 'participant' as one variable.

effectspecifications

A list of effects. Effect names must be variable names from variablespecification prefixed with 'b'. Must specify level at which to apply as second argument.

outcomespecification

A list containing the outcome distribution and any parameters to be computed based on the columns contained in the simulated dataset. Note that all such parameters should be prefixed with 'dataset$' and then call the variable name

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
Please note these parameter values are provided for illustrative purposes only

observedvariables = as.list(c(participant = "rep(1:20, each = 40)",
                              qriscore = "rnorm(participant, 10, 2)",
                              hlvascore = "rnorm(participant, 8, 0.5)",
                              texts = "rep(1:10, times = 20, each = 4)",
                              question = "rep(1:800)"))

effectvariables = as.list(c(intercept = "0.15",
                            bparticipant = "rnorm(participant, mean=0, sd=0.04)",
                            bqriscore = "rnorm(participant, 0.025, 0.001)",
                            bhlvascore = "rnorm(participant, 0.02, 0.001)",
                            btexts = "rnorm(texts, 0, 0.02)",
                            bquestion = "rnorm(question, 0, 0.015)"))

outcomegeneration = as.list(c(outcome= "rbinom(observation, 1, dataset$py)",
                              py = "dataset$intercept + dataset$bparticipant + dataset$bqriscore*dataset$qriscore + dataset$bhlvascore*dataset$hlvascore + dataset$btexts + dataset$bquestion"))

simdf(observedvariables, effectvariables, outcomegeneration)

chaddlewick/spr documentation built on May 14, 2019, 3:06 a.m.