next up previous
Next: Semi-parametric Nonlinear Regression Models Up: Non-Parametric Nonlinear Regression Models Previous: Model and Estimation

The nnr Function

The S function for fitting a NNR model is nnr. A typical call is

    nnr(formula, func, start, data)
The first three arguments are required. formula, a two-sided formula separated by the operator ~, lists the response variable on the left side, and an expression for the function $\eta$ on the right side. func is a list of formulae specifying all components in $\mbox{\boldmath$f$}$. Each formula in this list has the form $\mbox{\tt f} \sim \mbox{\tt list(} \sim \phi_1+\cdots+\phi_M, \mbox{\tt rk)}$. For example, suppose that $\mbox{\boldmath$f$}=(f_1,f_2)$, and both $f_1$ and $f_2$ are modeled using cubic splines. Then
   func=list(f1(t)~list(~t, cubic(t)), f2(t)~list(~t, cubic(t)))
or
   func=list(f1(t)+f2(t)~list(~t, cubic(t)))
start, a vector or an expression, specifies the initial values for the iterative procedure.

Method for selecting smoothing parameters is specified by the argument spar. spar=``v'', spar=``m'' and spar=``u'' correspond to GCV, GML and UBR methods respectively, with GCV as the default. Other options include correlation, weights, control, and subset. They all have the same functions as in ssr. The option method in the argument control specifies the iterative method. method=``GN'' and method=``NR'' correspond the Gauss-Newton and Newton-Raphson methods respectively, with the Newton-Rahson method as the default.

An object of nnr class is returned. Generic functions summary, predict and intervals can be applied to extract further information. See help files for details.

As a simple example, consider the following common form of a non-parametric regression model

$\displaystyle y_i = f(t_i) + \epsilon_i,~~~~t_i \in [0,1],~~i=1,\cdots,n.$     (35)

Suppose that we want to restrict $f$ as a positive function. We may use the exponential transformation $f=\exp (g)$ or square transformation $f=g^2$ to enforce positivity. Then we can model the unconstrained function $g$ by a spline model.

For the purpose of illustration, we generate $n=100$ samples from model ([*]) with $f(t)=\exp (\sin 2\pi t)$ and $\epsilon_i \stackrel{iid}{\sim} \mbox{N}(0,.5^2)$. We fit $f$ using the exponential transformation in nnrfit1 and square transformation in nnrfit2. We use a cubic periodic spline to model $g$. Figure [*] shows the fits.

t <- seq(0,1, len=100)
y <- exp(sin(2*pi*t))+0.5*rnorm(100)
nnrfit1 <- nnr(y~exp(g(t)), func=g(u)~list(~1, periodic(u)),
               start=log(abs(y)+0.001))
nnrfit2 <- nnr(y~g(t)**2, func=g(u)~list(~1, periodic(u)),
               start=sqrt(abs(y)))

Figure: Points are observations; Lines are the true and estimated functions.
\begin{figure}\centerline{\psfig{figure=nnrsimu.ps,height=2.6in,width=4.5in}}\end{figure}

See Section 7 for more interesting examples.


next up previous
Next: Semi-parametric Nonlinear Regression Models Up: Non-Parametric Nonlinear Regression Models Previous: Model and Estimation
Yuedong Wang 2004-05-19