% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/rcbin_flex.R
\name{rcbin_flex}
\alias{rcbin_flex}
\title{Generates correlated binary cluster data with flexible distributional options}
\usage{
rcbin_flex(prop = 0.5, prvar = 0, noc, csize, csvar = 0, mincsize = 2, rho)
}
\arguments{
\item{prop}{A numeric value between 0 and 1 denoting assumed proportion of
event of interest, default value is 0.5. See Details.}

\item{prvar}{A non-negative numeric value (strictly less than
\code{prop*(1-prop)}) denoting variance in assumed proportion of event
(\code{prop}), default value is 0. See Details.}

\item{noc}{A positive numeric value giving the number of clusters to be
generated.}

\item{csize}{A numeric value (\eqn{\ge 2}) denoting desired cluster size.}

\item{csvar}{A non-negative numeric value denoting variance of cluster size,
default value is 0. See Details.}

\item{mincsize}{A numeric value (\eqn{\ge 2}) denoting the minimum cluster
size, default value is 2. See Details.}

\item{rho}{A numeric value between 0 and 1 denoting desired level of
Intracluster Correlation.}
}
\value{
A dataframe with two columns: cluster id (\code{cid}) and binary
  response (\code{y}).
}
\description{
Generates correlated binary cluster data given value of Intracluster
Correlation, proportion of event and its variance, number of clusters,
cluster size and its variance, and minimum cluster size. Compared to
\code{\link{rcbin}}, this function uses a Beta distribution for
cluster-specific event proportions and supports overdispersed cluster sizes
via the Negative Binomial distribution. Parameters \code{prvar} and
\code{csvar} represent actual variances, not percentages.
}
\details{
If \code{prvar} is 0, the event proportion is constant across all
  clusters as supplied by \code{prop}. If \code{prvar} > 0, cluster-specific
  event proportions are generated from a Beta distribution with shape
  parameters \eqn{a} and \eqn{b} obtained by solving \code{prop}
  \eqn{= a/(a + b)} and \code{prvar} \eqn{= ab/[(a + b)^2(1 + a + b)]}.
  See \code{\link{rbeta}}.

If \code{csvar} is 0, all clusters have equal size \code{csize}.
  For \code{csvar} > 0, cluster sizes are generated from a Normal
  distribution when \code{csvar} < \code{csize} (see \code{\link{rnorm}}),
  or from a Negative Binomial distribution when \code{csvar} \eqn{\ge}
  \code{csize} to handle overdispersion (see \code{\link{rnbinom}}). Any
  cluster size below \code{mincsize} is replaced by \code{mincsize}.

Unlike \code{\link{rcbin}}, the parameters \code{prvar} and
  \code{csvar} represent actual variances, not percentages of \code{prop}
  or \code{csize}.
}
\examples{
rcbin_flex(prop = .6, prvar = .05, noc = 100, csize = 10, csvar = 12,
           rho = 0.2, mincsize = 2)

}
\references{
Lunn, A.D. and Davies, S.J., 1998. A note on generating
  correlated binary variables. Biometrika, 85(2), pp.487-490.
}
\seealso{
\code{\link{rcbin}} \code{\link{iccbin}}
}
\author{
Akhtar Hossain \email{ahossain@live.com}
}
