CV_reg: The cross-validation (CV) function in the regression context.

Description Usage Arguments Details Value References See Also Examples

View source: R/OSCV_regfunctions.R

Description

Computing CV(h), the value of the CV function in the regression context.

Usage

1
CV_reg(h, desx, y)

Arguments

h

numerical vector of bandwidth values,

desx

numerical vecror of design points,

y

numerical vecror of data values corresponding to the design points desx.

Details

The CV function is a measure of fit of the regression estimate to the data. The local linear estimator based on the Gaussian kernel is used. The cross-validation bandwidth is the minimizer of the CV function.

Value

The vector of values of CV(h) for the correponsing vector of h values.

References

Stone, C.J. (1977) Consistent nonparametric regression. Annals of Statistics, 5(4), 595-645.

See Also

loclin, h_ASE_reg, ASE_reg, OSCV_reg.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## Not run: 
# Example (Old Faithful geyser). Take x=waiting time; y=eruption duration. The sample size n=272.
xdat=faithful[[2]]
ydat=faithful[[1]]
harray=seq(0.5,10,len=100)
cv=CV_reg(harray,xdat,ydat)
R=range(xdat)
h_cv=round(optimize(CV_reg,c(0.01,(R[2]-R[1]/4)),desx=xdat,y=ydat)$minimum,digits=4)
dev.new()
plot(harray,cv,'l',lwd=3,xlab="h",ylab="CV(h)",main="CV function for the Old Faithful 
geyser data", cex.lab=1.7,cex.axis=1.7,cex.main=1.5)
legend(6,0.155,legend="n=272",cex=1.8,bty="n")
legend(1,0.18,legend=paste("h_CV=",h_cv),cex=2,bty="n")

## End(Not run)

OSCV documentation built on May 2, 2019, 6:44 a.m.