% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/fit_model.R
\name{fit_model}
\alias{fit_model}
\title{Fit the babebi model to observed data}
\usage{
fit_model(
  data,
  id,
  time,
  rater,
  outcome,
  time_order = NULL,
  rater_order = 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{n_draws}{Number of posterior draws used for approximation.}

\item{seed}{Optional integer seed used to initialise the random-number
generator for posterior sampling.}
}
\value{
A named list of class \code{babebi_fit}.
}
\description{
Fits the current babebi model to a fully observed 2 (time) x 2 (rater)
repeated-measures dataset. Estimation is based on difference scores and a
linear model including a rater indicator as covariate.
}
\details{
Posterior draws are obtained from a large-sample normal approximation to
the posterior of the regression coefficients under an improper flat prior.
}
\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
  )
)

fit <- fit_model(
  data = dat,
  id = id,
  time = time,
  rater = rater,
  outcome = y,
  time_order = c("pre", "post"),
  rater_order = c("r1", "r2"),
  n_draws = 500,
  seed = 123
)

print(fit)
summary(fit)
plot(fit)

}
