# 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. Predict discrete Choice x Confidence distribution:
preds_Conf <- predictMTLNR_Conf(paramDf, maxrt=7, subdivisions=50)
head(preds_Conf)
# 3. Compute RT density
preds_RT <- predictMTLNR_RT(paramDf, maxrt=7, subdivisions=50)
# same output with scaled density column:
preds_RT <- predictMTLNR_RT(paramDf, maxrt=7, subdivisions=50,
scaled=TRUE, DistConf = preds_Conf)
head(preds_RT)
# \donttest{
# produces a warning, if scaled=TRUE and DistConf missing
preds_RT <- predictMTLNR_RT(paramDf, maxrt=7, subdivisions=50,
scaled=TRUE)
# }
# \donttest{
# Example of visualization
library(ggplot2)
preds_Conf$rating <- factor(preds_Conf$rating, labels=c("unsure", "medium", "sure"))
preds_RT$rating <- factor(preds_RT$rating, labels=c("unsure", "medium", "sure"))
ggplot(preds_Conf, aes(x=interaction(rating, response), y=p))+
geom_bar(stat="identity")+
facet_grid(cols=vars(stimulus), rows=vars(condition), labeller = "label_both")
ggplot(preds_RT, aes(x=rt, color=interaction(rating, response), y=dens))+
geom_line(stat="identity")+
facet_grid(cols=vars(stimulus), rows=vars(condition), labeller = "label_both")+
theme(legend.position = "bottom")
ggplot(aggregate(densscaled~rt+correct+rating+condition, preds_RT, mean),
aes(x=rt, color=rating, y=densscaled))+
geom_line(stat="identity")+
facet_grid(cols=vars(condition), rows=vars(correct), labeller = "label_both")+
theme(legend.position = "bottom")
# }
# \donttest{
# Use PDFtoQuantiles to get predicted RT quantiles
# (produces warning because of few rt steps (--> inaccurate calculations))
PDFtoQuantiles(preds_RT, scaled = FALSE)
# }
# 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)
preds_Conf_asym <- predictMTLNR_Conf(paramDf_asym, maxrt=7, subdivisions=50)
head(preds_Conf_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)
preds_Conf_multi <- predictMTLNR_Conf(paramDf_multi, maxrt=7, subdivisions=50)
head(preds_Conf_multi)
Run the code above in your browser using DataLab