% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pated.R
\name{pated}
\alias{pated}
\title{Prognostic Variables Assisted Treatment Effect Detection}
\usage{
pated(
  ...,
  data,
  nboot = 0,
  compute_cov = TRUE,
  seed = NULL,
  transform = "identity"
)
}
\arguments{
\item{...}{model specifications built by \code{glm_()}, \code{coxph_()}, \code{logrank_()},
\code{gee_()}, \code{mmrm_()}, \code{km_()}, or \code{quantile_()}. The first specification is
the primary outcome whose treatment effect is being tested; the rest are
prognostic covariates used to tighten the SE.}

\item{data}{either a single data frame (when all models are fitted on
the same dataset) or a list of data frames (one entry per \code{data_index}).
Each data frame must have a \code{pid} column carrying subject identifiers;
records with the same \code{pid} across different data frames refer to the
same subject.}

\item{nboot}{non-zero integer if bootstrap is adopted. By default 0.}

\item{compute_cov}{logic. If \code{TRUE}, empirical covariance matrix is computed
using bootstrap estimate and returned. Bootstrap estimate will be abandoned. If
\code{FALSE}, bootstrap estimate will be returned and no empirical covariance
matrix is computed.}

\item{seed}{random seed when generate bootstrap data.}

\item{transform}{character. Now only supports \code{"identity"}.}
}
\value{
a data frame of testing results.
}
\description{
\code{pated} is a wrapper function of \code{jointCovariance} for testing treatment effect
in randomized clinical trials. It assumes that prognostic variables are fully
randomized. This assumption can help enhancing statistical power of conventional
approaches in detecting the treatment effect. Specifically, the sensitivity
of the conventional models specified in \code{...} are improved by \code{pated}.
}
\examples{
## More examples can be found in the vignettes.
library(survival)
library(mvtnorm)

genData <- function(seed = NULL){
  set.seed(seed)
  n <- 300
  sigma <- matrix(c(1, .6, .6, 1), 2)
  x <- rmvnorm(n, sigma = sigma)
  z1 <- rbinom(n, 1, .6)
  z2 <- rnorm(n)
  trt <- rbinom(n, 1, .5)

  bet <- c(-.2, .2)
  y <- -.5 + x \%*\% bet + z1 * .3 - z2 * .1 + .1 * trt - .1 * rnorm(n)
  death <- rbinom(n, 1, .8)
  data.frame(
    y = as.numeric(y), trt = trt,
    z1 = z1, z2 = z2,
    x1 = x[, 1], x2 = x[, 2],
    death, pid = paste0('s-', seq_len(n))
  )
}

dat <- genData(seed = 31415926)

## `data_index` defaults to 1 in every spec constructor and a single
## data.frame is auto-wrapped into a list, so neither needs spelling out
## when all models are fitted on the same dataset.
fit <-
  pated(
    coxph_(Surv(time = y, event = death) ~ trt),
    glm_(z1 ~ trt, family = 'binomial'),
    glm_(z2 ~ trt, family = 'gaussian'),
    glm_(x1 ~ trt, family = 'gaussian'),
    glm_(x2 ~ trt, family = 'gaussian'),
    data = dat
  )

fit

}
