在SAS中使用零膨胀泊松回归模型无法对测试集进行评分

时间:2014-07-09 15:21:55

标签: sas regression modeling glm poisson

我使用proc genmod运行零膨胀Poisson模型,我尝试使用Proc PLM对我的测试数据集进行评分,但它给了我这个错误:

proc genmod data = train2;
class region  / param=glm;
model response = var1 var2 var3 var4 var5
                    / dist=zip;
                    zeromodel;
output out = zeropoisson_output predicted= estprobzip;
store zero_poisson;
run;


proc plm source=zero_poisson;
  score data = test2 out= pred_zip;
run;

错误:此版本的PLM程序不支持评估零膨胀模型。

有关如何解决此问题的任何想法?

1 个答案:

答案 0 :(得分:0)

这将需要相当多的努力,但您总是可以使用ODS输出选项来获取参数估计值并从中解析数据。我从genmod上的SAS示例中获取了一些示例数据,并演示了保存系数并在下面解析它们的概念。输出是.sas文件,可以在任何数据步骤中包含%以对验证样本进行评分。

data drug;
   input drug$ x r n @@;
   datalines;
    A  .1   1  10   A  .23  2  12   A  .67  1   9
    B  .2   3  13   B  .3   4  15   B  .45  5  16   B  .78  5  13
    C  .04  0  10   C  .15  0  11   C  .56  1  12   C  .7   2  12
    D  .34  5  10   D  .6   5   9   D  .7   8  10
    E  .2  12  20   E  .34 15  20   E  .56 13  15   E  .8  17  20
    ;
run;

ods output ParameterEstimates = ZIP_COEFF_EST;
proc genmod data=drug;
      class drug;
      model r/n = x drug / dist = zip;
      zeromodel;
run;
ods output close;

data ZIP_COEFF_EST_Parsed;
    length equation $ 2500;
    set ZIP_COEFF_EST (rename=(estimate=coefficient)) end=last;
    where coefficient ne .;
    if upcase(Parameter) = "INTERCEPT" then do;
        equation = " = " || trim(left(put(coefficient,20.10)));
        output;
    end;
    else if LEVEL1 ne '' then do;
        equation = " + (" || trim(left(Parameter)) || " = '" || trim(left(LEVEL1)) || "') * (" || trim(left(put(coefficient,20.10))) || ")";
        output; 
    end;
    else do;
        equation = " + " || trim(left(Parameter)) || " * (" || trim(left(put(coefficient,20.10))) || ")";
        output;
    end;
    if last then do;
        equation=';';   
        output;
    end;
    keep equation;
run;

data _null_;
    set ZIP_COEFF_EST_Parsed;
    FILE  "C:/estimate_file.sas";;
    PUT equation;
run;