This function is taken from Jim Lindsey's R package rmutil.
What follows is taken from the help file of rmutil.
Note that not all the functionalities of finterp are implemented in nlgamlss.
finterp translates a model formula into a function of the
unknown parameters or of a vector of them. Such language formulae
can either be in Wilkinson and Rogers notation or be expressions
containing both known (existing) covariates and unknown (not
existing) parameters. In the latter, factor variables cannot be
used and parameters must be scalars.
The covariates in the formula are sought in the environment or in
the data object provided. If the data object has class, 'repeated'
or 'response', then the key words, 'times' will use the response
times from the data object as a covariate, 'individuals' will use
the index for individuals as a factor covariate, and 'nesting' the
index for nesting as a factor covariate. The latter two only work
for W&R notation.
Note that, in parameter displays, formulae in Wilkinson and Rogers
notation use variable names whereas those with unknowns use the
names of these parameters, as given in the formulae, and that the
meaning of operators (*, /, :, etc.) is different in the two
cases.
The function fmobj inspects a formula and returns a list containing the
objects referred to, with indicators as to which are unknown
parameters, covariates, factor variables, and functions.
A model formula beginning with ~, either in Wilkinson and
Rogers notation or containing unknown parameters. If it
contains unknown parameters, it can have several lines so
that, for example, local variables can be assigned temporary
values. In this case, enclose the formula in curly brackets
.envir
The environment in which the formula is to be interpreted or
a data object of class, 'repeated', 'tccov', or 'tvcov'.
.formula
If TRUE and the formula is in Wilkinson and Rogers notation,
just returns the formula.
.vector
If FALSE and the formula contains unknown parameters, the
function returned has them as separate arguments. If TRUE, it
has one argument, the unknowns as a vector, unless certain
parameter names are specified in '.args'. Always TRUE if
'.envir' is a data object.
.args
If '.vector' is TRUE, names of parameters that are to be
function arguments and not included in the vector.
.start
The starting index value of the parameter vector in the
function returned when '.vector' is TRUE.
.name
Character string giving the name of the data object specified
by '.envir'. Ignored unless the latter is such an object and
only necessary when 'finterp' is called within other
functions.
.expand
If TRUE, expand functions with only time-constant covariates
to return one value per observation instead of one value per
individual. Ignored unless '.envir' is an object of class,
'repeated'.
.intercept
If W&R notation is supplied and '.intercept=F', a model
function without intercept is returned.
.old
The name of an existing object of class 'formulafn' which has
common parameters with the one being created, or a list of
such objects. Only used if '.vector'=TRUE. The value of
'.start' should ensure that there is no conflict in indexing
the vector.
.response
If TRUE, any response variable can be used in the function.
If FALSE, checks are made that the response is not also used
as a covariate.
z
A model formula beginning with ~, either in Wilkinson and
Rogers notation or containing unknown parameters.
envir
The environment in which the formula is to be interpreted.
...
for extra arguments
Value
A function, of class formulafn, of the unknown parameters or of
a vector of them is returned. Its attributes give the formula
supplied, the model function produced, the covariate names, the
parameter names, and the range of values of the index of the
parameter vector. If 'formula' is TRUE and a Wilkinson and Rogers
formula was supplied, it is simply returned instead of creating a
function.
For fmobj a list, of class 'fmobj', containing a character vector
('objects') with the names of the objects used in a formula, and
logical vectors indicating which are unknown parameters
('parameters'), covariates ('covariates'), factor variables
('factors'), and functions ('functions') is returned.