% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/diagnostics.R
\name{plot_profile}
\alias{plot_profile}
\title{Profile plot (spaghetti plot) for longitudinal data}
\usage{
plot_profile(
  y,
  time_points = NULL,
  blocks = NULL,
  block_labels = NULL,
  title = "Profile Plot",
  xlab = "Time",
  ylab = "Measurement",
  ylim = NULL,
  show_sd = TRUE,
  individual_alpha = 0.3,
  individual_color = "grey50",
  mean_color = "blue",
  sd_color = "red",
  mean_lwd = 2
)
}
\arguments{
\item{y}{Numeric matrix with n_subjects rows and n_time columns,
or a data frame with measurements.}

\item{time_points}{Optional numeric vector of time points for x-axis.
Default uses 1:n_time or attempts to extract from column names.}

\item{blocks}{Optional integer vector of block memberships for stratified plotting.
If provided, creates separate panels for each block.}

\item{block_labels}{Optional character vector of labels for blocks.}

\item{title}{Plot title. Default "Profile Plot".}

\item{xlab}{X-axis label. Default "Time".}

\item{ylab}{Y-axis label. Default "Measurement".}

\item{ylim}{Optional y-axis limits as c(min, max).}

\item{show_sd}{Logical; if TRUE (default), show +/- 1 SD error bars.}

\item{individual_alpha}{Alpha (transparency) for individual trajectories. Default 0.3.}

\item{individual_color}{Color for individual trajectories. Default "grey50".}

\item{mean_color}{Color for mean trajectory. Default "blue".}

\item{sd_color}{Color for SD error bars. Default "red".}

\item{mean_lwd}{Line width for mean trajectory. Default 2.}
}
\value{
A ggplot2 object (invisibly). Called primarily for side effect (plotting).
}
\description{
Creates a profile plot showing individual subject trajectories with
overlaid mean trajectory and standard deviation bands.
}
\details{
This function provides a quick visual summary of longitudinal data showing:
\itemize{
\item Individual subject trajectories (light grey lines)
\item Mean trajectory across subjects (bold colored line)
\item +/- 1 standard deviation bands (error bars)
}

When \code{blocks} is provided, the plot is faceted by block membership,
allowing comparison of trajectories across treatment groups or other strata.
}
\examples{
\donttest{
data("bolus_inad")

# Basic profile plot
plot_profile(bolus_inad$y)

# With block stratification
plot_profile(bolus_inad$y, blocks = bolus_inad$blocks,
             block_labels = c("2mg", "1mg"))

# Customized
plot_profile(bolus_inad$y,
             time_points = seq(0, 44, by = 4),
             title = "Bolus Counts Over Time",
             xlab = "Hours", ylab = "Count")
}

}
