You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Proc Reg与Proc PLM生成置信区间的兼容性问题咨询

Proc REG vs PROC GLM: Why PROC PLM Fails to Generate Confidence/Prediction Intervals for REG-Stored Models?

I ran into exactly this issue recently: when I fit a linear regression with PROC REG, stored the model, then used PROC PLM to score a test dataset, all the confidence interval (LCLM/UCLM) and prediction interval (LCL/UCL) fields came up blank. But when I did the exact same workflow with PROC GLM, the intervals populated perfectly—even though the model parameter estimates from both procedures were identical.

The Root Cause: Model Metadata Differences

This isn't a compatibility bug—it's a deliberate difference in how PROC REG and PROC GLM store model metadata:

  • PROC GLM: When you use the STORE statement, it saves all auxiliary statistics needed to compute intervals, including residual sums of squares, degrees of freedom for error (DFE), mean squared error (MSE), and the inverse of the X'X matrix. PROC PLM relies on these values to calculate confidence/prediction bounds.
  • PROC REG: The default STORE output only saves the parameter estimates (coefficients) of the model. It does not include the variance-related statistics required for interval calculations. Even if you use OUTEST= or TABLEOUT, those outputs are separate from the stored model object—PROC PLM can't access them directly from the .itemstore file.

Verifying with Your Code

If you run the SAS code you provided, check the output datasets:

  • Pred (from the GLM model) will have fully populated lower_confidence_int, upper_confidence_int, lower_pred_int, and upper_pred_int columns.
  • Pred_lin_reg (from the REG model) will leave those columns empty—precisely because the stored REG model lacks the MSE and DFE values PROC PLM needs to compute the intervals.

Solutions

1. Switch to PROC GLM (Simplest Fix, When Possible)

If you're fitting a standard linear regression (no need for PROC REG-specific features like stepwise selection, ridge regression, or leverage diagnostics), just use PROC GLM to fit and store your model. As your code demonstrates, this works seamlessly with PROC PLM for interval generation.

2. Manual Interval Calculation (If You Must Use PROC REG)

If you need to stick with PROC REG (e.g., using its unique regression tools), you can compute the intervals manually by extracting the necessary stats from PROC REG outputs:

  1. Extract key statistics using ODS OUTPUT:

    ods output FitStatistics=RegFitStats ParameterEstimates=RegParams;
    proc reg data=A outest=RegOut tableout;
    model y = x;
    store work.proc_reg_model;
    quit;
    
    • RegFitStats will contain MSE and DFE.
    • RegOut (from TABLEOUT) includes the inverse of the X'X matrix (look for variables starting with XPX_).
  2. Compute intervals using the standard formulas:

    • Confidence interval for the mean response:
      $\hat{y} \pm t_{\alpha/2, DFE} \times \sqrt{MSE} \times \sqrt{x'(X'X)^{-1}x}$
    • Prediction interval for an individual response:
      $\hat{y} \pm t_{\alpha/2, DFE} \times \sqrt{MSE} \times \sqrt{1 + x'(X'X)^{-1}x}$

    You can implement this in a DATA step or using PROC IML for matrix operations.

内容的提问来源于stack exchange,提问作者asdiuh

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.14 07:21:25