Learn R Programming

mmcm (version 1.0-1)

mmcm.resamp: P-value for the modified maximum contrast statistics by using a resampling based procedure

Description

This function gives $P$-value for the modified maximum contrast statistics by using a resampling based procedure.

Usage

mmcm.resamp(
  x, g, contrast,
  nsample = 20000, seed = unclass(Sys.time())
)

Arguments

x
a numeric vector of data values
g
a integer vector giving the group for the corresponding elements of x
contrast
a numeric coefficient matrix for the modified maximum contrast statistics
nsample
specifies the number of resamples (defalt: 20,000)
seed
a 32-bit integer ($-2^{31}+1\leq \mbox{seed} \leq 2^{31}-1$) used as the seed for the pseudo-random number generator used for resampling (default: time-dependent integer)

Value

  • contsuffix of coefficient vector of $k$th pattern that gives the maximum contrast statistics (colmun number of coefficient matrix).
  • pval$P$-value of the modified maximum contrast statistics, which is simulated by using a resampling based procedure.
  • apvalvector of $P$-values ($\Pr(T^{\prime}_k>t^{\prime*}_k \mid H_0)$) for each modified contrast statistics.
  • astatvector of observed values ($T^{\prime}_k$) for each modified contrast statistics.
  • acontcoefficient matrix (copy of argument).
  • return value is mmcm.resamp class object.

Details

mmcm.resamp performs the modified maximum contrast method that is detecting a true response pattern when unbalanced sample size. $Y_{ij} (i=1,~ 2,~\ldots ;~ j=1,~ 2,~ \ldots,~ n_i)$ is an observed response for $j$th individual in $i$th group. $\bm{C}$ is coefficient matrix for the modified maximum contrast statistics ($i \times k$ matrix, $i$: No. of groups, $k$: No. of pattern). $$\bm{C}=(\bm{c}_1~ \bm{c}_2~ \ldots~ \bm{c}_k)$$ $\bm{c}_k$ is coefficient vector of $k$th pattern. $$\bm{c}_k=(c_{k1}~ c_{k2}~ \ldots~ c_{ki})^t \qquad (\textstyle \sum_i c_{ki}=0)$$ $T^{\prime}_{\max}$ is the modified maximum contrast statistics. $$\bar{Y}_i=\frac{\sum_{j=1}^{n_i} Y_{ij}}{n_{i}}, ~~ \bar{\bm{Y}}=(\bar{Y}_1~ \bar{Y}_2~ \ldots~ \bar{Y}_i)^t, ~~ T^{\prime}_{k}=\frac{\bm{c}^t_k \bar{\bm{Y}}}{\bm{c}^t_k \bm{c}_k}$$ $$T^{\prime}_{\max}=\max(T^{\prime}_1,~ T^{\prime}_2,~ \ldots,~ T^{\prime}_k)$$ Consider testing the overall null hypothesis $H_0: \mu_1=\mu_2=\ldots=\mu_i$, versus alternative hypotheses $H_1$ for response petterns ($H_1: \mu_1<\mu_2<\ldots<\mu_i,~ \mu_1="\mu_2<\ldots<\mu_i,~" \mu_1<\mu_2<\ldots="\mu_i$)." the="" $p$-value="" for="" probability="" distribution="" of="" $t^{\prime}_{\max}$="" under="" overall="" null="" hypothesis="" is="" $$p\mbox{-value}="\Pr(T^{\prime}_{\max}">t^{\prime*}_{\max} \mid H_0)$$ $t^{\prime*}_{\max}$ is observed value of statistics. This function gives distribution of $T^{\prime}_{\max}$ by using a resampling based procedure.

References

Sato, Y., Laird, N.M., Nagashima, K., et al. (2009) A new statistical screening approach for finding pharmacokinetics-related genes in genome-wide studies. Pharmacogenomics J. 9(2): 137--146. http://www.ncbi.nlm.nih.gov/pubmed/19104505

See Also

print.mmcm.resamp

Examples

Run this code
## Example 1 ##
#  true response pattern: dominant model c=(1, 1, -2)
set.seed(326584)
x <- c(
  rlnorm(130, meanlog = 0.91, sdlog = 0.1),
  rlnorm( 90, meanlog = 0.91, sdlog = 0.1),
  rlnorm( 10, meanlog = 0.85, sdlog = 0.25)
)
g <- rep(1:3, c(130, 90, 10))
boxplot(
  x ~ g,
  width=c(length(g[g==1]),length(g[g==2]),
    length(g[g==3])),
  main="Dominant model (sample data)",
  xlab="Genotype", ylab="PK parameter"
)

# coefficient matrix
# c_1: additive, c_2: recessive, c_3: dominant
contrast <- cbind(
  c(-1, 0, 1), c(-2, 1, 1), c(-1, -1, 2)
)
y <- mmcm.resamp(x, g, contrast, 20000, 5784324)
y

## Example 2 ##
#  for dataframe
#  true response pattern: pos = 1 dominant  model c=( 1,  1, -2)
#                               2 additive  model c=(-1,  0,  1)
#                               3 recessive model c=( 2, -1, -1)
set.seed(8415849)
x   <- c(
  rlnorm(130, meanlog = 0.91, sdlog = 0.1),
  rlnorm( 90, meanlog = 0.91, sdlog = 0.1),
  rlnorm( 10, meanlog = 0.85, sdlog = 0.25),
  rlnorm(130, meanlog = 0.79, sdlog = 0.1),
  rlnorm( 90, meanlog = 0.85, sdlog = 0.1),
  rlnorm( 10, meanlog = 0.91, sdlog = 0.25),
  rlnorm(130, meanlog = 0.85, sdlog = 0.1),
  rlnorm( 90, meanlog = 0.91, sdlog = 0.1),
  rlnorm( 10, meanlog = 0.91, sdlog = 0.25)
)
g   <- rep(rep(1:3, c(130, 90, 10)), 3)
pos <- rep(c("rsXXXX", "rsYYYY", "rsZZZZ"), each=230)
xx <- data.frame(pos = pos, x = x, g = g)

# coefficient matrix
# c_1: additive, c_2: recessive, c_3: dominant
contrast <- cbind(
  c(-1, 0, 1), c(-2, 1, 1), c(-1, -1, 2)
)
mmcmtapply <- function(r) {
  mmcm.resamp(
    xx$x[xx$pos==r[1]], xx$g[xx$pos==r[1]],
    contrast, 10000, 5784324+as.numeric(r[1])
  )
}
y <- tapply(xx$pos, xx$pos, mmcmtapply)
yy <- data.frame(
  Pos = as.vector(names(y)),
  Pval = as.vector(sapply(y, "[[", 5)),
  Pattern = as.vector(sapply(y, "[[", 6))
)
yy

Run the code above in your browser using DataLab