h.select: Selection of the smoothing parameter

Description Usage Arguments Details Value Side Effects References See Also Examples

Description

This function selects a smoothing parameter for density estimation in one or two dimensions and for nonparametric regression with one or two covariates. Several methods of selection are available.

Usage

1
 h.select(x, y = NA, weights = NA, group = NA, ...)

Arguments

x

a vector, or two-column matrix.

y

a vector of reponses, in regression case.

weights

a vector of integers representing frequencies of individual observations. Use of this parameter is incompatible with binning; hence nbins must then be set to 0 or left at its default value NA.

group

a vector of groups indicators (numeric or character values) or a factor

...

other optional parameters are passed to the sm.options function, through a mechanism which limits their effect only to this call of the function. There are three which are relevant for this function, namely method, which specifies the method of smoothing parameter selection, df, which specifies the approximate degrees of freedom associated with the selected smoothing parameter, and structure.2d which determines the form of the smoothing parameters in the two-dimensional case. A full description of these arguments are given in the documentation of sm.options.

Details

see the two references below for discussion of the methods of smoothing parameter selection.

If the sample size is large, binning will be employed. In the case of method = "cv" the answer will therefore be different from that obtained through the function hcv where binning is not used.

When the group argument is set, the chosen method of smoothing parameter selection is applied to each group and the value returned is the geometric mean of these. This is intended for use in sm.density.compare and sm.ancova, where the same smoothing parameter is used for all groups so that the principal bias terms cancel when the estimates are compared.

Value

the value of the selected smoothing parameter.

Side Effects

none

References

Bowman, A.W. and Azzalini, A. (1997). Applied Smoothing Techniques for Data Analysis: the Kernel Approach with S-Plus Illustrations. Oxford University Press, Oxford.

Hurvich, C.M., Simonoff, J.S. and Tsai, C.-L. (1998). Smoothing parameter selection in nonparametric regression using an improved Akaike information criterion. J. R. Statistic. Soc., Series B, 60, 271-293.

See Also

sm, hcv, hsj, hnorm

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
x <- rnorm(50)
h.select(x)
h.select(x, method = "sj")

x <- matrix(rnorm(100), ncol = 2)
h.select(x)
sm.density(x, method = "cv")

x <- rnorm(50)
y <- x^2 + rnorm(50)
h.select(x, y)
sm.regression(x, y, method = "aicc")

x <- matrix(rnorm(100), ncol = 2)
y <- x[,1]^2 + x[,2]^2 + rnorm(50)
h.select(x, y, method = "cv", structure.2d = "common")
sm.regression(x, y, df = 8)

Example output

Package 'sm', version 2.2-5.4: type help(sm) for summary information
[1] 0.4465847
[1] 0.2486255
[1] 0.5226070 0.5909681
Loading required package: rgl
Loading required package: rpanel
Loading required package: tcltk
Error: package or namespace load failed for 'tcltk':
 .onLoad failed in loadNamespace() for 'tcltk', details:
  call: fun(libname, pkgname)
  error: Can't find a usable init.tcl in the following directories: 
    /usr/share/tcltk/tcl8.6 ./lib/tcl8.6 ./lib/tcl8.6 ./library ./library ./tcl8.6.1/library ./tcl8.6.1/library

/usr/share/tcltk/tcl8.6/init.tcl: couldn't read file "/usr/share/tcltk/tcl8.6/init.tcl": permission denied
couldn't read file "/usr/share/tcltk/tcl8.6/init.tcl": permission denied
    while executing
"source /usr/share/tcltk/tcl8.6/init.tcl"
    ("uplevel" body line 1)
    invoked from within
"uplevel #0 [list source $tclfile]"


This probably means that Tcl wasn't installed properly.

Failed with error:  'package 'tcltk' could not be loaded'
In addition: Warning messages:
1: In rgl.init(initValue, onlyNULL) : RGL: unable to open X11 display
2: 'rgl_init' failed, running with rgl.useNULL = TRUE 
3: .onUnload failed in unloadNamespace() for 'rgl', details:
  call: fun(...)
  error: object 'rgl_quit' not found 
[1] 0.405744
[1] 0.7293659 0.7293659

sm documentation built on May 1, 2019, 8:06 p.m.

Related to h.select in sm...