cv.cov_ogk | R Documentation |
K-fold cross-validation for Bivariate Nadaraya-Watson smoothing for Covariance
cv.cov_ogk(
X,
type = c("huber", "bisquare", "tdist"),
MM = TRUE,
bw_cand = NULL,
K = 5,
ncores = 1
)
X |
a n x p matrix with or without NA. |
type |
the option for robust dispersion estimator. "huber", "bisquare", and "tdist" are supported. |
MM |
the option for M-scale estimator in GK identity. Default is same method using |
bw_cand |
a vector contains the candidates of bandwidths for bivariate smoothing. |
K |
the number of folds for K-fold cross validation. |
ncores |
the number of cores on |
a list contatining as follows:
selected_bw |
the optimal bandwidth selected from the robust K-fold cross-validation. |
cv.error |
a matrix containing CV error per bandwidth candidates. |
set.seed(100)
x.list <- sim_delaigle(n = 100,
type = "partial",
out.prop = 0.2,
dist = "normal")
x <- list2matrix(x.list)
# 5-fold CV for bivariate smoothing
# You can improve the computaion speed by setting "ncores" option.
bw_cand = seq(0.01, 0.1, length.out = 10)
cov.cv.obj <- cv.cov_ogk(x,
type = 'huber',
bw_cand = bw_cand,
K = 5,
ncores = 1)
print(cov.cv.obj$selected_bw)
# Robust smoothed covariance using selected bw from cross-validation
cov.obj <- cov_ogk(x,
type = "huber",
bw = cov.cv.obj$selected_bw)
mu.ogk.sm <- cov.obj$mean
cov.ogk.sm <- cov.obj$cov
noise.ogk.sm <- cov.obj$noise.var
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.