% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/plot_sprt.R
\name{plot_anova}
\alias{plot_anova}
\title{Plot Sequential ANOVA Results}
\usage{
plot_anova(
  anova_results,
  labels = TRUE,
  position_labels_x = 0.15,
  position_labels_y = 0.1,
  position_lr_x = NULL,
  position_lr_y = NULL,
  font_size = 15,
  line_size = 1,
  highlight_color = "#CD2626"
)
}
\arguments{
\item{anova_results}{A \code{seq_anova_results} object from \code{\link[=seq_anova]{seq_anova()}}.
\strong{Important:} The \code{seq_anova()} function must be called with \code{plot = TRUE}
to generate the necessary data for plotting.}

\item{labels}{Logical. If \code{TRUE} (default), display decision labels
("Accept H0" / "Accept H1") and the likelihood ratio at the decision point.}

\item{position_labels_x}{Numeric value between 0 and 1 controlling the
horizontal position of decision labels as a proportion of maximum sample
size. Default is \code{0.15} (left side); \code{0.5} centers the labels.}

\item{position_labels_y}{Numeric value controlling the vertical spacing
between decision boundaries and their labels. The value is multiplied by
\verb{max(|log-likelihood ratio|)} to determine spacing. Larger values move
labels further from boundaries. Default is \code{0.075}.}

\item{position_lr_x}{Optional numeric value for the x-coordinate (sample size)
of the likelihood ratio label. If \code{NULL} (default), positioned at the
decision point or final sample size.}

\item{position_lr_y}{Optional numeric value for the y-coordinate
(log-likelihood ratio) of the likelihood ratio label. If \code{NULL} (default),
positioned at \code{y = 0} for early decisions, or slightly offset for
continuing sampling scenarios.}

\item{font_size}{Numeric. Base font size for plot text. Default is \code{20}.}

\item{line_size}{Numeric. Line width for the trajectory and boundaries.
Default is \code{1.5}.}

\item{highlight_color}{Character string. Color for highlighting the decision
point or final sample. Default is \code{"#CD2626"} (red).}
}
\value{
A \code{\link[ggplot2:ggplot]{ggplot2::ggplot()}} object showing:
\itemize{
\item Log-likelihood ratio trajectory across sample sizes
\item Dashed horizontal lines indicating decision boundaries
\item Highlighted point showing where decision was reached (or final sample)
\item Optional labels for decision regions and likelihood ratio value
}
}
\description{
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}}

Creates a visualization of the sequential probability ratio test (SPRT) for
ANOVA results, showing the log-likelihood ratio trajectory across sample sizes
and decision boundaries.
}
\examples{
# simulate data for the example ------------------------------------------------
set.seed(3)
data <- sprtt::draw_sample_normal(3, f = 0.25, max_n = 50)

# calculate the SPRT -----------------------------------------------------------
anova_results <- sprtt::seq_anova(y~x, f = 0.25, data = data, plot = TRUE)

# plot the results -------------------------------------------------------------
# default settings
sprtt::plot_anova(anova_results)
# variant 1
sprtt::plot_anova(anova_results,
                 labels = TRUE,
                 position_labels_x = 0.05,
                 position_lr_x = 150,
                 position_lr_y = 0,
                 highlight_color = "green"
                 )
# variant 2
sprtt::plot_anova(anova_results,
                  labels = TRUE,
                  position_labels_x = 0.15,
                  position_labels_y = 0.2,
                  position_lr_x = 60,
                  position_lr_y = 1,
                  font_size = 25,
                  line_size = 2,
                  highlight_color = "darkred"
)
# no labels
sprtt::plot_anova(anova_results,
                 labels = FALSE
                 )
# custom additions
sprtt::plot_anova(anova_results) +
  ggplot2::geom_vline(xintercept = 66, linewidth = 1, linetype = "dashed")

# further information ----------------------------------------------------------
# run this code:
vignette("one_way_anova", package = "sprtt")
}
