modalreg {hdrcde} | R Documentation |
Nonparametric multi-valued regression based on the modes of conditional density estimates.
modalreg(x, y, xfix=seq(min(x),max(x),l=50), a, b, deg = 0, iter = 30, P = 2, start = "e", shrink = TRUE, shrink.const = 10, plot.type = c("p", 1), labels = c("", "x", "y"), pch=".", ...)
x |
Numerical vector: the conditioning variable. |
y |
Numerical vector: the response variable. |
xfix |
Numerical vector corresponding to the input values of which the fitted values shall be calculated. |
a |
Optional bandwidth in x-direction |
b |
Optional bandwidth in y-direction |
deg |
Degree of local polynomial used in estimation (0 or 1). |
iter |
Positive integer giving the number of mean shift iterations per point and branch. |
P |
Maximal number of branches. |
start |
Character determining how the starting points are selected.
"q" : proportional to quantiles; "e" : equidistant; "r" : random.
All, "q" , "e" , and "r" , give constant starting points.
As an alternative, the choice "v" gives variable starting points equal
to "q" for the smallest x , and equal to
the previously fitted values for all subsequent x . |
shrink |
Boolean. If TRUE, parts of branches are dismissed where their
associated kernel density value falls below the threshold
1/(shrink.const*(max(x)-min(x))*(max(y)-min(y))) |
shrink.const |
Numerical value giving the constant used above (the higher, the less shrinking) |
plot.type |
Vector with two elements. The first one is character-valued,
with possible values "p", "l", and "n". If equal to "n", no plotted output
is given at all. If equal to "p", fitted curves are symbolized as points in the
graphical output, otherwise as lines. (Warning: The latter setting might
give confusing outputs especially for high P .) |
labels |
Vector of three character strings. The first one is the "main" title of the graphical output, the second one is the label of the x axis, and the third one the label of the y axis. |
pch |
Plotting character. |
... |
Other arguments passed to cde.bandwidths . |
Computes multi-modal nonparametric regression curves based on the
maxima of conditional density estimates. The tool for the estimation
is the conditional mean shift as outlined in Einbeck and Tutz (2006).
Estimates of the conditional modes might fluctuate highly if deg=1
.
Hence, deg=0
is strongly recommended. For bandwidth selection, the
hybrid rule introduced by Bashtannyk and Hyndman (2001) is employed
if deg=0
; and the Hyndman and Yao (2002) algorithm if deg=1
.
A list with the following components:
Fitted.values |
A [P x length(xfix)] - matrix with fitted j-th branch
in the j-th row (1 <=j <=P)
|
Bandwidths |
A vector with bandwidths a and b |
Density |
A [P x length(xfix)] - matrix with estimated kernel densities |
Threshold |
The shrinkage threshold. |
Jochen Einbeck (2006)
Einbeck, J., and Tutz, G. (2006) "Modelling beyond regression functions: an application of multimodal regression to speed-flow data". Applied Statistics, 2006, in press.
Bashtannyk, D.M., and Hyndman, R.J. (2001) "Bandwidth selection for kernel conditional density estimation". Computational Statistics and Data Analysis, 36(3), 279-298.
Hyndman, R.J. and Yao, Q. (2002) "Nonparametric estimation and symmetry tests for conditional density functions". Journal of Nonparametric Statistics, 14(3), 259-278.
lane2.fit <- modalreg(lane2$flow, lane2$speed, xfix=(1:55)*40, a=100, b=4)