% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/model_simex.R
\name{fit_simex}
\alias{fit_simex}
\title{Fit Simulation-Extrapolation (SIMEX) Model}
\usage{
fit_simex(
  formula,
  data,
  me_vars = NULL,
  me_frac = 0.05,
  lambda_grid = c(0.5, 1, 1.5, 2),
  n_sim = 100,
  theta_me = 2,
  seed = 123
)
}
\arguments{
\item{formula}{an object of class \code{\link[stats]{formula}}.}

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

\item{me_vars}{character vector of covariate names measured with error.
If \code{NULL} (default), the first two term labels are used.}

\item{me_frac}{numeric; fraction of marginal variance used as measurement
error variance (default: 0.05).}

\item{lambda_grid}{numeric vector; SIMEX lambda grid
(default: \code{c(0.5, 1, 1.5, 2)}).}

\item{n_sim}{integer; number of SIMEX simulation replicates (default: 100).}

\item{theta_me}{positive numeric; Arvind parameter for measurement error
(default: 2.0).}

\item{seed}{integer; random seed for reproducibility (default: 123).}
}
\value{
An object of class \code{"ArvindFit"}, a list containing the
same standard fields as \code{\link[=fit_rw1]{fit_rw1()}}, plus:
\describe{
\item{beta}{numeric vector; SIMEX-corrected coefficient estimates.}
\item{simex_coefs}{matrix; coefficient estimates at each lambda level.}
\item{lambda_grid}{numeric vector; the SIMEX lambda grid used.}
\item{me_vars}{character vector; covariate names with measurement error.}
\item{sigma2_me}{named numeric vector; measurement error variances.}
}
}
\description{
Fits a regression model correcting for measurement error attenuation using
the SIMEX algorithm with Arvind-distributed measurement noise and residuals.
}
\examples{
dat <- simulate_arvind_data(n = 50, seed = 1)
m3 <- fit_simex(Y ~ X1 + X2 + X3, dat,
                me_vars = c("X1", "X2"),
                n_sim = 20, seed = 123)
m3$beta
m3$beta

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