% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/define_model_component.R
\name{define_model_component}
\alias{define_model_component}
\title{Define a model component}
\usage{
define_model_component(
  name,
  data,
  outcome,
  factor,
  evaluation_indicator = NULL,
  covariates,
  model_type = c("linear", "logit", "probit", "oprobit"),
  intercept = TRUE,
  num_choices = 2,
  nrank = NULL,
  exclude_chosen = TRUE,
  rankshare_var = NULL,
  loading_normalization = NULL,
  factor_spec = c("linear", "quadratic", "interactions", "full"),
  use_types = FALSE,
  skip_collinearity_check = FALSE
)
}
\arguments{
\item{name}{name of model component ####Long name and s name (like in the C++)}

\item{data}{data.frame for validation}

\item{outcome}{Character. Name of the outcome variable.}

\item{factor}{model. Object of Class factor_model.}

\item{evaluation_indicator}{Character (optional). Variable used for evaluation subsample.}

\item{covariates}{List of Character vectors. Names of covariates.}

\item{model_type}{Character. Type of model (e.g., "linear", "logit", "probit").}

\item{intercept}{Logical. Whether to include an intercept (default = TRUE).}

\item{num_choices}{Integer. Number of choices (for multinomial models).}

\item{nrank}{Integer (optional). Rank for exploded multinomial logit.}

\item{exclude_chosen}{Logical. For exploded logit, whether to exclude already-chosen
alternatives from later ranks (default TRUE). Set to FALSE for exploded nested logit
where the same nest can be chosen multiple times.}

\item{rankshare_var}{Character (optional). Column name (or prefix) for rank-share
correction variables. These provide rank-and-choice-specific adjustments to the
linear predictor. Data layout: (num_choices-1) * nrank columns, accessed as
rankshare_var + (num_choices-1)*irank + icat for irank=0..nrank-1, icat=0..num_choices-2.}

\item{loading_normalization}{Numeric vector of length \code{n_factors} (optional).
Component-specific loading constraints. Overrides factor model normalization.
\itemize{
\item \code{NA} --> loading is free (estimated).
\item numeric value --> loading is fixed at that value (e.g. \code{1} for identification).
If NULL, uses the factor model's default normalization.
}}

\item{factor_spec}{Character. Specification for factor terms in linear predictor.
\itemize{
\item \code{"linear"} (default): Only linear factor terms (lambda * f)
\item \code{"quadratic"}: Linear + quadratic terms (lambda * f + lambda_quad * f^2)
\item \code{"interactions"}: Linear + interaction terms (lambda * f + lambda_inter * f_j * f_k)
\item \code{"full"}: Linear + quadratic + interaction terms
Note: Interaction terms require n_factors >= 2.
}}

\item{use_types}{Logical. Whether this component uses type-specific intercepts
when n_types > 1 in the factor model. Default FALSE. When TRUE and n_types > 1,
the component will have (n_types - 1) type-specific intercept parameters that
shift the linear predictor for each non-reference type. This allows types to
affect outcome models while keeping measurement models type-invariant.}

\item{skip_collinearity_check}{Logical. If TRUE, skip the multicollinearity check
on the design matrix. Useful when many coefficients will be fixed via fix_coefficient()
after component creation, which resolves the collinearity. Default FALSE.}
}
\value{
An object of class "model_component". A list representing the model component
}
\description{
Define a model component
}
\examples{
dat <- data.frame(y = rnorm(50), intercept = 1)
fm <- define_factor_model(n_factors = 1)
mc <- define_model_component("Y", dat, "y", fm,
  covariates = "intercept", model_type = "linear",
  loading_normalization = 1)
}
