The S function for fitting a SNM model is `snm`.
A typical call is

snm(formula, func, fixed, start, random, data)The first 4 arguments are required. Arguments

`snm` inherits most of the options in `nlme`.
See documents of `nlme` and the help file of
`snm` for details. Generic functions `summary`,
`predict` and `intervals` can be applied to
extract further information. `intervals` provides approximate
posterior means and variances which can be used to
construct Bayesian confidence intervals for the
.
Derivatives of with respect to random effects are needed
to compute these quantities (Ke and Wang, 2001).
In `interval.snm`, numerical derivatives are to be used.

**Example 15**. Mixed-effects SIMs.
In the SIM () for repeated measure data, it is
more appropriate to consider parameters as random variables
(Ke and Wang, 2001):

where and is an unstructured positive-definite matrix. Suppose that we want to model f using a TPS on with . Note that no identifiability condition is necessary for since . We can fit model () with independent random errors by

snm(y~b1+exp(b2)*f((t-b3)/exp(b4)), func=list(f(u)~list(u,tp.pseudo(u))), fixed=list(b1~1), random=list(b1+b2+b3+b4~1), start=b10)