genZcor               package:geepack               R Documentation

_g_e_n_Z_c_o_r

_D_e_s_c_r_i_p_t_i_o_n:

     constructs the design matrix for the correlation structures:
     independence, echangeable, ar1 and unstructured The user will need
     this function only as a basis to construct a user defined
     correlation structure: use genZcor to get the design matrix Z  for
     the unstructured correlation and define the specific correlation
     structure by linear combinations of the columns of Z.

_U_s_a_g_e:

     genZcor(clusz, waves, corstrv)

_A_r_g_u_m_e_n_t_s:

   clusz: integer vector giving the number of observations in each
          cluster

   waves: integer vector, obervations in the same cluster with values
          of wave i and j have the correlation sigma_ij

 corstrv: correlation structures: 1=independence,2=exchangeable,3=ar1,
          4=unstructured

_D_e_t_a_i_l_s:

_V_a_l_u_e:

        : the design matrix for the correlation structure

_N_o_t_e:

_A_u_t_h_o_r(_s):

     Jun Yan,  jyan@stat.uiowa.edu

_R_e_f_e_r_e_n_c_e_s:

     a

_E_x_a_m_p_l_e_s:

     #example to construct a Toeplitz correlation structure
     #    sigma_ij=sigma_|i-j|

     #data set with 5 clusters and maximally 4 observations (visits) per cluster
      gendat <- function() {
            id <- gl(5, 4, 20)
            visit <- rep(1:4, 5)
            y <- rnorm(id)
            dat <- data.frame(y, id, visit)[c(-2,-9),]
     }

     set.seed(88)
     dat<-gendat()

     #generating the design matrix for the unstructured correlation
     zcor <- genZcor(clusz = table(dat$id), waves = dat$visit, corstrv=4)
     # defining the Toeplitz structure 
     zcor.toep<-matrix(NA, nrow(zcor),3)
     zcor.toep[,1]<-apply(zcor[,c(1,4,6)],1,sum)
     zcor.toep[,2]<-apply(zcor[,c(2,5)],1,sum)
     zcor.toep[,3]<-zcor[,3]

     zfit1 <- geese(y ~ 1,id = id, data = dat,
                        corstr = "userdefined", zcor = zcor.toep)

     zfit2 <- geeglm(y ~ 1,id = id, data = dat,
                        corstr = "userdefined", zcor = zcor.toep)

