Add diagnostics report PDF

This commit is contained in:
aseimel
2026-06-15 16:40:43 +02:00
parent bc2d616605
commit e2b0b1a025
9 changed files with 64 additions and 10 deletions
+1
View File
@@ -10,6 +10,7 @@ data/releases/
data/releases/*
!data/releases/SHA256SUMS
!data/releases/party_2d_diagnostics_report_*.md
!data/releases/party_2d_diagnostics_report_*.pdf
data/*.csv
!data/text_data.csv
!data/expert.csv
+2 -1
View File
@@ -1,3 +1,4 @@
b110155089daec726f781c5ab49d4ba5cb378f4402d1eddbbf34007b4b734dc8 party_2d_election_year_panel_v0.csv.gz
86773993d65f34d5813ca3ce1ebdde643d1c3a9993ccc342301fae3d1b106304 party_2d_annual_model_output_v0.csv.gz
2331fb6b1f7971be812c28b65dac743951030571e8146ca7b1fdd2f3237b4dbe party_2d_diagnostics_report_v0.md
bb69e71165dd3ea0276da3046fea6d1bf0422ddf48c71686ed498069fd323e26 party_2d_diagnostics_report_v0.md
11cbdfd3983bf2edc22bb18ca0b7c667f35a90b7081a74b9a16abc6824b41438 party_2d_diagnostics_report_v0.pdf
@@ -1,12 +1,16 @@
# Diagnostics report
Generated: 2026-06-15 16:21:39 CEST
Generated: 2026-06-15 16:40:02 CEST
Release: v0
Model positions source: `party_positions_2026-06-12_16-35-01.csv`
## Purpose
The purpose of this report is to provide the appendix-style diagnostics that document how the released party-position estimates are constructed, checked, and validated. The main article reports the central validation evidence; this report keeps the larger technical tables with the release so readers can inspect item coverage, source coverage, coding orientation, harmonization, convergence, posterior uncertainty, and validation details in one reproducible place.
## Overview
This report collects the large technical diagnostics that support the Scientific Data Data Descriptor. It follows the structure of the earlier technical appendix: data and item coverage, coding and scale orientation, party-union harmonization, model convergence, and validation. The report is generated from the model-ready inputs and completed model outputs; it is not part of the raw-data setup workflow.
This report follows the structure of the technical appendix material: data and item coverage, coding and scale orientation, party-union harmonization, construct checks, model convergence, and validation. It is generated from the model-ready inputs and completed model outputs; it is not part of the raw-data setup workflow.
## Data and item coverage
Binary file not shown.
+1 -1
View File
@@ -14,4 +14,4 @@ If model outputs are stored outside the repository root, point the script to the
PARTY2D_OUTPUTS_DIR=/path/to/outputs Rscript diagnostics/generate_diagnostics.R
```
Generated files are written to `diagnostics/generated/`. The Markdown report is also copied to `data/releases/party_2d_diagnostics_report_v0.md` for the release bundle.
Generated files are written to `diagnostics/generated/`. The Markdown and PDF reports are also copied to `data/releases/` for the release bundle. PDF rendering uses R Markdown/Pandoc and requires a LaTeX engine such as `pdflatex`.
+47 -3
View File
@@ -266,9 +266,13 @@ report_lines <- c(
paste0("Release: ", release_version),
paste0("Model positions source: `", display_path(model_positions_file), "`"),
"",
"## Purpose",
"",
"The purpose of this report is to provide the appendix-style diagnostics that document how the released party-position estimates are constructed, checked, and validated. The main article reports the central validation evidence; this report keeps the larger technical tables with the release so readers can inspect item coverage, source coverage, coding orientation, harmonization, convergence, posterior uncertainty, and validation details in one reproducible place.",
"",
"## Overview",
"",
"This report collects the large technical diagnostics that support the Scientific Data Data Descriptor. It follows the structure of the earlier technical appendix: data and item coverage, coding and scale orientation, party-union harmonization, model convergence, and validation. The report is generated from the model-ready inputs and completed model outputs; it is not part of the raw-data setup workflow.",
"This report follows the structure of the technical appendix material: data and item coverage, coding and scale orientation, party-union harmonization, construct checks, model convergence, and validation. It is generated from the model-ready inputs and completed model outputs; it is not part of the raw-data setup workflow.",
"",
"## Data and item coverage",
"",
@@ -353,6 +357,44 @@ writeLines(report_lines, report_path)
release_report <- file.path(release_dir, paste0("party_2d_diagnostics_report_", release_version, ".md"))
invisible(file.copy(report_path, release_report, overwrite = TRUE))
pdf_source <- file.path(generated_dir, "diagnostics_report.Rmd")
pdf_file <- file.path(generated_dir, "diagnostics_report.pdf")
release_pdf <- file.path(release_dir, paste0("party_2d_diagnostics_report_", release_version, ".pdf"))
pdf_lines <- c(
"---",
"title: \"Diagnostics report\"",
paste0("date: \"", format(Sys.time(), "%Y-%m-%d"), "\""),
"output:",
" pdf_document:",
" toc: true",
" number_sections: true",
"geometry: margin=0.75in",
"fontsize: 9pt",
"---",
"",
report_lines[-1]
)
writeLines(pdf_lines, pdf_source)
if (!requireNamespace("rmarkdown", quietly = TRUE)) {
stop("The rmarkdown package is required to render the diagnostics PDF.")
}
rmarkdown::render(
input = pdf_source,
output_format = rmarkdown::pdf_document(toc = TRUE, number_sections = TRUE),
output_file = basename(pdf_file),
output_dir = generated_dir,
quiet = TRUE
)
invisible(file.copy(pdf_file, release_pdf, overwrite = TRUE))
unlink(c(
pdf_source,
file.path(generated_dir, "diagnostics_report.log"),
file.path(generated_dir, "diagnostics_report.aux"),
file.path(generated_dir, "diagnostics_report.out"),
file.path(generated_dir, "diagnostics_report.toc"),
file.path(generated_dir, "diagnostics_report.tex")
), force = TRUE)
generated_readme <- c(
"# Generated diagnostics",
"",
@@ -364,7 +406,7 @@ generated_readme <- c(
"",
"The command requires completed model/post-estimation outputs. If those outputs are outside the repository root, set `PARTY2D_OUTPUTS_DIR` before running the script.",
"",
"The main Markdown report is `diagnostics_report.md`; the same report is copied into `data/releases/` for the release files."
"The main reports are `diagnostics_report.md` and `diagnostics_report.pdf`; both are copied into `data/releases/` for the release files."
)
writeLines(generated_readme, file.path(generated_dir, "README.md"))
@@ -372,7 +414,8 @@ sha_file <- file.path(release_dir, "SHA256SUMS")
release_files_for_sha <- c(
paste0("party_2d_election_year_panel_", release_version, ".csv.gz"),
paste0("party_2d_annual_model_output_", release_version, ".csv.gz"),
basename(release_report)
basename(release_report),
basename(release_pdf)
)
existing_release_files <- release_files_for_sha[file.exists(file.path(release_dir, release_files_for_sha))]
sha_lines <- vapply(existing_release_files, function(f) {
@@ -385,3 +428,4 @@ writeLines(sha_lines, sha_file)
message("Diagnostics written to diagnostics/generated")
message("Release diagnostics report written to ", release_report)
message("Release diagnostics PDF written to ", release_pdf)
+1 -1
View File
@@ -8,4 +8,4 @@ Rscript diagnostics/generate_diagnostics.R
The command requires completed model/post-estimation outputs. If those outputs are outside the repository root, set `PARTY2D_OUTPUTS_DIR` before running the script.
The main Markdown report is `diagnostics_report.md`; the same report is copied into `data/releases/` for the release files.
The main reports are `diagnostics_report.md` and `diagnostics_report.pdf`; both are copied into `data/releases/` for the release files.
+6 -2
View File
@@ -1,12 +1,16 @@
# Diagnostics report
Generated: 2026-06-15 16:21:39 CEST
Generated: 2026-06-15 16:40:02 CEST
Release: v0
Model positions source: `party_positions_2026-06-12_16-35-01.csv`
## Purpose
The purpose of this report is to provide the appendix-style diagnostics that document how the released party-position estimates are constructed, checked, and validated. The main article reports the central validation evidence; this report keeps the larger technical tables with the release so readers can inspect item coverage, source coverage, coding orientation, harmonization, convergence, posterior uncertainty, and validation details in one reproducible place.
## Overview
This report collects the large technical diagnostics that support the Scientific Data Data Descriptor. It follows the structure of the earlier technical appendix: data and item coverage, coding and scale orientation, party-union harmonization, model convergence, and validation. The report is generated from the model-ready inputs and completed model outputs; it is not part of the raw-data setup workflow.
This report follows the structure of the technical appendix material: data and item coverage, coding and scale orientation, party-union harmonization, construct checks, model convergence, and validation. It is generated from the model-ready inputs and completed model outputs; it is not part of the raw-data setup workflow.
## Data and item coverage
Binary file not shown.