Description Usage Arguments Details Value Examples
The matrix is used to simulate data. Each row represents one set of parameters for a participant.
1 | GetParameterMatrix(x, nsub, prior = NA, ps = NA, seed = NULL)
|
x |
a model object |
nsub |
number of subjects. |
prior |
a prior object |
ps |
a vector or a matirx. |
seed |
an integer specifying a random seed. |
One must enter either a vector or a matrix as true parameters
to the argument, ps
, when presuming to simulate data based on a
fixed-effect model. When the assumption is to simulate data based on a
random-effect model, one must enter a prior object to the argument,
prior
to first randomly generate a true parameter matrix.
a ns x npar matrix
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 | model <- BuildModel(
p.map = list(a ="1", v = "1",z = "1", d = "1", sz = "1", sv = "1",
t0 = "1", st0 = "1"),
match.map = list(M = list(s1 = "r1", s2 ="r2")),
factors = list(S = c("s1", "s2")),
constants = c(st0 = 0, d = 0),
responses = c("r1", "r2"),
type = "rd")
p.prior <- BuildPrior(
dists = c("tnorm", "tnorm", "beta", "beta", "tnorm", "beta"),
p1 = c(a = 1, v = 0, z = 1, sz = 1, sv = 1, t0 = 1),
p2 = c(a = 1, v = 2, z = 1, sz = 1, sv = 1, t0 = 1),
lower = c(0, -5, NA, NA, 0, NA),
upper = c(2, 5, NA, NA, 2, NA))
## Example 1: Randomly generate 2 sets of true parameters from
## parameter priors (p.prior)
GetParameterMatrix(model, 2, p.prior)
## a v z sz sv t0
## [1,] 1.963067 1.472940 0.9509158 0.5145047 1.344705 0.0850591
## [2,] 1.512276 -1.995631 0.6981290 0.2626882 1.867853 0.1552828
## Example 2: Use a user-selected true parameters
true.vector <- c(a=1, v=1, z=0.5, sz=0.2, sv=1, t0=.15)
GetParameterMatrix(model, 2, NA, true.vector)
## a v z sz sv t0
## [1,] 1 1 0.5 0.2 1 0.15
## [2,] 1 1 0.5 0.2 1 0.15
GetParameterMatrix(model, 2, ps = true.vector)
## Example 3: When a user enter arbritary sequence of parameters.
## Note sv is before sz. It should be sz before sv
## See correct sequence, by entering "attr(model, 'p.vector')"
## GetParameterMatrix will rearrange the sequence.
true.vector <- c(a=1, v=1, z=0.5, sv=1, sz = .2, t0=.15)
GetParameterMatrix(model, 2, NA, true.vector)
## a v z sz sv t0
## [1,] 1 1 0.5 0.2 1 0.15
## [2,] 1 1 0.5 0.2 1 0.15
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.