% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/babebi.R
\name{babebi}
\alias{babebi}
\title{Run the babebi workflow on user-supplied data}
\usage{
babebi(
  data,
  id,
  time,
  rater,
  outcome,
  time_order = NULL,
  rater_order = NULL,
  validate = TRUE,
  R = 1000,
  N = NULL,
  delta = NULL,
  bias_r2 = NULL,
  n_draws = 4000,
  seed = NULL
)
}
\arguments{
\item{data}{A data frame in long format.}

\item{id}{Unquoted column name identifying subjects or a character string.}

\item{time}{Unquoted column name identifying time points or a character string.}

\item{rater}{Unquoted column name identifying raters or a character string.}

\item{outcome}{Unquoted column name containing the observed score or a
character string.}

\item{time_order}{Optional character vector of length 2 giving the
order of the time factor: baseline first, follow-up second.}

\item{rater_order}{Optional character vector of length 2 giving the
order of the rater factor: reference rater first, second rater second.}

\item{validate}{Logical; if \code{TRUE}, run Monte Carlo validation after model fitting.}

\item{R}{Number of Monte Carlo repetitions when \code{validate = TRUE}.}

\item{N}{Optional override for the sample size used in validation.}

\item{delta}{Optional override for the pre-post effect used in validation.}

\item{bias_r2}{Optional override for the additive bias of the second rater
used in validation.}

\item{n_draws}{Number of posterior draws used in model fitting.}

\item{seed}{Optional integer seed for reproducibility.}
}
\value{
A named list containing:
\describe{
\item{fit}{A \code{babebi_fit} object returned by \code{fit_model()}.}
\item{validation}{A \code{babebi_validation} object returned by
\code{montecarlo_from_data()} when \code{validate = TRUE}, otherwise \code{NULL}.}
\item{call}{The original function call.}
}
}
\description{
Fits the babebi model to observed data and, optionally, performs Monte Carlo
validation calibrated on the observed design.
}
\examples{
dat <- data.frame(
  id = rep(1:4, each = 4),
  time = rep(c("pre", "pre", "post", "post"), times = 4),
  rater = rep(c("r1", "r2"), times = 8),
  y = c(
    3.0, 3.2, 3.8, 4.0,
    2.9, 3.1, 3.5, 3.7,
    3.4, 3.6, 4.0, 4.1,
    3.1, 3.3, 3.9, 4.0
  )
)

res <- babebi(
  data = dat,
  id = id,
  time = time,
  rater = rater,
  outcome = y,
  time_order = c("pre", "post"),
  rater_order = c("r1", "r2"),
  validate = TRUE,
  R = 100,
  n_draws = 500,
  seed = 123
)

print(res$fit)
summary(res$fit)
plot(res$fit)
print(res$validation)

}
