Title: | Robust Likelihood Cross Validation Bandwidth Selection |
---|---|
Description: | Robust likelihood cross validation bandwidth for uni- and multi-variate kernel densities. It is robust against fat-tailed distributions and/or outliers. Based on "Robust Likelihood Cross-Validation for Kernel Density Estimation," Wu (2019) <doi:10.1080/07350015.2018.1424633>. |
Authors: | Ximing Wu [aut, cre] |
Maintainer: | Ximing Wu <[email protected]> |
License: | GPL (>= 3) |
Version: | 1.0.0 |
Built: | 2024-11-15 06:35:38 UTC |
Source: | CRAN |
Univariate kernel density
kde(x.obs, x.new = NULL, h)
kde(x.obs, x.new = NULL, h)
x.obs |
Training (observed) data (n1 vector) |
x.new |
Evaluation data (n2 vector); default to x.obs |
h |
Bandwidth |
Density evaluated at x.new
Ximing Wu [email protected]
Wu, Ximing (2019), "Robust Likelihood Cross Validation for Kernel Density Estimation," Journal of Business and Economic Statistics, 37(4): 761-770.
x=rnorm(100) x.new=seq(-5,5,length=50) h=1.06*sd(x)*(length(x))^(-1/5) f=kde(x.new=x.new,x.obs=x,h=h)
x=rnorm(100) x.new=seq(-5,5,length=50) h=1.06*sd(x)*(length(x))^(-1/5) f=kde(x.new=x.new,x.obs=x,h=h)
Multivariate kernel density
kde_d(x.obs, x.new = NULL, h, stud = FALSE)
kde_d(x.obs, x.new = NULL, h, stud = FALSE)
x.obs |
Training (observed) data (n1 by d matrix, d>=2) |
x.new |
Evaluation data (n2 by d matrix, d>=2); default to x.obs |
h |
Bandwidth (d vector) |
stud |
Indicator for whether data are studentized; default to FALSE |
For multivariate distributions, bandwidth is calculated for studentized data.
Density evaluated at x.new
Ximing Wu [email protected]
Wu, Ximing (2019), "Robust Likelihood Cross Validation for Kernel Density Estimation," Journal of Business and Economic Statistics, 37(4): 761-770.
x=matrix(rnorm(200),ncol=2) x.new=matrix(rnorm(100),ncol=2) h=c(1,1) f=kde_d(x.new=x.new,x.obs=x,h=h)
x=matrix(rnorm(200),ncol=2) x.new=matrix(rnorm(100),ncol=2) h=c(1,1) f=kde_d(x.new=x.new,x.obs=x,h=h)
Likelihood cross validation bandwidth for univariate densities
lcv(x.obs, x.new = NULL)
lcv(x.obs, x.new = NULL)
x.obs |
Training (observed) data |
x.new |
Evaluation data; default to x.obs |
fhat: density evaluated at x.new; h: bandwidth
Ximing Wu [email protected]
Wu, Ximing (2019), "Robust Likelihood Cross Validation for Kernel Density Estimation," Journal of Business and Economic Statistics, 37(4): 761-770.
x=rt(200,df=5) x.new=seq(-5,5,length=100) fit=lcv(x.obs=x,x.new=x.new) # Mean squared errors f0=dt(x.new,df=5) mean((f0-fit$fhat)^2) matplot(x.new,cbind(f0,fit$fhat),type='l')
x=rt(200,df=5) x.new=seq(-5,5,length=100) fit=lcv(x.obs=x,x.new=x.new) # Mean squared errors f0=dt(x.new,df=5) mean((f0-fit$fhat)^2) matplot(x.new,cbind(f0,fit$fhat),type='l')
Likelihood cross validation bandwidth for multivariate kernel densities
lcv_d(x.obs, x.new = NULL)
lcv_d(x.obs, x.new = NULL)
x.obs |
Training (observed) data (n1 by d matrix, d>=2) |
x.new |
Evaluation data (n2 by d matrix, d>=2); default to x.obs |
fhat: density evaluated at x.new; h: bandwidth
Ximing Wu [email protected]
Wu, Ximing (2019), "Robust Likelihood Cross Validation for Kernel Density Estimation," Journal of Business and Economic Statistics, 37(4): 761-770.
# old faithful data x=datasets::faithful x=cbind(x[,1],x[,2]) fit=lcv_d(x.obs=x) # evaluation data x1=seq(min(x[,1])*.8,max(x[,1])*1.2,length=30) x2=seq(min(x[,2])*.8,max(x[,2])*1.2,length=30) x11=rep(x1,each=30) x22=rep(x2,30) fhat=kde_d(x.new=cbind(x11,x22),x.obs=x,h=fit$h) persp(x1,x2,matrix(fhat,30,30))
# old faithful data x=datasets::faithful x=cbind(x[,1],x[,2]) fit=lcv_d(x.obs=x) # evaluation data x1=seq(min(x[,1])*.8,max(x[,1])*1.2,length=30) x2=seq(min(x[,2])*.8,max(x[,2])*1.2,length=30) x11=rep(x1,each=30) x22=rep(x2,30) fhat=kde_d(x.new=cbind(x11,x22),x.obs=x,h=fit$h) persp(x1,x2,matrix(fhat,30,30))
Robust likelihood cross validation bandwidth for univariate densities
rlcv(x.obs, x.new = NULL)
rlcv(x.obs, x.new = NULL)
x.obs |
Training (observed) data |
x.new |
Evaluation data; default to x.obs |
fhat: density evaluated at x.new; h: bandwidth
Ximing Wu [email protected]
Wu, Ximing (2019), "Robust Likelihood Cross Validation for Kernel Density Estimation," Journal of Business and Economic Statistics, 37(4): 761-770.
x=rt(200,df=5) x.new=seq(-5,5,length=100) fit=rlcv(x.obs=x,x.new=x.new) # Mean squared errors f0=dt(x.new,df=5) mean((f0-fit$fhat)^2) matplot(x.new,cbind(f0,fit$fhat),type='l')
x=rt(200,df=5) x.new=seq(-5,5,length=100) fit=rlcv(x.obs=x,x.new=x.new) # Mean squared errors f0=dt(x.new,df=5) mean((f0-fit$fhat)^2) matplot(x.new,cbind(f0,fit$fhat),type='l')
Robust likelihood cross validation bandwidth for multivariate kernel densities
rlcv_d(x.obs, x.new = NULL)
rlcv_d(x.obs, x.new = NULL)
x.obs |
Training (observed) data (n1 by d matrix, d>=2) |
x.new |
Evaluation data (n2 by d matrix, d>=2); default to x.obs |
fhat: density evaluated at x.new; h: bandwidth
Ximing Wu [email protected]
Wu, Ximing (2019), "Robust Likelihood Cross Validation for Kernel Density Estimation," Journal of Business and Economic Statistics, 37(4): 761-770.
# old faithful data x=datasets::faithful x=cbind(x[,1],x[,2]) fit=rlcv_d(x.obs=x) # evaluation data x1=seq(min(x[,1])*.8,max(x[,1])*1.2,length=30) x2=seq(min(x[,2])*.8,max(x[,2])*1.2,length=30) x11=rep(x1,each=30) x22=rep(x2,30) fhat=kde_d(x.new=cbind(x11,x22),x.obs=x,h=fit$h) persp(x1,x2,matrix(fhat,30,30))
# old faithful data x=datasets::faithful x=cbind(x[,1],x[,2]) fit=rlcv_d(x.obs=x) # evaluation data x1=seq(min(x[,1])*.8,max(x[,1])*1.2,length=30) x2=seq(min(x[,2])*.8,max(x[,2])*1.2,length=30) x11=rep(x1,each=30) x22=rep(x2,30) fhat=kde_d(x.new=cbind(x11,x22),x.obs=x,h=fit$h) persp(x1,x2,matrix(fhat,30,30))