# Plot rt distribution ignoring confidence
curve(dMTLNR(x, 1, th1=-Inf, th2=Inf, mu_v1=0.5, mu_v2=-0.5,
mu_d1=1, mu_d2=1, t0=0.1), xlim=c(0,2.5), ylim=c(0,2))
curve(dMTLNR(x, 2, th1=-Inf, th2=Inf, mu_v1=0.5, mu_v2=-0.5,
mu_d1=1, mu_d2=1, t0=0.1), col="red", add=TRUE)
# t0 indicates minimal response time possible
abline(v=0.1)
# Generate a random sample
df1 <- rMTLNR(5000, mu_v1=0.2, mu_v2=-0.2, mu_d1=1, mu_d2=1, t0=0.1)
head(df1)
# Compute density with rt and response as separate arguments
dMTLNR(seq(0, 2, by =0.4), response=2, th1=0.5, th2=2,
mu_v1=0.2, mu_v2=-0.2, mu_d1=1, mu_d2=1, t0=0.1)
# Compute density with rt and response in data.frame argument
df1 <- subset(df1, response !=0) # drop trials where no accumulation hit its boundary
dMTLNR(df1[1:5,], th1=0, th2=Inf, mu_v1=0.2, mu_v2=-0.2,
mu_d1=1, mu_d2=1, t0=0.1)
# Example with correlation parameters
dMTLNR(df1[1:5,], th1=0, th2=Inf, mu_v1=0.2, mu_v2=-0.2,
mu_d1=1, mu_d2=1, rho_v=0.3, rho_d=0.2, t0=0.1)
# Example with multiple confidence ratings using dMTLNR_multiple_ratings
thresholds <- c(0.5, 1.5, 2.5, # for response=1 (increasing)
0.3, 1.2, 2.0) # for response=2 (increasing)
# Create some sample data with ratings
sample_data <- data.frame(
rt = c(0.8, 1.2, 0.9, 1.5, 1.1),
response = c(1, 2, 1, 2, 1),
rating = c(1, 2, 3, 1, 2)
)
dMTLNR_multiple_ratings(sample_data, thresholds=thresholds,
mu_v1=0.2, mu_v2=-0.2, mu_d1=1, mu_d2=1, t0=0.1)
# Compare RT and confidence distributions for different parameter settings
df_low_var <- rMTLNR(2000, thresholds = thresholds,
mu_v1=0.3, mu_v2=-0.3, mu_d1=1, mu_d2=1,
s_v1=0.5, s_v2=0.5, s_d1=0.5, s_d2=0.5, t0=0.1)
df_high_var <- rMTLNR(2000, thresholds=thresholds,
mu_v1=0.3, mu_v2=-0.3, mu_d1=1, mu_d2=1,
s_v1=1.5, s_v2=1.5, s_d1=1.5, s_d2=1.5, t0=0.1)
two_samples <- rbind(cbind(df_low_var, variance="low"),
cbind(df_high_var, variance="high"))
two_samples <- two_samples[two_samples$response != 0, ]
# Compare RT distributions
boxplot(log(rt) ~ variance + response, data = two_samples)
# Compare confidence distributions
boxplot(conf ~ variance + response, data = two_samples)
boxplot(rating ~ variance + response, data = two_samples)
if (requireNamespace("ggplot2", quietly = TRUE)) {
require(ggplot2)
ggplot(two_samples, aes(x = rt, y = conf)) +
stat_density_2d(aes(fill = after_stat(density)), geom = "raster", contour = FALSE, na.rm=TRUE) +
facet_grid(cols = vars(variance), rows = vars(response),
labeller = "label_both") +
xlim(c(0.2, 2.0)) + ylim(c(-2, 4))
}
Run the code above in your browser using DataLab