CV_reg {OSCV} | R Documentation |
The cross-validation (CV) function in the regression context.
Description
Computing CV(h)
, the value of the CV function in the regression context.
Usage
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 |
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
## 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)
[Package OSCV version 1.0 Index]