# NOT RUN {
library(DstarM)
tt = seq(0, 5, .1)
pars = c(.8, 2, .5, .5, .5, # condition 1
.8, 3, .5, .5, .5, # condition 2
.8, 4, .5, .5, .5) # condition 3
pdfND = dbeta(tt, 10, 30)
# simulate data for 2 participants
n = 1.2e3
data = rbind(simData(n = n, pars = pars, tt = tt, pdfND = pdfND),
simData(n = n, pars = pars, tt = tt, pdfND = pdfND))
# add participant column
data$pp = rep(1:2, each = n)
# define restriction matrix
restr = matrix(1:5, 5, 3)
restr[2, -1] = 6:7 # allow drift rates to differ
# fix variance parameters
fixed = matrix(c('sz1', .5, 'sv1', .5), 2, 2)
## Run D*M analysis by pp
resDpp = byParticipant(data = data,
argsEstDstarM = list(tt = tt,
restr = restr,
fixed = fixed,
Optim = list(parallelType = 1)))
coef(resDpp)
plot(resDpp)
resNDpp = byParticipant(resD = resDpp,
argsEstND = list(Optim = list(parallelType = 1)))
plot(resNDpp, xlim = 0:1)
lines(tt, pdfND, col = 3, type = 'b')
resObsPp = byParticipant(resD = resDpp,
resND = resNDpp)
plot(resObsPp)
# }
Run the code above in your browser using DataLab