暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

用SAS进行泊松,零膨胀泊松和有限混合Poisson模型分析

拓端数据部落 2023-05-05
518

原文链接:http://tecdat.cn/?p=6145

在本文中,我们用SAS进行泊松,零膨胀泊松和有限混合Poisson模型分析点击文末“阅读原文”获取完整代码数据


泊松模型

 
proc fmm data = tmp1 tech = trureg;

  model majordrg = age acadmos minordrg logspend dist = truncpoisson;


  probmodel age acadmos minordrg logspend;


/*

Fit Statistics

 

-2 Log Likelihood             8201.0

AIC  (smaller is better)      8221.0

AICC (smaller is better)      8221.0

BIC  (smaller is better)      8293.5

 

Parameter Estimates for 'Truncated Poisson' Model

  

                                Standard

Component  Effect     Estimate     Error  z Value  Pr > |z|

 

        1  Intercept   -2.0706    0.3081    -6.72    <.0001

        1  AGE         0.01796  0.005482     3.28    0.0011

        1  ACADMOS    0.000852  0.000700     1.22    0.2240

        1  MINORDRG     0.1739   0.03441     5.05    <.0001

        1  LOGSPEND     0.1229   0.04219     2.91    0.0036

 

Parameter Estimates for Mixing Probabilities

  

                         Standard

Effect       Estimate       Error    z Value    Pr > |z|

 

Intercept     -4.2309      0.1808     -23.40      <.0001

AGE           0.01694    0.003323       5.10      <.0001

ACADMOS      0.002240    0.000492       4.55      <.0001

MINORDRG       0.7653     0.03842      19.92      <.0001

LOGSPEND       0.2301     0.02683       8.58      <.0001

*/

 

*** HURDLE POISSON MODEL WITH NLMIXED PROCEDURE ***;

proc nlmixed data = tmp1 tech = trureg maxit = 500;

  parms B1_intercept = -4 B1_age = 0 B1_acadmos = 0 B1_minordrg = 0 B1_logspend = 0

        B2_intercept = -2 B2_age = 0 B2_acadmos = 0 B2_minordrg = 0 B2_logspend = 0;

 

  eta1 = B1_intercept + B1_age * age + B1_acadmos * acadmos + B1_minordrg * minordrg + B1_logspend * logspend;

  exp_eta1 = exp(eta1);

  p0 = 1 (1 + exp_eta1);

  eta2 = B2_intercept + B2_age * age + B2_acadmos * acadmos + B2_minordrg * minordrg + B2_logspend * logspend;

  exp_eta2 = exp(eta2);

  if majordrg = 0 then _prob_ = p0;

  else _prob_ = (1 - p0) * exp(-exp_eta2) * (exp_eta2 ** majordrg) ((1 - exp(-exp_eta2)) * fact(majordrg));

  ll = log(_prob_);

  model majordrg ~ general(ll);

run;

/*

Fit Statistics

 

-2 Log Likelihood                 8201.0

AIC (smaller is better)           8221.0

AICC (smaller is better)          8221.0

BIC (smaller is better)           8293.5

 

Parameter Estimates

  

                          Standard

Parameter      Estimate      Error     DF   t Value   Pr > |t|

 

B1_intercept    -4.2309     0.1808    1E4    -23.40     <.0001

B1_age          0.01694   0.003323    1E4      5.10     <.0001

B1_acadmos     0.002240   0.000492    1E4      4.55     <.0001

B1_minordrg      0.7653    0.03842    1E4     19.92     <.0001

B1_logspend      0.2301    0.02683    1E4      8.58     <.0001

============

B2_intercept    -2.0706     0.3081    1E4     -6.72     <.0001

B2_age          0.01796   0.005482    1E4      3.28     0.0011

B2_acadmos     0.000852   0.000700    1E4      1.22     0.2240

B2_minordrg      0.1739    0.03441    1E4      5.05     <.0001

B2_logspend      0.1229    0.04219    1E4      2.91     0.0036

*/

零膨胀泊松模型

*** ZERO-INFLATED POISSON MODEL WITH FMM PROCEDURE ***;

proc fmm data = tmp1 tech = trureg;

  model majordrg = age acadmos minordrg logspend dist = poisson;


  probmodel age acadmos minordrg logspend;

run;

/*

Fit Statistics

 

-2 Log Likelihood             8147.9

AIC  (smaller is better)      8167.9

AICC (smaller is better)      8167.9

BIC  (smaller is better)      8240.5

 

Parameter Estimates for 'Poisson' Model

  

                                Standard

Component  Effect     Estimate     Error  z Value  Pr > |z|

 

        1  Intercept   -2.2780    0.3002    -7.59    <.0001

        1  AGE         0.01956  0.006019     3.25    0.0012

        1  ACADMOS    0.000249  0.000668     0.37    0.7093

        1  MINORDRG     0.1176   0.02711     4.34    <.0001

        1  LOGSPEND     0.1644   0.03531     4.66    <.0001

 

Parameter Estimates for Mixing Probabilities

  

                         Standard

Effect       Estimate       Error    z Value    Pr > |z|

 

Intercept     -1.9111      0.4170      -4.58      <.0001

AGE          -0.00082    0.008406      -0.10      0.9218

ACADMOS      0.002934    0.001085       2.70      0.0068

MINORDRG       1.4424      0.1361      10.59      <.0001

LOGSPEND      0.09562     0.05080       1.88      0.0598

*/

 

*** ZERO-INFLATED POISSON MODEL WITH NLMIXED PROCEDURE ***;

proc nlmixed data = tmp1 tech = trureg maxit = 500;

  parms B1_intercept = -2 B1_age = 0 B1_acadmos = 0 B1_minordrg = 0 B1_logspend = 0

        B2_intercept = -2 B2_age = 0 B2_acadmos = 0 B2_minordrg = 0 B2_logspend = 0;

 

  eta1 = B1_intercept + B1_age * age + B1_acadmos * acadmos + B1_minordrg * minordrg + B1_logspend * logspend;

  exp_eta1 = exp(eta1);

  p0 = 1 (1 + exp_eta1);

  eta2 = B2_intercept + B2_age * age + B2_acadmos * acadmos + B2_minordrg * minordrg + B2_logspend * logspend;

  exp_eta2 = exp(eta2);

  if majordrg = 0 then _prob_ = p0 + (1 - p0) * exp(-exp_eta2);

  else _prob_ = (1 - p0) * exp(-exp_eta2) * (exp_eta2 ** majordrg) fact(majordrg);

  ll = log(_prob_);

  model majordrg ~ general(ll);

run;

/*

Fit Statistics

 

-2 Log Likelihood                 8147.9

AIC (smaller is better)           8167.9

AICC (smaller is better)          8167.9

BIC (smaller is better)           8240.5

 

Parameter Estimates

  

                          Standard

Parameter      Estimate      Error     DF   t Value   Pr > |t|

 

B1_intercept    -1.9111     0.4170    1E4     -4.58     <.0001

B1_age         -0.00082   0.008406    1E4     -0.10     0.9219

B1_acadmos     0.002934   0.001085    1E4      2.70     0.0068

B1_minordrg      1.4424     0.1361    1E4     10.59     <.0001

B1_logspend     0.09562    0.05080    1E4      1.88     0.0598

============

B2_intercept    -2.2780     0.3002    1E4     -7.59     <.0001

B2_age          0.01956   0.006019    1E4      3.25     0.0012

B2_acadmos     0.000249   0.000668    1E4      0.37     0.7093

B2_minordrg      0.1176    0.02711    1E4      4.34     <.0001

B2_logspend      0.1644    0.03531    1E4      4.66     <.0001

*/


点击标题查阅往期内容


R语言和Python用泊松过程扩展:霍克斯过程Hawkes Processes分析比特币交易数据订单到达自激过程时间序列


左右滑动查看更多


01

02

03

04



两类有限混合Poisson模型

*** TWO-CLASS FINITE MIXTURE POISSON MODEL WITH FMM PROCEDURE ***;

proc fmm data = tmp1 tech = trureg;

  model majordrg = age acadmos minordrg logspend dist = poisson k = 2;


run;

/*

Fit Statistics

 

-2 Log Likelihood             8136.8

AIC  (smaller is better)      8166.8

AICC (smaller is better)      8166.9

BIC  (smaller is better)      8275.7

 

Parameter Estimates for 'Poisson' Model

  

                                Standard

Component  Effect     Estimate     Error  z Value  Pr > |z|

 

        1  Intercept   -2.4449    0.3497    -6.99    <.0001

        1  AGE         0.02214  0.006628     3.34    0.0008

        1  ACADMOS    0.000529  0.000770     0.69    0.4920

        1  MINORDRG    0.05054   0.04015     1.26    0.2081

        1  LOGSPEND     0.2140   0.04127     5.18    <.0001

        2  Intercept   -8.0935    1.5915    -5.09    <.0001

        2  AGE         0.01150   0.01294     0.89    0.3742

        2  ACADMOS    0.004567  0.002055     2.22    0.0263

        2  MINORDRG     0.2638    0.6770     0.39    0.6968

        2  LOGSPEND     0.6826    0.2203     3.10    0.0019

 

Parameter Estimates for Mixing Probabilities

  

                         Standard

Effect       Estimate       Error    z Value    Pr > |z|

 

Intercept     -1.4275      0.5278      -2.70      0.0068

AGE          -0.00277     0.01011      -0.27      0.7844

ACADMOS      0.001614    0.001440       1.12      0.2623

MINORDRG       1.5865      0.1791       8.86      <.0001

LOGSPEND     -0.06949     0.07436      -0.93      0.3501

*/

 

*** TWO-CLASS FINITE MIXTURE POISSON MODEL WITH NLMIXED PROCEDURE ***;

proc nlmixed data = tmp1 tech = trureg maxit = 500;


        B2_intercept = -8 B2_age = 0 B2_acadmos = 0 B2_minordrg = 0 B2_logspend = 0


 

  eta1 = B1_intercept + B1_age * age + B1_acadmos * acadmos + B1_minordrg * minordrg + B1_logspend * logspend;

  exp_eta1 = exp(eta1);

  prob1 = exp(-exp_eta1) * exp_eta1 ** majordrg fact(majordrg);

  eta2 = B2_intercept + B2_age * age + B2_acadmos * acadmos + B2_minordrg * minordrg + B2_logspend * logspend;

  exp_eta2 = exp(eta2);

  prob2 = exp(-exp_eta2) * exp_eta2 ** majordrg fact(majordrg);

  eta3 = B3_intercept + B3_age * age + B3_acadmos * acadmos + B3_minordrg * minordrg + B3_logspend * logspend;

  exp_eta3 = exp(eta3);

  p = exp_eta3 (1 + exp_eta3);

  _prob_ = p * prob1 + (1 - p) * prob2;

  ll = log(_prob_);

  model majordrg ~ general(ll);

run;

/*

Fit Statistics

 

-2 Log Likelihood                 8136.8

AIC (smaller is better)           8166.8

AICC (smaller is better)          8166.9

BIC (smaller is better)           8275.7

 

Parameter Estimates

  

                          Standard

Parameter      Estimate      Error     DF   t Value   Pr > |t|

 

B1_intercept    -2.4449     0.3497    1E4     -6.99     <.0001

B1_age          0.02214   0.006628    1E4      3.34     0.0008

B1_acadmos     0.000529   0.000770    1E4      0.69     0.4920

B1_minordrg     0.05054    0.04015    1E4      1.26     0.2081

B1_logspend      0.2140    0.04127    1E4      5.18     <.0001

============

B2_intercept    -8.0935     1.5916    1E4     -5.09     <.0001

B2_age          0.01150    0.01294    1E4      0.89     0.3742

B2_acadmos     0.004567   0.002055    1E4      2.22     0.0263

B2_minordrg      0.2638     0.6770    1E4      0.39     0.6968

B2_logspend      0.6826     0.2203    1E4      3.10     0.0020

============

B3_intercept    -1.4275     0.5278    1E4     -2.70     0.0068

B3_age         -0.00277    0.01011    1E4     -0.27     0.7844

B3_acadmos     0.001614   0.001440    1E4      1.12     0.2623

B3_minordrg      1.5865     0.1791    1E4      8.86     <.0001

B3_logspend    -0.06949    0.07436    1E4     -0.93     0.3501

*/

 



点击文末“阅读原文”

获取全文完整代码数据资料


本文选自《用SAS进行泊松,零膨胀泊松和有限混合Poisson模型分析》。


点击标题查阅往期内容

R语言小数定律的保险业应用:泊松分布模拟索赔次数
R语言和Python用泊松过程扩展:霍克斯过程Hawkes Processes分析比特币交易数据订单到达自激过程时间序列
R语言逻辑回归和泊松回归模型对发生交通事故概率建模
R语言贝叶斯METROPOLIS-HASTINGS GIBBS 吉布斯采样器估计变点指数分布分析泊松过程车站等待时间
R语言中的模拟过程和离散化:泊松过程和维纳过程
R语言贝叶斯Poisson泊松-正态分布模型分析职业足球比赛进球数
R语言用泊松Poisson回归、GAM样条曲线模型预测骑自行车者的数量
R语言用GAM广义相加模型研究公交专用道对行程时间变异度数据的影响
【视频】广义相加模型(GAM)在电力负荷预测中的应用
分位数回归、GAM样条曲线、指数平滑和SARIMA对电力负荷时间序列预测
实现广义相加模型GAM和普通最小二乘(OLS)回归
R语言非参数模型厘定保险费率:局部回归、广义相加模型GAM、样条回归
R语言广义加性模型GAMs分析温度、臭氧环境数据绘制偏回归图与偏残差图
R语言广义相加(加性)模型(GAMs)与光滑函数可视化
R语言里的非线性模型:多项式回归、局部样条、平滑样条、 广义相加模型GAM分析
R语言用标准最小二乘OLS,广义相加模型GAM ,样条函数进行逻辑回归LOGISTIC分类
R语言ISLR工资数据进行多项式回归和样条回归分析
R语言中的多项式回归、局部回归、核平滑和平滑样条回归模型
R语言用泊松Poisson回归、GAM样条曲线模型预测骑自行车者的数量
R语言分位数回归、GAM样条曲线、指数平滑和SARIMA对电力负荷时间序列预测
R语言中的多项式回归、B样条曲线(B-spline Curves)回归
R语言广义相加模型 (GAMs)分析预测CO2时间序列数据
R语言中实现广义相加模型GAM和普通最小二乘(OLS)回归
在r语言中使用GAM(广义相加模型)进行电力负荷时间序列分析
R语言用泊松Poisson回归、GAM样条曲线模型预测骑自行车者的数量
Python用广义加性模型GAM进行时间序列分析
R语言广义线性模型GLM、多项式回归和广义可加模型GAM预测泰坦尼克号幸存者
R语言中的广义线性模型(GLM)和广义相加模型(GAM):多元(平滑)回归分析保险资金投资组合信用风险敞口
R语言对用电负荷时间序列数据进行K-medoids聚类建模和GAM回归
对用电负荷时间序列数据进行K-medoids聚类建模和GAM回归


文章转载自拓端数据部落,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论