Learn R Programming

assist (version 2.0)

nnr: Nonlinear Non-parametric Regression

Description

Fit a nonlinear nonparametric regression models with spline smoothing based on extended Gauss-Newton/Newton-Raphson and backfitting.

Usage

nnr(formula, func, spar="v", data=sys.parent(), start=list(),verbose=FALSE,  control=list())

Arguments

formula
a model formula, with the response on the left of a $\mbox{\textasciitilde}$ operator and on the right an expression representing the mean function with a nonparametric function appearing with a symbol, e.g. f.
func
a required formula specifying the spline components necessary to estimate the non-parametric function. On the left of a $\mbox{\textasciitilde}$ operator is the unknow function symbol as well as its arguments, while the right side is a list of two com
spar
a character string specifying a method for choosing the smoothing parameter. "v", "m" and "u" represent GCV, GML and UBR respectively. Default is "v" for GCV.
data
an optional data frame.
start
a list of vectors or expressions which input inital values for the unknown functions. If expressions, the argument(s) inside should be the same as in func. The length of start should be the same as the number of unknown functi
verbose
an optional logical numerical value. If TRUE, information on the evolution of the iterative algorithm is printed. Default is FALSE.
control
an optional list of control values to be used. See nnr.control for details.

Value

  • an object of class nnr is returned, containing fitted values, fitted function values as well as other information used to assess the estimate.

Details

A nonlinear nonparametric model is fitted using the algorithms developed in Ke and Wang (2002).

References

Ke, C. and Wang, Y. (2002). Nonlinear Nonparametric Regression Models. Submitted.

See Also

nnr.control, ssr, print.nnr, summary.nnr, intervals.nnr

Examples

Run this code
x<- 1:100/100
y<- exp(sin(2*pi*x))+0.3*rnorm(x)
fit<- nnr(y~exp(f(x)), func=list(f(u)~list(~u, cubic(u))), start=list(0))

## fit a generalized varying coefficient models
data(Arosa)
Arosa$csmonth <- (Arosa$month-0.5)/12
Arosa$csyear <- (Arosa$year-1)/45
ozone.vc.fit <- nnr(thick~f1(csyear)+exp(f2(csyear))*f3(csmonth),
        func=list(f1(x)~list(~I(x-.5),cubic(x)), f2(x)~list(~I(x-.5)-1,cubic(x)),
        f3(x)~list(~sin(2*pi*x)+cos(2*pi*x)-1,lspline(x,type="sine0"))),
        data=Arosa[Arosa$year%%2==1,], spar="m", start=list(f1=mean(thick),f2=0,f3=sin(csmonth)),
        control=list(backfit=1))

Run the code above in your browser using DataLab