Scénario de test & Cas d'usage
Simulation of high-volume web traffic (50,000 rows) with excessive zeros controlled by a 'IsMember' variable.
| 1 | |
| 2 | DATA mycas.web_traffic; |
| 3 | call streaminit(999); |
| 4 | DO session_id = 1 to 50000; |
| 5 | SessionDuration = rand('EXPONENTIAL') * 5; |
| 6 | IsMember = rand('BERNOULLI', 0.2); |
| 7 | IF rand('UNIFORM') < 0.8 THEN Purchases = 0; |
| 8 | ELSE Purchases = rand('POISSON', 1 + 0.1 * SessionDuration + 0.5 * IsMember); |
| 9 | OUTPUT; |
| 10 | END; |
| 11 | |
| 12 | RUN; |
| 13 |
| 1 | |
| 2 | PROC CAS; |
| 3 | countreg.countregFitModel / TABLE={name='web_traffic'} model={depVars={{name='Purchases'}}, effects={{vars={'SessionDuration', 'IsMember'}}}, modeloptions={modeltype='ZINB'}} zeromodel={effects={{vars={'SessionDuration'}}}, link='LOGISTIC'} OUTPUT={casout={name='scored_traffic', replace=true}, pred='PredCounts', probzero='ProbZero'}; |
| 4 | |
| 5 | RUN; |
| 6 |
| 1 | |
| 2 | PROC CAS; |
| 3 | TABLE.tableInfo / name='scored_traffic'; |
| 4 | |
| 5 | RUN; |
| 6 |
The ZINB model handles the high volume of zeros without convergence errors. The 'scored_traffic' table is created containing 'PredCounts' (expected purchases) and 'ProbZero' (probability of no purchase) for all 50,000 observations.