Chapter 14, Section 14.7

 

Clinical Trial of Contracepting Women

Random Effects Logistic Regression Model

 

use "amenorrhea.dta"

 

gen time2=time*time 

 

xtmelogit y time time2 c.trt#c.time c.trt#c.time2 || id:, intpoints(50)

 

Refining starting values: 

 

Iteration 0:   log likelihood = -2022.5045  

Iteration 1:   log likelihood = -1935.8762  

Iteration 2:   log likelihood = -1934.4832  

 

Performing gradient-based optimization: 

 

Iteration 0:   log likelihood = -1934.4832  

Iteration 1:   log likelihood =  -1934.465  

Iteration 2:   log likelihood =  -1934.465  

 

Mixed-effects logistic regression               Number of obs      =      3616

Group variable: id                              Number of groups   =      1151

 

                                                Obs per group: min =         1

                                                               avg =       3.1

                                                               max =         4

 

Integration points =  50                        Wald chi2(4)       =    291.00

Log likelihood =  -1934.465                     Prob > chi2        =    0.0000

 

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

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

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

        time |   1.133202   .2682199     4.22   0.000     .6075006    1.658903

       time2 |  -.0419231   .0548095    -0.76   0.444    -.1493479    .0655016

             |

c.trt#c.time |   .5644406   .1922393     2.94   0.003     .1876585    .9412228

             |

       c.trt#|

     c.time2 |  -.1095528   .0496097    -2.21   0.027     -.206786   -.0123195

             |

       _cons |  -3.805676   .3049794   -12.48   0.000    -4.403425   -3.207928

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

 

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

  Random-effects Parameters  |   Estimate   Std. Err.     [95% Conf. Interval]

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

id: Identity                 |

                   sd(_cons) |   2.250463   .1297551      2.009991    2.519705

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

LR test vs. logistic regression: chibar2(01) =   500.52 Prob>=chibar2 = 0.0000

 

test c.trt#c.time c.trt#c.time2

 

 ( 1)  [eq1]c.trt#c.time = 0

 ( 2)  [eq1]c.trt#c.time2 = 0

 

           chi2(  2) =   12.40

         Prob > chi2 =    0.0020

 

Marginal Logistic Regression Model

 

tsset id time

       panel variable:  id (strongly balanced)

        time variable:  time, 1 to 4

                delta:  1 unit

 

 

xtgee y time time2 c.trt#c.time c.trt#c.time2, family(binomial) ///

     link(logit) corr(unstr) robust

 

 

Iteration 1: tolerance = .03144156

Iteration 2: tolerance = .00031005

Iteration 3: tolerance = 1.457e-06

Iteration 4: tolerance = 1.874e-08

 

GEE population-averaged model                   Number of obs      =      3616

Group and time vars:               id time      Number of groups   =      1151

Link:                                logit      Obs per group: min =         1

Family:                           binomial                     avg =       3.1

Correlation:                  unstructured                     max =         4

                                                Wald chi2(4)       =    329.51

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]

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

        time |   .6979351   .1581439     4.41   0.000     .3879789    1.007891

       time2 |  -.0313663   .0317706    -0.99   0.324    -.0936355    .0309029

             |

c.trt#c.time |   .3380089    .109735     3.08   0.002     .1229323    .5530854

             |

       c.trt#|

     c.time2 |   -.069028   .0284191    -2.43   0.015    -.1247285   -.0133275

             |

       _cons |  -2.240794   .1765697   -12.69   0.000    -2.586864   -1.894723

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

 

xtcorr

 

Estimated within-id correlation matrix R:

 

        c1      c2      c3      c4

r1  1.0000

r2  0.3438  1.0000

r3  0.2594  0.4260  1.0000

r4  0.2730  0.3855  0.4993  1.0000

 

 

test c.trt#c.time c.trt#c.time2

 

 ( 1)  c.trt#c.time = 0

 ( 2)  c.trt#c.time2 = 0

 

           chi2(  2) =   12.02

         Prob > chi2 =    0.0025

 

 

Conditional Logistic Regression Model

 

clogit y time time2 c.trt#c.time c.trt#c.time2, group(id)

 

note: multiple positive outcomes within groups encountered.

note: 664 groups (1810 obs) dropped because of all positive or

      all negative outcomes.

 

Iteration 0:   log likelihood = -472.89468  

Iteration 1:   log likelihood = -470.65326  

Iteration 2:   log likelihood = -470.63808  

Iteration 3:   log likelihood = -470.63808  

 

Conditional (fixed-effects) logistic regression   Number of obs   =       1806

                                                  LR chi2(4)      =     425.78

                                                  Prob > chi2     =     0.0000

Log likelihood = -470.63808                       Pseudo R2       =     0.3115

 

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

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

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

        time |   .7587085   .3766458     2.01   0.044     .0204964    1.496921

       time2 |   .0366749   .0742164     0.49   0.621    -.1087866    .1821364

             |

c.trt#c.time |   1.210721    .532371     2.27   0.023     .1672935    2.254149

             |

       c.trt#|

     c.time2 |  -.2234542   .1040435    -2.15   0.032    -.4273757   -.0195327

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

 

test c.trt#c.time c.trt#c.time2

 

 ( 1)  [y]c.trt#c.time = 0

 ( 2)  [y]c.trt#c.time2 = 0

 

           chi2(  2) =    5.29

         Prob > chi2 =    0.0711

 

 

 

 

 

Clinical Trial of Epileptic Patients

Random Effects Log-Linear Regression Model

 

use "epilepsy.dta"

 

reshape long y, i(id) j(visit) 

(note: j = 0 1 2 3 4)

 

Data                               wide   ->   long

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

Number of obs.                       59   ->     295

Number of variables                   8   ->       5

j variable (5 values)                     ->   visit

xij variables:

                           y0 y1 ... y4   ->   y

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

 

gen time=0

 

replace time=1 if (visit > 0)

(236 real changes made)

 

gen ltime=log(8)

 

replace ltime=log(2) if (visit > 0)

(236 real changes made)

 

 

xtmepoisson y trt time  c.trt#c.time || id: time, offset(ltime) /// 

     cov(unstrintpoints(50) 

 

Refining starting values: 

 

Iteration 0:   log likelihood = -948.64173  (not concave)

Iteration 1:   log likelihood =  -945.4711  (not concave)

Iteration 2:   log likelihood = -933.17143  

 

Performing gradient-based optimization: 

 

Iteration 0:   log likelihood = -933.17143  

Iteration 1:   log likelihood = -929.56923  

Iteration 2:   log likelihood = -925.61279  

Iteration 3:   log likelihood = -925.51274  

Iteration 4:   log likelihood = -925.51226  

Iteration 5:   log likelihood = -925.51226  

 

Mixed-effects Poisson regression                Number of obs      =       295

Group variable: id                              Number of groups   =        59

 

                                                Obs per group: min =         5

                                                               avg =       5.0

                                                               max =         5

 

Integration points =  50                        Wald chi2(3)       =      8.37

Log likelihood = -925.51226                     Prob > chi2        =    0.0390

 

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

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

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

         trt |   .0513072   .1930728     0.27   0.790    -.3271085    .4297229

        time |  -.0003924   .1097187    -0.00   0.997    -.2154371    .2146523

             |

c.trt#c.time |  -.3064967   .1512594    -2.03   0.043    -.6029597   -.0100337

             |

       _cons |    1.07068   .1405523     7.62   0.000     .7952021    1.346157

       ltime |   (offset)

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

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

  Random-effects Parameters  |   Estimate   Std. Err.     [95% Conf. Interval]

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

id: Unstructured             |

                    sd(time) |   .4830775   .0628772      .3743042    .6234603

                   sd(_cons) |   .7078008   .0713327      .5809333    .8623743

            corr(time,_cons) |   .1581562   .1639081     -.1683817     .453415

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

LR test vs. Poisson regression:      chi2(3) =  2785.98   Prob > chi2 = 0.0000

 

Note: LR test is conservative and provided only for reference.

 

 

 

 

 

drop if (id==49)

(5 observations deleted)

 

xtmepoisson y trt time c.trt#c.time || id: time, offset(ltime) /// 

     cov(unstrintpoints(50)

 

Refining starting values: 

 

Iteration 0:   log likelihood =  -916.7319  (not concave)

Iteration 1:   log likelihood =  -902.7133  

Iteration 2:   log likelihood = -895.06751  

 

Performing gradient-based optimization: 

 

Iteration 0:   log likelihood = -895.06751  

Iteration 1:   log likelihood =   -893.591  

Iteration 2:   log likelihood = -893.54843  

Iteration 3:   log likelihood = -893.54837  

 

Mixed-effects Poisson regression                Number of obs      =       290

Group variable: id                              Number of groups   =        58

 

                                                Obs per group: min =         5

                                                               avg =       5.0

                                                               max =         5

 

Integration points =  50                        Wald chi2(3)       =     10.18

Log likelihood = -893.54837                     Prob > chi2        =    0.0171

 

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

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

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

         trt |   -.007947   .1860332    -0.04   0.966    -.3725654    .3566714

        time |   .0078075   .1070297     0.07   0.942    -.2019669    .2175819

             |

c.trt#c.time |  -.3461139   .1488568    -2.33   0.020    -.6378679   -.0543599

             |

       _cons |   1.069215   .1343632     7.96   0.000     .8058683    1.332562

       ltime |   (offset)

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

 

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

  Random-effects Parameters  |   Estimate   Std. Err.     [95% Conf. Interval]

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

id: Unstructured             |

                    sd(time) |   .4650389   .0631174      .3564182    .6067624

                   sd(_cons) |    .672984   .0694972      .5496718    .8239597

            corr(time,_cons) |    .048271   .1701862     -.2784762    .3650036

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

LR test vs. Poisson regression:      chi2(3) =  1654.60   Prob > chi2 = 0.0000

 

Note: LR test is conservative and provided only for reference.

 

 

 

 

 

 

Arthritis Clinical Trial

Random Effects Proportional Odds (Ordinal) Regression Model

 

 

 

 

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)

 

ssc install gllamm, replace

checking gllamm consistency and verifying not already installed...

all files already exist and are up to date.

 

gen trt_sqrtmonth=trt*sqrtmonth

 

gen constant = 1

 

eq intercept: constant

 

eq slope: sqrtmonth

 

gllamm y trt sqrtmonth trt_sqrtmonth, i(id) nrf(2) eqs(intercept slope) ///

     link(ologit) adapt nip(50)

 

Running adaptive quadrature

Iteration 0:    log likelihood = -1544.2044

Iteration 1:    log likelihood =  -1458.793

Iteration 2:    log likelihood = -1442.5267

Iteration 3:    log likelihood = -1435.2145

Iteration 4:    log likelihood = -1434.4705

Iteration 5:    log likelihood = -1434.4366

Iteration 6:    log likelihood = -1434.4365

 

 

Adaptive quadrature has converged, running Newton-Raphson

Iteration 0:   log likelihood = -1434.4365  

Iteration 1:   log likelihood = -1434.4365  (backed up)

Iteration 2:   log likelihood = -1434.4352  

Iteration 3:   log likelihood = -1434.4352  

 

number of level 1 units = 1194

number of level 2 units = 303

 

Condition Number = 10.20159

 

gllamm model

 

log likelihood = -1434.4352

 

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

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

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

y            |

         trt |  -.1139851   .3183912    -0.36   0.720    -.7380205    .5100502

   sqrtmonth |  -.4000437   .1018144    -3.93   0.000    -.5995962   -.2004912

trt_sqrtmo~h |  -.4005458   .1432472    -2.80   0.005    -.6813052   -.1197865

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

_cut11       |

       _cons |   -5.29452   .3289334   -16.10   0.000    -5.939217   -4.649822

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

_cut12       |

       _cons |  -2.008518   .2483358    -8.09   0.000    -2.495247   -1.521788

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

_cut13       |

       _cons |     1.0753    .238235     4.51   0.000     .6083678    1.542232

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

_cut14       |

       _cons |   3.868292   .3006138    12.87   0.000       3.2791    4.457484

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

 

 

Variances and covariances of random effects

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

 

 

***level 2 (id)

 

    var(1): 4.1424192 (.85485338)

    cov(2,1): -.05160623 (.26260113) cor(2,1): -.04452755

 

    var(2): .32425943 (.16172043)

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