---
title: "SPSS Compatibility"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{SPSS Compatibility}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

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

The statistical functions of **mariposa** are checked against reference
output of IBM SPSS Statistics 29. This article lists, for each function,
how many SPSS values its tests compare and which results are not compared
with SPSS.

*mariposa 0.7.4, status of 2026-10-19.*

## Summary

- **42** of 53 statistical functions are compared with SPSS output,
  with **14,622** SPSS values in total.
- **2** documented algorithmic differences (see below).

## How results are compared

Each comparison uses the precision with which SPSS prints the value:

- **Exact**: counts, degrees of freedom, and p-values that SPSS prints as
  `.000` (p < .001).
- **Printed precision**: all other values agree with SPSS to within half a
  unit of the last decimal SPSS prints (one unit for p-values).
- **Documented difference**: where SPSS and mariposa use different
  algorithms by design, the values agree within the tolerance listed under
  "Documented differences".

The reference values come from SPSS syntax runs on the `survey_data`
example data. The comparisons run with the package's test suite on every
change; the SPSS syntax and output are part of the source repository
([tests/spss_reference](https://github.com/YannickDiehl/mariposa/tree/main/tests/spss_reference)).

## Results by function

The `w_*()` functions share one set of SPSS references; each row shows
that total. The last column lists results that are not compared with
SPSS output. They are verified by other means: the weighted results of
the rank-based tests reproduce the unweighted results exactly when all
weights equal 1 (the weighted Mann-Whitney test also agrees with
`survey::svyranktest()`), and the remaining results are checked against
published formulas or independent implementations.

| Function | SPSS values | Exact | Printed precision | Documented difference | Not compared with SPSS |
|---|---:|---:|---:|---:|---|
| `ancova()` | 800 | 147 | 653 | 0 | — |
| `binomial_test()` | 58 | 24 | 34 | 0 | weighted results |
| `chi_square()` | 235 | 53 | 182 | 0 | — |
| `chisq_gof()` | 133 | 51 | 82 | 0 | — |
| `crosstab()` | 3,369 | 1,419 | 1,950 | 0 | adjusted standardized residuals |
| `describe()` | 288 | 18 | 270 | 0 | — |
| `dunn_test()` | 6 | 0 | 6 | 0 | weighted results |
| `efa()` | 578 | 21 | 473 | 84 | — |
| `factorial_anova()` | 609 | 200 | 409 | 0 | — |
| `fisher_test()` | 412 | 100 | 312 | 0 | — |
| `frequency()` | 150 | 24 | 126 | 0 | — |
| `friedman_test()` | 56 | 18 | 38 | 0 | weighted results |
| `kendall_tau()` | 202 | 100 | 102 | 0 | weighted results |
| `kruskal_wallis()` | 97 | 52 | 45 | 0 | weighted results |
| `levene_test()` | 144 | 0 | 144 | 0 | — |
| `linear_regression()` | 602 | 35 | 567 | 0 | — |
| `logistic_regression()` | 29 | 12 | 17 | 0 | all results (checked against the formulas of the SPSS algorithm) |
| `mann_whitney()` | 93 | 19 | 74 | 0 | weighted results |
| `mcnemar_test()` | 143 | 84 | 59 | 0 | — |
| `multiple_response()` | 52 | 19 | 33 | 0 | all results (checked by direct computation) |
| `normality_test()` | 21 | 6 | 15 | 0 | all results (checked against independent implementations) |
| `oneway_anova()` | 1,443 | 234 | 1,209 | 0 | — |
| `pairwise_wilcoxon()` | 242 | 106 | 136 | 0 | weighted results |
| `partial_cor()` | 20 | 4 | 16 | 0 | all results (checked against an equivalent regression computation) |
| `pearson_cor()` | 73 | 18 | 55 | 0 | — |
| `reliability()` | 458 | 45 | 413 | 0 | McDonald's omega |
| `scheffe_test()` | 1,422 | 0 | 1,422 | 0 | — |
| `spearman_rho()` | 238 | 118 | 120 | 0 | — |
| `t_test()` | 673 | 9 | 664 | 0 | — |
| `tukey_test()` | 1,418 | 0 | 1,418 | 0 | — |
| `w_iqr()` | 444 | 132 | 312 | 0 | — |
| `w_kurtosis()` | 444 | 132 | 312 | 0 | — |
| `w_mean()` | 444 | 132 | 312 | 0 | — |
| `w_median()` | 444 | 132 | 312 | 0 | — |
| `w_modus()` | 444 | 132 | 312 | 0 | — |
| `w_quantile()` | 444 | 132 | 312 | 0 | — |
| `w_range()` | 444 | 132 | 312 | 0 | — |
| `w_sd()` | 444 | 132 | 312 | 0 | — |
| `w_se()` | 444 | 132 | 312 | 0 | — |
| `w_skew()` | 444 | 132 | 312 | 0 | — |
| `w_var()` | 444 | 132 | 312 | 0 | — |
| `wilcoxon_test()` | 114 | 48 | 66 | 0 | weighted results |

## Documented differences

| Function | Results | Tolerance | Reason |
|---|---|---:|---|
| `efa()` | ML loadings, sums of squares, % of variance | 0.002 | SPSS stops the ML iteration at its convergence criterion (.001); mariposa iterates to the optimum. |
| `efa()` | ML communalities / SS where SPSS did not converge | 0.05 | The SPSS reference runs end without convergence (3 factors from 6 items, df = 0, Heywood cases). |

A documented difference describes a known difference between
the algorithms, not an error; its tolerance is the agreement the
two algorithms reach.

## Functions without their own SPSS comparison

- Computed by `chi_square()`, whose results are compared with SPSS: `cramers_v()`, `goodman_gamma()`, `phi()`
- Data transformations, covered by unit tests: `center()`, `pomps()`, `rec()`, `row_count()`, `row_means()`, `row_sums()`, `std()`
- Data documentation without an SPSS counterpart: `codebook()`

