## Not run: ------------------------------------
# # Example 1 (Old Faithful geyser data)
# dev.new()
# data=faithful[,1] # Data on n=272 eruption duration of the Old Faithful geyser.
# harray=seq(0.025,0.6,len=50)
# alp=16.8954588
# sig=1.01
# plot(harray,OSCV_LI_dens(harray,data,alpha=alp,sigma=sig),lwd=3,'l',xlab="h",
# ylab="L_I-based OSCV",main="OSCV_LI(h) for eruption duration",cex.main=1.5,cex.lab=1.7,
# cex.axis=1.7)
# h_OSCV_LI=round(optimize(OSCV_LI_dens,c(0.001,0.5),tol=0.001,dat=data,alpha=16.8954588,
# sigma=1.01)$minimum,digits=4)
# legend(0.01,-0.2,legend=c("n=272",paste("h_OSCV_LI=",h_OSCV_LI)),cex=1.8,bty="n")
# legend(0.25,-0.33,legend=c("Parameters of L_I:", paste("alpha=",alp),
# paste("sigma=",sig)),cex=1.7,bty="n")
#
# # Example 2 (Simulated example)
# dat_norm=rnorm(100) #generating a random sample of size n=100 from the N(0,1) density
# harray=seq(0.05,1.5,len=100)
# OSCVarray=OSCV_LI_dens(harray,dat=dat_norm,16.8954588,1.01)
# dev.new()
# plot(harray,OSCVarray,lwd=3,'l',xlab="h",ylab="L_I-based OSCV",
# main="OSCV_LI(h) for data generated from N(0,1)",cex.main=1.5,cex.lab=1.7,cex.axis=1.7)
# h_OSCV_LI_norm=round(optimize(OSCV_LI_dens,c(0.001,1),tol=0.001,
# dat=dat_norm,16.8954588,1.01)$minimum,digits=4)
# legend(0,OSCVarray[1],legend=c("n=100",paste("h_OSCV_LI=",h_OSCV_LI_norm),
# "Parameters of the robust kernel L_I:","alpha=16.8954588", "sigma=1.01"),cex=1.5,bty="n")
## ---------------------------------------------
Run the code above in your browser using DataLab