% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/fix_coefficient.R
\name{fix_coefficient}
\alias{fix_coefficient}
\title{Fix a coefficient in a model component}
\usage{
fix_coefficient(component, covariate, value, choice = NULL)
}
\arguments{
\item{component}{A model_component object from define_model_component()}

\item{covariate}{Character. Name of the covariate whose coefficient to fix.
Must be one of the covariates specified when creating the component.}

\item{value}{Numeric. The value to fix the coefficient to.}

\item{choice}{Integer (optional). For multinomial logit models with num_choices > 2,
specifies which choice's coefficient to fix. Must be between 1 and (num_choices - 1).
Choice 0 (reference category) has no parameters.
For other model types, this should be NULL (default).}
}
\value{
The modified model_component object with the fixed coefficient constraint added.
}
\description{
Constrains a regression coefficient (beta) to a fixed value during estimation.
The coefficient will not be optimized - it remains at the specified value.
}
\details{
Fixed coefficients are stored in the component and used during:
\itemize{
\item Parameter initialization: fixed values are used directly (no estimation)
\item Optimization: fixed parameters are excluded from the optimization
\item Likelihood evaluation: fixed values are inserted into the parameter vector
}

Note: This function only fixes regression coefficients (betas), not:
\itemize{
\item Factor loadings (use loading_normalization in define_model_component)
\item Sigma (for linear models)
\item Thresholds (for ordered probit)
}
}
\examples{
# Build a minimal model component and fix a coefficient
dat <- data.frame(intercept = 1, x1 = rnorm(20), y = rnorm(20))
fm <- define_factor_model(n_factors = 1)
mc <- define_model_component(
  name = "y", data = dat, outcome = "y", factor = fm,
  covariates = c("intercept", "x1"), model_type = "linear",
  loading_normalization = 1
)

# Fix intercept to 0 and x1 coefficient to 0.1
mc <- fix_coefficient(mc, covariate = "intercept", value = 0.0)
mc <- fix_coefficient(mc, covariate = "x1", value = 0.1)
length(mc$fixed_coefficients)  # 2 constraints stored on the component

}
