% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/power.R
\name{mb_sample_size}
\alias{mb_sample_size}
\title{Required sample size for a target power}
\usage{
mb_sample_size(
  effect_size = NULL,
  sd = 1,
  power = 0.8,
  alpha = 0.05,
  sides = 2L,
  type = c("mean", "proportion"),
  p1 = NULL,
  p2 = NULL
)
}
\arguments{
\item{effect_size}{Numeric. The standardised effect size:
Cohen's \code{d} for \code{type = "mean"}, or Cohen's \code{h} for
\code{type = "proportion"} (computed automatically if \code{p1} and \code{p2}
are supplied).}

\item{sd}{Numeric. Standard deviation, used only for \code{type = "mean"}. Default \code{1}, in which case \code{effect_size} is interpreted
in standard deviation units.}

\item{power}{Numeric in \verb{(0, 1)}. Target power. Default \code{0.8}.}

\item{alpha}{Numeric in \verb{(0, 1)}. Significance level. Default
\code{0.05}.}

\item{sides}{Integer. \code{2} (two-sided, default) or \code{1} (one-sided).}

\item{type}{Character. \code{"mean"} (default) or \code{"proportion"}.}

\item{p1, p2}{Optional numeric in \verb{(0, 1)}. If both supplied (and
\code{type = "proportion"}), the function computes Cohen's \code{h} and
ignores \code{effect_size}.}
}
\value{
Integer scalar. Sample size per arm (rounded up).
}
\description{
Given a target effect size, power, and significance level,
returns the required sample size per arm. Inverts \code{\link[=mb_power]{mb_power()}}.
}
\examples{
mb_sample_size(effect_size = 0.3, power = 0.8)
mb_sample_size(type = "proportion", p1 = 0.40, p2 = 0.50, power = 0.8)
}
\seealso{
\code{\link[=mb_power]{mb_power()}}, \code{\link[=mb_mde]{mb_mde()}}, \code{\link[=mb_cluster_design]{mb_cluster_design()}}.

Other power: 
\code{\link{mb_cluster_design}()},
\code{\link{mb_icc_reference}()},
\code{\link{mb_mde}()},
\code{\link{mb_power}()},
\code{\link{mb_stepped_wedge}()}
}
\concept{power}
