Running examples in ‘dynConfiR-Ex.R’ failed
The error most likely occurred in:

> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: RaceModels
> ### Title: Independent and partially anti-correlated Race Model for
> ###   Decision Confidence
> ### Aliases: RaceModels dIRM dPCRM rRM dRM rIRM rPCRM racemodels dIRM2
> ###   dIRM3
> 
> ### ** Examples
> 
> # Plot rt distribution ignoring confidence
> curve(dPCRM(x, 1, mu1=0.5, mu2=-0.5, a=1, b=1, th1=-Inf, th2=Inf, t0=0.1), xlim=c(0,2.5))
> curve(dPCRM(x, 2, mu1=0.5, mu2=-0.5, a=1, b=1, th1=-Inf, th2=Inf, t0=0.1), col="red", add=TRUE)
> curve(dIRM(x, 1, mu1=0.5, mu2=-0.5, a=1, b=1, th1=-Inf, th2=Inf, t0=0.1), lty=2,add=TRUE)
> curve(dIRM(x, 2, mu1=0.5, mu2=-0.5, a=1, b=1, th1=-Inf, th2=Inf, t0=0.1),
+       col="red", lty=2, add=TRUE)
> # t0 indicates minimal response time possible
> abline(v=0.1)
> ## Following example may be equivalently used for the IRM model functions.
> # Generate a random sample
> df1 <- rPCRM(5000,  mu1=0.2, mu2=-0.2, a=1, b=1, t0=0.1,
+             wx = 1) # Balance of Evidence
> # Same RT and response distribution but different confidence distribution
> df2 <- rPCRM(5000,  mu1=0.2, mu2=-0.2, a=1, b=1, t0=0.1,
+              wint = 0.2, wrt=0.8)
> head(df1)
     rt response         xl      conf
1  0.65        1 -0.1666653 1.1666653
2 11.59        1 -6.8019691 7.8019691
3  1.89        2 -0.3117717 1.3117717
4  0.85        2  0.5670769 0.4329231
5  0.77        2  0.2080419 0.7919581
6  0.32        1 -0.1913931 1.1913931
> 
> # Compute density with rt and response as separate arguments
> dPCRM(seq(0, 2, by =0.4), response= 2, mu1=0.2, mu2=-0.2, a=1, b=1, th1=0.5,
+          th2=2, wx = 0.3, wint=0.4, wrt=0.1, t0=0.1)
[1] 0.00000000 0.26919023 0.20371811 0.10962250 0.06320931 0.03928042
> # Compute density with rt and response in data.frame argument
> df1 <- subset(df1, response !=0) # drop trials where no accumulation hit its boundary
> dPCRM(df1[1:5,], mu1=0.2, mu2=-0.2, a=1, b=1, th1=0, th2=Inf, t0=0.1)
[1] 0.449022313 0.001737302 0.051678757 0.215121579 0.244686625
> # s1 and s2 scale other decision relevant parameters
>  s <- 2  # common (equal) standard deviation
> dPCRM(df1[1:5,], mu1=0.2*s, mu2=-0.2*s, a=1*s, b=1*s, th1=0, th2=Inf, t0=0.1, s1=s, s2=s)
[1] 0.449022313 0.001737302 0.051678757 0.215121579 0.244686625
> s1 <- 2  # different standard deviations
> s2 <- 1.5
> dPCRM(df1[1:5,], mu1=0.2*s1, mu2=-0.2*s2, a=1*s1, b=1*s2, th1=0, th2=Inf, t0=0.1, s1=s1, s2=s2)
[1] 0.449022313 0.001737302 0.051678757 0.215121579 0.244686625
> 
> 
> # s1 and s2 scale also confidence parameters
> df1[1:5,]$response <- 2   # set response to 2
> # for confidence it is important to scale confidence parameters with
> # the right variation parameter (the one of the loosing accumulator)
> dPCRM(df1[1:5,], mu1=0.2, mu2=-0.2, a=1, b=1,
+      th1=0.5, th2=2, wx = 0.3, wint=0.4, wrt=0.1, t0=0.1)
[1] 0.253627090 0.000290214 0.044476406 0.188375881 0.213369269
> dPCRM(df1[1:5,], mu1=0.2*s1, mu2=-0.2*s2, a=1*s1, b=1*s2,
+       th1=0.5, th2=2, wx = 0.3/s1, wint = 0.4/s1, wrt = 0.1, t0=0.1, s1=s1, s2=s2)
[1] 0.253627090 0.000290214 0.044476406 0.188375881 0.213369269
> dPCRM(df1[1:5,], mu1=0.2*s1, mu2=-0.2*s2, a=1*s1, b=1*s2,
+       th1=0.5*s1, th2=2*s1, wx = 0.3, wint = 0.4, wrt = 0.1*s1, t0=0.1, s1=s1, s2=s2)
[1] 0.253627090 0.000290214 0.044476406 0.188375881 0.213369269
> 
> two_samples <- rbind(cbind(df1, ws="BoE"),
+                    cbind(df2, ws="RT"))
> # drop not finished decision processes
> two_samples <- two_samples[two_samples$response!=0,]
> # no difference in RT distributions
> boxplot(rt~ws+response, data=two_samples)
> # but different confidence distributions
> boxplot(conf~ws+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, h=c(0.3, 0.7)) +
+   xlim(c(0.2, 1.3))+ ylim(c(0, 2.5))+
+   facet_grid(cols=vars(ws), rows=vars(response), labeller = "label_both")
+ }
Loading required package: ggplot2
Error in `stat_density_2d()`:
! Problem while computing stat.
ℹ Error occurred in the 1st layer.
Caused by error in `compute_layer()`:
! The package "MASS" is required for calculating 2D density.
Backtrace:
     ▆
  1. ├─base (local) `<fn>`(x)
  2. ├─ggplot2 (local) `print.ggplot2::ggplot`(x)
  3. │ ├─ggplot2::ggplot_build(x)
  4. │ └─ggplot2 (local) `ggplot_build.ggplot2::ggplot`(x)
  5. │   └─ggplot2:::by_layer(...)
  6. │     ├─rlang::try_fetch(...)
  7. │     │ ├─base::tryCatch(...)
  8. │     │ │ └─base (local) tryCatchList(expr, classes, parentenv, handlers)
  9. │     │ │   └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
 10. │     │ │     └─base (local) doTryCatch(return(expr), name, parentenv, handler)
 11. │     │ └─base::withCallingHandlers(...)
 12. │     └─ggplot2 (local) f(l = layers[[i]], d = data[[i]])
 13. │       └─l$compute_statistic(d, layout)
 14. │         └─ggplot2 (local) compute_statistic(..., self = self)
 15. │           └─self$stat$compute_layer(data, self$computed_stat_params, layout)
 16. │             └─ggplot2 (local) compute_layer(..., self = self)
 17. │               └─rlang::check_installed("MASS", reason = "for calculating 2D density.")
 18. │                 └─base::stop(cnd)
 19. └─rlang (local) `<fn>`(`<rlb_r___>`)
 20.   └─handlers[[1L]](cnd)
 21.     └─cli::cli_abort(...)
 22.       └─rlang::abort(...)
Execution halted