Charlotte Stevens
Charlotte Stevens

Reputation: 91

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?

Upvotes: 1

Views: 553

Answers (1)

JJFord3
JJFord3

Reputation: 1985

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; 

Upvotes: 0

Related Questions