Description Usage Arguments Examples
h.samples.dmc
initialise a DMC object with each particpant as a list
element in a list. A participant is himself/herself a list element, carrying
the DMC setting, such as theta, summed_log_likelihood, etc.
1 2 3 4 |
nmc |
number of Markov Chain Monte Carlo iteration |
p.prior |
prior distribution setting |
data |
a model data instance created by |
pp.prior |
prior distribution setting, hyper level |
samples |
a DMC posterior sample |
thin |
thinning length. Default 1 |
theta1 |
A user supplied initial theta cube |
phi1 |
A user supplied initial phi cube |
start.prior |
A user supplied (different) prior distribution setting |
hstart.prior |
A user supplied (different) hyper-prior distribution setting |
add |
whether add new MCMC iteration on top of previous DMC sample |
rp |
a DEMCMC tuning parameter |
setting |
a list container to store all DMC setting |
verbose |
whether to print debugging information |
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 | ## Set up a DDM Model, rate effect of factor F
m1 <- model.dmc(
p.map = list(a="1",v="F",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"), F=c("f1","f2")),
constants = c(st0=0,d=0),
responses = c("r1","r2"),
type = "rd")
## Population distribution
pop.mean <- c(a=2, v.f1=2.5, v.f2=1.5, z=0.5, sz=0.3, sv=1, t0=0.3)
pop.scale <- c(a=0.5, v.f1=.5, v.f2=.5, z=0.1, sz=0.1, sv=.3, t0=0.05)
pop.prior <- prior.p.dmc(
dists = rep("tnorm",7),
p1 = pop.mean,
p2 = pop.scale,
lower = c(0,-5, -5, 0, 0, 0, 0),
upper = c(5, 7, 7, 2, 2, 2, 2))
## Check population distributions
plot_priors(pop.prior)
## Simulate some data
dat <- h.simulate.dmc(m1, nsim=20, ns=4, p.prior=pop.prior)
mdi <- data.model.dmc(dat, m1)
head(dat)
## S F R RT
## 1 s1 f1 r1 0.9227881
## 2 s1 f1 r1 0.7878554
## 3 s1 f1 r1 0.4814711
## 4 s1 f1 r1 0.6864110
## 5 s1 f1 r1 0.5068179
## 6 s1 f1 r1 0.6356547
## Take a look at true parameters
ps <- round( attr(dat, "parameters"), 2)
ps
## a v.f1 v.f2 z sz sv t0
## 1 2.83 2.91 1.41 0.66 0.30 0.65 0.30
## 2 2.37 2.42 2.24 0.48 0.28 1.14 0.31
## 3 1.91 2.49 0.98 0.74 0.33 1.20 0.18
## 4 2.14 2.67 2.34 0.65 0.31 1.74 0.27
## FIT FIXED EFFECTS
## specify a broader prior than the true population distribution
p.prior <- prior.p.dmc(
dists= rep("tnorm", length(pop.mean)),
p1=pop.mean,
p2=pop.scale*5,
lower=c(0,-5, -5, 0, 0, 0, 0),
upper=c(5, 7, 7, 2, 2, 2, 2))
## Set up multiple participant DMC sample
samples0 <- h.samples.dmc(nmc=100, p.prior=p.prior, data=mdi, thin=1)
## Add 400 more iterations and change thinning length to 2
samples1 <- h.samples.dmc(nmc=100, p.prior=p.prior, samples=samples0,
thin=2, add=TRUE)
samples1[[1]]$nmc
## [1] 200
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.