# minimal_example

The following is a minimal example of a simple model fit.

    # Load libraries
    library(RColorBrewer)
    library(ggplot2)
    library(dplyr)
    #>
    #> Attaching package: 'dplyr'
    #> The following objects are masked from 'package:stats':
    #>
    #>     filter, lag
    #> The following objects are masked from 'package:base':
    #>
    #>     intersect, setdiff, setequal, union
    library(reshape2)
    library(latex2exp)
    library(lddmm)

    theme_set(theme_bw(base_size = 14))
    cols <- brewer.pal(9, "Set1")

    # Load the data
    data('data')

    # Descriptive plots
    plot_accuracy(data)
    plot_RT(data)

    # Run the model
    hypers <- NULL
    hypers$s_sigma_mu <- hypers$s_sigma_b <- 0.1

    # Change the number of iterations when running the model
    # Here the number is small so that the code can run in less than 1 minute
    Niter <- 25
    burnin <- 15
    thin <- 1
    samp_size <- (Niter - burnin) / thin

    set.seed(123)
    fit <- LDDMM(data = data,
                 hypers = hypers,
                 Niter = Niter,
                 burnin = burnin,
                 thin = thin)

    # Plot the results
    plot_post_pars(data, fit, par = 'drift')
    plot_post_pars(data, fit, par = 'boundary')

    # Compute the WAIC to compare models
    compute_WAIC(fit)

To extract relevant posterior draws or posterior summaries instead of simply plotting them, one can use the functions `extract_post_mean` or `extract_post_draws`. Auxiliary functions that assume constant boundary parameters over time (\(b_{d,s}^{(i)}(t) = b_{d,s} + u_{d,s}^{(i)}\) using the article notation) or fix the boundaries to the same level across input predictors (\(b_{d,s}^{(i)}(t) = b_{d}(t) + u^{(i)}_{d}(t)\) using the article notation) can be called with the options `boundaries = "constant"` and `boundaries = "fixed"`, respectively.