% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/parseFormula.R
\name{parseFormula}
\alias{parseFormula}
\title{Parse Formula}
\usage{
parseFormula(
  formula,
  data = NULL,
  specials,
  special.default.values = NULL,
  alias.names = NULL
)
}
\arguments{
\item{formula}{A model formula (e.g., Y ~ X + Z or Y ~ fun(X, param = value)).}

\item{data}{An optional data frame containing the variables referenced in the formula.}

\item{specials}{A character vector of special function names that should be specifically handled.}

\item{special.default.values}{A named list of named lists specifying default argument values for each special.}

\item{alias.names}{A named list mapping special names to their alias(es) (e.g., `list("special" = "alias")`).}
}
\value{
A list where each element corresponds to a special function in the formula and contains the parsed terms and their arguments.

A named list with an element for each special that contains a named list where each element
        corresponds to a formula term that is affected by the special that contains
        the value(s) of the additional argument(s) for this term.
}
\description{
Parse a formula to extract terms and handle special functions
}
\details{
This function parses a model formula, extracts terms, and processes specified 'special' functions and their arguments.
It allows defining default values for special functions and specifying aliases for those names.
}
\examples{
# Basic usage with specials
parseFormula(Y ~ fun(X, a = 1), specials = "fun")

# With defaults and aliases
parseFormula(Y ~ gfun(X, a = 7), 
             specials = "fun", 
             alias.names = list("fun" = "gfun"),
             special.default.values = list("fun" = list("a" = 0)))

# Complex use case with multiple specials
parseFormula(Surv(time, status) ~ age + strata(sex, test = 1) + prop(albumin),
             specials = c("prop", "strata"), 
             special.default.values = list("prop" = list(power = 0), "strata" = list(test = 1)))
parseFormula(Y~fun(X,a=1),specials="fun",special.default.values=list("fun"=list("a"=0)))
parseFormula(Y~fun(X),specials="fun",special.default.values=list("fun"=list("a"=0)))
parseFormula(Y~gfun(X,a=7),specials="fun",
             alias.names=list("fun"="gfun"),
             special.default.values=list("fun"=list("a"=0)))
parseFormula(formula = Surv(time,status)~age
                            +const(factor(edema))
                            +strata(sex,test=0)
                            +prop(alb)+prop(bili,power=1)
                            +tp(albumin),
                  specials = c("prop","timevar","strata","tp","const"),
                  special.default.values =list("prop" = list(power = 0),
                                               "strata" = list(test = 1)))
parseFormula(formula = Surv(time,status)~age
                            +const(factor(edema))
                            +strata(sex,test=0)
                            +prop(alb)+prop(bili,power=1)
                            +tp(albumin),
                  specials = c("prop","timevar","strata","tp"),
                  special.default.values =list("prop" = list(power = 0),
                                               "strata" = list(test = 1)),
                  alias.names=list("prop"="const"))
}
\seealso{
[stats::terms()], [strip.terms()]

model.design strip.terms
}
\author{
Thomas A. Gerds <tag@biostat.ku.dk>
}
