stat-logistic-regression
Fit a logistic regression model for binary outcomes, report odds ratios and model performance (AUC-ROC, confusion matrix).
- License 许可
- MIT
- 最近更新
- 2026-11-03
- Stars
- ★ 4
- Forks
- 1
01 前言 Front Matter
- name
- stat-logistic-regression
- description
- Fit a logistic regression model for binary outcomes, report odds ratios and model performance (AUC-ROC, confusion matrix).
02 资源文件 3
- 参考文档agents/claude.yaml336 B
- 参考文档agents/openai.yaml337 B
- 参考文档config.yaml300 B
03 SKILL.md 正文
Skill: Logistic Regression
Use When
- User wants to model the probability of a binary outcome (disease/healthy, expressed/not expressed, responder/non-responder)
- User needs odds ratios and their confidence intervals for each predictor
- User wants to evaluate model discrimination with AUC-ROC and calibration
- Common in medical, epidemiological, and genomics classification tasks
Inputs
- Required:
- Data table (CSV or TSV) with a binary outcome column (0/1 or two-level factor) and one or more predictor columns
- Outcome variable name
- Predictor variable name(s)
- Optional:
- Regularization:
none(default),l1(Lasso), orl2(Ridge) - Test set fraction for performance evaluation (default:
0.2) - Output directory (default:
./logit_output)
- Regularization:
Workflow
- Read data; validate that outcome column is binary; encode predictors as needed.
- Split data into training and test sets (stratified by outcome).
- Fit logistic regression on training set:
- If
regularization=none: unpenalized MLE fit for inferential reporting. - If
regularization=l1orl2: cross-validated penalized fit for prediction-focused modeling.
- If
- Report coefficients:
- Unpenalized model: log-odds estimate, standard error, z-statistic, p-value, odds ratio, 95% CI.
- Penalized model: shrunken coefficients and odds ratios; do not report classical p-values/z-statistics from penalized fit.
- Evaluate on test set: compute AUC-ROC, plot ROC curve, compute confusion matrix at 0.5 threshold (accuracy, sensitivity, specificity, PPV, NPV).
- Compute Hosmer-Lemeshow goodness-of-fit test for calibration for the unpenalized model; for penalized models, report calibration curve and Brier score.
- If regularization is used: report optimal lambda from cross-validation and non-zero coefficients at optimal lambda.
- Save the executable analysis script (
analysis_code.pyoranalysis_code.R) and software version manifest (session_info.txt) used to produce results. - Write coefficient table(s), performance metrics (TSV), ROC curve plot (PDF), and calibration plot (PDF) to output directory.
Output Contract
- Coefficient table (TSV, unpenalized): term, log_odds, std_error, z_statistic, p_value, odds_ratio, ci_lower_or, ci_upper_or
- Coefficient table (TSV, penalized): term, log_odds, odds_ratio, selected_at_lambda
- Performance metrics (TSV): auc, accuracy, sensitivity, specificity, ppv, npv, hl_test_p_or_na, brier_score
- ROC curve (PDF)
- Confusion matrix (printed to stdout)
- Reproducibility artifacts:
analysis_code.pyoranalysis_code.R, plussession_info.txt
Limits
- Assumes independence of observations; does not account for clustering or repeated measures.
- Requires sufficient events per variable (EPV ≥ 10 recommended) to avoid overfitting.
- Class imbalance can inflate accuracy; examine sensitivity/specificity and AUC.
- Penalized models are prediction-oriented; classical inferential statistics (standard errors/p-values) are not directly interpretable from penalized coefficients.
- Common failure: outcome column with more than two levels — binarize before running.
04 同仓库更多 Skills
structured-intelligence-skill-creator
Create or update repository skills that conform to local templates, provider metadata requirements, registry rules, and validation workflows.
stat-survival-analysis
Estimate and compare survival functions using Kaplan-Meier curves and log-rank test, with optional Cox proportional hazards regression.
stat-pca
Perform PCA on a numeric data matrix to reduce dimensionality, visualize sample structure, and identify top contributing features.
stat-pairwise-correlation
Compute pairwise correlations and significance tests across all numeric variables, and produce a correlation heatmap.
stat-nonlinear-embedding
Embed high-dimensional data into 2D using t-SNE or UMAP for exploratory visualization of sample or cell relationships.
stat-learn-bayesian-network
Learn the structure and conditional probabilities of a Bayesian network from observational data for causal discovery or dependency modeling.