简体   繁体   中英

Can't score test set using zero inflated Poisson regression model in SAS

I've run a zero-inflated Poisson model using proc genmod and I'm trying to score my test data set using Proc PLM but it's giving me this error:

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;

ERROR: Scoring zero-inflated models is not supported in this release of the PLM procedure.

any ideas of how to get around this?

It will take considerably more effort, but you could always use the ODS output option to get the Parameter Estimates and parse through the data from there. I grabbed some example data from a SAS example on genmod and have demonstrated the concept of saving the coefficients and parsing through them below. The output is a .sas file that can be %included in any data step to score a validation sample.

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; 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM