Description Usage Arguments Details Value Author(s) See Also Examples
Produce kernel density plots of results from repeated Kfold crossvalidation.
1 2 3 4 5 6 
x 
an object inheriting from class 
data 
currently ignored. 
subset 
a character, integer or logical vector indicating the subset of models for which to plot the crossvalidation results. 
select 
a character, integer or logical vector indicating the columns of crossvalidation results to be plotted. 
... 
additional arguments to be passed to the

For objects with multiple columns of repeated crossvalidation results, conditional kernel density plots are produced.
An object of class "trellis"
is returned
invisibly. The
update
method can
be used to update components of the object and the
print
method
(usually called by default) will plot it on an
appropriate plotting device.
Andreas Alfons
cvFit
, cvSelect
,
cvTuning
, plot
,
bwplot
,
xyplot
,
dotplot
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52  library("robustbase")
data("coleman")
set.seed(1234) # set seed for reproducibility
## set up folds for crossvalidation
folds < cvFolds(nrow(coleman), K = 5, R = 50)
## compare LS, MM and LTS regression
# perform crossvalidation for an LS regression model
fitLm < lm(Y ~ ., data = coleman)
cvFitLm < cvLm(fitLm, cost = rtmspe,
folds = folds, trim = 0.1)
# perform crossvalidation for an MM regression model
fitLmrob < lmrob(Y ~ ., data = coleman, k.max = 500)
cvFitLmrob < cvLmrob(fitLmrob, cost = rtmspe,
folds = folds, trim = 0.1)
# perform crossvalidation for an LTS regression model
fitLts < ltsReg(Y ~ ., data = coleman)
cvFitLts < cvLts(fitLts, cost = rtmspe,
folds = folds, trim = 0.1)
# combine results into one object
cvFits < cvSelect(LS = cvFitLm, MM = cvFitLmrob, LTS = cvFitLts)
cvFits
# plot results for the MM regression model
densityplot(cvFitLmrob)
# plot combined results
densityplot(cvFits)
## compare raw and reweighted LTS estimators for
## 50% and 75% subsets
# 50% subsets
fitLts50 < ltsReg(Y ~ ., data = coleman, alpha = 0.5)
cvFitLts50 < cvLts(fitLts50, cost = rtmspe, folds = folds,
fit = "both", trim = 0.1)
# 75% subsets
fitLts75 < ltsReg(Y ~ ., data = coleman, alpha = 0.75)
cvFitLts75 < cvLts(fitLts75, cost = rtmspe, folds = folds,
fit = "both", trim = 0.1)
# combine and plot results
cvFitsLts < cvSelect("0.5" = cvFitLts50, "0.75" = cvFitLts75)
cvFitsLts
densityplot(cvFitsLts)

Loading required package: lattice
Loading required package: robustbase
Warning messages:
1: In lmrob.S(x, y, control = control) :
find_scale() did not converge in 'maxit.scale' (= 200) iterations with tol=1e10, last rel.diff=0
2: In lmrob.S(x, y, control = control) :
find_scale() did not converge in 'maxit.scale' (= 200) iterations with tol=1e10, last rel.diff=0
3: In lmrob.S(x, y, control = control) :
find_scale() did not converge in 'maxit.scale' (= 200) iterations with tol=1e10, last rel.diff=0
4: In lmrob.S(x, y, control = control) :
find_scale() did not converge in 'maxit.scale' (= 200) iterations with tol=1e10, last rel.diff=0
5: In lmrob.S(x, y, control = control) :
find_scale() did not converge in 'maxit.scale' (= 200) iterations with tol=1e10, last rel.diff=0
6: In lmrob.S(x, y, control = control) :
find_scale() did not converge in 'maxit.scale' (= 200) iterations with tol=1e10, last rel.diff=0
7: In lmrob.S(x, y, control = control) :
find_scale() did not converge in 'maxit.scale' (= 200) iterations with tol=1e10, last rel.diff=0
8: In lmrob.S(x, y, control = control) :
find_scale() did not converge in 'maxit.scale' (= 200) iterations with tol=1e10, last rel.diff=0
9: In lmrob.S(x, y, control = control) :
find_scale() did not converge in 'maxit.scale' (= 200) iterations with tol=1e10, last rel.diff=0
5fold CV results:
Fit CV
1 LS 1.674485
2 MM 1.147130
3 LTS 1.291797
Best model:
CV
"MM"
5fold CV results:
Fit reweighted raw
1 0.5 1.291797 1.640922
2 0.75 1.065495 1.232691
Best model:
reweighted raw
"0.75" "0.75"
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.