% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/easy_ztest.R
\name{easy_ztest}
\alias{easy_ztest}
\title{One-Sample and Two-Sample Z-Tests with Automated Narrative Reporting}
\usage{
easy_ztest(
  x,
  y = NULL,
  data = NULL,
  mu = 0,
  sigma = NULL,
  sigma2 = NULL,
  alternative = "two.sided",
  conf_level = 0.95,
  alpha = 0.05
)
}
\arguments{
\item{x}{A numeric vector (Group 1), OR a formula \code{outcome ~ group}
for a two-sample test when \code{data} is provided.}

\item{y}{A numeric vector (Group 2) for a two-sample test. Ignored when
\code{x} is a formula.}

\item{data}{A data frame. Required when \code{x} is a formula.}

\item{mu}{Hypothesized population mean (one-sample) or mean difference
(two-sample). Default \code{0}.}

\item{sigma}{Known population SD for Group 1 (or the single group).
If \code{NULL} (default), the sample SD is used.}

\item{sigma2}{Known population SD for Group 2. If \code{NULL}, uses
the sample SD of Group 2.}

\item{alternative}{\code{"two.sided"} (default), \code{"less"},
or \code{"greater"}.}

\item{conf_level}{Confidence level. Default \code{0.95}.}

\item{alpha}{Significance threshold for narrative. Default \code{0.05}.}
}
\value{
An \code{"easystat_result"} object.
}
\description{
Performs a z-test using the normal distribution. When the population
standard deviation (\code{sigma}) is not provided, the sample SD is used
(valid for large samples, n \eqn{\geq} 30, by the Central Limit Theorem).
Key metrics — z-statistic, p-value, confidence interval, and Cohen's d —
are extracted and fed to the Narrative Generator Module.
}
\examples{
# One-sample z-test (large n, CLT)
result <- easy_ztest(mtcars$mpg, mu = 20)
print(result)

# Two-sample z-test via formula
result <- easy_ztest(mpg ~ am, data = mtcars)
print(result)

}
