. use "muscatine.dta"
. gen cage=age - 12
. gen cage2=cage*cage
. tsset id occasion
panel variable: id (strongly balanced)
time variable: occasion, 1 to 3
delta: 1 unit
. xtgee y i.gender cage cage2 i.gender#c.cage i.gender#c.cage2, ///
family(binomial) link(logit) corr(unstr) robust
Iteration 1: tolerance = .01601043
Iteration 2: tolerance = .00008379
Iteration 3: tolerance = 1.585e-06
Iteration 4: tolerance = 4.164e-08
GEE population-averaged model Number of obs = 9856
Group and time vars: id occasion Number of groups = 4856
Link: logit Obs per group: min = 1
Family: binomial avg = 2.0
Correlation: unstructured max = 3
Wald chi2(5) = 71.38
Scale parameter: 1 Prob > chi2 = 0.0000
(Std. Err. adjusted for clustering on id)
------------------------------------------------------------------------------
| Semirobust
y | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
1.gender | .1137967 .0711192 1.60 0.110 -.0255943 .2531878
cage | .0378425 .0132932 2.85 0.004 .0117884 .0638966
cage2 | -.0176874 .0033755 -5.24 0.000 -.0243033 -.0110715
|
gender#|
c.cage |
1 | .0071529 .0183061 0.39 0.696 -.0287264 .0430322
|
gender#|
c.cage2 |
1 | .0038899 .0046337 0.84 0.401 -.0051919 .0129717
|
_cons | -1.212052 .0505248 -23.99 0.000 -1.311078 -1.113025
------------------------------------------------------------------------------
. xtcorr
Estimated within-id correlation matrix R:
c1 c2 c3
r1 1.0000
r2 0.5978 1.0000
r3 0.4708 0.5479 1.0000
. test 1.gender#c.cage 1.gender#c.cage2
( 1) 1.gender#c.cage = 0
( 2) 1.gender#c.cage2 = 0
chi2( 2) = 0.87
Prob > chi2 = 0.6481
. xtgee y gender cage cage2,family(binomial) link(logit) corr(unstr) robust
Iteration 1: tolerance = .01571011
Iteration 2: tolerance = .0003364
Iteration 3: tolerance = 3.081e-06
Iteration 4: tolerance = 8.681e-08
GEE population-averaged model Number of obs = 9856
Group and time vars: id occasion Number of groups = 4856
Link: logit Obs per group: min = 1
Family: binomial avg = 2.0
Correlation: unstructured max = 3
Wald chi2(3) = 71.21
Scale parameter: 1 Prob > chi2 = 0.0000
(Std. Err. adjusted for clustering on id)
------------------------------------------------------------------------------
| Semi-robust
y | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
gender | .1426856 .0626843 2.28 0.023 .0198266 .2655447
cage | .0416386 .0091281 4.56 0.000 .0237479 .0595292
cage2 | -.0156835 .0023092 -6.79 0.000 -.0202095 -.0111575
_cons | -1.226743 .0476951 -25.72 0.000 -1.320223 -1.133262
------------------------------------------------------------------------------
. use "leprosy.dta"
. gen id=_n
. gen antibiotic=0
. replace antibiotic=1 if (drug != 0)
(20 real changes made)
. reshape long y, i(id) j(time)
(note: j = 1 2)
Data wide -> long
-----------------------------------------------------------------------------
Number of obs. 30 -> 60
Number of variables 5 -> 5
j variable (2 values) -> time
xij variables:
y1 y2 -> y
-----------------------------------------------------------------------------
. label variable y "Count of Leprosy Basilli"
. xtgee y 2.time i.drug#2.time,family(poisson) link(log) corr(unstr) ///
robust scale(x2)
Iteration 1: tolerance = .14470346
Iteration 2: tolerance = .00794855
Iteration 3: tolerance = .00030872
Iteration 4: tolerance = .00004549
Iteration 5: tolerance = 1.450e-06
Iteration 6: tolerance = 2.701e-07
GEE population-averaged model Number of obs = 60
Group and time vars: id time Number of groups = 30
Link: log Obs per group: min = 2
Family: Poisson avg = 2.0
Correlation: unstructured max = 2
Wald chi2(3) = 22.20
Scale parameter: 3.213811 Prob > chi2 = 0.0001
(Std. Err. adjusted for clustering on id)
------------------------------------------------------------------------------
| Semirobust
y | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
2.time | -.0028761 .1596889 -0.02 0.986 -.3158606 .3101085
|
drug#time |
1 2 | -.5625683 .2257767 -2.49 0.013 -1.005083 -.120054
2 2 | -.4952842 .2382042 -2.08 0.038 -.9621559 -.0284125
|
_cons | 2.373354 .0815078 29.12 0.000 2.213602 2.533107
------------------------------------------------------------------------------
(Standard errors scaled using square root of Pearson X2-based dispersion)
. xtcorr
Estimated within-id correlation matrix R:
c1 c2
r1 1.0000
r2 0.7384 1.0000
. test 1.drug#2.time 2.drug#2.time
( 1) 1.drug#2.time = 0
( 2) 2.drug#2.time = 0
chi2( 2) = 7.09
Prob > chi2 = 0.0288
. test 1.drug#2.time = 2.drug#2.time
( 1) 1.drug#2.time - 2.drug#2.time = 0
chi2( 1) = 0.09
Prob > chi2 = 0.7699
. xtgee y 2.time i.antibiotic#2.time,family(poisson) link(log) ///
corr(unstr) robust scale(x2)
Iteration 1: tolerance = .13032639
Iteration 2: tolerance = .00695181
Iteration 3: tolerance = .00030193
Iteration 4: tolerance = .00003147
Iteration 5: tolerance = 1.506e-06
Iteration 6: tolerance = 1.481e-07
GEE population-averaged model Number of obs = 60
Group and time vars: id time Number of groups = 30
Link: log Obs per group: min = 2
Family: Poisson avg = 2.0
Correlation: unstructured max = 2
Wald chi2(2) = 21.38
Scale parameter: 3.230823 Prob > chi2 = 0.0000
(Std. Err. adjusted for clustering on id)
------------------------------------------------------------------------------
| Semirobust
y | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
2.time | -.002855 .1596885 -0.02 0.986 -.3158387 .3101286
|
antibiotic#|
time |
1 2 | -.5278276 .2022255 -2.61 0.009 -.9241823 -.131473
|
_cons | 2.373354 .0815078 29.12 0.000 2.213602 2.533107
------------------------------------------------------------------------------
(Standard errors scaled using square root of Pearson X2-based dispersion)
. xtcorr
Estimated within-id correlation matrix R:
c1 c2
r1 1.0000
r2 0.7383 1.0000
. use "arthritis.dta"
. reshape long y, i(id) j(time)
(note: j = 1 2 3 4)
Data wide -> long
-----------------------------------------------------------------------------
Number of obs. 303 -> 1212
Number of variables 7 -> 5
j variable (4 values) -> time
xij variables:
y1 y2 ... y4 -> y
-----------------------------------------------------------------------------
. gen month=2*(time-1)
. gen sqrtmonth=month^0.5
. drop if y==.
(18 observations deleted)
. ologit y trt sqrtmonth trt#c.sqrtmonth, cluster(id)
Iteration 0: log pseudolikelihood = -1649.2551
Iteration 1: log pseudolikelihood = -1620.2638
Iteration 2: log pseudolikelihood = -1620.1446
Iteration 3: log pseudolikelihood = -1620.1446
Ordered logistic regression Number of obs = 1194
Wald chi2(3) = 72.10
Prob > chi2 = 0.0000
Log pseudolikelihood = -1620.1446 Pseudo R2 = 0.0177
(Std. Err. adjusted for 303 clusters in id)
------------------------------------------------------------------------------
| Robust
y | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
trt | -.0713875 .193902 -0.37 0.713 -.4514286 .3086535
sqrtmonth | -.2481326 .0619707 -4.00 0.000 -.369593 -.1266722
|
trt#|
c.sqrtmonth |
1 | -.235426 .0894341 -2.63 0.008 -.4107137 -.0601383
-------------+----------------------------------------------------------------
/cut1 | -3.190244 .1996446 -3.58154 -2.798948
/cut2 | -1.204158 .1524371 -1.502929 -.9053864
/cut3 | .5736485 .1474602 .2846318 .8626652
/cut4 | 2.477013 .2000607 2.084901 2.869125
------------------------------------------------------------------------------