---
lang: en-GB
title: "Scale reliability and validity"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Scale reliability and validity}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r setup, include = FALSE}
knitr::opts_chunk$set(collapse = TRUE, comment = "#>")
library(surveyframe)
library(knitr)
```

```{=html}
<style>
body { color: #1a1a2e; }
h1, h2, h3 { color: #1a1a2e; }
a { color: #0e7c7a; }
table { border-collapse: collapse; margin: 1em 0; }
table caption { caption-side: top; font-style: italic; color: #444; padding-bottom: .3em; }
th { border-top: 2px solid #1a1a2e; border-bottom: 1px solid #1a1a2e; padding: 6px 12px; }
td { padding: 5px 12px; border: none; }
tbody tr:last-child td { border-bottom: 2px solid #1a1a2e; }
/* WCAG 2.2 AA pass: darker link and syntax-token colours (at least
   4.5:1 on the #f7f7f7 code background), wrapped code lines instead of a
   keyboard-inaccessible scroll region, empty per-line anchors removed from
   the accessibility tree, and 24px minimum TOC link targets. */
code span.at { color: #576419; }
code span.dv, code span.fl, code span.bn { color: #276245; }
code span.co { color: #396a80; }
pre, pre code { white-space: pre-wrap; word-break: break-word; }
div.sourceCode { overflow: visible; }
pre.sourceCode a:empty { display: none; }
#TOC a { display: inline-block; min-height: 24px; }
</style>
```

Measurement quality is part of the research design. This vignette works through
the reliability and validity evidence from the published Thailand digital
marketing study (Sharafuddin, Madhavan, and Wangtueai 2024). The reliability and
item reports read scale definitions from an instrument, so they are shown on the
bundled tourism demo, a synthetic companion to the study. The validity summary
runs on the loadings the paper reported, which needs no raw data.

## Reliability from the instrument

`reliability_report()` reads the scale definitions and reports Cronbach's alpha
and, with the optional `psych` package, McDonald's omega. The published study
reported strong reliability for every construct. At the higher-order level the
alpha and composite reliability were 0.828 and 0.883 for digital marketing
effectiveness, 0.792 and 0.906 for service quality, 0.769 and 0.843 for
sustainability quality, 0.897 and 0.936 for satisfaction, and 0.921 and 0.950
for behavioural intention.

```{r reliability, eval = requireNamespace("psych", quietly = TRUE)}
demo      <- sframe_demo_data()
instr     <- demo$instrument
responses <- demo$responses

rr <- reliability_report(responses, instr, omega = TRUE)
rel_df <- do.call(rbind, lapply(rr, function(s) data.frame(
  Scale   = paste0(s$label, " (", s$scale_id, ")"),
  Items   = s$n_items,
  N       = s$n,
  Alpha   = if (!is.null(s$alpha))   sprintf("%.2f", s$alpha)   else "n/a",
  Omega_h = if (!is.null(s$omega_h)) sprintf("%.2f", s$omega_h) else "n/a",
  Omega_t = if (!is.null(s$omega_t)) sprintf("%.2f", s$omega_t) else "n/a",
  stringsAsFactors = FALSE)))
kable(rel_df, row.names = FALSE,
      col.names = c("Scale", "Items", "N", "Alpha", "Omega h", "Omega total"),
      align = c("l", "c", "c", "r", "r", "r"),
      caption = "Scale reliability statistics")
```

## Item diagnostics

Item diagnostics identify sparse items, weak item-total relationships, and floor
or ceiling effects. These are the item-level facts behind a retention decision.

```{r item-report}
demo      <- sframe_demo_data()
instr     <- demo$instrument
responses <- demo$responses

items <- item_report(responses, instr)
first  <- items[[1]]
kable(first$diagnostics, digits = 2,
      caption = paste0("Item diagnostics: ", first$label, " (", first$scale_id, ")"))
```

## EFA readiness

`efa_report()` reports the Kaiser-Meyer-Olkin measure and Bartlett's test as a
screening step before a confirmatory model.

```{r efa, eval = requireNamespace("psych", quietly = TRUE)}
efa_report(responses, instr)
```

## Convergent validity from the published loadings

This step needs no raw data. `validity_report()` computes composite reliability
and average variance extracted from standardised loadings. Feeding the outer
loadings reported in the paper reproduces its convergent validity, which is a
direct check of the measurement model.

```{r validity}
published_loadings <- list(
  DMRE = c(dmre_1 = .815, dmre_2 = .899, dmre_3 = .668, dmre_4 = .838),
  DMAU = c(dmau_1 = .843, dmau_2 = .915, dmau_3 = .920),
  DMEU = c(dmeu_1 = .897, dmeu_2 = .929, dmeu_3 = .932),
  DMPV = c(dmpv_1 = .818, dmpv_2 = .916, dmpv_3 = .900, dmpv_4 = .863),
  DSQA = c(dsqa_1 = .904, dsqa_2 = .920, dsqa_3 = .869),
  DSQT = c(dsqt_1 = .778, dsqt_2 = .883, dsqt_3 = .879, dsqt_4 = .811, dsqt_5 = .713),
  DSUQ = c(dsuq_1 = .780, dsuq_2 = .855, dsuq_3 = .845, dsuq_4 = .551, dsuq_5 = .529),
  TS   = c(ts_1 = .912, ts_2 = .950, ts_3 = .869),
  BI   = c(bi_1 = .937, bi_2 = .911, bi_3 = .940)
)

validity <- validity_report(published_loadings)
kable(validity$reliability, digits = 2,
      caption = "Composite reliability and average variance extracted")
```

The average variance extracted exceeds 0.5 for every construct, and the
composite reliability exceeds 0.7, so each construct explains more than half the
variance in its items. The sustainability construct sits lowest, in line with
the two weaker items the paper flagged (DSUQ4 and DSUQ5).

## Discriminant validity

The study assessed discriminant validity in two ways. The Fornell-Larcker
criterion compares the square root of a construct's AVE with its correlations
with the others. The square roots, 0.810 for digital marketing effectiveness,
0.910 for service quality, 0.726 for sustainability quality, 0.911 for
satisfaction, and 0.930 for behavioural intention, each exceeded the
off-diagonal correlations. The Heterotrait-Monotrait ratios were all below the
0.90 threshold, the highest being 0.766 between ease of use and accessibility.
Both results support discriminant validity.

When construct scores are available, `validity_report()` returns the
Fornell-Larcker matrix and the HTMT matrix directly.

```{r validity-scores, eval = FALSE}
validity_report(published_loadings, construct_scores = scored_constructs)
```

## Collinearity

The study reported variance inflation factors below 5 for every indicator, which
indicates no severe multicollinearity. `assumption_report()` returns variance
inflation factors when a regression is specified, which is shown in the
analysing-responses vignette.

## Cautious interpretation

Reliability and validity summaries are diagnostics, not automatic decisions.
Read them with the questionnaire wording, the sampling context, the construct
definitions, and the planned model in view.
