mhgr                  package:Hmisc                  R Documentation

_M_i_s_c_e_l_l_a_n_e_o_u_s _F_u_n_c_t_i_o_n_s _f_o_r _E_p_i_d_e_m_i_o_l_o_g_y

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

     The 'mhgr' function computes the Cochran-Mantel-Haenszel
     stratified risk ratio and its confidence limits using the
     Greenland-Robins variance estimator.

     The 'lrcum' function takes the results of a series of 2x2 tables
     representing the relationship between test positivity and
     diagnosis and computes positive and negative likelihood ratios
     (with all their deficiencies) and the variance of their
     logarithms.  Cumulative likelihood ratios and their confidence
     intervals (assuming independence of tests) are computed, assuming
     a string of all positive tests or a string of all negative tests. 
     The method of Simel et al as described in Altman et al is used.

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

     mhgr(y, group, strata, conf.int = 0.95)
     ## S3 method for class 'mhgr':
     print(x, ...)

     lrcum(a, b, c, d, conf.int = 0.95)
     ## S3 method for class 'lrcum':
     print(x, dec=3, ...)

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

       y: a binary response variable

   group: a variable with two unique values specifying comparison
          groups

  strata: the stratification variable

conf.int: confidence level

       x: an object created by 'mhgr' or 'lrcum'

       a: frequency of true positive tests

       b: frequency of false positive tests

       c: frequency of false negative tests

       d: frequency of true negative tests

     dec: number of places to the right of the decimal to print for
          'lrcum'

     ...: addtitional arguments to be passed to other print functions

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

     Uses equations 4 and 13 from Greenland and Robins.

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

     a list of class '"mhgr"' or of class '"lrcum"'.

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

     Frank E Harrell Jr f.harrell@vanderbilt.edu

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

     Greenland S, Robins JM (1985): Estimation of a common effect
     parameter from sparse follow-up data.  Biometrics 41:55-68.

     Altman DG, Machin D, Bryant TN, Gardner MJ, Eds. (2000):
     Statistics with Confidence, 2nd Ed.  Bristol: BMJ Books, 105-110.

     Simel DL, Samsa GP, Matchar DB (1991): Likelihood ratios with
     confidence: sample size estimation for diagnostic test studies.  J
     Clin Epi 44:763-770.

_S_e_e _A_l_s_o:

     'logrank'

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

     # Greate Migraine dataset used in Example 28.6 in the SAS PROC FREQ guide
     d <- expand.grid(response=c('Better','Same'),
                      treatment=c('Active','Placebo'),
                      sex=c('female','male'))
     d$count <- c(16, 11, 5, 20, 12, 16, 7, 19)
     d
     # Expand data frame to represent raw data
     r <- rep(1:8, d$count)
     d <- d[r,]
     with(d, mhgr(response=='Better', treatment, sex))

     # Discrete survival time example, to get Cox-Mantel relative risk and CL
     # From Stokes ME, Davis CS, Koch GG, Categorical Data Analysis Using the
     # SAS System, 2nd Edition, Sectino 17.3, p. 596-599
     #
     # Input data in Table 17.5
     d <- expand.grid(treatment=c('A','P'), center=1:3)
     d$healed2w    <- c(15,15,17,12, 7, 3)
     d$healed4w    <- c(17,17,17,13,17,17)
     d$notHealed4w <- c( 2, 7,10,15,16,18)
     d
     # Reformat to the way most people would collect raw data
     d1 <- d[rep(1:6, d$healed2w),]
     d1$time <- '2'
     d1$y <- 1
     d2 <- d[rep(1:6, d$healed4w),]
     d2$time <- '4'
     d2$y <- 1
     d3 <- d[rep(1:6, d$notHealed4w),]
     d3$time <- '4'
     d3$y <- 0
     d <- rbind(d1, d2, d3)
     d$healed2w <- d$healed4w <- d$notHealed4w <- NULL
     d
     # Finally, duplicate appropriate observations to create 2 and 4-week
     # risk sets.  Healed and not healed at 4w need to be in the 2-week
     # risk set as not healed
     d2w      <- subset(d, time=='4')
     d2w$time <- '2'
     d2w$y    <- 0
     d24      <- rbind(d, d2w)
     with(d24, table(y, treatment, time, center))
     # Matches Table 17.6

     with(d24, mhgr(y, treatment, interaction(center, time, sep=';')))

     # Get cumulative likelihood ratios and their 0.95 confidence intervals
     # based on the following two tables
     #
     #          Disease       Disease
     #          +     -       +     -
     # Test +   39    3       20    5
     # Test -   21   17       22   15

     lrcum(c(39,20), c(3,5), c(21,22), c(17,15))

