R Code for Regional Analysis: Shiny Applications for Teaching Logistic Regression with Reporting Templates in Japanese and English

Read full text
Authors: Yasutoshi Moteki
Cited by: 4
References: 1

Abstract

This deposit is part of the R Code for Regional Analysis series. It contains a Shiny application for binary logistic regression — a single R script with an English interface, depending only on shiny, ggplot2 and MASS — together with slide decks for two teaching sessions built around it. Live demonstration: https://moteki.shinyapps.io/logistic/ The application covers the standard workflow — data upload, outcome and predictor selection, reference-level selection, forced entry and stepwise procedures, odds ratios with confidence intervals, classification accuracy, ROC curves, goodness-of-fit tests and leave-one-out cross-validation — but its distinguishing feature is a write-up generator that renders the fitted model in the reporting conventions of academic journals. The convention is chosen by the user: APA style, including the table structure (B, SE, Wald, df, p, OR, 95% CI), the omission of leading zeros from bounded statistics, and the reporting of effect sizes; or the conventions of Japanese social science publications, which produce a table and accompanying prose of their own. Passages requiring the analyst's own theoretical reasoning and substantive interpretation are left as explicit blanks, so that the generated text scaffolds rather than replaces the student's writing. Version 3.2 adds a slide deck for the preceding session (Session 5), which introduces the method with the iris data built into the application. In one of its tasks, entering all four measurements produces quasi-complete separation, and the application declines to generate the write-up. The Session 6 deck is retitled "Logistic Regression ②: Reading and Reproducing a Published Model"; its content is unchanged. Version 3.1 adds a slide on which predictors to select and why. The student worksheet and instructor key have been withdrawn; the slide deck is the teaching material of record. In the teaching dataset, the two categories of insurance status are now those the authors recorded, Paid and Free for charge, in place of the earlier NotInsured and Insured: the original terms describe whether the patient paid for care, which is not the same thing as whether the patient held insurance. Version 3.0 merges what were, through version 2.1, two separate applications — one with a Japanese interface, one with an English interface. They are now a single application in which the reporting convention is a setting rather than a separate deployment; the Japanese address has been retired and the live demonstration is at one place. Nothing was removed from the write-up: both conventions are reproduced word for word from the applications they replace. Version 2.0 added a teaching package in which the application is used to reproduce a published analysis rather than to analyze a dataset prepared for the classroom. Students load the patient-level data deposited with Wassie, Beshah and Tiruneh (2022), a study of advanced-stage presentation among 367 colorectal cancer patients in northwest Ethiopia, and reproduce its multivariable logistic regression. Four of the five published odds ratios reproduce to one decimal place; the fifth does not, and the published description is not detailed enough to determine why. The exercise then yields statistics the source article does not report: the model classifies 85.6% of cases correctly against a no-information rate of 83.1%, with sensitivity of .95 and specificity of .37, while the area under the ROC curve is .858. A predictor recorded both continuously and dichotomized gives OR = 1.00 in the first form and OR = 5.59 in the second. The package comprises a slide deck (PowerPoint) and a 17-column CSV reformatted from the authors' Supporting Information file. Two design decisions in the application are pedagogical rather than technical. The no-information rate is printed beside the classification accuracy every time, unasked, because accuracy alone is close to meaningless in an unbalanced sample. The Hosmer–Lemeshow test is reported and annotated: it is no longer the recommended approach to calibration, but reviewers continue to ask for it, and a tool that refuses to produce what a research community expects will not be used by that community. The application also detects complete and quasi-complete separation and suppresses the generated write-up with an explanation of why the estimates cannot be interpreted. Working with a published dataset required five revisions that the built-in sample had not prompted: blank spreadsheet cells were read as a category rather than as missing, trailing blank rows were counted as cases, leading whitespace split one category into two, long generated lines did not wrap, and the reference level of a categorical predictor could not be chosen. None of these appeared with the built-in sample, which is clean by selection and — more decisively — is the data the code was written against. An application intended for classroom use is not finished until it has been driven through data that nobody prepared for teaching. Shiny applications for logistic regression are not new; Gjika's Logistic-Regression-Shiny-App and the jsmodule package offer comparable analytical functionality, and the present application was developed independently of them. What distinguishes this deposit is its orientation toward the act of writing up results, in two languages and two sets of disciplinary conventions, and its use of an openly published clinical dataset to make reproduction rather than simulation the basis of instruction. The teaching dataset accompanies the following article, published under a Creative Commons Attribution 4.0 International license. We thank the authors for depositing their data. Wassie M, Beshah DT, Tiruneh YM (2022) Advanced stage presentation and its determinant factors among colorectal cancer patients in Amhara regional state Referral Hospitals, Northwest Ethiopia. PLoS ONE 17(10): e0273692. https://doi.org/10.1371/journal.pone.0273692

Publication details

Journal / source
Zenodo (CERN European Organization for Nuclear Research)
Publication date
22 September 2026