Using Asthma Data with condGEE

David Clement

# data is available from: http://www.blackwellpublishing.com/rss/Volumes/Cv52p3.htm
# it was previously used by Duchateau et al. JRSSC volume 52 (2003), part 3, pages 355-363

library(condGEE)
data(asthma)
n.subjects <- length(unique(asthma$id.w))

med.nar <- 4       #median time not at risk before current gap     
med.rec <- 40      #median length of at risk period

i <- 1
k <- 1
asth <- NULL
while(k <= n.subjects) 
{
  n <- asthma$nn[i]         #number of gaps for subject k
  inds <- i:(i+n-1)         #indices of subject k's gaps 
  gaps <- asthma$stop.w[inds] - asthma$start.w[inds]

  if(n > 1)
  {
    nar <- (asthma$start.w[inds[-1]]-asthma$stop.w[inds[-n]]) > med.nar
    rec <- gaps[1:(n-1)] > med.rec
  }
  age1 <- asthma$start.w[inds]>182 & asthma$start.w[inds]<366
  age2 <- asthma$start.w[inds]>=366

  subj.k <- cbind(asthma$id.w[i], log(gaps), asthma$st.w[i:(i+n-1)], asthma$trt.w[i],
                !asthma$fevent[i:(i+n-1)], c(0,nar), c(0,rec), asthma$trt.w[i]*c(0,nar),
                 age1, age2)

  asth <- rbind(asth, subj.k)

  k <- k + 1
  i <- i + n
}  

#the results look at little different than Clement and Strawderman (2009) because our code
#has been updated. Qualitatively nothing has changed though.

start <- c(4.4, 0.4, -1, 0.3, 0.8, -0.5, -0.3, -0.5, 3)
condGEE(asth, start, k1 = K1.t3, k2 = K2.t3)
## $eta
## [1]  4.4167117  0.4442439 -0.7225587  0.3222722  0.7167941 -0.4635109 -0.3159546
## [8] -0.4485230  3.3774312
## 
## $a.var
##                [,1]         [,2]         [,3]          [,4]         [,5]
##  [1,]  0.0181177345 -0.016778062 -0.006772284 -0.0034127331 -0.002945423
##  [2,] -0.0167780617  0.029670179 -0.007025685  0.0066486483  0.008040455
##  [3,] -0.0067722836 -0.007025685  0.064219473 -0.0107144909 -0.034814486
##  [4,] -0.0034127331  0.006648648 -0.010714491  0.0200782559  0.005566964
##  [5,] -0.0029454226  0.008040455 -0.034814486  0.0055669643  0.039440200
##  [6,]  0.0072011667 -0.011143623 -0.002277381 -0.0163149035 -0.005664269
##  [7,]  0.0004249389  0.002806742 -0.019789443  0.0012410649  0.005481312
##  [8,] -0.0015381352  0.005898135 -0.019638789 -0.0007288387  0.002682853
##  [9,] -0.0074545630  0.005291254 -0.002729188  0.0019672451  0.008905041
##                [,6]          [,7]          [,8]          [,9]
##  [1,]  0.0072011667  4.249389e-04 -0.0015381352 -7.454563e-03
##  [2,] -0.0111436231  2.806742e-03  0.0058981345  5.291254e-03
##  [3,] -0.0022773808 -1.978944e-02 -0.0196387889 -2.729188e-03
##  [4,] -0.0163149035  1.241065e-03 -0.0007288387  1.967245e-03
##  [5,] -0.0056642690  5.481312e-03  0.0026828532  8.905041e-03
##  [6,]  0.0454385114  3.793633e-04  0.0070598181  9.920955e-04
##  [7,]  0.0003793633  1.980044e-02  0.0130080867  7.656330e-06
##  [8,]  0.0070598181  1.300809e-02  0.0251653582 -2.140584e-04
##  [9,]  0.0009920955  7.656330e-06 -0.0002140584  3.771240e-02