Description Usage Arguments Details Value Examples
Initialise the random effects for each subject using MCMC.
1 2 3 4 5 6 7 |
pmwgs |
The sampler object that provides the parameters. |
start_mu |
An array of starting values for the group means |
start_sig |
An array of starting values for the group covariance matrix |
display_progress |
Display a progress bar during sampling |
particles |
The number of particles to generate in initialisation |
Before sampling can start the Particle Metropolis within Gibbs sampler needs
initial values for the random effects. The init
function generates
these values using a Monte Carlo algorithm. One alternative methods would be
setting the initial values randomly.
Optionally takes starting values for the model parameters and the variance / covariance matrix. All arrays must match the appropriate shape.
For example, with 5 parameters and 10 subjects, the model parameter start means must be a vector of length 5 and the covariance matrix must be an array of 5 x 5.
Alternatively the if argument values for the starting points are left at the default (NULL) then starting points will be sampled from the prior for group level values (model parameters and covariance matrix)
The sampler object but with initial values set for theta_mu
,
theta_sig
, alpha
and other values for the first sample.
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 | lba_ll <- function(x, data) {
x <- exp(x)
if (any(data$rt < x["t0"])) {
return(-1e10)
}
sum(
log(
rtdists::dLBA(
rt = data$rt,
response = data$correct,
A = x["A"],
b = x["A"] + x[c("b1", "b2", "b3")][data$condition],
t0 = x["t0"],
mean_v = x[c("v1", "v2")],
sd_v = c(1, 1),
silent = TRUE
)
)
)
}
sampler <- pmwgs(
forstmann,
c("b1", "b2", "b3", "A", "v1", "v2", "t0"),
lba_ll
)
sampler <- init(sampler)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.