# 1. Define some parameter set in a data.frame
paramDf <- data.frame(v1=0.5, v2=1.0, t0=0.1, st0=0,
mu_d1=1, mu_d2=1,
s1=0.5, s2=0.5, rho=0.2,
theta1=0.8, theta2=1.5)
# 2. Simulate trials for both stimulus categories and all conditions (2)
simus <- simulateMTLNR(paramDf)
head(simus)
# \donttest{
library(ggplot2)
simus <- simus[simus$response != 0, ]
simus$rating <- factor(simus$rating, labels = c("unsure", "medium", "sure"))
ggplot(simus, aes(x = rt, group = interaction(correct, rating),
color = as.factor(correct), linetype = rating)) +
geom_density(linewidth = 1.2, na.rm=TRUE) + xlim(c(0, 5)) +
facet_grid(rows = vars(condition), labeller = "label_both")
# }
# automatically aggregate simulation distribution
# to get only accuracy x confidence rating distribution for
# all conditions
agg_simus <- simulateMTLNR(paramDf, agg_simus = TRUE)
head(agg_simus)
# \donttest{
agg_simus$rating <- factor(agg_simus$rating, labels = c("unsure", "medium", "sure"))
library(ggplot2)
ggplot(agg_simus, aes(x = rating, group = correct, fill = as.factor(correct), y = p)) +
geom_bar(stat = "identity", position = "dodge") +
facet_grid(cols = vars(condition), labeller = "label_both")
# }
# \donttest{
# Compute Gamma correlation coefficients between
# confidence and other behavioral measures
# output will be a list
simu_list <- simulateMTLNR(paramDf, n = 400, gamma = TRUE)
simu_list
# }
# Example with asymmetric confidence thresholds
paramDf_asym <- data.frame(v1=0.5, v2=1.0, t0=0.1, st0=0,
mu_d1=1, mu_d2=1,
s1=0.5, s2=0.5, rho=0.2,
thetaLower1=0.5, thetaLower2=1.2,
thetaUpper1=0.7, thetaUpper2=1.8)
simus_asym <- simulateMTLNR(paramDf_asym, n = 1000)
head(simus_asym)
# Example with multiple conditions
paramDf_multi <- data.frame(v1=0.3, v2=0.6, v3=1.2, t0=0.1, st0=0,
mu_d1=1, mu_d2=1,
s1=0.5, s2=0.5, rho=0.2,
theta1=0.8, theta2=1.5)
simus_multi <- simulateMTLNR(paramDf_multi, n = 1000)
table(simus_multi$condition, simus_multi$correct)
Run the code above in your browser using DataLab