poisson reg2557 1 - @@ home - kku web hostingpoisson regression ส าหรบข อม...

23
1 Poisson Regression ผู ้ช่วยศาสตราจารย์ นิคม ถนอมเสียง ภาควิชาชีวสถิติและประชากรศาสตร์ คณะสาธารณสุขศาสตร์ มหาวิทยาลัยขอนแก่น Email: [email protected]; Web: http://home.kku.ac.th/nikom เนื ้ อหา GLM สําหรับข้อมูลแจงนับ -Poisson Regression for count -Poisson regression for rate Inference and model checking -Wald, Likelihood ratio -Checking Poisson Regression -Residuals -Confidence intervals for fit values (means) -Overdisperion Fitting GLM -Newton-Raphson algorithm,Fisher scoring Iteratively Re-weight Least Square (IRLS) -Statistic inference & the Likelihood function Poisson Regression - to concentrate on describing the relation between dependent (response) variable and the predictor variables through the regression model. - estimate incidence rates & ratio (Frome & Checkoway 1985) - applied to estimate hazard rate ratio (Taulbee 1979; Laird & Olivier 1981; McCullagh and Nelder 2000.) Frome, 1983, 1986; Frome & Checkoway 1985;

Upload: others

Post on 07-Jan-2020

7 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: poisson reg2557 1 - @@ Home - KKU Web HostingPoisson Regression ส าหรบข อม ลแจงน บ Response (Dependent) หร อ outcome variable Y เป นจ านวนน

1

Poisson Regression

ผชวยศาสตราจารย นคม ถนอมเสยง

ภาควชาชวสถตและประชากรศาสตร

คณะสาธารณสขศาสตร มหาวทยาลยขอนแกน

Email: [email protected]; Web: http://home.kku.ac.th/nikom

เน อหา

GLM สาหรบขอมลแจงนบ

-Poisson Regression for count

-Poisson regression for rate

Inference and model checking

-Wald, Likelihood ratio

-Checking Poisson Regression

-Residuals

-Confidence intervals for fit values (means)

-Overdisperion

Fitting GLM

-Newton-Raphson algorithm,Fisher scoring

Iteratively Re-weight Least Square (IRLS)

-Statistic inference & the Likelihood function

Poisson Regression

- to concentrate on describing the relation between

dependent (response) variable and the predictor

variables through the regression model.

- estimate incidence rates & ratio (Frome & Checkoway 1985)

- applied to estimate hazard rate ratio (Taulbee 1979;

Laird & Olivier 1981; McCullagh and Nelder 2000.)

Frome, 1983, 1986; Frome & Checkoway 1985;

Page 2: poisson reg2557 1 - @@ Home - KKU Web HostingPoisson Regression ส าหรบข อม ลแจงน บ Response (Dependent) หร อ outcome variable Y เป นจ านวนน

2

GLM สาหรบขอมลแจงนบ

-Response (Dependent) หรอ outcome variable Y เปนจานวนนบ

-GLM สาหรบขอมลแจงนบ เมอ random component

คอ Poisson Distribution และ link function คอ log

เรยกอกชอหนงวา Poisson regression for count

ตวอยาง

- ปจจยทมผลตอ จานวนครงของอาการกาเรบ (exacerbation)

ในผปวย COPD

- จานวนคนเสยชวตดวยโรคเอดสในชวง 3 เดอนจาก

ม.ค.2526-ม.ย.2529

- การเกดโรคหวใจ coronary ระหวางชายกบหญงเมอทราบ

person-year

-Relationship of asthma management, socioeconomic status, and medicationinsurance characteristics to exacerbation frequency in children with asthma(Wendy J. Ungar, at al. Ann Allergy Asthma Immunol. 2011;106:17–23.)

-Increased mortality in COPD among construction workers exposed toinorganic dust. (Bergdahl, I.A. et al., (2004) European Respiratory Journal.)

Page 3: poisson reg2557 1 - @@ Home - KKU Web HostingPoisson Regression ส าหรบข อม ลแจงน บ Response (Dependent) หร อ outcome variable Y เป นจ านวนน

3

-A Multidimensional Grading System (BODE Index) as Predictor of Hospitalizationfor COPD. Ong K-C., Earnest. A, & Lu, S-J.CHEST / 128/6/DECEMBER,2005)

Poisson Regression สาหรบขอมลแจงนบ

Response (Dependent) หรอ outcome variable Y เปนจานวนนบ

Explanatory variable (s)

-ตวแปรกลม (categorical) (ขอมลสามารถอยในรปตารางการณจร)

เรยกวา “Loglinear model”

-ตวแปรตอเนอง เรยกวา “Poisson Regression”

เมอ Y เปนจานวนนบ, Y/t หรอ Y/person-time คอ rate

เรยกวา Poisson regression for rate

x )log(

Page 4: poisson reg2557 1 - @@ Home - KKU Web HostingPoisson Regression ส าหรบข อม ลแจงน บ Response (Dependent) หร อ outcome variable Y เป นจ านวนน

4

Component of GLM สาหรบขอมลจานวนนบ

Random component: Poisson Distribution และโมเดล

สาหรบคาคาดหวงของ Y ไดแก E(Y) =

Systematic component: 1 ตวแปรหรอมากกวา

Link function: Log link log( ) หรอเรยกวา “canonical link”

เขยนเปนสมการ Poisson Regression ดงน

เนองจากใช log( ) มชอเรยก “Poisson loglinear model”

x )log(

ตวแปร response เปนตวแปรของการเกดเหตการณทขนกบ

-เวลา (time)

-พนท (space)

-หรอขนาดดชนอนๆ (index of size)

ตวแปร response เปนอตรา (rate)

ตวแปร explanatory เปนตวแปรกลม (categorical data) หรอตวแปรตอเนอง

เรยกวา “Poisson regression for rate”

Poisson regression for rate

)log()log(

)log()log(

)/log(

tx

xt

xt

offset

x )log(Poisson loglinear model

xx eeeex )()exp( )( ตวอยาง BODE Index (body mass index, airflow obstruction,

dyspnea, and exercise capacity) as Predictor of

Hospitalization for COPD (Simulate DATA)

6

6

10

5

9

Y

6

13

4

9

12

y

10

9

8

7

6

id

4

7

1

5

6

BODE

55

54

53

32

41

BODEid

เมอคา log คาคาดหวง Y เปนฟงกชนเชงเสนของตวแปร

explanatory ดงนนคาคาดหวง Y คอฟงกชนผลคณของ x ดงน

Page 5: poisson reg2557 1 - @@ Home - KKU Web HostingPoisson Regression ส าหรบข อม ลแจงน บ Response (Dependent) หร อ outcome variable Y เป นจ านวนน

5

. glm y bode ,family(poisson) link(log)OR. poisson y bodeIteration 0: log likelihood = -20.831272Iteration 1: log likelihood = -20.831256Iteration 2: log likelihood = -20.831256

Poisson regression Number of obs = 10LR chi2(1) = 7.53Prob > chi2 = 0.0061

Log likelihood = -20.831256 Pseudo R2 = 0.1530------------------------------------------------------------------------------

y | Coef. Std. Err. z P>|z| [95% Conf. Interval]-------------+----------------------------------------------------------------

bode | .2116015 .0801191 2.64 0.008 .0545709 .3686322_cons | 1.076421 .4130118 2.61 0.009 .2669327 1.885909

------------------------------------------------------------------------------

. poisgofGoodness-of-fit chi2 = 2.927329Prob > chi2(8) = 0.9388

bode).21160153(1.076421ˆˆ)ˆlog( x

- ความหมายของ คออะไร

- แปลผลสมประสทธอยางไร

)(

)4(

6.8402694

))4(21160152.076421.1exp()ˆˆexp(ˆxee

x

bode).21160153(1.076421ˆˆ)ˆlog( x

เมอ BODE Index เพมขน 1 คะแนน หรอ (4+1=5) คะแนน

Predictor of Hospitalization เทากบ 8.452216 ครง

เมอ BODE Index เทากบ 4 คะแนน Predictor of Hospitalization

เทากบ 6.8402694 ครง

8.452216

))5(21160152.076421.1exp()ˆˆexp(ˆ )5(

x

ซงเทากบ

)(eˆ 1)4.21160153(1.076421)11()2()5(

eeeee xxx

e

eee

ee

e

eeeee

x

x

xxx

)4(

)1(

21160153.4).21160153(1.076421

)21160153.4).21160153(1.076421

1)4.21160153(1.076421)11()2()5(

ˆ

e

e

)(eˆ

8402694.6ˆ )1()4(

xx ee

เมอ BODE index เพมขน 1 คะแนน (5 คะแนน) ทาใหคาเฉลยเพมขนเทากบ

1.235 เทา ( ) ของคาเฉลย เมอ BODE index เทากบ 4 คะแนน

หรอ คาเฉลยเพมขน ( ) = 23.56 %

e100x

6.8402694

6.8402694)-(8.452216

Incidence Rate Ratio

Page 6: poisson reg2557 1 - @@ Home - KKU Web HostingPoisson Regression ส าหรบข อม ลแจงน บ Response (Dependent) หร อ outcome variable Y เป นจ านวนน

6

6.8402694eˆ 4).21160153(1.076421)1()4( eee x

x

235655.1.21160153 ee

8.4522158)235655.1)(8402694.6(

e

ˆ21160153.4).21160153(1.076421

)1()5(

ee

eee xx

. poisson py bode ,irrIteration 0: log likelihood = -20.831272Iteration 1: log likelihood = -20.831256Iteration 2: log likelihood = -20.831256

Poisson regression Number of obs = 10LR chi2(1) = 7.53Prob > chi2 = 0.0061

Log likelihood = -20.831256 Pseudo R2 = 0.1530------------------------------------------------------------------------------

py | IRR Std. Err. z P>|z| [95% Conf. Interval]-------------+----------------------------------------------------------------

bode | 1.235655 .0989996 2.64 0.008 1.056087 1.445756------------------------------------------------------------------------------

12

1)1(

2

)2(2

)1(1

arg

1,0

thanerltimeseis

eeee

ee

ee

andethenif

x

x

x

12

1)1(

2

)2(2

)1(1

10,0

thansmallertimeseis

eeee

ee

ee

ethenif

x

x

x

. di exp(.00001)1.00001. di exp(0)1

. di exp(-0.00001)

.99999

1

. di exp(0)1

ตวแปร response เปนตวแปรของการเกดเหตการณทขนกบ

-เวลา (time)

-พนท (space)

-หรอขนาดดชนอนๆ (index of size)

ตวแปร response เปนอตรา (rate)

ตวแปร explanatory เปนตวแปรกลม (categorical data) หรอตวแปรตอเนอง

เรยกวา “Poisson regression for rate”

Poisson regression for rate

)log()log(

)log()log(

)/log(

tx

xt

xt

offset

Page 7: poisson reg2557 1 - @@ Home - KKU Web HostingPoisson Regression ส าหรบข อม ลแจงน บ Response (Dependent) หร อ outcome variable Y เป นจ านวนน

7

Poisson regression for rate

Poisson regression for rate ไดแก

Log(t) เรยกวา “offset” เปนคาทปรบแตละคาเมอคา t

เปลยนแปลง

tyYEt

tYE /)(1

)/(

)log()log(

)log()log(

)/log(

tx

xt

xt

ตวอยาง จานวนผปวยดวยโรค coronary heart disease (Levy,1999)

การเกดโรคหวใจ coronary ระหวางชายกบหญงเมอทราบ

person-year ในการศกษา Framingham heart study

ชาย หญง รวม

โรคหวใจ coronary 823 650 1473

Person-year 42688 61773 104461

พนฐาน Estimate incidence rates ratio

การแปลผล incidence rates ratioถา X เปนตวแปรตอเนองเชน อาย (เปนป)IRR = 0.95 หมายถง "ทก 1 ปทอายเพมขน อตราหรอความเสยงตอการเกดเหตการณลดลง 5%“IRR = 1.05 หมายถง "ทก 1 ปทอายเพมขน อตราหรอความเสยงตอการเกดเหตการณเพมขน 5%"IRR = 2.05 หมายถง "ทก 1 ปทอายเพมขน อตราหรอความเสยงตอการเกดเหตการณ

คดเปน 2.05 เทาของคากอนหนาน หรอ อตราหรอความเสยงเปนผลคณของคา 2.05“ตวแปรตอเนอง เชน อาย, systolic BP ฯลฯ คาทเพมขน 1 ป 1 (mmHg) หรอลดลง 1 ป

(mmHg) นอยเกนไป ไมนาสนใจทาง อาจใช 5, 10 ปตวแปรตอเนอง x มคา 0-1 คาทเพมขน 1 ป หรอลดลง 1 ป มากเกนไป อาจใช .01

ถา X เปนตวแปรกลมเชน เพศ (1=ผชาย 0= ผหญง)IRR = 0.95 หมายถง “ผชายมอตราหรอโอกาสเสยงตอการเกดเหตการณนอยกวาผหญง 5%"IRR = 1.05 หมายถง “ผชายมอตราหรอโอกาสเสยงตอการเกดเหตการณมากกวาผหญง 5%“IRR = 2.05 หมายถง “ผชายมอตราหรอโอกาสเสยงตอการเกดเหตการณมากกวาผหญง

เปน 2.05 เทา"

Page 8: poisson reg2557 1 - @@ Home - KKU Web HostingPoisson Regression ส าหรบข อม ลแจงน บ Response (Dependent) หร อ outcome variable Y เป นจ านวนน

8

การคานวณ Rate ตางๆ

ตวอยาง จานวนผปวยดวยโรค coronary heart disease (Levy,1999)

ชาย หญง

จานวนผปวย 823 [d1] 650 [d

0]

Person-year of follow-up 42688 [n1] 61723 [n

0]

incidence rate ( )= IRR =iji

i

n

d

0

1

i

i

0192794.42688

823

1

11 n

di 0105224.

61773

650

0

00 n

di

832227.10105224.

0192794.

0

1 i

iiirr

IRR = 1.83 หมายถง “ผชายมอตราการเกดโรค coronary heart disease

มากกวาผหญงเปน 1.83 เทา"

1044111029381473total

6172361073650Female

4268841865823Male

No CHDCHD

totalOutcomeGender

RR = 1.83 หมายถง “ผชายมโอกาสเสยงตอการเกดโรค coronary heart

disease มากกวาผหญงเปน 1.83 เทา"

832227.161723/650

42688/823RR

]96.1exp[%95 2)log(irri sirrci

1

2)log(

11

dds

oirri

. iri 823 650 42688 61773

| Exposed Unexposed | Total-----------------+------------------------+------------

Cases | 823 650 | 1473Person-time | 42688 61773 | 104461

-----------------+------------------------+------------| |

Incidence Rate | .0192794 .0105224 | .014101| || Point estimate | [95% Conf. Interval]|------------------------+------------------------

Inc. rate diff. | .008757 | .0072113 .0103028Inc. rate ratio | 1.832227 | 1.651137 2.033836 (exact)Attr. frac. ex. | .4542162 | .3943566 .5083183 (exact)Attr. frac. pop | .2537814 |

+-------------------------------------------------(midp) Pr(k>=823) = 0.0000 (exact)(midp) 2*Pr(k>=823) = 0.0000 (exact)

Page 9: poisson reg2557 1 - @@ Home - KKU Web HostingPoisson Regression ส าหรบข อม ลแจงน บ Response (Dependent) หร อ outcome variable Y เป นจ านวนน

9

การวเคราะห IRR ดวย Poisson Regression. do "G:\cat2011\poisson_chd_ex.do". clear. input male chd per_yrs

male chd per_yrs1. 0 650 617732. 1 823 426883. end

. glm chd male, family(poisson) link(log) lnoffset(per_yrs)Iteration 0: log likelihood = -8.4353186Iteration 1: log likelihood = -8.4330708Iteration 2: log likelihood = -8.4330708

Generalized linear models No. of obs = 2Optimization : ML Residual df = 0

Scale parameter = 1Deviance = 6.52811e-14 (1/df) Deviance = .Pearson = 3.23538e-21 (1/df) Pearson = .Variance function: V(u) = u [Poisson]Link function : g(u) = ln(u) [Log]

AIC = 10.43307Log likelihood = -8.433070809 BIC = 6.53e-14------------------------------------------------------------------------------

| OIMchd | Coef. Std. Err. z P>|z| [95% Conf. Interval]

-------------+----------------------------------------------------------------male | .6055324 .0524741 11.54 0.000 .5026851 .7083797

_cons | -4.554249 .0392232 -116.11 0.000 -4.631125 -4.477373per_yrs | (exposure)

------------------------------------------------------------------------------

การวเคราะห IRR ดวย Poisson Regression. glm chd male, family(poisson) link(log) lnoffset(per_yrs)eform

Iteration 0: log likelihood = -8.4353186Iteration 1: log likelihood = -8.4330708Iteration 2: log likelihood = -8.4330708

Generalized linear models No. of obs = 2Optimization : ML Residual df = 0

Scale parameter = 1Deviance = 6.52811e-14 (1/df) Deviance = .Pearson = 3.23538e-21 (1/df) Pearson = .

Variance function: V(u) = u [Poisson]Link function : g(u) = ln(u) [Log]

AIC = 10.43307Log likelihood = -8.433070809 BIC = 6.53e-14

------------------------------------------------------------------------------| OIM

chd | IRR Std. Err. z P>|z| [95% Conf. Interval]-------------+----------------------------------------------------------------

male | 1.832227 .0961444 11.54 0.000 1.653154 2.030698per_yrs | (exposure)

------------------------------------------------------------------------------

intercept ( ) = ln (mean y) หรอ ln เมอ x=0

X10

X)|lnE(Y ββ

0

554249.4)61773/650ln(0

0105224.61773

650

0

00 n

di

0

00 n

di

------------------------------------------------------------------------------chd | Coef. Std. Err. z P>|z| [95% Conf. Interval]

-------------+----------------------------------------------------------------male | .6055324 .0524741 11.54 0.000 .5026851 .7083797

_cons | -4.554249 .0392232 -116.11 0.000 -4.631125 -4.477373per_yrs | (exposure)

------------------------------------------------------------------------------

)0|(ln)ln( 00 xyEi

ดงนน exp( ) = 0 0i

| Exposed Unexposed | Total-----------------+------------------------+------------

Cases | 823 650 | 1473Person-time | 42688 61773 | 104461

-----------------+------------------------+------------

Page 10: poisson reg2557 1 - @@ Home - KKU Web HostingPoisson Regression ส าหรบข อม ลแจงน บ Response (Dependent) หร อ outcome variable Y เป นจ านวนน

10

การแปลความหมาย

จากสมการ

คา แปลความหมายไดดงน

ทานาย (predicted) อตราการเกดเกดโรคหวใจ CHD ในกลมผหญง

เทากบ exp(-4.554249) = 0.0105224 หรอ 10.5224 รายตอ

1000 Person-Year of Follow-Up

(male)..E(Y|X) 605532365542494ln

554249.4)61773/650ln(0

0105224.61773

650

0

00 n

di00)exp( i

i

i

n

drateincidence

0

XββE(Y|X)10

ln

)0|(ln)ln( 00 xyEi10

1ln ββ)E(Y|X

เมอ

ดงนน

slope ( ) =

10ln1ln β)E(y|x)E(Y|X

10ln1ln β)E(y|x)-E(Y|X

10

1ln β

)E(y|x

)E(y|x

]ln[0

1ln

0

1

i

i

)E(y|x

)E(y|x

1

irr1

)exp( 11 irr ดงนน exp( ) = 10 1i

| Exposed Unexposed | Total-----------------+------------------------+----------

Cases | 823 650 | 1473Person-time | 42688 61773 | 104461

-----------------+------------------------+----------

------------------------------------------------------------------------------chd | Coef. Std. Err. z P>|z| [95% Conf. Interval]

-------------+----------------------------------------------------------------male | .6055324 .0524741 11.54 0.000 .5026851 .7083797

_cons | -4.554249 .0392232 -116.11 0.000 -4.631125 -4.477373per_yrs | (exposure)

------------------------------------------------------------------------------. di exp(ln((823/42688)/(650/61773)))1.8322274

slope ( ) =

10

1ln β

)E(y|x

)E(y|x

60553236.61773/650

42688/823ln]ln[

0

1ln

0

1

i

i

)E(y|x

)E(y|x

1

832274.1)60553236exp(.)exp( 10

11

i

iirr

1

11 n

di

0

00 n

di

Page 11: poisson reg2557 1 - @@ Home - KKU Web HostingPoisson Regression ส าหรบข อม ลแจงน บ Response (Dependent) หร อ outcome variable Y เป นจ านวนน

11

การแปลความหมาย กรณขอมลกลม (0=female,1=male)

จากสมการ

แปลความหมายไดดงน

-อตราการเกดโรคหวใจ CHD ในผชายสงกวาผหญง เทากบ

exp(.60553236) = 1.832273 เทา หรอ

-ผชายมโอกาสเสยงตอการเกดโรคหวใจ CHD สงกวาผหญง 1.83

เทา

(male)..E(Y|X) 605532365542494ln

1

832274160553236expexp 10

11 .)(.)(β

λ

λirr

i

i

ตวอยาง การสบบหรและการเกดมะเรงปอด ( lung cancer)

From 1983 การเกดมะเรงปอดและการสบบหร (smoking

ลกษณะ continuous data)

id smk pyear calung1. 0 1421 02. 5.2 927 03. 11.2 988 24. 15.2 849 25. 20.4 1567 96. 27.4 1409 107. 40.8 556 7

. do "G:\cat2011\poisson_calung_ex.do"

. input id smk pyear calungid smk pyear calung

1. 1 0 1421 02. 2 5.2 927 03. 3 11.2 988 24. 4 15.2 849 25. 5 20.4 1567 96. 6 27.4 1409 107. 7 40.8 556 78. end

. glm calung smk, family(poisson) link(log) lnoffset(pyear)Iteration 0: log likelihood = -12.155888... Iteration 3: log likelihood = -12.062056Generalized linear models No. of obs = 7Optimization : ML Residual df = 5

Scale parameter = 1Deviance = 6.878384154 (1/df) Deviance = 1.375677Pearson = 4.866088691 (1/df) Pearson = .9732177Variance function: V(u) = u [Poisson]Link function : g(u) = ln(u) [Log]

AIC = 4.01773Log likelihood = -12.06205596 BIC = -2.851167------------------------------------------------------------------------------

| OIMcalung | Coef. Std. Err. z P>|z| [95% Conf. Interval]

-------------+----------------------------------------------------------------smk | .0745704 .0155644 4.79 0.000 .0440648 .105076

_cons | -7.128196 .4515324 -15.79 0.000 -8.013183 -6.243209pyear | (exposure)

------------------------------------------------------------------------------

วเคราะหดวย GLM

Page 12: poisson reg2557 1 - @@ Home - KKU Web HostingPoisson Regression ส าหรบข อม ลแจงน บ Response (Dependent) หร อ outcome variable Y เป นจ านวนน

12

. glm calung smk, family(poisson) link(log) lnoffset(pyear)eform

Iteration 0: log likelihood = -12.155888... Iteration 3: log likelihood = -12.062056

Generalized linear models No. of obs = 7Optimization : ML Residual df = 5

Scale parameter = 1Deviance = 6.878384154 (1/df) Deviance = 1.375677Pearson = 4.866088691 (1/df) Pearson = .9732177

Variance function: V(u) = u [Poisson]Link function : g(u) = ln(u) [Log]

AIC = 4.01773Log likelihood = -12.06205596 BIC = -2.851167

------------------------------------------------------------------------------| OIM

calung | IRR Std. Err. z P>|z| [95% Conf. Interval]-------------+----------------------------------------------------------------

smk | 1.077421 .0167694 4.79 0.000 1.04505 1.110795pyear | (exposure)

------------------------------------------------------------------------------

วเคราะหดวย Poisson Regression

. poisson lung_ca smk,exposure(pop)

Iteration 0: log likelihood = -12.062141Iteration 1: log likelihood = -12.062056Iteration 2: log likelihood = -12.062056

Poisson regression Number of obs = 7LR chi2(1) = 24.02Prob > chi2 = 0.0000

Log likelihood = -12.062056 Pseudo R2 = 0.4990

------------------------------------------------------------------------------lung_ca | Coef. Std. Err. z P>|z| [95% Conf. Interval]

-------------+----------------------------------------------------------------smk | .0745704 .0155644 4.79 0.000 .0440648 .105076

_cons | -7.128196 .4515324 -15.79 0.000 -8.013183 -6.243209pop | (exposure)

------------------------------------------------------------------------------

ประมาณ (predicted) อบตการณ การเกดมะเรงปอด ในกลมไมสบบหรเทากบ

exp(-7.128196) = .00080217 หรอ 0.80 รายตอ 1000 Person-Year

. poisson lung_ca smk,exposure(pop)---omit---------------------------------------------------------------------------------

lung_ca | Coef. Std. Err. z P>|z| [95% Conf. Interval]-------------+----------------------------------------------------------------

smk | .0745704 .0155644 4.79 0.000 .0440648 .105076_cons | -7.128196 .4515324 -15.79 0.000 -8.013183 -6.243209

pop | (exposure)------------------------------------------------------------------------------

. poisson lung_ca smk,exposure(pop) irr---omit---------------------------------------------------------------------------------

lung_ca | IRR Std. Err. z P>|z| [95% Conf. Interval]-------------+----------------------------------------------------------------

smk | 1.077421 .0167694 4.79 0.000 1.04505 1.110795pop | (exposure)

------------------------------------------------------------------------------

เมอสบบหรเพมขน 1 มวน/วน อตราการเกดมะเรงปอด เพมขนเทากบ

exp(.0745704) =1.077421 เทา ถาสบบหร 20 มวน/วน อตราการมะเรง

ปอดเพมขนเทากบ exp(20x0.0745704) = 4.4433473 เทา

Page 13: poisson reg2557 1 - @@ Home - KKU Web HostingPoisson Regression ส าหรบข อม ลแจงน บ Response (Dependent) หร อ outcome variable Y เป นจ านวนน

13

กรณมตวแปรอสระหลายตวแปร Multiple Poisson Regression

pp xxx ...)log( 2211

)log(...)log( 2211 txxx pp

offset

ตวแปร explanatory เปนตวแปรกลม หรอตวแปรตอเนองทมมากกวา

1 ตวแปร

ตวอยาง A comparison of financial performance, organizational

characteristics and management strategy among rural &

urban facillities. (Smith, HL., Piland, NF. & Fisher, N.

J. Rural Health,27-40, 1992)

Poisson regression for rate

Poisson regression for count

ตวอยาง A comparison of financial performance, organizational

characteristics and management strategy among rural &

urban facillities. (Smith, HL., Piland, NF. & Fisher, N.

J. Rural Health,27-40, 1992)

Sample: Licensed Nurse n=52

bed = number of beds in home,

tdays = annual total patient days (in hundreds)

pcrev = annual total patient care revenue(in $ millions)

nsal = annual nursing salaries(in $ millions)

fexp = annual facilities expenditures(in $ millions)

rural = (1 =rural; 0= nonrural)

ตวอยาง การศกษาการเปรยบเทยบสมรรถนะดานการเงน คณลกษณะดานองคกร

กลยทธการบรหาร ระหวางการบรการพยาบาล ในเขตเมองและชนบท

(Smith, HL., Piland, N.F. & Fisher, N., 1992)

- ศกษาจากพยาบาลวชาชพ 52 คน

- จานวนเตยง (number of bed, bed)

- ผปวยรายวนทงหมดสทธ (annual total patient day: in hundreds, tdays)

- จานวนเงนทไดรบทงหมด สาหรบการรกษาพยาบาลรายป (annual total patient

care revenue: in $ millions, pcrev)

- เงนเดอนของพยาบาลรายป (annual nursing salaries: in $ millions, nsal)

- คาใชจายดานในการบรการพยาบาลรายป (annual facilities expenditures:

in $ million, fexp)

- พนทศกษา (เขตเมอง = 0, เขตชนบท = 1, rural)

Page 14: poisson reg2557 1 - @@ Home - KKU Web HostingPoisson Regression ส าหรบข อม ลแจงน บ Response (Dependent) หร อ outcome variable Y เป นจ านวนน

14

10.45850.41561.830931810018

10.44430.19880.7791338017

10.52060.52572.145337512016

10.11230.41661.30892848015

10.1280.19250.70851645914

00.42310.59461.765532111613

10.3360.20662.098742612012

00.12360.24090.88961926211

10.64420.32241.172918812010

00.1260.19550.8812169969

10.09660.41731.4025305908

10.49980.44062.21473721207

10.04490.36221.0531234656

00.62250.53621.74213631205

00.63460.6592.23544191204

00.61150.63042.193921203

10.04930.24590.916203592

00.53340.5232.35213852441

ruralfexpnsalpcrevtdaysbedunit

00.12790.29051.16492787935

10.01370.30250.3948883034

10.12090.21430.80821896233

00.11980.68572.133437514632

00.41970.46510.28532869031

10.04110.27820.61642206230

10.29870.59331.744636610829

00.10640.23670.89512046228

10.44460.47290.87822146427

10.25430.12883.602977622126

10.45310.20080.4078832525

00.21230.38031.24742026024

10.17560.20510.94241915923

00.33510.74892.382944213522

00.09070.4631.700433612021

10.56860.51731.788128011020

10.16750.19140.88722136019

ruralfexpnsalpcrevtdaysbedunit

00.62740.44322.018232712052

10.02450.20880.75561445451

00.11540.2821.06442136050

10.14840.39951.23623908349

10.12420.36720.93272037848

00.13440.74852.427447113547

10.30060.38661.449935510246

10.29590.3721.13122008645

10.22120.27841.24062226244

10.38930.40291.666132311043

10.11220.22451.04122055842

10.19110.19950.84591368241

10.64020.60592.255533612340

10.38740.2810.81971774939

10.25610.35471.753230010038

00.35240.62362.903542312037

10.12730.14980.7851584436

ruralfexpnsalpcrevtdaysbedunit

Page 15: poisson reg2557 1 - @@ Home - KKU Web HostingPoisson Regression ส าหรบข อม ลแจงน บ Response (Dependent) หร อ outcome variable Y เป นจ านวนน

15

. use "G:\cate_2549\fliess_poisson.dta", clear

. glm bed pcrev nsal fexp rural pn pf nf,f(po) l(log) lnoffset(tdays)Iteration 0: log likelihood = -267.31398Iteration 1: log likelihood = -264.4224Iteration 2: log likelihood = -264.42103Iteration 3: log likelihood = -264.42103

Generalized linear models No. of obs = 52Optimization : ML Residual df = 44

Scale parameter = 1Deviance = 201.947793 (1/df) Deviance = 4.589723Pearson = 216.1809053 (1/df) Pearson = 4.913202

Variance function: V(u) = u [Poisson]Link function : g(u) = ln(u) [Log]

AIC = 10.47773Log likelihood = -264.421028 BIC = 28.09307------------------------------------------------------------------------------

| OIMbed | Coef. Std. Err. z P>|z| [95% Conf. Interval]

-------------+----------------------------------------------------------------pcrev | -.3478217 .0709137 -4.90 0.000 -.48681 -.2088333nsal | .2783367 .4841752 0.57 0.565 -.6706292 1.227303fexp | 1.467563 .2830687 5.18 0.000 .9127581 2.022367

rural | -.1331174 .0357456 -3.72 0.000 -.2031776 -.0630573pn | .2654922 .1495259 1.78 0.076 -.0275732 .5585577pf | .7085387 .2566749 2.76 0.006 .2054652 1.211612nf | -4.496535 .9551153 -4.71 0.000 -6.368527 -2.624544

_cons | -.972998 .1091216 -8.92 0.000 -1.186872 -.7591237tdays | (exposure)

------------------------------------------------------------------------------

Inference and model checking

-Wald, Likelihood ratio test

-Checking Poisson Regression

-Residuals

-Confidence intervals for fit values (means)

-Overdisperion

Inference and model checking

เมอ fit Poisson regression model

จากตวอยาง การสบบหรและการเกดมะเรงปอด สมการ Poisson

regression model ไดแก

การทดสอบสมมตฐานตวแปร explanatory มความสมพนธ

กบตวแปร response ไดแก

x )log(

)(075.0128.7)ˆlog( smki

0: oH

Page 16: poisson reg2557 1 - @@ Home - KKU Web HostingPoisson Regression ส าหรบข อม ลแจงน บ Response (Dependent) หร อ outcome variable Y เป นจ านวนน

16

Inference and model checking

-การทดสอบใชสถต Ward test

-หรอ

)1,0(~ˆˆ

0 NASEASE

z

21

2

2 ~ˆ

dfASE

z

ASEz 2/ˆ%100)1(

. glm calung smk, family(poisson) link(log) lnoffset(pyear)Iteration 0: log likelihood = -12.155888... Iteration 3: log likelihood = -12.062056Generalized linear models No. of obs = 7Optimization : ML Residual df = 5

Scale parameter = 1Deviance = 6.878384154 (1/df) Deviance = 1.375677Pearson = 4.866088691 (1/df) Pearson = .9732177Variance function: V(u) = u [Poisson]Link function : g(u) = ln(u) [Log]

AIC = 4.01773Log likelihood = -12.06205596 BIC = -2.851167------------------------------------------------------------------------------

| OIMcalung | Coef. Std. Err. z P>|z| [95% Conf. Interval]

-------------+----------------------------------------------------------------smk | .0745704 .0155644 4.79 0.000 .0440648 .105076

_cons | -7.128196 .4515324 -15.79 0.000 -8.013183 -6.243209pyear | (exposure)

------------------------------------------------------------------------------

วเคราะหดวย Generalized Linear Model

ASEztestWald

; 0: oH

ASEz 2/ˆ%100)1(

Goodness of fit

model provides a “good” or accurate description of the data

- Global fit Statistics

- Residual

- Confidence interval

- Overdispersion

Page 17: poisson reg2557 1 - @@ Home - KKU Web HostingPoisson Regression ส าหรบข อม ลแจงน บ Response (Dependent) หร อ outcome variable Y เป นจ านวนน

17

. use "G:\cate_2549\fliess_poisson.dta", clear

. glm bed pcrev nsal fexp rural pn pf nf,f(po) l(log) lnoffset(tdays)Iteration 0: log likelihood = -267.31398Iteration 1: log likelihood = -264.4224Iteration 2: log likelihood = -264.42103Iteration 3: log likelihood = -264.42103

Generalized linear models No. of obs = 52Optimization : ML Residual df = 44

Scale parameter = 1Deviance = 201.947793 (1/df) Deviance = 4.589723Pearson = 216.1809053 (1/df) Pearson = 4.913202

Variance function: V(u) = u [Poisson]Link function : g(u) = ln(u) [Log]

AIC = 10.47773Log likelihood = -264.421028 BIC = 28.09307------------------------------------------------------------------------------

| OIMbed | Coef. Std. Err. z P>|z| [95% Conf. Interval]

-------------+----------------------------------------------------------------pcrev | -.3478217 .0709137 -4.90 0.000 -.48681 -.2088333nsal | .2783367 .4841752 0.57 0.565 -.6706292 1.227303fexp | 1.467563 .2830687 5.18 0.000 .9127581 2.022367

rural | -.1331174 .0357456 -3.72 0.000 -.2031776 -.0630573pn | .2654922 .1495259 1.78 0.076 -.0275732 .5585577pf | .7085387 .2566749 2.76 0.006 .2054652 1.211612nf | -4.496535 .9551153 -4.71 0.000 -6.368527 -2.624544

_cons | -.972998 .1091216 -8.92 0.000 -1.186872 -.7591237tdays | (exposure)

------------------------------------------------------------------------------

Goodness of fit : Global fit Statistics

ทดสอบ goodness of fit สมมตฐาน

Ho: The Model fits the data

-Pearson Statistics

-Likelihood ratio test --->Deviance

- AIC, BIC

N

i i

iiy

1

22

ˆ)ˆ(

N

iiii yyG

1

2 )ˆ/log(2

Akaike information criterion (AIC)

คา AIC มคานอยแสดงวา better fit model

p = จานวน predictor

n = จานวนคาสงเกต

L(Mk) = log likelihood ของโมเดล k

n

2p)2L(MAIC

k

10.47773252

2(8)3)2(264.4210-AIC

Page 18: poisson reg2557 1 - @@ Home - KKU Web HostingPoisson Regression ส าหรบข อม ลแจงน บ Response (Dependent) หร อ outcome variable Y เป นจ านวนน

18

Bayesian information criterion (AIC)

D(Mk) = deviance ของโมเดล k

การแปลความหมายคา BIC (Raftery,1996)

|difference| Degree of preference

0-2 Weak

2-8 Positive

6-10 Strong

>10 Very strong

)ln()()(BIC ndfMD k 093069.28)52ln(48947793.201BIC

. glm bed pcrev nsal fexp rural pn pf nf,f(po) l(log) lnoffset(tdays)

...AIC = 10.47773

Log likelihood = -264.421028 BIC = 28.09307------------------------------------------------------------------------------

| OIMbed | Coef. Std. Err. z P>|z| [95% Conf. Interval]

-------------+----------------------------------------------------------------pcrev | -.3478217 .0709137 -4.90 0.000 -.48681 -.2088333nsal | .2783367 .4841752 0.57 0.565 -.6706292 1.227303fexp | 1.467563 .2830687 5.18 0.000 .9127581 2.022367rural | -.1331174 .0357456 -3.72 0.000 -.2031776 -.0630573

pn | .2654922 .1495259 1.78 0.076 -.0275732 .5585577pf | .7085387 .2566749 2.76 0.006 .2054652 1.211612nf | -4.496535 .9551153 -4.71 0.000 -6.368527 -2.624544

_cons | -.972998 .1091216 -8.92 0.000 -1.186872 -.7591237tdays | (exposure)

------------------------------------------------------------------------------. glm bed pcrev nsal fexp rural ,f(po) l(log) lnoffset(tdays)...

AIC = 11.01377Log likelihood = -281.3580559 BIC = 50.11339------------------------------------------------------------------------------

| OIMbed | Coef. Std. Err. z P>|z| [95% Conf. Interval]

-------------+----------------------------------------------------------------pcrev | -.0567001 .0208635 -2.72 0.007 -.0975918 -.0158084nsal | -.3066778 .108703 -2.82 0.005 -.5197318 -.0936237fexp | .5136242 .084782 6.06 0.000 .3474545 .6797938rural | -.1044837 .0343053 -3.05 0.002 -.1717208 -.0372466_cons | -.9770666 .0592194 -16.50 0.000 -1.093134 -.8609988tdays | (exposure)

------------------------------------------------------------------------------

Overdispersion: mean<variance

ทาให SE ตากวาความเปนจรง

การตรวจสอบ overdispersion

ในการวเคราะห โมเดลปวซงค การพจารณาวาเกด overdispersion หรอไม

-เปนเรองทมความสาคญ เนองจากมขอกาหนดของปวซงค

ไดแก คาเฉลยเทากบคาความแปรปรวน

วธการตรวจสอบประกอบดวยวธตางๆ เชน

(1) การทดสอบโดยใชพนฐานของสมการถดถอย (regression based test)

(2) การทดสอบดวยวธ Lagrange

(3) การทดสอบดวย Likelihood function ระหวางการ fit ดวย Poisson

Regression กบ Negative Binomial Regression

(4) การทดสอบดวย Dean Statistics

Page 19: poisson reg2557 1 - @@ Home - KKU Web HostingPoisson Regression ส าหรบข อม ลแจงน บ Response (Dependent) หร อ outcome variable Y เป นจ านวนน

19

n

i

iypn

1

21

ˆ)ˆ(

)(~

คาพารามเตอรของ overdispersion ในการวเคราะห

แบบ Poisson regression แนวคดจาก Pearson Chi-Square

เมอ p คอ จานวนพารามเตอร

1. การทดสอบโดยใชพนฐานของสมการถดถอย (regression based test)

-การทดสอบโดยใชพนฐานของสมการถดถอย (Cameron & Trivedi, 1990)

เปนวธทพจารณาวา regression slop เบยงเบนไปจากคา 0 เพยงใด

การวเคราะหตงสมมตฐานดงน

โดยคานวณคา ของแตละรายขอมล ดงน

เมอ คอคาทไดจากการ predicted จากการ fit โมเดลปวซงค

และ fit สมการถดถอยอยางงาย ระหวางตวแปร z กบคาคงท (constant)

ทดสอบสถตสมประสทธคาคงท ดวยสถต t

เมอคา p-value มนยสาคญทางสถตหรอปฏเสธสมมตฐาน H0

แสดงวาคาความแปรปรวนไมเทากบคาเฉลย หรอเกด overdispersion

]([)()(:

)()(:0

iiiA

ii

yEgyEyVarH

yEyVarH

2ˆ)ˆ( 2

i

iii yyz

i

. do "F:\516707_2556\over_test_reg_1.do"

. use "F:\data\fliess_poisson_stata10.dta", clear

. qui glm bed pcrev nsal fexp rural pn pf nf,f(po) l(log) ///> lnoffset(tdays) nolog noheader. predict double mu,mu. generate z = ((bed-mu)^2-bed) / (mu*sqrt(2)). regress z

Source | SS df MS Number of obs = 52-------------+------------------------------ F( 0, 51) = 0.00

Model | 0 0 . Prob > F = .Residual | 1646.13049 51 32.2770685 R-squared = 0.0000

-------------+------------------------------ Adj R-squared = 0.0000Total | 1646.13049 51 32.2770685 Root MSE = 5.6813

------------------------------------------------------------------------------z | Coef. Std. Err. t P>|t| [95% Conf. Interval]

-------------+----------------------------------------------------------------_cons | 2.221609 .7878533 2.82 0.007 .6399279 3.803291

------------------------------------------------------------------------------. drop mu z

. qui glm bed pcrev nsal fexp rural pn pf nf,f(po) l(log) ///> lnoffset(tdays) nolog noheader. overreg bedTest of Overdispersion [Regresion Base test]in Poisson Regression Model----------------------------------------------------------Overdispersion parameter df t P > |t|----------------------------------------------------------

4.58972 51 2.81983 0.0068264----------------------------------------------------------

Page 20: poisson reg2557 1 - @@ Home - KKU Web HostingPoisson Regression ส าหรบข อม ลแจงน บ Response (Dependent) หร อ outcome variable Y เป นจ านวนน

20

2. การทดสอบดวยวธ Lagrange

การทดสอบดวยวธ Lagrane เปนวธทใชในการทดสอบ overdispersion

ทพจารณาตรวจสอบขอมลนนๆ มการแจกแจงแบบอนทไมใชการแจกแจง

แบบปวซงค เชน negative binomial เมอคาถวงนาหนก

เปนคาทเกดขนจากการแจกแจงแบบอนๆ

n

ii

n

iiiii yyw

LM

1

1

2

ˆ2

])ˆ[(ˆ

iw

iw

. quietly glm bed pcrev nsal fexp rural pn pf nf,f(po) l(log) /// lnoffset(tdays)

. overlag bed(option mu assumed; predicted mean bed)Test of Overdispersion [Lagrange multiplier test]in Poisson Regression Model----------------------------------------------------------Overdispersion parameter df chi-square P > |Chi|----------------------------------------------------------

4.58972 1 2.5805e+05 0.0000000----------------------------------------------------------

. do "F:\516707_2556\over_LM_glm.do"

. use "F:\data\fliess_poisson_stata10.dta", clear

. qui glm bed pcrev nsal fexp rural pn pf nf,f(po) l(log) ///> lnoffset(tdays) nolog noheader

. predict double mu,mu

. summarize bed, meanonly

. scalar nybar = r(sum)

. generate double musq = mu*mu

. summarize musq,meanonly

. scalar mu2 = r(sum)

. scalar chival = (mu2-nybar)^2/(2*mu2)

. di as txt "LM-Test =" as res chival _n as txt "P-Value = " ///> as res %8.5f chi2tail(1,chival)LM-Test =258051.82P-Value = 0.00000

. qui drop mu

. qui drop musq

3. การทดสอบดวย Likelihood function ระหวางการ fit ดวย

Poisson Regression กบ Negative Binomial Regression. nbreg bed pcrev nsal fexp rural pn pf nf, exposure(tdays)Fitting Poisson model:Iteration 0: log likelihood = -264.43404 …Negative binomial regression Number of obs = 52

LR chi2(7) = 17.60Dispersion = mean Prob > chi2 = 0.0139Log likelihood = -223.23966 Pseudo R2 = 0.0379------------------------------------------------------------------------------

bed | Coef. Std. Err. z P>|z| [95% Conf. Interval]-------------+----------------------------------------------------------------

pcrev | -.3868934 .1543459 -2.51 0.012 -.6894058 -.0843809nsal | .1556637 .9194312 0.17 0.866 -1.646388 1.957716fexp | 1.429801 .511777 2.79 0.005 .4267365 2.432866

rural | -.1193119 .0704735 -1.69 0.090 -.2574375 .0188137pn | .3323483 .2933881 1.13 0.257 -.2426818 .9073784pf | .7531993 .5164349 1.46 0.145 -.2589945 1.765393nf | -4.56582 2.00498 -2.28 0.023 -8.495509 -.6361308

_cons | -.9103272 .1988939 -4.58 0.000 -1.300152 -.5205023tdays | (exposure)

-------------+----------------------------------------------------------------/lnalpha | -3.505601 .2714876 -4.037707 -2.973495

-------------+----------------------------------------------------------------alpha | .0300287 .0081524 .0176379 .0511243

------------------------------------------------------------------------------Likelihood-ratio test of alpha=0: chibar2(01) = 82.36 Prob>=chibar2 = 0.000

Page 21: poisson reg2557 1 - @@ Home - KKU Web HostingPoisson Regression ส าหรบข อม ลแจงน บ Response (Dependent) หร อ outcome variable Y เป นจ านวนน

21

. poisson bed pcrev nsal fexp rural pn pf nf, exposure(tdays)Iteration 0: log likelihood = -264.43404 Iteration 1: log likelihood = -264.42103 Iteration 2: log likelihood = -264.42103 Poisson regression Number of obs = 52

LR chi2(7) = 78.86Prob > chi2 = 0.0000

Log likelihood = -264.42103 Pseudo R2 = 0.1298------------------------------------------------------------------------------

bed | Coef. Std. Err. z P>|z| [95% Conf. Interval]-------------+----------------------------------------------------------------

pcrev | -.3478217 .0709137 -4.90 0.000 -.48681 -.2088333nsal | .2783367 .4841752 0.57 0.565 -.6706292 1.227303fexp | 1.467563 .2830687 5.18 0.000 .9127581 2.022367

rural | -.1331174 .0357456 -3.72 0.000 -.2031776 -.0630573pn | .2654922 .1495259 1.78 0.076 -.0275732 .5585577pf | .7085387 .2566749 2.76 0.006 .2054652 1.211612nf | -4.496535 .9551153 -4.71 0.000 -6.368527 -2.624544

_cons | -.972998 .1091216 -8.92 0.000 -1.186872 -.7591237tdays | (exposure)

------------------------------------------------------------------------------. di "LL change = " -2*((-264.421028)- (-223.23966 ))LL change = 82.362736. di " pval = " %9.5f chi2tail(1,82.362736 )pval = 0.00000

คานวณคา Log likelihood ทเปลยนไปจากคา -2*((-264.421028)- (-223.23966 ))=82.36 p-value นอยกวา 0.00001 สอดคลองกบ negative binomial แสดงวาเกด overdispersion

4. Score Statistics (Dean & Lawless,1989; Dean,1992)

ใชทดสอบการเกด Overdispresion โดยพจารณาจาก ความแปรปรวน

ของความแปรปรวนดงน

0:;

ˆ2

)ˆ(

0

1

2

1

2

1

H

YY

Qn

ii

n

iiii

1:;

ˆ

)ˆ(

2

10

1

2

2

H

YY

nQ

i

n

iiii

. use "G:\cate_2549\fliess_poisson.dta", clear

. glm bed pcrev nsal fexp rural pn pf nf,f(po) l(log) lnoffset(tdays)

...Generalized linear models No. of obs = 52Optimization : ML: Newton-Raphson Residual df = 44

Scale parameter = 1Deviance = 201.947793 (1/df) Deviance = 4.589723Pearson = 216.1809053 (1/df) Pearson = 4.913202Variance function: V(u) = u [Poisson]Link function : g(u) = ln(u) [Log]Standard errors : OIMLog likelihood = -264.421028 AIC = 10.47773BIC = 28.09306938------------------------------------------------------------------------------

bed | Coef. Std. Err. z P>|z| [95% Conf. Interval]-------------+----------------------------------------------------------------

pcrev | -.3478217 .0709137 -4.90 0.000 -.48681 -.2088333

..._cons | -.972998 .1091216 -8.92 0.000 -1.186872 -.7591237tdays | (exposure)

------------------------------------------------------------------------------

. dean bedTesst of Overdispersion [Score test]----------------------------------------------------------Overdispersion parameter df chi-square P > |Chi|----------------------------------------------------------model 1(Dean1) 4.58972 1 289.49131 0.0000000model 2(Dean2) 4.91320 1 256.64868 0.0000000----------------------------------------------------------

Page 22: poisson reg2557 1 - @@ Home - KKU Web HostingPoisson Regression ส าหรบข อม ลแจงน บ Response (Dependent) หร อ outcome variable Y เป นจ านวนน

22

วธวเคราะหกรณพบ overdispersion

- ใชวธ quisi-likelihood approach

standard error ดวยการปรบคา deviance

standard error ดวยการปรบคา Pearson

- วเคราะหดวย Negative Binomial

ASEdfASEadj /2

ใชวธ quisi-likelihood approach.glm bed pcrev nsal fexp rural pn pf nf,f(po) l(log)lnoffset(tdays)irls scale(dev)Iteration 1: deviance = 207.7337Iteration 2: deviance = 201.9505Iteration 3: deviance = 201.9478Iteration 4: deviance = 201.9478Generalized linear models No. of obs = 52Optimization : MQL Fisher scoring Residual df = 44

(IRLS EIM) Scale parameter = 1Deviance = 201.947793 (1/df) Deviance = 4.589723Pearson = 216.1808084 (1/df) Pearson = 4.9132Variance function: V(u) = u [Poisson]Link function : g(u) = ln(u) [Log]Standard errors : EIMBIC = 28.09306938------------------------------------------------------------------------------

| EIMbed | Coef. Std. Err. z P>|z| [95% Conf. Interval]

-------------+----------------------------------------------------------------pcrev | -.3478217 .151923 -2.29 0.022 -.6455853 -.0500581nsal | .2783367 1.037279 0.27 0.788 -1.754693 2.311366fexp | 1.467563 .606436 2.42 0.016 .2789698 2.656155

rural | -.1331174 .0765801 -1.74 0.082 -.2832118 .0169769pn | .2654922 .3203389 0.83 0.407 -.3623605 .8933449pf | .7085387 .5498909 1.29 0.198 -.3692276 1.786305nf | -4.496535 2.046204 -2.20 0.028 -8.507022 -.4860492

_cons | -.972998 .233778 -4.16 0.000 -1.431194 -.5148015tdays | (exposure)

------------------------------------------------------------------------------(Standard errors scaled using square root of deviance-based dispersion)

. glm bed pcrev nsal fexp rural pn pf nf,f(po) l(log)lnoffset(tdays)irls scale(x2)Iteration 1: deviance = 207.7337Iteration 2: deviance = 201.9505Iteration 3: deviance = 201.9478Iteration 4: deviance = 201.9478Generalized linear models No. of obs = 52Optimization : MQL Fisher scoring Residual df = 44

(IRLS EIM) Scale parameter = 1Deviance = 201.947793 (1/df) Deviance = 4.589723Pearson = 216.1808084 (1/df) Pearson = 4.9132

Variance function: V(u) = u [Poisson]Link function : g(u) = ln(u) [Log]

BIC = 28.09307

------------------------------------------------------------------------------| EIM

bed | Coef. Std. Err. z P>|z| [95% Conf. Interval]-------------+----------------------------------------------------------------

pcrev | -.3478217 .1571855 -2.21 0.027 -.6558996 -.0397437nsal | .2783367 1.07321 0.26 0.795 -1.825116 2.381789fexp | 1.467563 .6274426 2.34 0.019 .2377977 2.697328

rural | -.1331174 .0792328 -1.68 0.093 -.2884109 .0221761pn | .2654922 .3314352 0.80 0.423 -.3841089 .9150934pf | .7085387 .5689388 1.25 0.213 -.4065608 1.823638nf | -4.496535 2.117083 -2.12 0.034 -8.645942 -.3471283

_cons | -.972998 .2418759 -4.02 0.000 -1.447066 -.4989299tdays | (exposure)

------------------------------------------------------------------------------(Standard errors scaled using square root of Pearson X2-based dispersion)

Page 23: poisson reg2557 1 - @@ Home - KKU Web HostingPoisson Regression ส าหรบข อม ลแจงน บ Response (Dependent) หร อ outcome variable Y เป นจ านวนน

23

- วเคราะหดวย Negative binomial. glm bed pcrev nsal fexp rural pn pf nf,f(nb .0300287) l(log) lnoffset(tdays)Iteration 0: log likelihood = -223.40459 Iteration 1: log likelihood = -223.23966 Iteration 2: log likelihood = -223.23966 Generalized linear models No. of obs = 52Optimization : ML Residual df = 44

Scale parameter = 1Deviance = 52.37225142 (1/df) Deviance = 1.190278Pearson = 57.59302114 (1/df) Pearson = 1.308932Variance function: V(u) = u+(.03)u^2 [Neg. Binomial]Link function : g(u) = ln(u) [Log]

AIC = 8.893833Log likelihood = -223.239656 BIC = -121.4825------------------------------------------------------------------------------

| OIMbed | Coef. Std. Err. z P>|z| [95% Conf. Interval]

-------------+----------------------------------------------------------------pcrev | -.386893 .1543257 -2.51 0.012 -.6893659 -.0844201nsal | .1556643 .9194157 0.17 0.866 -1.646357 1.957686fexp | 1.429801 .5116406 2.79 0.005 .4270041 2.432598

rural | -.119312 .0704696 -1.69 0.090 -.2574298 .0188058pn | .3323478 .2933804 1.13 0.257 -.2426672 .9073629pf | .7531989 .5163959 1.46 0.145 -.2589184 1.765316nf | -4.565819 2.004979 -2.28 0.023 -8.495506 -.6361314

_cons | -.9103275 .1988346 -4.58 0.000 -1.300036 -.5206189tdays | (exposure)

------------------------------------------------------------------------------

Fitting GLM: Poisson Regression

- Newton-Raphson algorithm

- Iteratively Reweight Least Square (IRLS)

Fisher scoring

- Statistic inference & the Likelihood function

- Deviance

Fitting Generalized linear Model: Poisson

-iterative reweighted least square (Fisher Scoring)

เรมตนดวยการกาหนดเมตรกซองคประกอบเชงระบบ

เทากบ

- เมตรกซคาถวงนาหนก

- และเมตรกซ

การวนรอบลาดบท i (iterative) ประมาณ

- เมตรกซ

- เมตรกซ เมอเมตรกซ

- คานวณ

- คานวณคา

)ln(

2/)( yyW i

/)()ln( iyZ

)ˆexp( 0i

iiW 0ˆi

i Xn

i

iii y

z

)(1

iii zWXXWX 11)(ˆ

iii zWXXWX 11)(ˆ

02

1))()/ln((2

i

i

yif

yifyyyDeviance