You are on page 1of 4

data zip1;

input y x1 x2 x3 x4;
cards;
0
0
0
0
2
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0

0.924118438
1.444227474
-0.349251962
-0.002512604
0.625205198
0.433900725
0.7268357
1.175205559
-0.050338722
-0.349251962
-0.349251962
0.475748579
1.013792409
3.23770691
0.798574877
-0.79762182
1.671401536
0.45183552
-0.420991139
1.444227474
-0.050338722
0.565422551
-0.612295612
-0.648165201
0.547487756
-2.740557876
0.398031137
-0.349251962
-0.79762182
-0.199795342
0.696944376
1.444227474
-0.349251962
-3.338384354
0.248574517
-0.349251962
3.23770691
-0.498708581
1.145314235
-0.349251962
-2.142731397
-0.546534699
1.444227474
-0.648165201
0.846400995
-0.24762146
1.073575057
0.948031497
0.995857615
-0.648165201
-1.395448299
-0.349251962
-0.719904378
0.194770134

-0.871743597
-1.380800761
-1.078602737
-1.301643247
-0.615465678
-0.65001509
-1.237792434
-1.296832569
-1.020874605
-1.344064677
-1.00731724
-0.718239246
-1.081226743
-1.349750023
-1.090410764
-1.06985605
-1.162133594
-0.908042347
1.405456276
0.33398716
-0.987199861
-0.963146473
0.410520668
1.458811065
0.027853126
-0.882239621
0.26838701
1.011855376
1.244954576
0.260952326
-0.740980631
0.482680833
-0.529748148
-0.51881479
0.064151876
-0.553801537
0.246520293
-0.332947698
-0.319390334
-1.247851124
0.00598641
0.771321493
1.886524043
-0.740980631
1.667856876
2.086385833
-1.427595535
-0.65001509
-0.812266128
-0.287902262
0.79318821
0.055842524
0.81243092
-0.320702337

-1.576771344
-1.312801912
-1.81199163
-2.047211915
-1.291893443
-1.122012125
-1.93482889
-1.741425544
-1.467001877
-1.007015541
-1.804150953
-1.464388319
-1.976645829
-1.498364582
-0.957357925
-1.158601948
-0.416351269
-0.139314044
1.245872082
0.135109623
-0.191585218
-0.646344437
0.548051902
-1.150761271
-0.12624625
0.150790975
-0.669866465
0.375557026
0.968834857
0.114201153
-0.654185113
0.043635067
-0.418964827
-1.13246636
0.156018093
-0.766568138
1.115194146
0.527143432
-1.122012125
0.767590835
0.629072223
0.940085711
0.5924824
-0.408510593
0.929631476
1.376550019
-1.004401983
-0.322263154
0.255333324
-0.484303796
-0.669866465
-0.042612371
0.772817953
0.882587419

-0.271794512
-0.667653537
0.519923538
-0.073864999
-0.073864999
0.321994026
-1.162477318
-0.172829756
-0.766618293
-0.667653537
-0.568688781
-0.667653537
-0.370759268
-1.261442074
0.420958782
1.410606345
0.025099757
-1.558336343
-0.568688781
-1.360406831
0.321994026
-1.360406831
0.321994026
1.80646537
-1.063512562
0.915782563
0.915782563
0.22302927
-0.172829756
-0.271794512
-0.073864999
0.519923538
0.22302927
2.301289151
-0.271794512
0.025099757
-0.172829756
-0.964547806
-0.865583049
-0.469724024
-0.568688781
-0.172829756
-0.667653537
-1.261442074
0.420958782
2.400253907
0.025099757
1.01474732
-0.172829756
0.321994026
-1.162477318
0.717853051
1.113712076
-0.370759268

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
1
0
0
0
0
0

-1.293817798
0.995857615
0.995857615
-0.349251962
-0.570447759
0.099117897
-0.1220779
-1.245991679
0.248574517
-1.64653542
1.025748939
-0.050338722
-0.050338722
-2.142731397
1.444227474
-0.271534519
-0.199795342
-0.199795342
-1.843818158
-1.09653506
0.051291779
-0.050338722
-0.050338722
-0.349251962
0.009443926
-1.018817618
0.421944196
-0.349251962
0.924118438
-0.050338722
-0.845447939
-0.94707844
0.547487756
0.039335249
-0.349251962
-0.749795702
0.696944376
0.224661458
0.009443926
-0.050338722
0.517596432
0.995857615
0.332270224
-0.349251962
-0.349251962
0.17683534
-0.050338722
-0.755773967
1.444227474
-0.450882463
-0.349251962
-0.94707844
0.995857615
-0.648165201
-0.349251962
-0.648165201
-2.740557876
0.099117897
-0.050338722
1.444227474

1.562896636
-0.163261977
-0.011506964
0.169986785
-0.04955505
1.555461952
-0.354814415
0.05846653
0.207160203
1.23926923
1.270319967
0.694787985
1.799057176
0.295939073
2.236391509
-0.486014715
0.943193886
0.009485084
-0.08891514
3.340660701
-0.877428943
-0.970581156
-1.010815915
1.398021593
0.744644099
0.011671756
-1.171317615
0.33398716
0.800622893
0.180920143
-0.300147623
1.991484283
-0.645641747
-0.402046523
0.686915967
0.27450969
0.013421093
-0.486889384
0.408333996
-1.142016215
0.24826963
-0.890548973
0.408333996
1.099322243
-0.314579656
0.141560053
0.994362003
0.55003032
-1.30601659
-1.232981756
-0.71561524
-0.09591249
0.093453276
0.237336272
1.090575556
0.193602839
1.857222642
-0.026813665
-0.45321464
-0.457587983

1.585634717
-0.353625859
-0.609754615
-0.12624625
0.610777311
0.741455248
1.397458489
1.376550019
0.514075639
1.533363543
1.637905892
0.396465496
2.116187139
0.265787559
1.115194146
0.919177241
-0.638503761
-0.31180892
0.495780727
1.311211051
-0.471236002
-1.817218747
-0.583619027
0.723160337
0.184767239
1.572566923
-0.633276643
-1.106330773
1.551658454
-0.638503761
1.562112689
1.428821193
-0.374534329
0.767590835
1.300756816
-0.416351269
-0.975652837
0.213516385
0.122041829
-1.399049351
0.090679125
-1.171669741
0.069770655
-0.060907282
0.5924824
0.200448591
0.278855353
0.707478984
-1.58461202
-1.208259563
0.331126528
-0.191585218
-1.281439208
0.406919731
1.428821193
0.5924824
2.683329383
-0.353625859
-0.497371589
0.487940051

0.618888295
-0.964547806
0.025099757
-1.261442074
0.22302927
-0.865583049
-0.667653537
-0.964547806
0.420958782
1.410606345
-0.370759268
0.618888295
1.707500614
0.519923538
0.22302927
-2.646948662
-0.073864999
-0.766618293
-0.172829756
0.025099757
0.519923538
-0.766618293
0.618888295
0.618888295
-1.261442074
0.519923538
-0.172829756
-0.172829756
0.321994026
0.22302927
-0.964547806
2.202324395
2.697148176
0.519923538
1.01474732
-0.469724024
1.01474732
-0.073864999
1.311641589
-1.360406831
0.420958782
0.618888295
0.816817807
-2.646948662
1.01474732
1.311641589
2.499218664
-0.370759268
-0.172829756
0.519923538
0.420958782
-0.172829756
-1.360406831
-0.073864999
0.22302927
2.202324395
-1.261442074
-1.558336343
-0.766618293
-0.568688781

0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
;

0.7268357
-0.749795702
0.547487756
-0.11012137
-0.648165201
0.924118438
-0.719904378
-0.648165201
-1.616644096
0.146944016
-0.349251962
-0.827513144
-0.498708581
-0.349251962
0.547487756
-1.198165561
1.073575057
-0.349251962
1.444227474
0.547487756
1.892597333
-0.845447939
0.995857615
0.995857615

-0.915914365
3.010910613
-1.343627343
-0.472020016
-0.890548973
-1.162133594
-0.221427443
2.484360076
0.204973531
0.063277207
-0.936906413
-0.185566028
0.122754677
0.082519918
-0.693748523
-0.119091209
-0.420414565
0.180920143
-0.087603137
0.145933396
-0.658761777
-0.070547098
2.529842847
-0.929909063

-0.669866465
1.300756816
-0.750886786
-0.518280059
0.004431687
0.516689197
-0.766568138
0.331126528
0.474872258
0.213516385
-0.800544402
0.189994356
2.029939701
0.461804464
-0.340558066
0.18215368
0.396465496
0.004431687
-1.534954404
0.487940051
0.487940051
1.572566923
1.115194146
1.115194146

-1.360406831
-0.271794512
-0.271794512
0.025099757
0.025099757
-0.469724024
2.697148176
-1.954195368
-0.766618293
-1.063512562
1.113712076
0.124064513
0.519923538
-0.865583049
1.311641589
-0.865583049
0.321994026
1.608535857
-0.370759268
0.025099757
0.618888295
0.816817807
-0.667653537
-0.766618293

run;
/*Poisson Log-Linear model */
title'poisson model';
proc nlmixed data=zip1;
parms a0=0 a1=0 a2=0 a4=0;
eta=a0+a1*x1+a2*x2+a4*x4;
lambda=exp(eta);
model y~poisson(lambda);
predict_ll out=LL_1;
run;
/*Zero-Inflated Poisson Model*/
title"zip model";
proc nlmixed data=zip1;
parameter a0=0 a1=0 a2=0 a4=0 b0=0 b1=0 b2=0 b4=0;
linpinfl=a0+a1*x1+a2*x2+a4*x4;
bpart=b0+b1*x1+b2*x2+b4*x4;
lambda=exp(bpart)

infprob=exp(linpinfl)/(1+exp(linpinfl));
if y=0 then ll=log(infprob+(1-infprob)*exp(-lambda));
else ll=log((1-infprob))+y*log(lambda)-lgamma(y+1)lambda;
model y~general(ll);
predict _ll out=LL_2;
run;
/*Vuong Test*/
title1'vuong test for zip vs. poisson';
title2'H0=no improvement of zip over poisson';
data ll_diff;
merge ll_1(rename=(pred=ll_poisson))
ll_2(rename=(pred=ll_zip));
run;
data ll_diff;
set ll_diff;
lr_i=ll_poisson_ll_zip;
keep ll_poisson ll_zip lr_i;
run;
proc means data=ll_diff vardef=n;
var lr_i;
output out=vuong_stats mean=LR var=V_lr_i n=n;
run;
data vuong_stats;
set vuong_stats;
vuong=-(LR/sqrt(v lr i/n));
p=2*(1-probnorm(vuong));
put vuong=p=;
run;

You might also like