Skip to content

多因素Logistic分析 ​

分析二分类结局发生的优势与解释因素之间的关系。

计算口径 ​

结局必须恰有两个有效类别;填写“结局事件编码”以指定所研究事件。分类解释因素整体编码,参照组单独设置;出现完全分离时普通极大似然估计不可靠。

把X及控制因素一起加入一个模型,采用共同完整样本。结合研究依据确定调整集,避免仅凭单因素p值机械筛选。

报告OR、置信区间和p值。OR针对优势,不等于概率比或风险比。多类别因素除各水平比较外,也应关注原始输出中的整体检验。

同源实现 ​

以下片段来自 core/statistical/regression.py 的 analyze_regression,由镜像脚本按语法树提取。共享辅助函数和分发逻辑包含在完整下载包中。

py
def analyze_regression(data, method, options):
    if method in ('stat_linear_simple', 'stat_linear_multiple', 'stat_linear_hierarchical'):
        return linear_regression(data, options, hierarchical=method == 'stat_linear_hierarchical', simple=method == 'stat_linear_simple')
    if method in ('stat_logistic_univariate', 'stat_logistic_multivariate'):
        return logistic_regression(data, options, univariate=method == 'stat_logistic_univariate')
    if method.startswith('stat_mediation_'):
        from .mechanisms import mediation
        return mediation(data, method, options)
    from .mechanisms import moderation
    return moderation(data, method, options)

查看完整模块 · 下载算法包 · 复现指南

复现本方法 ​

在解压目录安装 requirements.txt 后执行。样例为固定种子的模拟数据,仅供验证;输出不得冒充真实研究结果。

python
import examples._bootstrap
from examples.statistics_cases import build_data, method_cases
from core.statistical.runner import analyze

method = "stat_logistic_multivariate"
options = dict(method_cases())[method]
result = analyze(build_data(), method, options)
print(result.tables[0].html())

页面操作与解读教程

Released under the AGPL-3.0 License.