Sie sind auf Seite 1von 9

Morten Frydenberg Thursday, 17 November 2005

Linear and Logistic Regression: Note 3 1


Morfen Frydenberg Lineor ond Logisfic regression - Mofe 3
I
Logistic regression
Morten Frydenberg
Institut for iostutistik
When one mighf use Iogisfic regression.
Some exompIes:
One binury independenf voriobIe. (one odds rutio).
ProbobiIifies, odds ond fhe Iogif funcfion
One continuous independenf voriobIe.
One cutegoricuI independenf voriobIe.
(The WuId fesf)
One binury independenf voriobIe ond continuous
independenf voriobIe no inferocfion.
One binury independenf voriobIe ond continuous
independenf voriobIe wifh inferocfion.
Morfen Frydenberg Lineor ond Logisfic regression - Mofe 3
Z
Wofch ouf for 'smoII' reference groups
The IikeIihood rutio test: comporing fwo nesfed modeIs.
The Iogistic regression modeI in generuI
The modeI ond fhe ussumptions.
The dutu ond fhe ossumpfion of independence.
Estimution ond inference
Morfen Frydenberg Lineor ond Logisfic regression - Mofe 3 3
A Iogisfic regression is o possibIe modeI if fhe dependent
voriobIe (fhe response) is dichotomous deod/oIive obese/nof
obese efc.
Confrory fo whof mony beIieve fhere ore no ussumptions obouf
fhe independent voriobIes.
They con be cofegoricoI or confinuous.
When working wifh binory response if is custom fo code fhe
"positive" evenf (eg. deod) os 1 ond o "negutive" evenf (oIive)
os 0.
A Iogisfic regression modeIs fhe probubiIity of o "posifive
evenf" vio odds.
And fhe ossociofions vio odds rutio.
If fhe event is rure fhen odds rutios esfimofe fhe reIutive
risk,
Logistic regression modeIs: Introduction
Morfen Frydenberg Lineor ond Logisfic regression - Mofe 3 4
A Iogisfic regression con oIso be used fo esfimofe fhe odds
rofios in o unmutched cuse-controI sfudy.
For such dofo fhe constunt ferms hove no meuning.
And fhe odds rofios comporobIe odds rofio from o foIIow-up
study.
Mony other epidemioIogicuI design ore onoIy;ed by Iogisfic
regression modeIs.
Logistic regression modeIs: Introduction
Morfen Frydenberg Lineor ond Logisfic regression - Mofe 3 b
Estimuting one odds rutio using Iogistic regresion
We ore now considering o Iorger porf of fhe Fromminghom
dofo sef, consisfing of 4o90 person wifh known MI of fhe
sforf.
We wiII focus on fhe risk obesify (8MIz30 kg/m
Z
) .
Ouf of fhe 4o90 persons o0I ~ IZ.87 were obese.
Divided info gender
I8ZI ZZo (II.07) Men
ZZo8 37b (I4.Z7) Women
Mof-Obese Obese
We see o higher prevoIence omong women: OP: I.33 (I.IZ,I.b9).
Thof is the odds of being obese is befween IZ ond b9 percenf
higher for women.(
2
=10.2 p-value=0.001)
Morfen Frydenberg Lineor ond Logisfic regression - Mofe 3 o
Finding un odds rutio using Iogistic regresion
The odds rofio is defined os:
Women
Men
odds
OR
odds
=
( ) ( ) ( ) ln ln ln ln
Women
Women Men
Men
odds
OR odds odds
odds

= =


( ) ( ) ( ) ln ln ln
Women Men
odds odds OR = +
So oppIying fhe Iogorifhm we gef:
And reorronging ferms :
Thof is fhe Iog-odds obesify for fhe women con be wriffen os
fhe sum of fwo ferms:
The Iog-odds in reference group (men)
The Iog of fhe odds rofio
Morten Frydenberg Thursday, 17 November 2005
Linear and Logistic Regression: Note 3 2
Morfen Frydenberg Lineor ond Logisfic regression - Mofe 3 7
Finding un odds rutio using Iogistic regresion
( )
0 1
ln odds woman = +
( ) ( ) ( ) ln ln ln
Women Men
odds odds OR = +
For men we gef:
If we ogoin Ief women be o indicofor/dummy voriobIe, fhen we
con consider fhe modeI:
( )
0
ln odds =
And for women: ( )
0 1
ln odds = +
Comporing wifh fhe equofion on fop we gef:
( )
0
ln
Men
odds =
ond
( )
1
ln OR =
Morfen Frydenberg Lineor ond Logisfic regression - Mofe 3 8
Finding un odds rutio using Iogistic regresion
( )
0 1
ln odds woman = +
( ) ln
Men
odds ( ) ln OR
Or fo be more precise: ( ) 1
ln
Womenvs Men
OR =
So, if we con fif fhe modeI obove fo fhe dofo, fhen we con
gef on esfimofe of fhe log(OR) ond hence of ORl
Morfen Frydenberg Lineor ond Logisfic regression - Mofe 3 9
ProbubiIities und odds
If p denofe fhe probobiIify of on evenf (fhe risk, fhe
prevuIence proporfion, or cumuIuted incidence proporfion)
fhen fhe odds is given by :
1
p
odds
p
=

In mofhemofics fhe Iosf funcfion of p is coIIed fhe "logit"


funcfion.
( ) ln ln
1
p
odds
p

=


( ) logit ln
1
p
p
p

=


Mofe: odds=1 p=0.5 ln(odds)=0
Morfen Frydenberg Lineor ond Logisfic regression - Mofe 3 I0
ProbubiIities und odds
0
.1
.2
.3
.4
.5
.6
.7
.8
.9
1
P
r
o
b
a
b
i
l
i
t
y
-5 -4 -3 -2 -1 0 1 2 3 4 5
logit=ln(odds)
PIof0I
Morfen Frydenberg Lineor ond Logisfic regression - Mofe 3 II
So modeIIing fhe Iog-odds is fhe some os modeIIing logit(p)
ond modeI from before couId be wriffen.
( )
0 1
logit p woman = +
( )
0 1
ln odds woman = +
ProbubiIities und odds
0oing from odds fo probobiIifies:
1
odds
p
odds
=
+
( )
( )
0 1
0 1
exp
1 exp
woman
p
woman


+
=
+ +
The modeI on probubiIity scuIe is :
Morfen Frydenberg Lineor ond Logisfic regression - Mofe 3 IZ
Finding un odds rutio using Iogistic regresion
8ock fo finding fhe esfimofes.
In STATA:
cha sex|om1f]1
x1: 1og1f obese 1.sex
( ) ( )
0 1
logit ln p odds woman = = +
1.sex lsex1-2 {nafua11y coded lsex1 om1ffed}
lfeaf1on 0: 1og 11ke11hood = -1795.5437
lfeaf1on 3: 1og 11ke11hood = -1790.3703
Log1f esf1mafes Numbe of obs = 4690
Lk ch12{1} = 10.35
Pob > ch12 = 0.0013
Log 11ke11hood = -1790.3703 Pseudo k2 = 0.0029
-----------------------------------------------------------------------
obese | Coef. 5fd. L. z P>|z| |95x Conf. lnfeva1]
--------+-------------------------------------------------------------
lsex2 | .2674 .09972 3.19 0.001 .110631 .463073
cons | -2.06606 .070526 -29.59 0.000 -2.22435 -1.9437
-----------------------------------------------------------------------
Morten Frydenberg Thursday, 17 November 2005
Linear and Logistic Regression: Note 3 3
Morfen Frydenberg Lineor ond Logisfic regression - Mofe 3 I3
Finding un odds rutio using Iogistic regresion
( ) ( )
0 1
logit ln p odds woman = = +
-----------------------------------------------------------------------
obese | Coef. 5fd. L. z P>|z| |95x Conf. lnfeva1]
--------+-------------------------------------------------------------
lsex2 | .2674 .09972 3.19 0.001 .110631 .463073
cons | -2.06606 .070526 -29.59 0.000 -2.22435 -1.9437
-----------------------------------------------------------------------

( ) 1

ln OR = 9b7 CI for ln(OR)

( ) 0.2868784 e 1 xp .33 OR = = 9b7 CI: (1.12;1.59).


Tesf for fhe hypofhesis : ln(OR)=0 OR=1
PrevuIence omong men: 0.1104 (0.0975;0.1247).
Odds in reference group (men) ~ exp(-2.086606)=0.1241
9b7 CI :(0.1081;0.1425).
Morfen Frydenberg Lineor ond Logisfic regression - Mofe 3 I4
Finding un odds rutio using Iogistic regresion
An eosier woy fo obfoin fhe odds rofio.
x1: 1og1f obese 1.sex ,o ,o ,o ,o
( ) ( )
0 1
logit ln p odds woman = = +
1.sex lsex1-2 {nafua11y coded lsex1 om1ffed}
lfeaf1on 0: 1og 11ke11hood = -1795.5437
lfeaf1on 3: 1og 11ke11hood = -1790.3703
Log1f esf1mafes Numbe of obs = 4690
Lk ch12{1} = 10.35
Pob > ch12 = 0.0013
Log 11ke11hood = -1790.3703 Pseudo k2 = 0.0029
-----------------------------------------------------------------------
obese | Odds kaf1o 5fd. L. z P>|z| |95x Conf. lnfeva1]
--------+--------------------------------------------------------------
lsex2 | 1.332262 .1197667 3.19 0.001 1.117041 1.5951
-----------------------------------------------------------------------
Note we connof find ony informofion obouf fhe risk in fhe
reference group , i.e. fhe odds ond prevoIence omong menl
Morfen Frydenberg Lineor ond Logisfic regression - Mofe 3 Ib
Thof is o Iineor reIofion on fhe Iog-odds scoIe.
As we hove seen before using age impIies fhof
0
references fo
o newborn (age~0).
So we wiII chose age~4b reference insfeod:
The obesity und uge: version 1
In fhe previous secfion we sow fhof fhe prevoIence of obesify
wos differenf befween men ond women.
Is if oIso ossociofed wifh oge7
The simpIesf modeI on the Iogit scuIe wouId be:
( ) ( )
0 1
logit ln p odds age = = +
( ) ( ) ( )
0 1
logit ln 45 p odds age = = +
Morfen Frydenberg Lineor ond Logisfic regression - Mofe 3 Io
Mofe, fhof fhis odds rofio is ussumed fo be fhe some no
moffer whof oge fhe fwo persons hove, os Iong os fhey differ
by one yeorl
The Iog odds rofio is proportionuI fo fhe oge differences,
e.g. OP increoses eponentiuIIy wifh fhe oge differences.
The obesity und uge: version 1
The inferprefofion of fhe poromefers:

0
: fhe Iog odds for 4b yeor oId person.

1
: fhe Iog odds rutio, when comporing fwo persons who
differ I yeor in oge.
exp(
1
): fhe odds rutio, when comporing fwo persons who
differ I yeor in oge.
( ) ( ) ( )
0 1
logit ln 45 p odds age = = +
Morfen Frydenberg Lineor ond Logisfic regression - Mofe 3 I7
The obesity und uge: version 1
Obfoining fhe esfimofes in STATA:
gene age45=age-45
1og1f obese age45
( ) ( ) ( )
0 1
logit ln 45 p odds age = = +
lfeaf1on 0: 1og 11ke11hood = -1795.5437
lfeaf1on 3: 1og 11ke11hood = -1772.339
Log1f esf1mafes Numbe of obs = 4690
Lk ch12{1} = 46.32
Pob > ch12 = 0.0000
Log 11ke11hood = -1772.339 Pseudo k2 = 0.0129
-----------------------------------------------------------------------
obese | Coef. 5fd. L. z P>|z| |95x Conf. lnfeva1]
------+----------------------------------------------------------------
age45 | .034023 .0051296 6.7 0.000 .024744 .044561
cons | -1.95922 .0463594 -42.4 0.000 -2.07675 -1.95059
-----------------------------------------------------------------------
Tesf for no ossociofion wifh age
Morfen Frydenberg Lineor ond Logisfic regression - Mofe 3 I8
The obesity und uge: version 1
( ) ( ) ( )
0 1
logit ln 45 p odds age = = +
Esfimofe:
0
: 1.985 (2.0767;1.8951)
The odds for obesify for umong 4 yeur oId:
0.1373 (0.1253;0.1503)
The prevuIence of obesify for umong 4 yeur oId:
0.1207 (0.1114;0.1307)
Morten Frydenberg Thursday, 17 November 2005
Linear and Logistic Regression: Note 3 4
Morfen Frydenberg Lineor ond Logisfic regression - Mofe 3 I9
The obesity und uge: version 1
( ) ( ) ( )
0 1
logit ln 45 p odds age = = +
Esfimofes:
1
: 0.0348 (0.0247;0.0449)
The odds rutio for being obese is 1.0354 (1.0251;1.0459)
when comporing fhe oId person fo fhe young person, if fhey
differ wifh one yeur in uge.
If fhey differ wifh 4, yeurs fhen fhe odds rofio is
1.0354
4.5
(1.0251
4.5
;1.0459
4.5
)= 1.17 (1.12;1.22)
In STATA:
1og1f obese age45,o ,o ,o ,o
wiII give you fhe OP for one yeor oge difference direcfIy.
-----------------------------------------------------------------------
obese | Odds kaf1o 5fd. L. z P>|z| |95x Conf. lnfeva1]
------+----------------------------------------------------------------
age45 | 1.035415 .0053113 6.7 0.000 1.025057 1.04577
-----------------------------------------------------------------------
Morfen Frydenberg Lineor ond Logisfic regression - Mofe 3 Z0
( ) ( ) 1.98 l 6 0. n 45 0348 odds age = +
The obesity und uge: version 1
Esfimofed reIofionship:
-2.5
-2
-1.5
-1
lo
g

o
d
d
s
30 35 40 45 50 55 60 65 70
Age in Years
PIof0Z
Morfen Frydenberg Lineor ond Logisfic regression - Mofe 3 ZI
.05
.1
.15
.2
.25
p
r
e
v
a
le
n
c
e
30 35 40 45 50 55 60 65 70
Age in Years
( ) ( )
( ) ( )
1.986 0.0348
1.986 0.034
e
8
xp 45
1 exp 45
age
prevalence
age
+
=
+ +

The obesity und uge: version 1


Esfimofed reIofionship:
PIof03
Morfen Frydenberg Lineor ond Logisfic regression - Mofe 3 ZZ
The obesity und uge: version Z
This modeI ossumes fhof one yeor of oge difference is
ossociofed wifh fhe some odds rofio irrespecfiveIy of fhe oge.
An ofher woy fo modeI fhe prevoIence couId be fo ossume o
sfep funcfion fhof is fo cofegori;e oge.
We wiII here Iook of oge divided in seven five-yeors groups:
egen agegp7=cuf{age}, af{0,35,40,45,50,55,60,120} 1abe1
Wifh fhis commond fhe youngest oge group wiII be number 0
fhe second youngest: I ond fhe oIdest: o
( ) ( )
0 1
ln 45 odds age = +
Morfen Frydenberg Lineor ond Logisfic regression - Mofe 3 Z3
The obesity und uge: version Z
fab1e agegp7 ,c{m1n age max age counf obese sum obese} oW
----------------------------------------------------------
agegp7 | m1n{age} max{age} N{obese} sum{obese}
----------+-----------------------------------------------
0- | 30 34 352 23
35- | 35 39 973 105
40- | 40 44 5 93
45- | 45 49 799 95
50- | 50 54 733 115
55- | 55 59 613 95
60- | 60 66 335 75
|
1ofa1 | 30 66 4,690 601
----------------------------------------------------------
( )
0
6
1
ln
i
i
od a i ds ge
=
= +

A modeI fhof hove differenf odds in eoch oge group :


Where agei is on indicofor for being in fhe ifh oge group
Morfen Frydenberg Lineor ond Logisfic regression - Mofe 3 Z4
The obesity und uge: version Z
The inferprefofion of fhe poromefers:

0
: fhe Iog odds in reference group~fhe youngesf.

i
: fhe Iog odds rutio, when comporing one person in oge
group i wifh one in fhe reference group~fhe youngesf.
cha agegp7|om1f]0
x1: 1og1f obese 1.agegp7 Nof a11 oufpuf Nof a11 oufpuf Nof a11 oufpuf Nof a11 oufpuf
-------------------------------------------------------------------------
obese | Coef. 5fd. L. z P>|z| |95x Conf. lnfeva1]
-------------+-----------------------------------------------------------
lagegp71 | .5433 .23915 2.29 0.022 .079603 1.017061
lagegp72 | .5160 .24193 2.14 0.032 .0444155 .99277
lagegp73 | .65766 .24179 2.72 0.007 .137537 1.13157
lagegp74 | .97900 .2339 4.11 0.000 .5117642 1.44625
lagegp75 | .96446 .2424 3.97 0.000 .44941 1.440436
lagegp76 | 1.41737 .2523 5.62 0.000 .922701 1.912032
cons | -2.66056 .21567 -12.34 0.000 -3.032 -2.23739
-------------------------------------------------------------------------
( )
0
6
1
ln
i
i
od a i ds ge
=
= +

Morten Frydenberg Thursday, 17 November 2005


Linear and Logistic Regression: Note 3 5
Morfen Frydenberg Lineor ond Logisfic regression - Mofe 3 Zb
The obesity und uge: version Z
( )
0
6
1
ln
i
i
odds agei
=
= +

x1: 1og1f obese 1.agegp7,o Nof a11 oufpuf Nof a11 oufpuf Nof a11 oufpuf Nof a11 oufpuf
-------------------------------------------------------------------------
obese |Odds kaf1o 5fd. L. z P>|z| |95x Conf. lnfeva1]
------------+------------------------------------------------------------
lagegp71 | 1.730365 .413201 2.29 0.022 1.0257 2.765057
lagegp72 | 1.679677 .4063746 2.14 0.032 1.045417 2.69747
lagegp73 | 1.930274 .4667295 2.72 0.007 1.20172 3.100522
lagegp74 | 2.66112 .6345592 4.11 0.000 1.66232 4.247159
lagegp75 | 2.62334 .637006 3.97 0.000 1.6296 4.22253
lagegp76 | 4.126254 1.041397 5.62 0.000 2.516095 6.76625
-------------------------------------------------------------------------
The OP befween fhe second oIdest ond fhe youngest:
2.62 (1.63;4.22)
8efween o 63 ond 322 percenf increuse in odds.
SmoII prevoIence: 63 ond 322 percenf increuse in prevoIence.
A sfofisficoI significonf difference in prevoIencel
Morfen Frydenberg Lineor ond Logisfic regression - Mofe 3 Zo
The obesity und uge: version Z
The oufpuf confoins si tests of no difference in risk -
comporing eoch of fhe six groups wifh fhe reference (fhe
youngesf) group.
The commond: fesfpam lagegp"
wiII give o "WuId test" of no difference befween fhe seven
groups .
{ 1} lagegp71 = 0
{ 2} lagegp72 = 0
{ 3} lagegp73 = 0
{ 4} lagegp74 = 0
{ 5} lagegp75 = 0
{ 6} lagegp76 = 0
ch12{ 6} = 55.26
Pob > ch12 = 0.0000
HighIy significonf
differences
( )
0
6
1
ln
i
i
od a i ds ge
=
= +

Morfen Frydenberg Lineor ond Logisfic regression - Mofe 3 Z7


The obesity und uge: version Z
cha agegp7|om1f]3 33 3
x1: 1og1f obese 1.agegp7,o Nof a11 oufpuf Nof a11 oufpuf Nof a11 oufpuf Nof a11 oufpuf
-------------------------------------------------------------------------
obese |Odds kaf1o 5fd. L. z P>|z| |95x Conf. lnfeva1]
------------+-----------------------------------------------------------
lagegp70 | .51061 .1252643 -2.72 0.007 .3225264 .321407
lagegp71 | .96434 .134312 -0.73 0.467 .6675609 1.20377
lagegp72 | .70175 .1347005 -0.90 0.369 .6424561 1.1761
lagegp74 | 1.3791 .2057436 2.15 0.031 1.029341 1.4735
lagegp75 | 1.359073 .2123097 1.96 0.050 1.000625 1.45927
lagegp76 | 2.137652 .364206 4.45 0.000 1.529915 2.9603
-------------------------------------------------------------------------
The OP befween fhe second oIdest ond fhe 4-49 oId:
1.36 (1.00;1.85)
8efween o no ond 85 percenf increuse in (odds) prevoIence.
A borderIine significonf differenf in prevoIencel
Using fhe oge group 4b-49 os reference
Morfen Frydenberg Lineor ond Logisfic regression - Mofe 3 Z8
-3
-2.5
-2
-1.5
-1
l
o
g

o
d
d
s
30 35 40 45 50 55 60 65 70
Age in Years
.05
.1
.15
.2
.25
p
r
e
v
a
l
e
n
c
e
30 35 40 45 50 55 60 65 70
Age in Years
The obesity und uge: version Z
Esfimofed reIofionship
0 4
+
0

PIof04
Morfen Frydenberg Lineor ond Logisfic regression - Mofe 3 Z9
The obesity und uge: version 1 und Z
-3
-2.5
-2
-1.5
-1
l
o
g

o
d
d
s
30 35 40 45 50 55 60 65 70
Age in Years
model1
model2
.05
.1
.15
.2
.25
p
r
e
v
a
l
e
n
c
e
30 35 40 45 50 55 60 65 70
Age in Years
model1
model2
PIof0b
Morfen Frydenberg Lineor ond Logisfic regression - Mofe 3 30
This is bosed on fhree ussumptions:
Additivity on Iogit scuIe: The confribufion from sex ond oge
ore udded.
ProportionuIty on Iogit scuIe: The confribufion from oge is
proportionuI fo if is voIue.
No effectmodificution on Iogit scuIe: The confribufion from
one independenf voriobIe is the sume whofever fhe voIue is
for fhe ofher.
The obesity se und uge: version 1
The firsf onoIysis onIy Iooked of sex ond fhe second onIy of
oge.
Lef us fry fo Iook of fhose fwo of fhe some fime
The simpIesf modeI on the Iogit scuIe wouId be:
( ) ( )
0 1 2
ln 45 odds woman age = + +
Morten Frydenberg Thursday, 17 November 2005
Linear and Logistic Regression: Note 3 6
Morfen Frydenberg Lineor ond Logisfic regression - Mofe 3 3I
The obesity se und uge : version 1
( ) ( )
0 1 2
ln 45 odds woman age = + +
The inferprefofion of fhe poromefers:

0
: fhe Iog odds for 4b yeor oId mun.

1
: fhe Iog odds rutio, when comporing o womon fo o mon of
fhe some oge.

2
: fhe Iog odds rutio, when comporing fwo persons of fhe
some sex, where fhe firsf is one yeor oIder fhon fhe
ofher.

2
^age: fhe Iog odds rutio, when comporing fwo persons of
fhe some sex, where fhe firsf is age yeors oIder fhon
fhe ofher.
Morfen Frydenberg Lineor ond Logisfic regression - Mofe 3 3Z
Obfoining fhe esfimofes in STATA:
x1:1og1f obese 1.sex age45
1.sex lsex1-2 {nafua11y coded lsex1 om1ffed}
lfeaf1on 0: 1og 11ke11hood = -1795.5437
lfeaf1on 3: 1og 11ke11hood = -1767.7019
Log1f esf1mafes Numbe of obs = 4690
Lk ch12{2} = 55.6
Pob > ch12 = 0.0000
Log 11ke11hood = -1767.7019 Pseudo k2 = 0.0155
----------------------------------------------------------------------
obese | Coef. 5fd. L. z P>|z| |95x Conf. lnfeva1]
--------+--------------------------------------------------------------
lsex2 | .2743977 .090335 3.04 0.002 .0973375 .45145
age45 | .0344723 .0051354 6.71 0.000 .0244072 .0445374
cons | -2.147056 .072191 -29.74 0.000 -2.2561 -2.00555
-----------------------------------------------------------------------
( ) ( )
0 1 2
ln 45 odds woman age = + +
Tests: Mo ossociofion wifh sex Mo ossociofion wifh age
PrevoIence is b07 omong 4b yeor oId men
The obesity se und uge : version 1
Morfen Frydenberg Lineor ond Logisfic regression - Mofe 3 33
x1:1og1f obese 1.sex age45, o , o , o , o
obese | Odds kaf1o 5fd. L. z P>|z| |95x Conf. lnfeva1]
--------+--------------------------------------------------------------
lsex2 | 1.31573 .1161 3.04 0.002 1.102232 1.5706
age45 | 1.035073 .0053155 6.71 0.000 1.024707 1.045544
-----------------------------------------------------------------------
( ) ( )
0 1 2
ln 45 odds woman age = + +
OP for women compored fo men "odjusfed for oge" :
1.32 (1.10;1.57)
The unudgusted wos 1.33 (1.12;1.59).
OP for one yeur uge difference "odjusfed for sex" :
1.04 (1.02;1.05)
The unudgusted wos 1.04 (1.03;1.05)
Mof much hos chongedl
The obesity se und uge : version 1
Morfen Frydenberg Lineor ond Logisfic regression - Mofe 3 34
-3
-2.5
-2
-1.5
-1
l
o
g

o
d
d
s
30 35 40 45 50 55 60 65 70
Age in Years
men
women
.05
.1
.15
.2
.25
p
r
e
v
a
l
e
n
c
e
30 35 40 45 50 55 60 65 70
Age in Years
men
women
The esfimofed reIofionship
The obesity se und uge : version 1
( ) ( )
0 1 2
ln 45 odds woman age = + +
PIof0o
Morfen Frydenberg Lineor ond Logisfic regression - Mofe 3 3b
This is bosed on one ussumptions:
ProportionuIty on Iogit scuIe: The confribufion oge is
proportionuI fo if is voIue.
If con be wriffen in jusf one formuIo (wifh inferocfion):
The obesity se und uge: version Z
A more compIicofed modeI on the Iogit scuIe wouId be:
( ) ( )
( ) ( )
0 1
0 1
ln 45
ln 45
men:
women:
odds age
odds age


= +
= +
( ) ( ) ( )
0 1 2 3
ln 45 45 odds woman age woman age = + + +
0 0 1 2
0 0 1 1 2 3


= =
= + = +
Where:
Thof is:
1 0 0 3 1 1
= =
Morfen Frydenberg Lineor ond Logisfic regression - Mofe 3 3o
The obesity se und uge: version Z
Esfimofes Iog odds:
( ) ( ) ( )
0 1 2 3
ln 45 45 odds woman age woman age = + + +
x1: 1og1f obese 1.sex"age45
-------------------------------------------------------------------------
obese | Coef. 5fd. L. z P>|z| |95x Conf. lnfeva1]
-------------+-----------------------------------------------------------
lsex2 | .116797 .095034 1.23 0.219 -.069467 .303061
age45 | -.005649 .00372 -0.6 0.497 -.022095 .010725
lsexXage4~2 | .06503 .01074 6.13 0.000 .044747 .065
cons |-2.03041 .070643 -29.49 0.000 -2.22149 -1.94453
-----------------------------------------------------------------------
Men
Difference befween women ond men
Esfimofes odds rofios:
obese | Odds kaf1o 5fd. L z P>|z| |95x Conf. lnfeva1]
-------------+-----------------------------------------------------------
lsex2 | 1.12391 .1060 1.23 0.219 .93290 1.353997
age45 | .994331 .0032 -0.6 0.497 .97147 1.01073
lsexXage4~2 | 1.06016 .01147 6.13 0.000 1.045763 1.090743
-------------------------------------------------------------------------
Morten Frydenberg Thursday, 17 November 2005
Linear and Logistic Regression: Note 3 7
Morfen Frydenberg Lineor ond Logisfic regression - Mofe 3 37
-3
-2.5
-2
-1.5
-1
-.5
l
o
g

o
d
d
s
30 35 40 45 50 55 60 65 70
Age in Years
men
women
0
.1
.2
.3
.4
p
r
e
v
a
l
e
n
c
e
30 35 40 45 50 55 60 65 70
Age in Years
men
women
The esfimofed reIofionship
The obesity se und uge: version Z
( ) ( ) ( )
0 1 2 3
ln 45 45 odds woman age woman age = + + +
PIof07
Morfen Frydenberg Lineor ond Logisfic regression - Mofe 3 38
The cuse controI eumpIe
fabodds cance age, o
------------------------------------------------------------------------
age | Odds kaf1o ch12 P>ch12 |95x Conf. lnfeva1]
------+-------------------------------------------------------------
25-34 | 1.000000 . . . .
35-44 | 2.74736 1.76 0.143 0.579474 13.025660
45-54 | 15.97604 24.1 0.0000 3.5609 71.123412
55-64 | 26.554217 41.14 0.0000 5.3471 120.50133
65-74 | 30.094340 43.99 0.0000 6.27745 144.24362
>=75 | 24.32251 29.40 0.0000 4.402342 134.30270
------------------------------------------------------------------------
fabodds cance age
------------------------------------------------------------------------
age | cases confo1s odds |95x Conf. lnfeva1]
------+-------------------------------------------------------------
25-34 | 2 116 0.01724 0.00426 0.06976
35-44 | 9 190 0.04737 0.02427 0.09244
45-54 | 46 167 0.27545 0.1975 0.3175
55-64 | 76 166 0.4573 0.3499 0.60061
65-74 | 55 106 0.517 0.37463 0.7164
>=75 | 13 31 0.41935 0.21944 0.013
----------------------------------------------------------------------
Few evenfs in reference group~ wide CI's
Morfen Frydenberg Lineor ond Logisfic regression - Mofe 3 39
The cuse controI eumpIe
fabodds cance age, o base{3} base{3} base{3} base{3}
-------------------------------------------------------------------------
age | Odds kaf1o ch12 P>ch12 |95x Conf. lnfeva1]
------+---------------------------------------------------------------
25-34 | 0.062594 24.1 0.0000 0.014060 0.27660
35-44 | 0.17196 25.6 0.0000 0.079661 0.371235
45-54 | 1.000000 . . . .
55-64 | 1.662127 5.54 0.016 1.0344 2.54952
65-74 | 1.3716 7.32 0.006 1.1169 3.00209
>=75 | 1.522440 1.30 0.2546 0.734799 3.154365
-------------------------------------------------------------------------
fabodds cance age
------------------------------------------------------------------------
age | cases confo1s odds |95x Conf. lnfeva1]
------+-------------------------------------------------------------
25-34 | 2 116 0.01724 0.00426 0.06976
35-44 | 9 190 0.04737 0.02427 0.09244
45-54 | 46 167 0.27545 0.1975 0.3175
55-64 | 76 166 0.4573 0.3499 0.60061
65-74 | 55 106 0.517 0.37463 0.7164
>=75 | 13 31 0.41935 0.21944 0.013
----------------------------------------------------------------------
'Mony' evenfs in reference group~ norrow CI's
Morfen Frydenberg Lineor ond Logisfic regression - Mofe 3 40
The cuse controI eumpIe
cha age |om1f]1 11 1
x1:1og1f cance 1.smoke 1.age,o
1.smoke lsmoke0-1 {nafua11y coded lsmoke0 om1ffed}
1.age lage1-6 {nafua11y coded lage1 om1ffed lage1 om1ffed lage1 om1ffed lage1 om1ffed}
lfeaf1on 0: 1og 11ke11hood = -496.5562
lfeaf1on 1: 1og 11ke11hood = -437.55133
lfeaf1on 2: 1og 11ke11hood = -429.6007
lfeaf1on 3: 1og 11ke11hood = -42.9933
lfeaf1on 4: 1og 11ke11hood = -42.94473
lfeaf1on 5: 1og 11ke11hood = -42.94432
lfeaf1on 6: 1og 11ke11hood = -42.94432
Log1f esf1mafes Numbe of obs = 977
Lk ch12{6} = 135.23
Pob > ch12 = 0.0000
Log 11ke11hood = -42.94432 Pseudo k2 = 0.1362
-------------------------------------------------------------------------
cance | Odds kaf1o 5fd. L. z P>|z| |95x Conf. lnfeva1]
-----------+------------------------------------------------------------
lsmoke1 | 2.350 .451303 4.45 0.000 1.613342 3.424472
lage2 | 2.32 2.2436 1.31 0.19 .5995103 13.379
lage3 | 16.5 12.1737 3.2 0.000 3.93226 69.91422
lage4 | 27.9 20.32374 4.57 0.000 6.691356 116.3235
lage5 | 34.79 25.59029 4.3 0.000 .231516 147.0764
lage6 | 27.71 21.9267 4.21 0.000 5.917 130.3509
-------------------------------------------------------------------------
"Mony" iferofions
Morfen Frydenberg Lineor ond Logisfic regression - Mofe 3 4I
The cuse controI eumpIe
cha age |om1f]3 33 3
x1:1og1f cance 1.smoke 1.age,o
1.smoke lsmoke0-1 {nafua11y coded lsmoke0 om1ffed}
1.age lage1-6 {nafua11y coded lage3 om1ffed lage3 om1ffed lage3 om1ffed lage3 om1ffed}
lfeaf1on 0: 1og 11ke11hood = -496.5562
lfeaf1on 1: 1og 11ke11hood = -437.55133
lfeaf1on 2: 1og 11ke11hood = -429.6007
lfeaf1on 3: 1og 11ke11hood = -42.9933
lfeaf1on 4: 1og 11ke11hood = -42.94473
lfeaf1on 5: 1og 11ke11hood = -42.94432
Log1f esf1mafes Numbe of obs = 977
Lk ch12{6} = 135.23
Pob > ch12 = 0.0000
Log 11ke11hood = -42.94432 Pseudo k2 = 0.1362
-------------------------------------------------------------------------
cance | Odds kaf1o 5fd. L. z P>|z| |95x Conf. lnfeva1]
-----------+-------------------------------------------------------------
lsmoke1 | 2.3504 .451303 4.45 0.000 1.613343 3.424469
lage1 | .0603 .0442767 -3.3 0.000 .0143051 .254271
lage2 | .170 .0652397 -4.63 0.000 .007999 .3610977
lage4 | 1.626 .37011 2.37 0.01 1.093327 2.5953
lage5 | 2.094 .504262 3.0 0.002 1.31025 3.36091
lage6 | 1.6713 .6277714 1.37 0.171 .005146 3.49699
-------------------------------------------------------------------------
Morfen Frydenberg Lineor ond Logisfic regression - Mofe 3 4Z
Things to Iook out for in the output
In generoI:
Wide CI's or Iurge stundurd errors in o Iogisfic regression
indicofes fhof of Ieosf one group hos few eventsl
Muny iterutions in o Iogisfic regression indicofes fhof some
of fhe purumeters ure hurd to estimute.
Morten Frydenberg Thursday, 17 November 2005
Linear and Logistic Regression: Note 3 8
Morfen Frydenberg Lineor ond Logisfic regression - Mofe 3 43
Compuring two modeIs: the IikeIihood rutio test
EorIier we sow how one couId use o WuId fo fesf if severoI
coefficienfs couId be ;ero .
An ofher woy fo "compore" fwo modeIs is by o IikeIihood
rutio test.
In fhe Iogisfic regression oufpuf from STATA we find o
IikeIihood rofio fesf comporing fhe fitted modeI wifh fhe
modeI wifh no dependenf voriobIes fhe constunt odds modeI:
Lk ch12{6} = 135.23
Pob > ch12 = 0.0000
The concIusion: The modeI wifh smoker ond oge is stutisticuI
significunt beffer, fhon o modeI ossuming fhe some odds, risk
for everybody.
Morfen Frydenberg Lineor ond Logisfic regression - Mofe 3 44
Compuring two modeIs: the IikeIihood rutio test
One con compore fwo modeIs wifh o IikeIihood rofio fesf if:
The fwo modeIs ore fiffed on exocfIy fhe sume dutu set.
The fwo modeIs ore nested, i.e. one con go from one modeI
fo fhe ofher by seffing some coefficienfs fo ;ero.
In STATA fhe fesf is found in fhis woy:
x1:1og1f cance 1.smoke 1.age
esf1mafes sfoe mode11 esf1mafes sfoe mode11 esf1mafes sfoe mode11 esf1mafes sfoe mode11
x1:1og1f cance 1.smoke
esf1mafes sfoe mode12 esf1mafes sfoe mode12 esf1mafes sfoe mode12 esf1mafes sfoe mode12
1fesf 1fesf 1fesf 1fesf mode11 mode12 mode11 mode12 mode11 mode12 mode11 mode12
Oufpuf:
11ke11hood-af1o fesf Lk ch12{5} = 120.2
{Assumpf1on: mode12 nesfed 1n mode11} Pob > ch12 = 0.0000
i.oge odds stutisticuI significunt informofion fo fhe modeI
onIy confoining smokingl
Morfen Frydenberg Lineor ond Logisfic regression - Mofe 3 4b
This is bosed on fhree ossumpfions:
u, Additivity on Iog-odds scuIe: The confribufion from eoch
of fhe independenf voriobIes ore udded.
b,ProportionuIty: The confribufion from independenf voriobIes
is proportionuI fo if is voIue (wifh o focfor )
c, No effectmodificution: The confribufion from one
independenf voriobIes is the sume whofever fhe voIues ore
for fhe ofher.
Mofe u, con oIso be formuIofe os muItipIicutivity on odds scuIe
Logistic regression modeI in generuI
( )
0
1
ln
k
p
p
p
odds x
=
= +

1 2
0 1 2
k
x x
k
x
odds OR OR od O ds R =
Morfen Frydenberg Lineor ond Logisfic regression - Mofe 3 4o
If one consider fwo persons who differ wifh
x
1
in x
1
, x
2
in x
2
, ond x
k
in x
k
fhen difference in fhe Iog odds is :
1
p
k
p
p
x
=

Agoin we see fhof fhe confribufion for eoch of fhe


expIonofory voriobIes:
ore udded,
ore proportionuI fo fhe difference
ond does not dependent of fhe difference in fhe ofher
on the Iog odds scuIe,
( )
0
1
ln
k
p
p
p
odds x
=
= +

Logistic regression modeI in generuI


Morfen Frydenberg Lineor ond Logisfic regression - Mofe 3 47
If one consider fwo persons who differ wifh
x
1
in x
1
, x
2
in x
2
, ond x
k
in x
k
fhen odds rofio :
( )
0
1
ln
k
p
p
p
odds x
=
= +

1 2
1 2
k
x x x
k
OR OR OR OR

=
Note fhe modeI mighf oIso be formuIofed:
( ) [ ] ( )
0
1
0
1
exp
ln ln Pr 1
1 exp
p
p p
k
p
p
k
p
x
p Y
x


=
=

+


= = =

+ +

Logistic regression modeI in generuI


Morfen Frydenberg Lineor ond Logisfic regression - Mofe 3 48
The dutu: Y =1/0 dichofomous dependenf voriobIe
x
1
, x
2
, x
k
independenf/expIonofory voriobIes
Like in fhe normoI regression modeIs if is ossumed fhof fhe Y's
ore independent given fhe expIonofory voriobIes.
This ossumpfion con, in generoI, onIy be checked by
scrutinising fhe design.
Look ouf for dofo sompIed in cIusters:
Pofienfs wifhin fhe sume SP
ChiIdren wifhin fhe sume fumiIy
Twins,
( )
0
1
ln
k
p
p
p
odds x
=
= +

Logistic regression modeI in generuI


Morten Frydenberg Thursday, 17 November 2005
Linear and Logistic Regression: Note 3 9
Morfen Frydenberg Lineor ond Logisfic regression - Mofe 3 49
Estimution:
Excepfing fhe fwo by fwo fobIes, fhere ore no cIosed form for
fhe esfimofes.
The distribution of fhe esfimofes ure not known.
Esfimofes ore found by fhe mefhod of muimum IikeIihood.
Esfimofes ore using iterutive methods.
Sfondord errors, confidence infervoIs ond oII fesfs ore bosed
on usymptotics.
Thof is, oII sfofisficoI inference ore upproimute.
The more dutu - fhe more evenfs -fhe better fhe
opproximofions.
Logistic regression modeI in generuI

Das könnte Ihnen auch gefallen