## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

## ----setup--------------------------------------------------------------------
library(tempodisco)

## -----------------------------------------------------------------------------
data("td_bc_single_ptpt")
rt_cutoffs <- quantile(td_bc_single_ptpt$rt, c(0.025, 0.975))
td_bc_single_ptpt <- subset(td_bc_single_ptpt, rt_cutoffs[1] < rt & rt < rt_cutoffs[2])

## -----------------------------------------------------------------------------
ddm <- td_ddm(td_bc_single_ptpt, discount_function = 'exponential',
              gamma_par_starts = 0.01,
              beta_par_starts = 0.5,
              alpha_par_starts = 3.5,
              tau_par_starts = 0.9)
print(ddm)

## -----------------------------------------------------------------------------
plot(ddm, log = 'x', verbose = F, p_lines = c(0.25, 0.75))

## -----------------------------------------------------------------------------
predicted_rts <- predict(ddm, type = 'rt')
cor.test(predicted_rts, ddm$data$rt)

## -----------------------------------------------------------------------------
plot(ddm, type = 'rt', q_lines = c(0.05, 0.95), ylim = c(1, 9))

## -----------------------------------------------------------------------------
ddm_sig <- td_ddm(td_bc_single_ptpt,
                  discount_function = 'exponential',
                  drift_transform = 'logis',
                  gamma_par_starts = 0.01,
                  beta_par_starts = 0.5,
                  alpha_par_starts = 3.5,
                  tau_par_starts = 0.9)
print(BIC(ddm))
print(BIC(ddm_sig))

## -----------------------------------------------------------------------------
plot(ddm_sig, type = 'link')

