% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/model_mixed.R
\name{fit_mixed}
\alias{fit_mixed}
\title{Fit Mixed-Effects Regression with Arvind Errors}
\usage{
fit_mixed(formula, data, group_var = "Season", re_formula = NULL, seed = 42)
}
\arguments{
\item{formula}{an object of class \code{\link[stats]{formula}} specifying
the fixed-effects structure.}

\item{data}{a data frame containing the variables in the formula and the
grouping variable.}

\item{group_var}{character string; the name of the grouping variable in
\code{data} (default: \code{"Season"}).}

\item{re_formula}{optional random-effects formula (e.g.,
\code{(1 + X1 | group)}). If \code{NULL} (default), a random intercept
model \code{(1 | group_var)} is used.}

\item{seed}{integer; random seed for reproducibility (default: 42).}
}
\value{
An object of class \code{"ArvindFit"}, a list containing the
same standard fields as \code{\link[=fit_rw1]{fit_rw1()}}, plus:
\describe{
\item{lme_model}{the fitted \code{lme4::lmer} object.}
\item{theta_re}{numeric; Arvind parameter estimated from random effects.}
\item{group_var}{character; the grouping variable name.}
}
}
\description{
Fits a mixed-effects regression model with Arvind-distributed random
effects and observation-level errors. Estimation uses a two-stage approach:
REML initialisation via \pkg{lme4}, followed by Arvind MLE on the
residuals.
}
\examples{
dat <- simulate_arvind_data(n = 50, seed = 1)
m4 <- fit_mixed(Y ~ X1 + X2 + X3, dat, group_var = "Group", seed = 42)
m4$theta
m4$theta

}
\seealso{
\code{\link[=diagnostics_arvind]{diagnostics_arvind()}}, \code{\link[=forecast_arvind]{forecast_arvind()}}, \code{\link[=cv_arvind]{cv_arvind()}}
}
