# NOT RUN {
library(crmReg)
data(topgear)
# get case weights from a robust estimator (covMCD function in robustbase package):
MCD <- robustbase::covMcd(topgear, alpha = 0.5)
# SPADIMO with diagnostic plots:
# Example 1:
Peugeot <- spadimo(data = topgear,
weights = MCD$mcd.wt,
obs = which(rownames(topgear) == "Peugeot 107"))
# check the plots!
# individual variable names contributing most to Peugeot 107's outlyingness:
print(Peugeot$outlvars)
# sparse direction of maximal outlyingness with eta = Peugeot$eta:
print(Peugeot$a)
# default SPADIMO control parameters:
print(Peugeot$control)
# Example 2:
Bugatti <- spadimo(data = topgear,
weights = MCD$mcd.wt,
obs = which(rownames(topgear) == "Bugatti Veyron"),
control = list(stopearly = TRUE, trace = TRUE, plot = TRUE))
# check the plots!
# individual variable names contributing most to Bugatti Veyron's outlyingness:
print(Bugatti$outlvars)
# sparse direction of maximal outlyingness with eta = Bugatti$eta:
print(Bugatti$a)
# }
Run the code above in your browser using DataLab