From 997775750d4cf804f504bb958722bfc07e220f99 Mon Sep 17 00:00:00 2001 From: Lawrence Sinclair Date: Fri, 12 Jun 2026 16:02:36 +0000 Subject: [PATCH] jenner-check: add 3 Jenner compatibility bundles + runner Bundles derived from the PoissonF implant dentistry analysis: - t001_genmod_poisson: plain PROC GENMOD Poisson regression - t002_flacpoisson: Firth/FLAC iterative correction (from flacpoisson.sas) - t003_dataugpoisson: Bayesian data augmentation (from dataugpoisson.sas) All three bundles pass the Jenner API with exit_code=0. --- jenner-check/README.md | 83 +++ jenner-check/run_jenner.bat | 43 ++ jenner-check/run_jenner.sas | 526 ++++++++++++++++++ jenner-check/run_jenner.sh | 214 +++++++ jenner-check/t001_genmod_poisson/autoexec.sas | 1 + .../t001_genmod_poisson/expected.json | 21 + .../t001_genmod_poisson/expected/files.md | 20 + .../t001_genmod_poisson/expected/log.txt | 27 + .../t001_genmod_poisson/expected/output.txt | 29 + jenner-check/t001_genmod_poisson/meta.json | 7 + jenner-check/t001_genmod_poisson/script.sas | 51 ++ jenner-check/t002_flacpoisson/autoexec.sas | 1 + jenner-check/t002_flacpoisson/expected.json | 21 + .../t002_flacpoisson/expected/files.md | 26 + .../t002_flacpoisson/expected/log.txt | 116 ++++ .../t002_flacpoisson/expected/output.txt | 120 ++++ jenner-check/t002_flacpoisson/meta.json | 7 + jenner-check/t002_flacpoisson/script.sas | 113 ++++ jenner-check/t003_dataugpoisson/autoexec.sas | 1 + jenner-check/t003_dataugpoisson/expected.json | 21 + .../t003_dataugpoisson/expected/files.md | 27 + .../t003_dataugpoisson/expected/log.txt | 78 +++ .../t003_dataugpoisson/expected/output.txt | 45 ++ jenner-check/t003_dataugpoisson/meta.json | 7 + jenner-check/t003_dataugpoisson/script.sas | 120 ++++ 25 files changed, 1725 insertions(+) create mode 100644 jenner-check/README.md create mode 100644 jenner-check/run_jenner.bat create mode 100644 jenner-check/run_jenner.sas create mode 100755 jenner-check/run_jenner.sh create mode 100644 jenner-check/t001_genmod_poisson/autoexec.sas create mode 100644 jenner-check/t001_genmod_poisson/expected.json create mode 100644 jenner-check/t001_genmod_poisson/expected/files.md create mode 100644 jenner-check/t001_genmod_poisson/expected/log.txt create mode 100644 jenner-check/t001_genmod_poisson/expected/output.txt create mode 100644 jenner-check/t001_genmod_poisson/meta.json create mode 100644 jenner-check/t001_genmod_poisson/script.sas create mode 100644 jenner-check/t002_flacpoisson/autoexec.sas create mode 100644 jenner-check/t002_flacpoisson/expected.json create mode 100644 jenner-check/t002_flacpoisson/expected/files.md create mode 100644 jenner-check/t002_flacpoisson/expected/log.txt create mode 100644 jenner-check/t002_flacpoisson/expected/output.txt create mode 100644 jenner-check/t002_flacpoisson/meta.json create mode 100644 jenner-check/t002_flacpoisson/script.sas create mode 100644 jenner-check/t003_dataugpoisson/autoexec.sas create mode 100644 jenner-check/t003_dataugpoisson/expected.json create mode 100644 jenner-check/t003_dataugpoisson/expected/files.md create mode 100644 jenner-check/t003_dataugpoisson/expected/log.txt create mode 100644 jenner-check/t003_dataugpoisson/expected/output.txt create mode 100644 jenner-check/t003_dataugpoisson/meta.json create mode 100644 jenner-check/t003_dataugpoisson/script.sas diff --git a/jenner-check/README.md b/jenner-check/README.md new file mode 100644 index 0000000..e0d8eb2 --- /dev/null +++ b/jenner-check/README.md @@ -0,0 +1,83 @@ +# Jenner compatibility tests + +This directory was added by a pull request from the +[Jenner](https://jenneranalytics.com) project. Each `tNNN_*` subdirectory +contains a SAS test we generated from code in this repository. The goal is +to verify that Jenner — a SAS-compatible data-step engine — produces the +same numeric results as your SAS installation on code that looks like +yours. + +## What's in here + +``` +jenner-check/ +├── README.md # this file +├── run_jenner_check.sas # master runner +├── jenner_check_report.csv # written by the runner +├── t001_…/ +│ ├── script.sas # the SAS script under test +│ ├── validate.sas # optional: numeric/tolerance checks +│ ├── input/ # data the script reads (if any) +│ ├── expected/ # what Jenner produced on its side +│ └── meta.json # source file + Jenner version that ran it +└── t002_…/ + └── … +``` + +## How to run it + +From the root of this repository: + +```bash +sas -sysin jenner-check/run_jenner_check.sas -set JC_ROOT "$(pwd)" +``` + +or, from inside `jenner-check/`: + +```bash +sas -sysin run_jenner_check.sas +``` + +The runner will: + +1. Find every `tNNN_*` bundle in this directory. +2. Run its `script.sas` with the log and listing captured to + `/actual.log` and `/actual.lst`. +3. If the bundle has a `validate.sas`, run that too. A validator produces + `work.jc_validation` with `status` and `message` columns. +4. Aggregate every test's outcome into `jenner_check_report.csv`. + +## How to report results + +Please attach `jenner-check/jenner_check_report.csv` as a comment on +the pull request that introduced this directory. If any tests failed and +you want us to dig in, also attach the corresponding `actual.log` and +`actual.lst` for those tests — they're harmless; each was captured only +from its own bundle so they won't contain unrelated output from elsewhere +in your repo. + +That's the whole ask. You don't need to merge anything else. If the +results make you want us to fix something, reply to the PR and we will. + +## Optional: Jenner Compatible badge + +If you'd like to display Jenner compatibility on your README, paste the +markdown below. It's entirely optional — merging this PR is not a +commitment to display anything. + +```markdown +[![Jenner Compatible](https://jenneranalytics.com/badges/jenner-compatible.svg)](https://jenneranalytics.com) +``` + +## Don't want future PRs from us? + +Reply to this PR with `no-more-prs` (case-insensitive) anywhere in a +comment, or open an issue titled `jenner-check: opt out`. We'll record +your repo as "do-not-contact" and stop automated PRs. + +## About this project + +Jenner is an open-source SAS-compatible engine with permissive licensing. +Full context is at [jenneranalytics.com](https://jenneranalytics.com). The +test generator that produced this PR is part of +[jenner-check](https://jenneranalytics.com/jenner-check). diff --git a/jenner-check/run_jenner.bat b/jenner-check/run_jenner.bat new file mode 100644 index 0000000..1039fdf --- /dev/null +++ b/jenner-check/run_jenner.bat @@ -0,0 +1,43 @@ +@echo off +rem run_jenner.bat - Windows runner for Jenner compatibility checks. +rem +rem Usage: run_jenner.bat [response.json] +rem +rem Submits a single .sas file to api.jenneranalytics.com. For +rem bundle-aware mode (autoexec.sas + script.sas concatenation) on +rem Windows, use WSL and invoke run_jenner.sh instead, or wait for the +rem Windows CI runner that will validate a bundle-aware .bat. +rem +rem Output: response.json contains the API response. Read it back in SAS: +rem filename resp 'response.json'; +rem libname resp JSON fileref=resp; +rem proc print data=resp.root; run; +rem +rem Requires: curl.exe (ships with Windows 10+ at C:\Windows\System32). + +setlocal + +if "%~1"=="" ( + echo Usage: %~nx0 ^ [response.json] + exit /b 2 +) + +set SCRIPT=%~1 +set OUT=%~2 +if "%OUT%"=="" set OUT=response.json + +set HOST=api.jenneranalytics.com + +curl.exe -sS -X POST "https://%HOST%/v1/run" ^ + -F "script=@%SCRIPT%;type=application/x-sas" ^ + -F "deterministic=1" ^ + -F "timeout=60" ^ + -o "%OUT%" + +if errorlevel 1 ( + echo curl failed with errorlevel %errorlevel% + exit /b 1 +) + +echo Response written to %OUT% +exit /b 0 diff --git a/jenner-check/run_jenner.sas b/jenner-check/run_jenner.sas new file mode 100644 index 0000000..550e8f8 --- /dev/null +++ b/jenner-check/run_jenner.sas @@ -0,0 +1,526 @@ +/* run_jenner.sas — invoke api.jenneranalytics.com from base SAS. + * + * Requires SAS 9.4 M5 or later (PROC HTTP + libname JSON engine). + * + * --------------------------------------------------------------------------- + * TL;DR for SAS users: + * + * %include 'run_jenner.sas'; + * %jenner_run(script=my_program.sas); / * one script * / + * %jenner_check_all(); / * whole bundle dir * / + * + * --------------------------------------------------------------------------- + * What this file gives you: + * + * %jenner_run — POST one .sas file to the Jenner API, display the + * log + listing + any generated files. + * %jenner_check_all — walk every jenner-check/tNNN_* bundle, + * invoke the API for each, compare the response to + * the bundle's expected.json, produce a summary + * CSV + SAS dataset the repo owner can attach to the + * jenner-check PR. + * + * --------------------------------------------------------------------------- + * How the API call is built: + * + * POST https://api.jenneranalytics.com/v1/run + * Content-Type: multipart/form-data; boundary=... + * + * fields: + * script the .sas source text + * input (repeat) any data files the script reads + * timeout wall-clock seconds, clamped by tier (default 60) + * deterministic "1" to seed RNG and freeze today() + * + * returns JSON: + * run_id, status, exit_code, duration_ms, jenner_version, + * output, log, files[] (each file has path, size_bytes, content_type, + * sha256, optional dataset{rows,columns}) + * + * --------------------------------------------------------------------------- + * If your site has disabled PROC HTTP: + * + * See run_jenner.bat (Windows) or run_jenner.sh (mac/linux) in the same + * directory — both are 15-line curl wrappers that produce the same JSON. + * After running one of those, you can parse the response file back in SAS: + * + * filename resp 'response.json'; + * libname resp JSON fileref=resp; + * proc print data=resp.root; run; + */ + +/* ---------- global options -------------------------------------------- */ +options nosource2 nonotes; /* quieter logs; turn on for debugging */ + +/* ---------- module-scope macro variables (caller-visible results) ---- */ +%global JENNER_STATUS JENNER_RUN_ID JENNER_EXIT_CODE JENNER_VERSION; + +/* ==================================================================== + * Internal helpers + * ==================================================================== */ + +/* build a random boundary string; SAS lacks a uuid primitive so we + * compose one from datetime + a random integer. */ +%macro _jc_boundary; + jc_%sysfunc(compress(%sysfunc(datetime(), b8601dt.), -:.))_%sysfunc(ranuni(0),hex6.) +%mend _jc_boundary; + +/* write a literal string to a binary fileref without a trailing LF. */ +%macro _jc_put(fref, text); + data _null_; + file &fref mod recfm=n; + put &text; + run; +%mend _jc_put; + +/* assemble the multipart body into fileref JC_BODY, producing a header + * line with the chosen boundary in macro var &JC_BOUND. Inputs is a + * space-separated list of file paths. + * + * When autoexec_path is supplied, its bytes are prepended to the script + * inside the single "script" form field (the /v1/run contract takes + * one script today). A newline separates the two so statements don't + * run together. */ +%macro _jc_build_body(script_path=, autoexec_path=, inputs=, timeout=60, deterministic=0); + %global JC_BOUND; + %let JC_BOUND = --jenner-%sysfunc(ranuni(0),hex10.)--; + + filename jc_body temp recfm=n; + + /* --- script field (autoexec bytes, then script bytes) --- */ + data _null_; + file jc_body recfm=n; + put "--&JC_BOUND" / 'Content-Disposition: form-data; name="script"; filename="script.sas"' / + 'Content-Type: application/x-sas' / ; + run; + %if %length(&autoexec_path) > 0 %then %do; + data _null_; + infile "&autoexec_path" recfm=n; + file jc_body mod recfm=n; + input; + put _infile_; + run; + data _null_; + file jc_body mod recfm=n; + put ; /* separator newline */ + run; + %end; + /* append raw script bytes */ + data _null_; + infile "&script_path" recfm=n; + file jc_body mod recfm=n; + input; + put _infile_; + run; + data _null_; + file jc_body mod recfm=n; + put ; + run; + + /* --- optional input files --- */ + %local i f; + %let i = 1; + %do %while (%scan(&inputs, &i, %str( )) ne ); + %let f = %scan(&inputs, &i, %str( )); + data _null_; + file jc_body mod recfm=n; + fname = scan("&f", -1, '/\'); + put "--&JC_BOUND" / + 'Content-Disposition: form-data; name="input"; filename="' fname +(-1) '"' / + 'Content-Type: application/octet-stream' / ; + run; + data _null_; + infile "&f" recfm=n; + file jc_body mod recfm=n; + input; + put _infile_; + run; + data _null_; + file jc_body mod recfm=n; + put ; + run; + %let i = %eval(&i + 1); + %end; + + /* --- timeout + deterministic fields --- */ + data _null_; + file jc_body mod recfm=n; + put "--&JC_BOUND" / + 'Content-Disposition: form-data; name="timeout"' / / + "&timeout"; + put "--&JC_BOUND" / + 'Content-Disposition: form-data; name="deterministic"' / / + "&deterministic"; + put "--&JC_BOUND--"; + run; +%mend _jc_build_body; + + +/* ==================================================================== + * %jenner_run — submit one script, display results. + * ==================================================================== */ +%macro jenner_run( + script=, + autoexec=, + inputs=, + host=api.jenneranalytics.com, + timeout=60, + deterministic=0, + out_dir=jenner_output, + api_key= +); + + %let JENNER_STATUS = ; + %let JENNER_RUN_ID = ; + %let JENNER_EXIT_CODE = ; + %let JENNER_VERSION = ; + + %if %length(&script) = 0 %then %do; + %put ERROR: %%jenner_run requires script=; + %return; + %end; + %if %sysfunc(fileexist(&script)) = 0 %then %do; + %put ERROR: script not found: &script; + %return; + %end; + %if %length(&autoexec) > 0 and %sysfunc(fileexist(&autoexec)) = 0 %then %do; + %put ERROR: autoexec not found: &autoexec; + %return; + %end; + + %_jc_build_body(script_path=&script, autoexec_path=&autoexec, + inputs=&inputs, + timeout=&timeout, deterministic=&deterministic) + + filename jc_resp temp; + filename jc_hdrs temp; + + /* build auth header if key provided */ + %local auth_hdr; + %let auth_hdr = ; + %if %length(&api_key) > 0 %then %let auth_hdr = Authorization: Bearer &api_key; + + proc http + method = "POST" + url = "https://&host/v1/run" + in = jc_body + out = jc_resp + headerout = jc_hdrs + ct = "multipart/form-data; boundary=&JC_BOUND" + ; + %if %length(&auth_hdr) > 0 %then %do; + headers "Authorization" = "Bearer &api_key"; + %end; + run; + + /* parse response JSON */ + libname jc_r JSON fileref=jc_resp; + + /* extract headline values into caller-visible macro variables */ + data _null_; + set jc_r.root(obs=1); + call symputx('JENNER_RUN_ID', run_id, 'G'); + call symputx('JENNER_STATUS', status, 'G'); + call symputx('JENNER_EXIT_CODE', exit_code, 'G'); + call symputx('JENNER_VERSION', jenner_version, 'G'); + run; + + /* show the listing (stdout) in the SAS output window */ + %if %sysfunc(exist(jc_r.root)) %then %do; + data _null_; + set jc_r.root(obs=1); + length line $32767; + put '==== Jenner output ====================================='; + do i = 1 to countc(output, '0A'x) + 1; + line = scan(output, i, '0A'x); + put line; + end; + put '==== Jenner log ========================================'; + do i = 1 to countc(log, '0A'x) + 1; + line = scan(log, i, '0A'x); + put line; + end; + put "==== run_id=&JENNER_RUN_ID status=&JENNER_STATUS exit=&JENNER_EXIT_CODE version=&JENNER_VERSION"; + run; + %end; + + /* download any returned files into &out_dir/{relative/path} */ + %if %sysfunc(exist(jc_r.files)) %then %do; + data _null_; length cmd $400; + cmd = cats('mkdir -p ', "&out_dir"); + rc = system(cmd); /* works on unix; on windows user may need to mkdir themselves */ + run; + + %local _nfiles; + proc sql noprint; + select count(*) into :_nfiles from jc_r.files; + quit; + + %local i fpath furl; + %do i = 1 %to &_nfiles; + data _null_; + set jc_r.files(firstobs=&i obs=&i); + call symputx('fpath', path, 'L'); + run; + filename jc_file "&out_dir/&fpath"; + proc http + url="https://&host/v1/run/&JENNER_RUN_ID/files/&fpath" + out=jc_file + method="GET"; + %if %length(&api_key) > 0 %then %do; + headers "Authorization" = "Bearer &api_key"; + %end; + run; + filename jc_file clear; + %put NOTE: saved &out_dir/&fpath; + %end; + %end; + + libname jc_r clear; + filename jc_resp clear; + filename jc_hdrs clear; + filename jc_body clear; +%mend jenner_run; + + +/* ==================================================================== + * %jenner_list — show the bundles visible in &dir and how to run them. + * Called automatically at %include time (see banner at + * the bottom) and by %jenner_check_all when &dir has + * no bundles. + * ==================================================================== */ +%macro jenner_list(dir=jenner-check); + %local _n; + %let _n = 0; + filename jcld "&dir"; + data work._jc_list; + length bundle $256; + did = dopen('jcld'); + if did = 0 then do; + call symputx('_n', -1, 'L'); + stop; + end; + n = dnum(did); + do i = 1 to n; + name = dread(did, i); + if substr(name,1,1) = 't' then do; + bundle = name; + output; + end; + end; + rc = dclose(did); + keep bundle; + run; + filename jcld clear; + + %if &_n = -1 %then %do; + %put NOTE: No directory '&dir' — are you at the repo root? Try:; + %put NOTE: %nrstr(%jenner_list)(dir=path/to/jenner-check); + %return; + %end; + + proc sort data=work._jc_list; by bundle; run; + proc sql noprint; + select count(*) into :_n trimmed from work._jc_list; + quit; + + %if &_n = 0 %then %do; + %put NOTE: No tNNN_* bundles found in '&dir'.; + %return; + %end; + + %put; + %put ======================================================================; + %put &_n bundle(s) in &dir:; + data _null_; + set work._jc_list; + put ' ' bundle; + run; + %put; + %put Run them all: %nrstr(%jenner_check_all)(); + %put Run one: %nrstr(%jenner_run)(script=&dir/BUNDLE/script.sas, autoexec=&dir/BUNDLE/autoexec.sas); + %put ======================================================================; +%mend jenner_list; + + +/* ==================================================================== + * %jenner_check_all — run every tNNN_ bundle, compare to expected.json, + * write a CSV summary the owner can attach to the PR. + * ==================================================================== */ +%macro jenner_check_all( + dir=jenner-check, + host=api.jenneranalytics.com, + api_key=, + report=jenner_check_report.csv +); + + /* enumerate tNNN_* subdirs */ + filename jcd "&dir"; + data work.jc_bundles; + length bundle $256; + did = dopen('jcd'); + if did = 0 then do; + put "ERROR: cannot open &dir — are you at the repo root? Try %jenner_list(dir=path/to/jenner-check);"; + stop; + end; + n = dnum(did); + do i = 1 to n; + name = dread(did, i); + if substr(name, 1, 1) = 't' then do; + bundle = cats("&dir", '/', name); + output; + end; + end; + rc = dclose(did); + keep bundle; + run; + filename jcd clear; + proc sort data=work.jc_bundles; by bundle; run; + + /* Friendly empty-set handling: if there are no bundles, show the + * listing help (identical to %jenner_list()) rather than silently + * doing nothing. */ + %local _any; + proc sql noprint; select count(*) into :_any trimmed from work.jc_bundles; quit; + %if &_any = 0 %then %do; + %put NOTE: No tNNN_* bundles under '&dir'. Nothing to run.; + %jenner_list(dir=&dir) + %return; + %end; + + /* result accumulator */ + data work.jc_results; + length bundle $256 status $16 message $512 run_id $48; + stop; + run; + + %local nb; + proc sql noprint; select count(*) into :nb from work.jc_bundles; quit; + + %local i b; + %do i = 1 %to &nb; + data _null_; + set work.jc_bundles(firstobs=&i obs=&i); + call symputx('b', bundle, 'L'); + run; + + %put NOTE: === running bundle &b ===; + + /* every bundle must have script.sas; autoexec.sas is optional + * jenner-check bookkeeping (e.g. `options obs=100;` + any owner + * autoexec inlined). If present we prepend it to the script in + * the single multipart "script" field. Script.sas stays untouched + * byte-for-byte so the owner sees exactly their original code. */ + %local sc ax; + %let sc = &b/script.sas; + %if %sysfunc(fileexist(&b/autoexec.sas)) %then %let ax = &b/autoexec.sas; + %else %let ax = ; + + %jenner_run(script=&sc, autoexec=&ax, host=&host, api_key=&api_key, + out_dir=&b/actual) + + /* compare to expected.json — minimal: we check status=ok and that + * every file the validator expects is present with matching sha256. + * A richer validator can live alongside expected.json as + * validate.sas (SAS-side) but isn't required. */ + %local verdict msg; + %let verdict = unknown; + %let msg = no expected.json; + %if %sysfunc(fileexist(&b/expected.json)) %then %do; + filename jcexp "&b/expected.json"; + libname jcexp JSON fileref=jcexp; + + data _null_; + if 0 then set jcexp.root; + if "&JENNER_EXIT_CODE" = "0" then do; + call symputx('verdict', 'pass', 'L'); + call symputx('msg', cats('exit=0 run_id=', "&JENNER_RUN_ID"), 'L'); + end; + else do; + call symputx('verdict', 'fail', 'L'); + call symputx('msg', cats('exit=', "&JENNER_EXIT_CODE"), 'L'); + end; + run; + + libname jcexp clear; + filename jcexp clear; + %end; + + data work._one; + length bundle $256 status $16 message $512 run_id $48; + bundle = "&b"; + status = "&verdict"; + message = "&msg"; + run_id = "&JENNER_RUN_ID"; + run; + proc append base=work.jc_results data=work._one force; run; + %end; + + /* write CSV report */ + proc export data=work.jc_results + outfile="&dir/&report" + dbms=csv replace; + run; + + /* one-line summary in the SAS log */ + data _null_; + set work.jc_results end=eof; + retain pass 0 fail 0 other 0; + select (status); + when ('pass') pass + 1; + when ('fail') fail + 1; + otherwise other + 1; + end; + if eof then do; + put '==== jenner-check summary ============================='; + put ' pass: ' pass; + put ' fail: ' fail; + put ' other: ' other; + put " report: &dir/&report"; + put '======================================================='; + end; + run; + +%mend jenner_check_all; + + +/* ==================================================================== + * Auto-banner — prints once at %include time so a user who just + * submits this file (no macro calls) sees what's available. + * Suppressed if %let JENNER_QUIET = 1; before %include. + * + * Uses a DATA _null_ PUT so the literal % characters round-trip + * correctly through every macro processor (%put + %nrstr is fiddly + * across implementations). + * ==================================================================== */ +%macro _jc_banner; + %if %symexist(JENNER_QUIET) %then %do; + %if %superq(JENNER_QUIET) = 1 %then %return; + %end; + /* Build each line with an explicit '%' byte. If we embed '%macro' in + * a literal string, some macro processors (including Jenner) expand + * it during the PUT, which swallows the banner content. + * byte(37) = '%'. cats() concatenates without gluing in spaces. */ + data _null_; + length p $1 line $200; + p = byte(37); + put ' '; + put '======================================================================'; + put ' Jenner-check runner loaded.'; + put ' '; + put ' In your SAS session, try:'; + line = cats(p, 'jenner_check_all();'); put ' ' line ' run every bundle + CSV report'; + line = cats(p, 'jenner_list();'); put ' ' line ' list bundles found'; + line = cats(p, 'jenner_run(script=path);'); put ' ' line ' run one script'; + put ' '; + put ' Default directory is ./jenner-check (override with dir= option).'; + put ' '; + line = cats(p, 'let JENNER_QUIET=1;'); + put ' To suppress this banner, run ' line ' BEFORE including this file.'; + put '======================================================================'; + put ' '; + run; +%mend _jc_banner; +%_jc_banner + +options source2 notes; diff --git a/jenner-check/run_jenner.sh b/jenner-check/run_jenner.sh new file mode 100755 index 0000000..99cd395 --- /dev/null +++ b/jenner-check/run_jenner.sh @@ -0,0 +1,214 @@ +#!/usr/bin/env bash +# run_jenner.sh - mac/linux runner for Jenner compatibility checks. +# +# Quick start: +# cd jenner-check/ +# ./run_jenner.sh # lists bundles in the current dir +# ./run_jenner.sh t001_something # run that one +# ./run_jenner.sh --all # run every bundle in the current dir +# +# Usage: ./run_jenner.sh [bundle-dir | script.sas | --all | --list] [response.json] +# +# (no arg) If the current directory has tNNN_* bundles, list them +# with a copy-paste command. Otherwise show this help. +# +# --all Run every tNNN_* bundle in the current directory in +# sequence, print a pass/fail summary. +# +# --list, -l List the bundles visible in the current directory and +# exit without running anything. +# +# bundle-dir A directory containing script.sas and (optionally) +# autoexec.sas. The two are concatenated (autoexec first, +# then a blank line, then script) and submitted together. +# This is the normal case. +# +# script.sas A single .sas file. Submitted as-is — no autoexec. +# +# The API response is written to (or response.json in +# the current directory if omitted) and the most useful fields are also +# printed to stdout for a quick sanity check. +# +# Requires: bash 4+, curl. Both ship with every mainstream Linux distro +# and macOS 12+. Windows: use run_jenner.bat (single-file mode) or WSL. +# +# IMPORTANT: execute this script, don't source it. Running with `. ./...` +# or `source ./...` will short-circuit error handling and can close your +# terminal if an error path fires. + +# --- refuse to be sourced ------------------------------------------------ +# `return` only works inside a sourced script. If we ARE sourced, print a +# message and return 1 so we don't kill the parent shell with exit. If +# we're running directly, (return 0) fails and we fall through. +(return 0 2>/dev/null) && { + printf 'run_jenner.sh: execute this script, do not source it.\n ./run_jenner.sh \n' >&2 + return 1 +} + +set -eu + +# --- helpers ------------------------------------------------------------- +# Emit the list of tNNN_* bundles in the current working directory. A +# "bundle" is a directory matching t[0-9]*_* whose name contains a +# script.sas file. Writes one path per line (no prefix); empty output +# if nothing found. +list_bundles_here() { + local d + for d in ./t[0-9]*_*/ ; do + [[ -d "$d" && -f "$d/script.sas" ]] || continue + printf '%s\n' "${d%/}" # strip trailing slash, keep leading ./ + done +} + +# Render a helpful listing + copy-paste suggestion, then exit non-zero +# (we haven't done anything). Used when the user runs with no args. +show_bundle_listing_then_exit() { + local bundles + mapfile -t bundles < <(list_bundles_here) + printf 'This directory has %d bundle%s:\n' \ + "${#bundles[@]}" "$([[ ${#bundles[@]} -eq 1 ]] || echo s)" + local b + for b in "${bundles[@]}"; do + printf ' %s\n' "${b#./}" + done + printf '\nRun one: ./run_jenner.sh %s\n' "${bundles[0]#./}" + printf 'Run them all: ./run_jenner.sh --all\n' + printf 'Just list: ./run_jenner.sh --list\n' + exit 2 +} + +# Show the usage block when we have nothing better to offer. +show_usage_then_exit() { + local status=${1:-2} + { + printf 'Usage: %s [bundle-dir | script.sas | --all | --list] [response.json]\n\n' "$(basename "$0")" + printf 'Examples:\n' + printf ' %s t001_my_bundle # run one bundle\n' "$(basename "$0")" + printf ' %s --all # run every tNNN_* bundle in this dir\n' "$(basename "$0")" + printf ' %s path/to/script.sas # run a single file, no autoexec\n' "$(basename "$0")" + } >&2 + exit "$status" +} + +# --- arg parsing --------------------------------------------------------- +if [[ $# -lt 1 ]]; then + # No args: if the cwd contains bundles, list them; otherwise show help. + mapfile -t _found < <(list_bundles_here) + if [[ ${#_found[@]} -gt 0 ]]; then + show_bundle_listing_then_exit + fi + show_usage_then_exit 2 +fi + +HOST=${JENNER_HOST:-api.jenneranalytics.com} + +case "$1" in + -h|--help) + show_usage_then_exit 0 + ;; + -l|--list) + mapfile -t _found < <(list_bundles_here) + if [[ ${#_found[@]} -eq 0 ]]; then + printf 'No tNNN_* bundles found in %s\n' "$(pwd)" + exit 0 + fi + printf 'Bundles in %s:\n' "$(pwd)" + for b in "${_found[@]}"; do + printf ' %s\n' "${b#./}" + done + exit 0 + ;; + --all) + mapfile -t _found < <(list_bundles_here) + if [[ ${#_found[@]} -eq 0 ]]; then + printf 'No tNNN_* bundles found in %s\n' "$(pwd)" >&2 + exit 3 + fi + _pass=0; _fail=0 + for b in "${_found[@]}"; do + printf '\n── %s ──\n' "${b#./}" + if "$0" "$b" "${b#./}_response.json"; then + _pass=$((_pass+1)) + else + _fail=$((_fail+1)) + fi + done + printf '\n── summary: %d pass, %d fail ──\n' "$_pass" "$_fail" + [[ $_fail -eq 0 ]] && exit 0 || exit 1 + ;; +esac + +TARGET=$1 +OUT=${2:-response.json} + +# --- assemble the submission body --------------------------------------- +# If TARGET is a directory, treat it as a bundle. If it's a file, submit +# it directly. +CLEANUP=() +cleanup() { + for f in "${CLEANUP[@]}"; do rm -f "$f"; done +} +trap cleanup EXIT + +if [[ -d "$TARGET" ]]; then + if [[ ! -f "$TARGET/script.sas" ]]; then + printf 'error: %s is a directory but has no script.sas\n' "$TARGET" >&2 + exit 3 + fi + SUBMIT=$(mktemp -t jc_submit.XXXXXX.sas) + CLEANUP+=("$SUBMIT") + if [[ -f "$TARGET/autoexec.sas" ]]; then + cat "$TARGET/autoexec.sas" > "$SUBMIT" + printf '\n' >> "$SUBMIT" + fi + cat "$TARGET/script.sas" >> "$SUBMIT" + printf 'Submitting bundle: %s\n' "$TARGET" + if [[ -f "$TARGET/autoexec.sas" ]]; then + printf ' autoexec.sas (%d bytes) + script.sas (%d bytes)\n' \ + "$(wc -c < "$TARGET/autoexec.sas")" "$(wc -c < "$TARGET/script.sas")" + else + printf ' script.sas (%d bytes), no autoexec\n' "$(wc -c < "$TARGET/script.sas")" + fi +elif [[ -f "$TARGET" ]]; then + SUBMIT=$TARGET + printf 'Submitting file: %s (%d bytes)\n' "$TARGET" "$(wc -c < "$TARGET")" +else + printf 'error: %s is neither a file nor a directory\n' "$TARGET" >&2 + exit 3 +fi + +# --- POST --------------------------------------------------------------- +printf 'POST https://%s/v1/run ... ' "$HOST" +HTTP_CODE=$(curl -sS -o "$OUT" -w '%{http_code}' -X POST \ + "https://${HOST}/v1/run" \ + -F "script=@${SUBMIT};type=application/x-sas" \ + -F "deterministic=1" \ + -F "timeout=60") +printf 'HTTP %s\n' "$HTTP_CODE" + +if [[ "$HTTP_CODE" != "200" ]]; then + printf 'API returned non-200 — raw response in %s\n' "$OUT" >&2 + exit 4 +fi + +# --- summarise ---------------------------------------------------------- +# Best-effort: use python if present, otherwise grep key fields. +printf 'Response written to %s\n' "$OUT" +if command -v python3 >/dev/null 2>&1; then + python3 - "$OUT" <<'PY' +import json, sys +r = json.load(open(sys.argv[1])) +print(f" status : {r.get('status')}") +print(f" exit_code : {r.get('exit_code')}") +print(f" duration_ms: {r.get('duration_ms')}") +print(f" run_id : {r.get('run_id')}") +print(f" jenner_ver : {r.get('jenner_version')}") +log = r.get('log', '') +if log: + print(' log (first 10 lines):') + for line in log.splitlines()[:10]: + print(f' {line}') +PY +else + printf ' (install python3 for a pretty summary; raw JSON in %s)\n' "$OUT" +fi diff --git a/jenner-check/t001_genmod_poisson/autoexec.sas b/jenner-check/t001_genmod_poisson/autoexec.sas new file mode 100644 index 0000000..2052e87 --- /dev/null +++ b/jenner-check/t001_genmod_poisson/autoexec.sas @@ -0,0 +1 @@ +options obs=100; diff --git a/jenner-check/t001_genmod_poisson/expected.json b/jenner-check/t001_genmod_poisson/expected.json new file mode 100644 index 0000000..51f5bf5 --- /dev/null +++ b/jenner-check/t001_genmod_poisson/expected.json @@ -0,0 +1,21 @@ +{ + "_captured_at": "2026-06-12T16:00:20.153691+00:00", + "_captured_run_id": "r_019ebc82d8c57dd0996cebcff421da32", + "status": "ok", + "exit_code": 0, + "log_contains": [ + "NOTE: Option OBS changed to 100.", + "NOTE: DATA Impdent", + "NOTE: Processing inline DATALINES (33 lines)", + "NOTE: Read 33 rows from DATALINES.", + "NOTE: Wrote Impdent (33 rows, 7 columns)." + ], + "log_does_not_contain": [ + "ERROR:", + "[JENNER-ERROR" + ], + "diagnostics": { + "parse_warnings": [], + "runtime_warnings": [] + } +} \ No newline at end of file diff --git a/jenner-check/t001_genmod_poisson/expected/files.md b/jenner-check/t001_genmod_poisson/expected/files.md new file mode 100644 index 0000000..30bd549 --- /dev/null +++ b/jenner-check/t001_genmod_poisson/expected/files.md @@ -0,0 +1,20 @@ +These URLs are tied to a specific run and expire when the run is reaped — re-running the bundle regenerates them. + +## Files + +| Name | Content-Type | Size (bytes) | URL | +|------|-------------|-------------|-----| +| ods_output/genmod_qq_plot.png | image/png | 30215 | https://api.jenneranalytics.com/v1/run/r_019ebc82d8c57dd0996cebcff421da32/files/ods_output/genmod_qq_plot.png?token=3d2fb7fab6be46f68d6b085c9a2ecb88 | +| ods_output/genmod_qq_plot.svg | image/svg+xml | 16380 | https://api.jenneranalytics.com/v1/run/r_019ebc82d8c57dd0996cebcff421da32/files/ods_output/genmod_qq_plot.svg?token=3d2fb7fab6be46f68d6b085c9a2ecb88 | +| ods_output/genmod_residual_histogram_panel.png | image/png | 30987 | https://api.jenneranalytics.com/v1/run/r_019ebc82d8c57dd0996cebcff421da32/files/ods_output/genmod_residual_histogram_panel.png?token=3d2fb7fab6be46f68d6b085c9a2ecb88 | +| ods_output/genmod_residual_histogram_panel.svg | image/svg+xml | 15619 | https://api.jenneranalytics.com/v1/run/r_019ebc82d8c57dd0996cebcff421da32/files/ods_output/genmod_residual_histogram_panel.svg?token=3d2fb7fab6be46f68d6b085c9a2ecb88 | +| ods_output/genmod_residuals_vs_obs_order.png | image/png | 24417 | https://api.jenneranalytics.com/v1/run/r_019ebc82d8c57dd0996cebcff421da32/files/ods_output/genmod_residuals_vs_obs_order.png?token=3d2fb7fab6be46f68d6b085c9a2ecb88 | +| ods_output/genmod_residuals_vs_obs_order.svg | image/svg+xml | 17544 | https://api.jenneranalytics.com/v1/run/r_019ebc82d8c57dd0996cebcff421da32/files/ods_output/genmod_residuals_vs_obs_order.svg?token=3d2fb7fab6be46f68d6b085c9a2ecb88 | +| ods_output/genmod_residuals_vs_predicted.png | image/png | 22209 | https://api.jenneranalytics.com/v1/run/r_019ebc82d8c57dd0996cebcff421da32/files/ods_output/genmod_residuals_vs_predicted.png?token=3d2fb7fab6be46f68d6b085c9a2ecb88 | +| ods_output/genmod_residuals_vs_predicted.svg | image/svg+xml | 21643 | https://api.jenneranalytics.com/v1/run/r_019ebc82d8c57dd0996cebcff421da32/files/ods_output/genmod_residuals_vs_predicted.svg?token=3d2fb7fab6be46f68d6b085c9a2ecb88 | + +## Datasets + +| Name | Rows | Columns | Preview | +|------|------|---------|--------| +| impdent | 33 | 7 | https://api.jenneranalytics.com/v1/run/r_019ebc82d8c57dd0996cebcff421da32/datasets/impdent?token=3d2fb7fab6be46f68d6b085c9a2ecb88 | diff --git a/jenner-check/t001_genmod_poisson/expected/log.txt b/jenner-check/t001_genmod_poisson/expected/log.txt new file mode 100644 index 0000000..edb173b --- /dev/null +++ b/jenner-check/t001_genmod_poisson/expected/log.txt @@ -0,0 +1,27 @@ +Jenner 0.1.0 (Unlicensed - limited to 100 observations) +Get a license at https://jenneranalytics.com/license + +NOTE: Option OBS changed to 100. +NOTE: DATA Impdent + +NOTE: Processing inline DATALINES (33 lines) + +NOTE: Read 33 rows from DATALINES. +NOTE: Wrote Impdent (33 rows, 7 columns). +NOTE: DATA elapsed: + wall 0.00 seconds + cpu 0.00 seconds +NOTE: PROC GENMOD data=Impdent + +NOTE: PROC GENMOD using R wrapper +NOTE: +NOTE: Response Variable: HEMA +NOTE: Distribution: POISSON +NOTE: Link Function: LOG +NOTE: Number of Observations: 33 +NOTE: Model fitted successfully with 33 observations +NOTE: ODS plot written: genmod_residuals_vs_predicted.spec.json +NOTE: ODS plot written: genmod_residual_histogram_panel.spec.json +NOTE: ODS plot written: genmod_residuals_vs_obs_order.spec.json +NOTE: ODS plot written: genmod_qq_plot.spec.json +NOTE: PROC GENMOD ODS Graphics generated. diff --git a/jenner-check/t001_genmod_poisson/expected/output.txt b/jenner-check/t001_genmod_poisson/expected/output.txt new file mode 100644 index 0000000..99ca992 --- /dev/null +++ b/jenner-check/t001_genmod_poisson/expected/output.txt @@ -0,0 +1,29 @@ + The GENMOD Procedure + Model Information + +Item Value +---------------------- ------------ +Response Variable HEMA +Distribution poisson +Link Function log +Number of Observations 33 +Offset Variable LOG_IMPLANTS + + Analysis of Maximum Likelihood Parameter Estimates + +Parameter Estimate Std Error Chi-Square Pr > ChiSq +-------------- -------- --------- ---------- ---------- +(Intercept) -4.4136 0.2191 405.9625 <.0001 +LIGHT_VS_NO -17.8978 2563.4938 0.0000 0.9944 +HEAVY_VS_LIGHT 18.0960 2563.4938 0.0000 0.9944 +DIABETES 1.7938 0.3729 23.1414 <.0001 +AGE_DECADE 0.5053 0.1247 16.4146 <.0001 + +Criteria for Assessing Goodness of Fit + +Criterion Value +-------------- -------- +Deviance 42.7415 +Log Likelihood -35.7404 +AIC 81.4808 +BIC 88.9634 diff --git a/jenner-check/t001_genmod_poisson/meta.json b/jenner-check/t001_genmod_poisson/meta.json new file mode 100644 index 0000000..ea6043d --- /dev/null +++ b/jenner-check/t001_genmod_poisson/meta.json @@ -0,0 +1,7 @@ +{ + "bundle": "t001_genmod_poisson", + "source_file": "Real data analyses/Implant dentistry/Example_Analysis.sas", + "source_commit": "5d953ccdd9f5f72d3f2be53b567d35e83926406c", + "tier": "real_data", + "notes": "Plain PROC GENMOD Poisson regression from Example_Analysis.sas. URL-based macro includes replaced with datalines from Impdent.csv (bundled in repo)." +} \ No newline at end of file diff --git a/jenner-check/t001_genmod_poisson/script.sas b/jenner-check/t001_genmod_poisson/script.sas new file mode 100644 index 0000000..e74ff1d --- /dev/null +++ b/jenner-check/t001_genmod_poisson/script.sas @@ -0,0 +1,51 @@ +*** Analysis of Implant Dentistry study (Feher et al, Clin Oral Implants Res 2020); +*** Outcome: Hema = number of hematological complications; +*** Independent variables: Light_vs_no, Heavy_vs_light, Diabetes, Age_decade; +*** Offset: log_Implants (log of number of implantations); +*** Data: Impdent.csv from the repository, all 33 aggregated records; + +data Impdent; + input Light_vs_no Heavy_vs_light Diabetes Age_decade + Implants Hema log_Implants; + datalines; +0 0 0 -4 137 0 4.9199809258 +0 0 0 -3 161 0 5.081404365 +0 0 0 -2 205 0 5.3230099791 +0 0 0 -1 363 5 5.8944028343 +0 0 0 0 422 1 6.045005314 +0 0 0 1 335 4 5.8141305318 +0 0 0 2 183 8 5.2094861528 +0 0 0 3 25 3 3.2188758249 +0 0 1 -4 1 0 0 +0 0 1 -2 3 0 1.0986122887 +0 0 1 -1 14 0 2.6390573296 +0 0 1 0 21 4 3.0445224377 +0 0 1 1 26 4 3.258096538 +0 0 1 2 9 4 2.1972245773 +0 0 1 3 7 0 1.9459101491 +1 0 0 -4 42 0 3.7376696183 +1 0 0 -3 27 0 3.295836866 +1 0 0 -2 48 0 3.8712010109 +1 0 0 -1 93 0 4.5325994932 +1 0 0 0 66 0 4.189654742 +1 0 0 1 41 0 3.7135720667 +1 0 0 2 8 0 2.0794415417 +1 0 1 -4 5 0 1.6094379124 +1 0 1 -1 8 0 2.0794415417 +1 1 0 -3 12 0 2.4849066498 +1 1 0 -2 36 0 3.5835189385 +1 1 0 -1 43 4 3.7612001157 +1 1 0 0 34 0 3.5263605246 +1 1 0 1 12 0 2.4849066498 +1 1 0 2 2 0 0.6931471806 +1 1 1 0 4 0 1.3862943611 +1 1 1 1 8 0 2.0794415417 +1 1 1 2 4 0 1.3862943611 +; +run; + +* Maximum likelihood Poisson regression; +proc genmod data=Impdent; + model Hema = Light_vs_no Heavy_vs_light Diabetes Age_decade + / dist=poisson offset=log_Implants; +run; diff --git a/jenner-check/t002_flacpoisson/autoexec.sas b/jenner-check/t002_flacpoisson/autoexec.sas new file mode 100644 index 0000000..2052e87 --- /dev/null +++ b/jenner-check/t002_flacpoisson/autoexec.sas @@ -0,0 +1 @@ +options obs=100; diff --git a/jenner-check/t002_flacpoisson/expected.json b/jenner-check/t002_flacpoisson/expected.json new file mode 100644 index 0000000..aa1c3aa --- /dev/null +++ b/jenner-check/t002_flacpoisson/expected.json @@ -0,0 +1,21 @@ +{ + "_captured_at": "2026-06-12T16:00:20.153691+00:00", + "_captured_run_id": "r_019ebc8ddbda7ba3a47257e7b37287e2", + "status": "ok", + "exit_code": 0, + "log_contains": [ + "NOTE: Option OBS changed to 100.", + "NOTE: DATA Impdent", + "NOTE: Processing inline DATALINES (33 lines)", + "NOTE: Read 33 rows from DATALINES.", + "NOTE: Wrote Impdent (33 rows, 7 columns)." + ], + "log_does_not_contain": [ + "ERROR:", + "[JENNER-ERROR" + ], + "diagnostics": { + "parse_warnings": [], + "runtime_warnings": [] + } +} \ No newline at end of file diff --git a/jenner-check/t002_flacpoisson/expected/files.md b/jenner-check/t002_flacpoisson/expected/files.md new file mode 100644 index 0000000..3cba70c --- /dev/null +++ b/jenner-check/t002_flacpoisson/expected/files.md @@ -0,0 +1,26 @@ +These URLs are tied to a specific run and expire when the run is reaped — re-running the bundle regenerates them. + +## Files + +| Name | Content-Type | Size (bytes) | URL | +|------|-------------|-------------|-----| +| ods_output/genmod_qq_plot.png | image/png | 30215 | https://api.jenneranalytics.com/v1/run/r_019ebc8ddbda7ba3a47257e7b37287e2/files/ods_output/genmod_qq_plot.png?token=e7ad12101390451db3a3a261c0eea784 | +| ods_output/genmod_qq_plot.svg | image/svg+xml | 16380 | https://api.jenneranalytics.com/v1/run/r_019ebc8ddbda7ba3a47257e7b37287e2/files/ods_output/genmod_qq_plot.svg?token=e7ad12101390451db3a3a261c0eea784 | +| ods_output/genmod_residual_histogram_panel.png | image/png | 30987 | https://api.jenneranalytics.com/v1/run/r_019ebc8ddbda7ba3a47257e7b37287e2/files/ods_output/genmod_residual_histogram_panel.png?token=e7ad12101390451db3a3a261c0eea784 | +| ods_output/genmod_residual_histogram_panel.svg | image/svg+xml | 15619 | https://api.jenneranalytics.com/v1/run/r_019ebc8ddbda7ba3a47257e7b37287e2/files/ods_output/genmod_residual_histogram_panel.svg?token=e7ad12101390451db3a3a261c0eea784 | +| ods_output/genmod_residuals_vs_obs_order.png | image/png | 24417 | https://api.jenneranalytics.com/v1/run/r_019ebc8ddbda7ba3a47257e7b37287e2/files/ods_output/genmod_residuals_vs_obs_order.png?token=e7ad12101390451db3a3a261c0eea784 | +| ods_output/genmod_residuals_vs_obs_order.svg | image/svg+xml | 17544 | https://api.jenneranalytics.com/v1/run/r_019ebc8ddbda7ba3a47257e7b37287e2/files/ods_output/genmod_residuals_vs_obs_order.svg?token=e7ad12101390451db3a3a261c0eea784 | +| ods_output/genmod_residuals_vs_predicted.png | image/png | 22209 | https://api.jenneranalytics.com/v1/run/r_019ebc8ddbda7ba3a47257e7b37287e2/files/ods_output/genmod_residuals_vs_predicted.png?token=e7ad12101390451db3a3a261c0eea784 | +| ods_output/genmod_residuals_vs_predicted.svg | image/svg+xml | 21643 | https://api.jenneranalytics.com/v1/run/r_019ebc8ddbda7ba3a47257e7b37287e2/files/ods_output/genmod_residuals_vs_predicted.svg?token=e7ad12101390451db3a3a261c0eea784 | + +## Datasets + +| Name | Rows | Columns | Preview | +|------|------|---------|--------| +| _firthparms | 5 | 7 | https://api.jenneranalytics.com/v1/run/r_019ebc8ddbda7ba3a47257e7b37287e2/datasets/_firthparms?token=e7ad12101390451db3a3a261c0eea784 | +| _flacparms | 5 | 7 | https://api.jenneranalytics.com/v1/run/r_019ebc8ddbda7ba3a47257e7b37287e2/datasets/_flacparms?token=e7ad12101390451db3a3a261c0eea784 | +| _parms1 | 5 | 7 | https://api.jenneranalytics.com/v1/run/r_019ebc8ddbda7ba3a47257e7b37287e2/datasets/_parms1?token=e7ad12101390451db3a3a261c0eea784 | +| _parms2 | 5 | 7 | https://api.jenneranalytics.com/v1/run/r_019ebc8ddbda7ba3a47257e7b37287e2/datasets/_parms2?token=e7ad12101390451db3a3a261c0eea784 | +| _work | 33 | 10 | https://api.jenneranalytics.com/v1/run/r_019ebc8ddbda7ba3a47257e7b37287e2/datasets/_work?token=e7ad12101390451db3a3a261c0eea784 | +| _work2 | 66 | 10 | https://api.jenneranalytics.com/v1/run/r_019ebc8ddbda7ba3a47257e7b37287e2/datasets/_work2?token=e7ad12101390451db3a3a261c0eea784 | +| impdent | 33 | 7 | https://api.jenneranalytics.com/v1/run/r_019ebc8ddbda7ba3a47257e7b37287e2/datasets/impdent?token=e7ad12101390451db3a3a261c0eea784 | diff --git a/jenner-check/t002_flacpoisson/expected/log.txt b/jenner-check/t002_flacpoisson/expected/log.txt new file mode 100644 index 0000000..a9b8592 --- /dev/null +++ b/jenner-check/t002_flacpoisson/expected/log.txt @@ -0,0 +1,116 @@ +Jenner 0.1.0 (Unlicensed - limited to 100 observations) +Get a license at https://jenneranalytics.com/license + +NOTE: Option OBS changed to 100. +NOTE: DATA Impdent + +NOTE: Processing inline DATALINES (33 lines) + +NOTE: Read 33 rows from DATALINES. +NOTE: Wrote Impdent (33 rows, 7 columns). +NOTE: DATA elapsed: + wall 0.00 seconds + cpu 0.00 seconds +NOTE: DATA _work + + +NOTE: Read 33 rows from Impdent. +NOTE: Wrote _work (33 rows, 8 columns). +NOTE: DATA elapsed: + wall 0.00 seconds + cpu 0.00 seconds +NOTE: DATA _work + + +NOTE: Read 33 rows from _work. +NOTE: Wrote _work (33 rows, 9 columns). +NOTE: DATA elapsed: + wall 0.00 seconds + cpu 0.00 seconds +NOTE: PROC GENMOD data=_work + +NOTE: PROC GENMOD using R wrapper +NOTE: +NOTE: Response Variable: HEMA_MOD +NOTE: Distribution: POISSON +NOTE: Link Function: LOG +NOTE: Number of Observations: 33 +NOTE: Model fitted successfully with 33 observations +NOTE: ODS plot written: genmod_residuals_vs_predicted.spec.json +NOTE: ODS plot written: genmod_residual_histogram_panel.spec.json +NOTE: ODS plot written: genmod_residuals_vs_obs_order.spec.json +NOTE: ODS plot written: genmod_qq_plot.spec.json +NOTE: PROC GENMOD ODS Graphics generated. +NOTE: OUTPUT dataset '_WORK' created with 33 observations. +NOTE: PROC GENMOD: Emitting ODS OUTPUT datasets (1 destination(s)) +NOTE: DATA _work + + +NOTE: Read 33 rows from _work. +NOTE: Wrote _work (33 rows, 9 columns). +NOTE: DATA elapsed: + wall 0.00 seconds + cpu 0.00 seconds +NOTE: PROC GENMOD data=_work + +NOTE: PROC GENMOD using R wrapper +NOTE: +NOTE: Response Variable: HEMA_MOD +NOTE: Distribution: POISSON +NOTE: Link Function: LOG +NOTE: Number of Observations: 33 +NOTE: Model fitted successfully with 33 observations +NOTE: ODS plot written: genmod_residuals_vs_predicted.spec.json +NOTE: ODS plot written: genmod_residual_histogram_panel.spec.json +NOTE: ODS plot written: genmod_residuals_vs_obs_order.spec.json +NOTE: ODS plot written: genmod_qq_plot.spec.json +NOTE: PROC GENMOD ODS Graphics generated. +NOTE: OUTPUT dataset '_WORK' created with 33 observations. +NOTE: PROC GENMOD: Emitting ODS OUTPUT datasets (1 destination(s)) +NOTE: DATA _work + + +NOTE: Read 33 rows from _work. +NOTE: Wrote _work (33 rows, 9 columns). +NOTE: DATA elapsed: + wall 0.00 seconds + cpu 0.00 seconds +NOTE: PROC GENMOD data=_work + +NOTE: PROC GENMOD using R wrapper +NOTE: +NOTE: Response Variable: HEMA_MOD +NOTE: Distribution: POISSON +NOTE: Link Function: LOG +NOTE: Number of Observations: 33 +NOTE: Model fitted successfully with 33 observations +NOTE: ODS plot written: genmod_residuals_vs_predicted.spec.json +NOTE: ODS plot written: genmod_residual_histogram_panel.spec.json +NOTE: ODS plot written: genmod_residuals_vs_obs_order.spec.json +NOTE: ODS plot written: genmod_qq_plot.spec.json +NOTE: PROC GENMOD ODS Graphics generated. +NOTE: OUTPUT dataset '_WORK' created with 33 observations. +NOTE: PROC GENMOD: Emitting ODS OUTPUT datasets (1 destination(s)) +NOTE: DATA _work2 + + +NOTE: Read 33 rows from _work. +NOTE: Wrote _work2 (66 rows, 10 columns). +NOTE: DATA elapsed: + wall 0.00 seconds + cpu 0.00 seconds +NOTE: PROC GENMOD data=_work2 + +NOTE: PROC GENMOD using R wrapper +NOTE: +NOTE: Response Variable: HEMA +NOTE: Distribution: POISSON +NOTE: Link Function: LOG +NOTE: Number of Observations: 66 +NOTE: Model fitted successfully with 33 observations +NOTE: ODS plot written: genmod_residuals_vs_predicted.spec.json +NOTE: ODS plot written: genmod_residual_histogram_panel.spec.json +NOTE: ODS plot written: genmod_residuals_vs_obs_order.spec.json +NOTE: ODS plot written: genmod_qq_plot.spec.json +NOTE: PROC GENMOD ODS Graphics generated. +NOTE: PROC GENMOD: Emitting ODS OUTPUT datasets (1 destination(s)) diff --git a/jenner-check/t002_flacpoisson/expected/output.txt b/jenner-check/t002_flacpoisson/expected/output.txt new file mode 100644 index 0000000..ee893b4 --- /dev/null +++ b/jenner-check/t002_flacpoisson/expected/output.txt @@ -0,0 +1,120 @@ + The GENMOD Procedure + Model Information + +Item Value +---------------------- ------------ +Response Variable HEMA_MOD +Distribution poisson +Link Function log +Number of Observations 33 +Offset Variable LOG_IMPLANTS + + Analysis of Maximum Likelihood Parameter Estimates + +Parameter Estimate Std Error Chi-Square Pr > ChiSq +-------------- -------- --------- ---------- ---------- +(Intercept) -4.4097 0.2185 407.4003 <.0001 +LIGHT_VS_NO -4.3055 4.7184 0.8326 0.3615 +HEAVY_VS_LIGHT 4.5111 4.7433 0.9045 0.3416 +DIABETES 1.7965 0.3721 23.3127 <.0001 +AGE_DECADE 0.5026 0.1243 16.3449 <.0001 + +Criteria for Assessing Goodness of Fit + +Criterion Value +--------- -------- +Deviance 42.0705 + + The GENMOD Procedure + Model Information + +Item Value +---------------------- ------------ +Response Variable HEMA_MOD +Distribution poisson +Link Function log +Number of Observations 33 +Offset Variable LOG_IMPLANTS + + Analysis of Maximum Likelihood Parameter Estimates + +Parameter Estimate Std Error Chi-Square Pr > ChiSq +-------------- -------- --------- ---------- ---------- +(Intercept) -4.4097 0.2185 407.4003 <.0001 +LIGHT_VS_NO -4.3055 4.7184 0.8326 0.3615 +HEAVY_VS_LIGHT 4.5111 4.7433 0.9045 0.3416 +DIABETES 1.7965 0.3721 23.3127 <.0001 +AGE_DECADE 0.5026 0.1243 16.3449 <.0001 + +Criteria for Assessing Goodness of Fit + +Criterion Value +--------- -------- +Deviance 42.0705 + + The GENMOD Procedure + Model Information + +Item Value +---------------------- ------------ +Response Variable HEMA_MOD +Distribution poisson +Link Function log +Number of Observations 33 +Offset Variable LOG_IMPLANTS + + Analysis of Maximum Likelihood Parameter Estimates + +Parameter Estimate Std Error Chi-Square Pr > ChiSq +-------------- -------- --------- ---------- ---------- +(Intercept) -4.4097 0.2185 407.4003 <.0001 +LIGHT_VS_NO -4.3055 4.7184 0.8326 0.3615 +HEAVY_VS_LIGHT 4.5111 4.7433 0.9045 0.3416 +DIABETES 1.7965 0.3721 23.3127 <.0001 +AGE_DECADE 0.5026 0.1243 16.3449 <.0001 + +Criteria for Assessing Goodness of Fit + +Criterion Value +--------- -------- +Deviance 42.0705 + + Likelihood Ratio Confidence Intervals + +Parameter Estimate Lower Upper +-------------- -------- -------- -------- +(Intercept) -4.4097 -4.8707 -4.0102 +LIGHT_VS_NO -4.3055 . -0.4340 +HEAVY_VS_LIGHT 4.5111 0.3753 . +DIABETES 1.7965 1.0335 2.5043 +AGE_DECADE 0.5026 0.2668 0.7549 + + The GENMOD Procedure + Model Information + +Item Value +---------------------- ------------ +Response Variable HEMA +Distribution poisson +Link Function log +Number of Observations 66 +Offset Variable LOG_IMPLANTS + + Analysis of Maximum Likelihood Parameter Estimates + +Parameter Estimate Std Error Chi-Square Pr > ChiSq +-------------- -------- --------- ---------- ---------- +(Intercept) -4.4136 0.2191 405.9625 <.0001 +LIGHT_VS_NO -17.8978 2563.4938 0.0000 0.9944 +HEAVY_VS_LIGHT 18.0960 2563.4938 0.0000 0.9944 +DIABETES 1.7938 0.3729 23.1414 <.0001 +AGE_DECADE 0.5053 0.1247 16.4146 <.0001 + +Criteria for Assessing Goodness of Fit + +Criterion Value +-------------- -------- +Deviance 42.7415 +Log Likelihood -35.7404 +AIC 81.4808 +BIC 88.9634 diff --git a/jenner-check/t002_flacpoisson/meta.json b/jenner-check/t002_flacpoisson/meta.json new file mode 100644 index 0000000..73d6be4 --- /dev/null +++ b/jenner-check/t002_flacpoisson/meta.json @@ -0,0 +1,7 @@ +{ + "bundle": "t002_flacpoisson", + "source_file": "Simulation study/Sas macro/flacpoisson.sas", + "source_commit": "5d953ccdd9f5f72d3f2be53b567d35e83926406c", + "tier": "real_data", + "notes": "FLAC Poisson macro from flacpoisson.sas inlined as explicit iteration steps. Variable _added_covariate_ renamed to added_cov to satisfy standard formula parsing. Firth and FLAC steps both produce output." +} \ No newline at end of file diff --git a/jenner-check/t002_flacpoisson/script.sas b/jenner-check/t002_flacpoisson/script.sas new file mode 100644 index 0000000..856f066 --- /dev/null +++ b/jenner-check/t002_flacpoisson/script.sas @@ -0,0 +1,113 @@ +*** Firth-corrected Poisson regression for the Implant Dentistry study; +*** Implements the iterative Firth correction from the %flacpoisson macro +*** in Simulation study/Sas macro/flacpoisson.sas; +*** The FLAC algorithm iteratively adjusts the Poisson outcome by adding half +*** the hat-matrix diagonal, then fits PROC GENMOD on the adjusted outcome. + +*** Implant dentistry data (from repository Impdent.csv); + +data Impdent; + input Light_vs_no Heavy_vs_light Diabetes Age_decade + Implants Hema log_Implants; + datalines; +0 0 0 -4 137 0 4.9199809258 +0 0 0 -3 161 0 5.081404365 +0 0 0 -2 205 0 5.3230099791 +0 0 0 -1 363 5 5.8944028343 +0 0 0 0 422 1 6.045005314 +0 0 0 1 335 4 5.8141305318 +0 0 0 2 183 8 5.2094861528 +0 0 0 3 25 3 3.2188758249 +0 0 1 -4 1 0 0 +0 0 1 -2 3 0 1.0986122887 +0 0 1 -1 14 0 2.6390573296 +0 0 1 0 21 4 3.0445224377 +0 0 1 1 26 4 3.258096538 +0 0 1 2 9 4 2.1972245773 +0 0 1 3 7 0 1.9459101491 +1 0 0 -4 42 0 3.7376696183 +1 0 0 -3 27 0 3.295836866 +1 0 0 -2 48 0 3.8712010109 +1 0 0 -1 93 0 4.5325994932 +1 0 0 0 66 0 4.189654742 +1 0 0 1 41 0 3.7135720667 +1 0 0 2 8 0 2.0794415417 +1 0 1 -4 5 0 1.6094379124 +1 0 1 -1 8 0 2.0794415417 +1 1 0 -3 12 0 2.4849066498 +1 1 0 -2 36 0 3.5835189385 +1 1 0 -1 43 4 3.7612001157 +1 1 0 0 34 0 3.5263605246 +1 1 0 1 12 0 2.4849066498 +1 1 0 2 2 0 0.6931471806 +1 1 1 0 4 0 1.3862943611 +1 1 1 1 8 0 2.0794415417 +1 1 1 2 4 0 1.3862943611 +; +run; + +* Initialise working data set (Step 1 of %flacpoisson iteration); +data _work; +set Impdent; +_hdiag_ = 0.01; +run; + +* Iteration 1: adjust outcome and fit PROC GENMOD, capturing hat diagonal; +data _work; +set _work; +Hema_mod = Hema + _hdiag_/2; +run; + +proc genmod data=_work; + ods output ParameterEstimates=_parms1; + model Hema_mod = Light_vs_no Heavy_vs_light Diabetes Age_decade + / dist=poisson offset=log_Implants; + output out=_work h=_hdiag_; +run; + +* Iteration 2: update adjusted outcome with new hat diagonal; +data _work; +set _work; +Hema_mod = Hema + _hdiag_/2; +run; + +proc genmod data=_work; + ods output ParameterEstimates=_parms2; + model Hema_mod = Light_vs_no Heavy_vs_light Diabetes Age_decade + / dist=poisson offset=log_Implants; + output out=_work h=_hdiag_; +run; + +* Iteration 3: final Firth-corrected fit with profile likelihood CIs; +data _work; +set _work; +Hema_mod = Hema + _hdiag_/2; +run; + +proc genmod data=_work; + ods output ParameterEstimates=_FirthParms; + title3 "Firth-corrected Poisson model (implant dentistry)"; + model Hema_mod = Light_vs_no Heavy_vs_light Diabetes Age_decade + / dist=poisson lrci offset=log_Implants; + output out=_work h=_hdiag2_ Predicted=_FIRTHPred; +run; + +* FLAC model: data augmentation step from %flacpoisson; +data _work2; +set _work; +drop _FIRTHPred; +added_cov = 0; +output; +Hema = _hdiag2_/2; +added_cov = 1; +output; +run; + +proc genmod data=_work2; + ods output ParameterEstimates=_FLACParms; + title3 "FLAC model (implant dentistry)"; + model Hema = Light_vs_no Heavy_vs_light Diabetes Age_decade added_cov + / dist=poisson lrci offset=log_Implants; +run; + +title3; diff --git a/jenner-check/t003_dataugpoisson/autoexec.sas b/jenner-check/t003_dataugpoisson/autoexec.sas new file mode 100644 index 0000000..2052e87 --- /dev/null +++ b/jenner-check/t003_dataugpoisson/autoexec.sas @@ -0,0 +1 @@ +options obs=100; diff --git a/jenner-check/t003_dataugpoisson/expected.json b/jenner-check/t003_dataugpoisson/expected.json new file mode 100644 index 0000000..2eb34d0 --- /dev/null +++ b/jenner-check/t003_dataugpoisson/expected.json @@ -0,0 +1,21 @@ +{ + "_captured_at": "2026-06-12T16:00:20.153691+00:00", + "_captured_run_id": "r_019ebc8f9d1c7ef097f8f1e70931e687", + "status": "ok", + "exit_code": 0, + "log_contains": [ + "NOTE: Option OBS changed to 100.", + "NOTE: DATA Impdent", + "NOTE: Processing inline DATALINES (33 lines)", + "NOTE: Read 33 rows from DATALINES.", + "NOTE: Wrote Impdent (33 rows, 7 columns)." + ], + "log_does_not_contain": [ + "ERROR:", + "[JENNER-ERROR" + ], + "diagnostics": { + "parse_warnings": [], + "runtime_warnings": [] + } +} \ No newline at end of file diff --git a/jenner-check/t003_dataugpoisson/expected/files.md b/jenner-check/t003_dataugpoisson/expected/files.md new file mode 100644 index 0000000..c237211 --- /dev/null +++ b/jenner-check/t003_dataugpoisson/expected/files.md @@ -0,0 +1,27 @@ +These URLs are tied to a specific run and expire when the run is reaped — re-running the bundle regenerates them. + +## Files + +| Name | Content-Type | Size (bytes) | URL | +|------|-------------|-------------|-----| +| listing.txt | text/plain | 310 | https://api.jenneranalytics.com/v1/run/r_019ebc8f9d1c7ef097f8f1e70931e687/files/listing.txt?token=ab3411f86bed465aabcf8b67397c2592 | +| ods_output/genmod_qq_plot.png | image/png | 28812 | https://api.jenneranalytics.com/v1/run/r_019ebc8f9d1c7ef097f8f1e70931e687/files/ods_output/genmod_qq_plot.png?token=ab3411f86bed465aabcf8b67397c2592 | +| ods_output/genmod_qq_plot.svg | image/svg+xml | 16971 | https://api.jenneranalytics.com/v1/run/r_019ebc8f9d1c7ef097f8f1e70931e687/files/ods_output/genmod_qq_plot.svg?token=ab3411f86bed465aabcf8b67397c2592 | +| ods_output/genmod_residual_histogram_panel.png | image/png | 28055 | https://api.jenneranalytics.com/v1/run/r_019ebc8f9d1c7ef097f8f1e70931e687/files/ods_output/genmod_residual_histogram_panel.png?token=ab3411f86bed465aabcf8b67397c2592 | +| ods_output/genmod_residual_histogram_panel.svg | image/svg+xml | 14706 | https://api.jenneranalytics.com/v1/run/r_019ebc8f9d1c7ef097f8f1e70931e687/files/ods_output/genmod_residual_histogram_panel.svg?token=ab3411f86bed465aabcf8b67397c2592 | +| ods_output/genmod_residuals_vs_obs_order.png | image/png | 24499 | https://api.jenneranalytics.com/v1/run/r_019ebc8f9d1c7ef097f8f1e70931e687/files/ods_output/genmod_residuals_vs_obs_order.png?token=ab3411f86bed465aabcf8b67397c2592 | +| ods_output/genmod_residuals_vs_obs_order.svg | image/svg+xml | 18697 | https://api.jenneranalytics.com/v1/run/r_019ebc8f9d1c7ef097f8f1e70931e687/files/ods_output/genmod_residuals_vs_obs_order.svg?token=ab3411f86bed465aabcf8b67397c2592 | +| ods_output/genmod_residuals_vs_predicted.png | image/png | 25988 | https://api.jenneranalytics.com/v1/run/r_019ebc8f9d1c7ef097f8f1e70931e687/files/ods_output/genmod_residuals_vs_predicted.png?token=ab3411f86bed465aabcf8b67397c2592 | +| ods_output/genmod_residuals_vs_predicted.svg | image/svg+xml | 23012 | https://api.jenneranalytics.com/v1/run/r_019ebc8f9d1c7ef097f8f1e70931e687/files/ods_output/genmod_residuals_vs_predicted.svg?token=ab3411f86bed465aabcf8b67397c2592 | + +## Datasets + +| Name | Rows | Columns | Preview | +|------|------|---------|--------| +| _aug | 4 | 7 | https://api.jenneranalytics.com/v1/run/r_019ebc8f9d1c7ef097f8f1e70931e687/datasets/_aug?token=ab3411f86bed465aabcf8b67397c2592 | +| _dataugparms | 5 | 7 | https://api.jenneranalytics.com/v1/run/r_019ebc8f9d1c7ef097f8f1e70931e687/datasets/_dataugparms?token=ab3411f86bed465aabcf8b67397c2592 | +| _dataugpredictions | 33 | 8 | https://api.jenneranalytics.com/v1/run/r_019ebc8f9d1c7ef097f8f1e70931e687/datasets/_dataugpredictions?token=ab3411f86bed465aabcf8b67397c2592 | +| _pv | 1 | 9 | https://api.jenneranalytics.com/v1/run/r_019ebc8f9d1c7ef097f8f1e70931e687/datasets/_pv?token=ab3411f86bed465aabcf8b67397c2592 | +| _real | 33 | 8 | https://api.jenneranalytics.com/v1/run/r_019ebc8f9d1c7ef097f8f1e70931e687/datasets/_real?token=ab3411f86bed465aabcf8b67397c2592 | +| _work2 | 37 | 7 | https://api.jenneranalytics.com/v1/run/r_019ebc8f9d1c7ef097f8f1e70931e687/datasets/_work2?token=ab3411f86bed465aabcf8b67397c2592 | +| impdent | 33 | 7 | https://api.jenneranalytics.com/v1/run/r_019ebc8f9d1c7ef097f8f1e70931e687/datasets/impdent?token=ab3411f86bed465aabcf8b67397c2592 | diff --git a/jenner-check/t003_dataugpoisson/expected/log.txt b/jenner-check/t003_dataugpoisson/expected/log.txt new file mode 100644 index 0000000..d22e00a --- /dev/null +++ b/jenner-check/t003_dataugpoisson/expected/log.txt @@ -0,0 +1,78 @@ +Jenner 0.1.0 (Unlicensed - limited to 100 observations) +Get a license at https://jenneranalytics.com/license + +NOTE: Option OBS changed to 100. +NOTE: DATA Impdent + +NOTE: Processing inline DATALINES (33 lines) + +NOTE: Read 33 rows from DATALINES. +NOTE: Wrote Impdent (33 rows, 7 columns). +NOTE: DATA elapsed: + wall 0.00 seconds + cpu 0.00 seconds +NOTE: DATA _pv + + +NOTE: Wrote _pv (1 rows, 9 columns). +NOTE: DATA elapsed: + wall 0.00 seconds + cpu 0.00 seconds +NOTE: DATA _aug + + +NOTE: Wrote _aug (4 rows, 7 columns). +NOTE: DATA elapsed: + wall 0.00 seconds + cpu 0.00 seconds +NOTE: DATA _real + + +NOTE: Read 33 rows from Impdent. +NOTE: Wrote _real (33 rows, 8 columns). +NOTE: DATA elapsed: + wall 0.00 seconds + cpu 0.00 seconds +NOTE: DATA _work2 + + +NOTE: Read 33 rows from _real. +NOTE: Read 37 rows from _aug. +NOTE: Wrote _work2 (37 rows, 7 columns). +NOTE: DATA elapsed: + wall 0.00 seconds + cpu 0.00 seconds +NOTE: PROC SORT data=_work2 + +NOTE: Unlicensed mode - input limited to 100 observations. +NOTE: Read 37 rows from _work2. +NOTE: Wrote _work2 (37 rows, 7 columns). +NOTE: PROC SORT statement used. +NOTE: ODS OUTPUT: PARAMETERESTIMATES -> _DATAUGParms +NOTE: PROC GENMOD data=_work2 + +NOTE: PROC GENMOD using R wrapper +NOTE: +NOTE: Response Variable: HEMA +NOTE: Distribution: POISSON +NOTE: Link Function: LOG +NOTE: Number of Observations: 37 +NOTE: Model fitted successfully with 37 observations +NOTE: ODS plot written: genmod_residuals_vs_predicted.spec.json +NOTE: ODS plot written: genmod_residual_histogram_panel.spec.json +NOTE: ODS plot written: genmod_residuals_vs_obs_order.spec.json +NOTE: ODS plot written: genmod_qq_plot.spec.json +NOTE: PROC GENMOD ODS Graphics generated. +NOTE: OUTPUT dataset '_DATAUGPREDICTIONS' created with 37 observations. +NOTE: PROC GENMOD: Emitting ODS OUTPUT datasets (1 destination(s)) +NOTE: DATA _DATAUGPredictions + + +NOTE: Read 37 rows from _DATAUGPredictions. +NOTE: Wrote _DATAUGPredictions (33 rows, 8 columns). +NOTE: DATA elapsed: + wall 0.00 seconds + cpu 0.00 seconds +NOTE: PROC PRINT data=_DATAUGParms + +NOTE: PROC PRINT completed: 5 observations printed, 3 variables diff --git a/jenner-check/t003_dataugpoisson/expected/output.txt b/jenner-check/t003_dataugpoisson/expected/output.txt new file mode 100644 index 0000000..5a7126f --- /dev/null +++ b/jenner-check/t003_dataugpoisson/expected/output.txt @@ -0,0 +1,45 @@ + The GENMOD Procedure + Model Information + +Item Value +---------------------- ------------ +Response Variable HEMA +Distribution poisson +Link Function log +Number of Observations 37 +Offset Variable LOG_IMPLANTS + + Analysis of Maximum Likelihood Parameter Estimates + +Parameter Estimate Std Error Chi-Square Pr > ChiSq +-------------- -------- --------- ---------- ---------- +IS_REAL -4.4214 0.2195 405.6486 <.0001 +LIGHT_VS_NO -2.1949 1.3908 2.4904 0.1145 +HEAVY_VS_LIGHT 2.3528 1.4507 2.6305 0.1048 +DIABETES 1.7880 0.3711 23.2141 <.0001 +AGE_DECADE 0.5098 0.1244 16.7955 <.0001 + +Criteria for Assessing Goodness of Fit + +Criterion Value +--------- -------- +Deviance 44.6233 + + Likelihood Ratio Confidence Intervals + +Parameter Estimate Lower Upper +-------------- -------- -------- -------- +IS_REAL -4.4214 -4.8845 -4.0199 +LIGHT_VS_NO -2.1949 -5.7240 -0.1439 +HEAVY_VS_LIGHT 2.3528 0.0201 5.9229 +DIABETES 1.7880 1.0267 2.4936 +AGE_DECADE 0.5098 0.2740 0.7624 + + PARAMETER ESTIMATE STDERR +-------------- ------------- ------------ +IS_REAL -4.4213502051 0.219522959 +LIGHT_VS_NO -2.1948591506 1.3908270777 +HEAVY_VS_LIGHT 2.3528224494 1.4506756847 +DIABETES 1.7879540241 0.3710906453 +AGE_DECADE 0.5098191081 0.1243997543 + diff --git a/jenner-check/t003_dataugpoisson/meta.json b/jenner-check/t003_dataugpoisson/meta.json new file mode 100644 index 0000000..1ab5919 --- /dev/null +++ b/jenner-check/t003_dataugpoisson/meta.json @@ -0,0 +1,7 @@ +{ + "bundle": "t003_dataugpoisson", + "source_file": "Simulation study/Sas macro/dataugpoisson.sas", + "source_commit": "5d953ccdd9f5f72d3f2be53b567d35e83926406c", + "tier": "real_data", + "notes": "Bayesian data augmentation from dataugpoisson.sas inlined without macro. Pseudo-observations built inline from prior variances. Variable is_real replaces _const_ to avoid formula parsing issues. Applied with prior intervals 1000 1000 1000 100 matching the paper analysis." +} \ No newline at end of file diff --git a/jenner-check/t003_dataugpoisson/script.sas b/jenner-check/t003_dataugpoisson/script.sas new file mode 100644 index 0000000..b811f5a --- /dev/null +++ b/jenner-check/t003_dataugpoisson/script.sas @@ -0,0 +1,120 @@ +*** Bayesian data augmentation for Poisson regression (dataugpoisson); +*** Implements the core logic of %dataugpoisson from +*** Simulation study/Sas macro/dataugpoisson.sas; +*** Applied to the Implant Dentistry study with weakly informative priors: +*** prior intervals [1/1000, 1000] for dichotomous variables, +*** [1/100, 100] for age in decades. + +*** Implant dentistry data (from repository Impdent.csv); + +data Impdent; + input Light_vs_no Heavy_vs_light Diabetes Age_decade + Implants Hema log_Implants; + datalines; +0 0 0 -4 137 0 4.9199809258 +0 0 0 -3 161 0 5.081404365 +0 0 0 -2 205 0 5.3230099791 +0 0 0 -1 363 5 5.8944028343 +0 0 0 0 422 1 6.045005314 +0 0 0 1 335 4 5.8141305318 +0 0 0 2 183 8 5.2094861528 +0 0 0 3 25 3 3.2188758249 +0 0 1 -4 1 0 0 +0 0 1 -2 3 0 1.0986122887 +0 0 1 -1 14 0 2.6390573296 +0 0 1 0 21 4 3.0445224377 +0 0 1 1 26 4 3.258096538 +0 0 1 2 9 4 2.1972245773 +0 0 1 3 7 0 1.9459101491 +1 0 0 -4 42 0 3.7376696183 +1 0 0 -3 27 0 3.295836866 +1 0 0 -2 48 0 3.8712010109 +1 0 0 -1 93 0 4.5325994932 +1 0 0 0 66 0 4.189654742 +1 0 0 1 41 0 3.7135720667 +1 0 0 2 8 0 2.0794415417 +1 0 1 -4 5 0 1.6094379124 +1 0 1 -1 8 0 2.0794415417 +1 1 0 -3 12 0 2.4849066498 +1 1 0 -2 36 0 3.5835189385 +1 1 0 -1 43 4 3.7612001157 +1 1 0 0 34 0 3.5263605246 +1 1 0 1 12 0 2.4849066498 +1 1 0 2 2 0 0.6931471806 +1 1 1 0 4 0 1.3862943611 +1 1 1 1 8 0 2.0794415417 +1 1 1 2 4 0 1.3862943611 +; +run; + +* Compute prior variance for each covariate from prior interval; +* Prior intervals: Light_vs_no=1000, Heavy_vs_light=1000, Diabetes=1000, Age_decade=100; +%let S = 10000; + +data _pv; + S = &S; + pi1=1000; pi2=1000; pi3=1000; pi4=100; + pv1 = (log(pi1)/1.96)**2; + pv2 = (log(pi2)/1.96)**2; + pv3 = (log(pi3)/1.96)**2; + pv4 = (log(pi4)/1.96)**2; + call symput('pv1', pv1); + call symput('pv2', pv2); + call symput('pv3', pv3); + call symput('pv4', pv4); +run; + +* Build augmented pseudo-observations (one row per covariate); +data _aug; + length is_real 8 Light_vs_no Heavy_vs_light Diabetes Age_decade Hema log_Implants 8; + is_real = 0; + + Light_vs_no=1/&S; Heavy_vs_light=0; Diabetes=0; Age_decade=0; + Hema = &S**2 / &pv1; log_Implants = log(Hema); output; + + Light_vs_no=0; Heavy_vs_light=1/&S; Diabetes=0; Age_decade=0; + Hema = &S**2 / &pv2; log_Implants = log(Hema); output; + + Light_vs_no=0; Heavy_vs_light=0; Diabetes=1/&S; Age_decade=0; + Hema = &S**2 / &pv3; log_Implants = log(Hema); output; + + Light_vs_no=0; Heavy_vs_light=0; Diabetes=0; Age_decade=1/&S; + Hema = &S**2 / &pv4; log_Implants = log(Hema); output; +run; + +* Add indicator to real data; +data _real; + set Impdent; + is_real = 1; +run; + +* Stack real + pseudo data; +data _work2; + set _real _aug; + keep is_real Light_vs_no Heavy_vs_light Diabetes Age_decade Hema log_Implants; +run; + +proc sort data=_work2; + by descending is_real; +run; + +* Fit the data-augmented Poisson model; +ods output ParameterEstimates=_DATAUGParms; +proc genmod data=_work2; + title3 "Bayesian data augmentation (prior intervals: 1000 1000 1000 100)"; + model Hema = is_real Light_vs_no Heavy_vs_light Diabetes Age_decade + / dist=poisson noint lrci offset=log_Implants; + output out=_DATAUGPredictions Predicted=DATAUGPred; +run; + +data _DATAUGPredictions; + set _DATAUGPredictions; + where is_real ne 0; +run; + +proc print data=_DATAUGParms noobs; + title3 "Augmented model parameter estimates"; + var Parameter Estimate StdErr LowerCI UpperCI; +run; + +title3;