20  Installation Guide

To install in one go all the packages used in this textbook, run the following code.

# ==============================================================================
# PsyStatsPracticals environment setup
# Install and load all packages used at
# https://kosugitti.github.io/PsyStatsPracticals/
# ==============================================================================

# ------------------------------------------------------------------------------
# Package manager
# ------------------------------------------------------------------------------
if (!requireNamespace("pacman", quietly = TRUE)) {
  install.packages("pacman")
}

# ------------------------------------------------------------------------------
# Core and data manipulation
# ------------------------------------------------------------------------------
pacman::p_load(
  tidyverse,    # meta-package for dplyr, ggplot2, tidyr, forcats, ...
  broom         # tidy model output
)

# ------------------------------------------------------------------------------
# Visualisation
# ------------------------------------------------------------------------------
pacman::p_load(
  ggplot2,      # bundled in tidyverse but loaded standalone in some chapters
  patchwork,    # combining plots
  gridExtra,    # arranging plots
  RColorBrewer, # colour palettes
  ggrepel,      # avoid label overlap
  corrplot,     # correlation-matrix visualisation
  GGally,       # pair plots
  bayesplot,    # MCMC visualisation
  qgraph,       # network diagrams
  semPlot,      # SEM path diagrams
  lavaanPlot    # lavaan result visualisation
)

# ------------------------------------------------------------------------------
# General statistics and multivariate analysis
# ------------------------------------------------------------------------------
pacman::p_load(
  psych,        # general psychometric utilities
  car,          # regression diagnostics (Anova, etc.)
  MASS,         # multivariate normal RNG and others
  effsize,      # effect sizes
  pwr,          # power analysis
  e1071,        # skewness, kurtosis, fuzzy c-means, ...
  mclust        # Gaussian mixture clustering
)

# ------------------------------------------------------------------------------
# Regression and mixed models
# ------------------------------------------------------------------------------
pacman::p_load(
  lmerTest,     # linear mixed-effects models
  multilevel    # ICC and related tools
)

# ------------------------------------------------------------------------------
# Bayesian
# ------------------------------------------------------------------------------
pacman::p_load(
  brms,         # Stan front-end
  cmdstanr,     # CmdStan interface
  bayestestR    # posterior summaries
)
# Note: cmdstanr is distributed by the Stan-dev repository, not by CRAN.
#       If not yet installed:
#       install.packages("cmdstanr",
#         repos = c("https://stan-dev.r-universe.dev", getOption("repos")))
#       After installation, install CmdStan itself with cmdstanr::install_cmdstan().

# ------------------------------------------------------------------------------
# Structural equation modelling
# ------------------------------------------------------------------------------
pacman::p_load(
  lavaan        # SEM
)

# ------------------------------------------------------------------------------
# Item response theory and test theory
# ------------------------------------------------------------------------------
pacman::p_load(
  ltm,          # unidimensional IRT
  mirt,         # multidimensional IRT
  exametrika    # integrated test theory
)

# ------------------------------------------------------------------------------
# Multidimensional scaling
# ------------------------------------------------------------------------------
pacman::p_load(
  smacof        # MDS
)

# ------------------------------------------------------------------------------
# Text mining
# ------------------------------------------------------------------------------
pacman::p_load(
  gibasa        # Japanese morphological analysis
)
# Note: gibasa relies on a MeCab (or mecab-ipadic-neologd) installation. On
# macOS, `brew install mecab mecab-ipadic` is the usual route. The text-mining
# example in Chapter 16 is Japanese-language; for other languages, substitute
# an appropriate tokeniser.