Handling an Inconsistently Coded Categorical Variable in a Longitudinal Dataset
Overview
Unifying an inconsistently coded categorical variable between two different time points in accordance with a mapping table. The main rule is to replicate the observation if it could be assigned to a few categories. Then using frequencies or statistical methods to approximate the probabilities of being assigned to each of them. This procedure was invented and implemented in the paper by 'Nasinski', 'Majchrowska', and 'Broniatowska' (2020) doi:10.24425/cejeme.2020.134747.
This release incorporates feedback from the PhD dissertation reviewers: dr hab. Andrzej Dudek, dr hab. Joanna Landmesser-Rusek, and dr hab. Paweł Andrzej Strzelecki.
New features
- New
occup_paneldataset - a rotational panel covering 2009Q1--2010Q4 - used to illustrateid_vardirect matching and to exercise the panel-data code path in tests. - Naive Bayes (
"nb") added to the supported ML methods, viae1071(Suggests). summary_c2c()now supports bothlmandglm, adds input/shape validation (df_old/df_new, coefficient table checks), and reports the reference distribution used for p-values (tor normal). Added edge-case tests and aligned regression/panel vignette examples with currentsummary_c2c()output and fixed-effects inference guidance.cat2cat_ml_run()now reports the Brier score and mean P(true class) in addition to accuracy. A proper scoring rule matters becausecat2catweights are *probabilities*, not classifications - a model can be accurate and still be poorly calibrated.- All
stopifnot()assertions now carry descriptive messages, so failures point the user at the offending argument instead of printing the raw expression. cat2cat()ML fallback is now configurable viaml$on_fail("freq","naive","na","error") with optional warning control viaml$fail_warn. Failed ML weights are now explicitly handled according to this policy instead of always silently falling back to frequency weights.cat2cat()ML now acceptsfactorfeatures in addition to numeric/logical: factor columns listed inml$featuresare automatically one-hot encoded using the union of levels observed inml$dataand the target period.
Documentation
- Vignettes reorganised into three clearer guides: *Get Started*, *Choosing Weights and Validating ML*, and *Advanced Workflows*. The goal is a cleaner reader path: core concepts first, method choice second, advanced workflows third.
- *Get Started* now focuses on the two-period workflow, core assumptions, and the value added of cat2cat for group-level longitudinal analysis, with sharper pointers to the more advanced guides.
Show all changes in 0.6.1Hide the rest of the changes in 0.6.1
- *Choosing Weights and Validating ML* is now structured as a decision guide: understanding weight assumptions, checking robustness across methods, validating ML against naive/frequency baselines, and handling failed ML predictions.
- *Advanced Workflows* now collects ML setup, multi-period chaining, rotational panels with
id_var, aggregated-data workflows, hierarchical-code mappings, and regression/inference after harmonisation into one better-structured advanced reference. - Added a *When cat2cat won't help* section distinguishing hard blockers (no mapping table, unobserved category) from method-specific limitations with available workarounds.
- Corrected the $R^2$ guidance: ordinary $R^2$ is preserved in neutral replication cases when replicated copies keep the same response/covariates and weights sum back to the source observation; adjusted $R^2$, AIC, and BIC require original-scale degrees-of-freedom care, and fit statistics with harmonised-category covariates are conditional on the chosen weights.
- Roxygen for
cat2cat()andcat2cat_agg()trimmed - argument documentation kept, conceptual material moved to the vignettes where it belongs.
Bug fixes
- Fixed the
nomnomldiagram that previously mislabelled the base/target sides under forward mapping. - Fixed
get_freqs()forr-devel/R CMD check: replacedas.data.frame(table(...))conversion with directdata.frame(input = names(tab), Freq = as.integer(tab))construction to avoid failures whenNAappears in table names (row names contain missing values).
From NEWS.md in the release
Install
Health
- OK13 OK2026-08-05
- NOTE12 OK, 1 NOTE2026-08-01
- OK13 OK2026-06-09
- ERROR12 OK, 1 ERROR2026-06-08
- OK13 OK2026-05-09
Show 2 earlier changesHide 2 earlier changes
- ERROR12 OK, 1 ERROR2026-05-03
- OK14 OK2026-03-10
Documentation
- Help pages
- 22 (5 internal)
- Examples that run
- 67%10 run in a plain check · 1 only when donttest examples are enabled (R CMD check --as-cran) · 4 never run
- Exported functions with examples
- 100%
- Documented parameters
- 80%
- Return-value docs
- 100%
- Help pages citing references
- 0%
Downloads
Repository
- PRs merged (all time)
- 88%
- Median days to close, 50 most recently updated closed issues
- 39
- Median days to close, 50 most recently updated closed PRs
- 3
Stars over time
Forks over time
Releases over time
Issues over time
PRs over time
10 development-tooling and community-health practices detected across 7 families in the upstream repository
Checks run against github.com/polkas/cat2cat on 2026-10-22.
The R CMD check workflow runs on Linux, macOS and Windows, and on R-devel
GitHub Pages site last deployed 2026-05-17 · The repository has a site deploy workflow
pkgdown site last built 2026-05-17
Show all practicesHide 3 practices
Dependencies
Installing cat2cat adds no packages beyond those that come with R.
Code & Tests
Datasets
People & History
Pick two releases to compare their code metrics.
- 0.6.1Latest
- RR 4.6.0 released · 2026-04-24
- RR 4.5.0 released · 2025-04-11
- RR 4.4.0 released · 2024-04-24
- 0.4.7
- RR 4.3.0 released · 2023-04-21
- 0.4.62023-02-01 · diff ↗
- 0.4.52022-09-25 · diff ↗
- 0.4.42022-08-31 · diff ↗
- 0.4.22022-08-05 · diff ↗
- 0.4.1
- RR 4.2.0 released · 2022-04-22
- 0.3.32022-03-11 · diff ↗
- 0.3.12022-02-06 · diff ↗
- RR 4.1.0 released · 2021-05-18
- 0.2.12021-03-27 · diff ↗
Package metadata
- First published
- 2020-09-22
- Total releases
- 13 / 6 yrs
- License
- GPL (>= 2) | file LICENSE OSI
- Minimum R
- ≥ 3.6
- Bundled data
- 2.2 MB / 6 files
- Download size
- 2.4 MB
Cite
Cite this package
Run in R for the authors' entry:
citation("cat2cat")The package provides a citation file, so citation() returns the authors' own entry.
It points to 10.1016/j.softx.2023.101525.
Cite the R Observatory
For a number measured here: a download total, a coverage figure, an archival date.
From data release v2026-10-24, which the citation names so these numbers can be found later. More on citing and the projects behind them.