# kern.reg.circ.lin: Nonparametric regression estimation for circular data In NPCirc: Nonparametric Circular Methods

## Description

Function `kern.reg.circ.lin` implements the Nadaraya-Watson estimator and the Local-Linear estimator for circular-linear data (circular covariate and linear response), as described in Di Marzio et al. (2009) and Oliveira et al. (2013), taking the von Mises distribution as kernel.

Function `kern.reg.circ.circ` implements the Nadaraya-Watson estimator and the Local-Linear estimator for circular-circular data (circular covariate and circular response), as described in Di Marzio et al. (2012), taking the von Mises distribution as kernel.

Function `kern.reg.lin.circ` implements the Nadaraya-Watson estimator and the Local-Linear estimator for linear-circular data (linear covariate and circular response), as described in Di Marzio et al. (2012), taking the Normal distribution as kernel.

## Usage

 ```1 2 3 4 5 6 7``` ```kern.reg.circ.lin(x, y, t=NULL, bw, method="LL", from=circular(0), to=circular(2*pi), len=250, tol=300) kern.reg.circ.circ(x, y, t=NULL, bw, method="LL", from=circular(0), to=circular(2*pi), len=250) kern.reg.lin.circ(x, y, t=NULL, bw, method="LL", len=250) ## S3 method for class 'regression.circular' print(x, digits=NULL, ...) ```

## Arguments

 `x` Vector of data for the independent variable. The object is coerced to class `circular` when using functions `kern.reg.circ.lin` and `kern.reg.circ.circ`. `y` Vector of data for the dependent variable. This must be same length as `x`. The object is coerced to class `circular` when using functions `kern.reg.circ.circ` and `kern.reg.lin.circ`. `t` Points where the regression function is estimated. If `NULL` equally spaced points are used according to the parameters `from`, `to` and `len`. `bw` Smoothing parameter to be used. The value of the smoothing parameter can be chosen by using the function `bw.reg.circ.lin`, `bw.reg.circ.circ` and `bw.reg.lin.circ`. `method` Character string giving the estimator to be used. This must be one of `"LL"` for Local-Linear estimator or `"NW"` for Nadaraya-Watson estimator. Default `method="LL"`. `from, to` Left and right-most points of the grid at which the density is to be estimated. The objects are coerced to class `circular`. `len` Number of equally spaced points at which the density is to be estimated. `tol` Tolerance parameter to avoid overflow when `bw` is larger than `tol`. Default is `tol=300`. `digits` Integer indicating the precision to be used. `...` further arguments

## Details

See Di Marzio et al. (2012). See Section 3 in Oliveira et al. (2013). See Di Marzio et al. (2009). The NAs will be automatically removed.

## Value

An object with class "regression.circular" whose underlying structure is a list containing the following components:

 `data` Original dataset. `x` The n coordinates of the points where the regression is estimated. `y` The estimated values. `bw` The smoothing parameter used. `N` The sample size after elimination of missing values. `call` The call which produced the result. `data.name` The deparsed name of the x argument. `has.na` Logical, for compatibility (always FALSE).

## Author(s)

María Oliveira, Rosa M. Crujeiras and Alberto Rodríguez–Casal

## References

Di Marzio, M., Panzera A. and Taylor, C. C. (2009) Local polynomial regression for circular predictors. Statistics and Probability Letters, 79, 2066–2075.

Di Marzio, M., Panzera A. and Taylor, C. C. (2012) Non–parametric regression for circular responses. Scandinavian Journal of Statistics, 40, 228–255.

Oliveira, M., Crujeiras R.M. and Rodríguez–Casal, A. (2013) Nonparametric circular methods for exploring environmental data. Environmental and Ecological Statistics, 20, 1–17.

Oliveira, M., Crujeiras R.M. and Rodríguez–Casal, A. (2014) NPCirc: an R package for nonparametric circular methods. Journal of Statistical Software, 61(9), 1–26. http://www.jstatsoft.org/v61/i09/

`plot.regression.circular`, `lines.regression.circular`
 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47``` ```### circular-linear data(speed.wind2) dir <- speed.wind2\$Direction vel <- speed.wind2\$Speed nas <- which(is.na(vel)) dir <- circular(dir[-nas],units="degrees") vel <- vel[-nas] estLL <- kern.reg.circ.lin(dir, vel, method="LL") estNW <- kern.reg.circ.lin(dir, vel, method="NW") # Circular representation res<-plot(estNW, plot.type="circle", points.plot=TRUE, labels=c("N","NE","E","SE","S","SO","O","NO"), label.pos=seq(0,7*pi/4,by=pi/4), zero=pi/2, clockwise=TRUE) lines(estLL, plot.type="circle", plot.info=res, line.col=2) # Linear representation plot(estNW, plot.type="line", points.plot=TRUE, xlab="direction", ylab="speed (m/s)") lines(estLL, plot.type="line", line.col=2) ### circular-circular data(wind) wind6 <- circular(wind\$wind.dir[seq(7,1752,by=24)]) wind12 <- circular(wind\$wind.dir[seq(13,1752,by=24)]) estNW <- kern.reg.circ.circ(wind6,wind12,t=NULL,bw=6.1,method="NW") estLL <- kern.reg.circ.circ(wind6,wind12,t=NULL,bw=2.25,method="LL") # Torus representation plot(estNW, plot.type="circle", points.plot=TRUE, line.col=2, lwd=2, points.col=2, units="degrees") lines(estLL, plot.type="circle", line.col=3, lwd=2) # Linear representation plot(estNW, plot.type="line", points.plot=TRUE, xlab="Wind direction at 6 a.m.", ylab="Wind direction at noon") lines(estLL, plot.type="line", line.col=2) ### linear-circular data(periwinkles) dist <- periwinkles\$distance dir <- circular(periwinkles\$direction, units="degrees") estNW <- kern.reg.lin.circ(dist,dir,t=NULL,bw=12.7,method="NW") estLL <- kern.reg.lin.circ(dist,dir,t=NULL,bw=200,method="LL") # Cylinder representation plot(estNW, plot.type="circle", points.plot=TRUE, line.col=2, lwd=2, points.col=2) lines(estLL, plot.type="circle", line.col=3, lwd=2) # Linear representation plot(estNW, plot.type="line", points.plot=TRUE, units="radians", main="") lines(estLL, plot.type="line", line.col=2, units="radians") ```