【发布时间】:2020-01-03 16:54:21
【问题描述】:
我已经使用 Proc Reg 和 Proc GLM 对一组训练数据进行了线性回归。当我对测试数据集进行评分时,我只能在保存的 Proc GLM 模型上使用 Proc PLM 创建 Confidence - Proc Reg 模型导致空白(尽管是相同的模型)
这只是一个关于 Proc Reg 在生成测试数据的置信区间时是否与 Proc PLM 不兼容的问题。
以下代码可在任何机器上运行(生成要回归的虚拟数据)
/* the original data; fit model to these values */
data A;
input x y @@;
datalines;
1 4 2 9 3 20 4 25 5 1 6 5 7 -4 8 12
;
/* the scoring data; evaluate model on these values */
%let NumPts = 200;
data ScoreX(keep=x);
min=1; max=8;
do i = 0 to &NumPts-1;
x = min + i*(max-min)/(&NumPts-1); /* evenly spaced values */
output; /* no Y variable; only X */
end;
run;
proc reg data=A outest=RegOut tableout;
model y = x; /* name of model is used by PROC SCORE */
store work.proc_reg_model;
quit;
ods output ParameterEstimates=Pi_Parameters FitStatistics=Pi_Summary;
proc glm data=A;
model y = x;
store work.proc_glm_model; /* store the model */
quit;
proc plm restore=work.proc_glm_model;
score data=ScoreX out=Pred predicted=yhat lcl=lower_pred_int lclm=lower_confidence_int ucl=upper_pred_int uclm=upper_confidence_int; /* evaluate the model on new data */
run;
proc plm restore=work.proc_reg_model;
score data=ScoreX out=Pred_lin_reg predicted=yhat lcl=lower_pred_int lclm=lower_confidence_int ucl=upper_pred_int uclm=upper_confidence_int; /* evaluate the model on new data */
run;
我希望两个模型的 PROC PLM 过程的输出数据集相同。 proc reg 模型的 PROC PLM 导致置信区间和预测区间的空白数据。可以看出,最后两个感兴趣的数据集是: pred_proc_reg(置信区间和预测区间的空白值) pred_proc_glm(置信区间和预测区间的填充值)
【问题讨论】:
标签: sas regression confidence-interval scoring