Refits a SLOPE model using the optimal parameters found through cross-validation. This is a convenience function to avoid having to manually extract optimal parameters and refit.
Arguments
- object
an object of class
'TrainedSLOPE', typically from a call tocvSLOPE()ortrainSLOPE()- x
the design matrix. If
NULL(default), uses the training data stored inobject.- y
the response vector. If
NULL(default), uses the training data stored inobject.- measure
which performance measure to use for selecting optimal parameters. If
NULL(default), uses the first measure in theTrainedSLOPEobject.- ...
additional arguments passed to
SLOPE()
See also
Other model-tuning:
cvSLOPE(),
plot.TrainedSLOPE(),
summary.TrainedSLOPE(),
trainSLOPE()
Examples
# Cross-validation
tune <- trainSLOPE(
bodyfat$x,
bodyfat$y,
q = c(0.1, 0.2),
measure = "mse"
)
# Refit with optimal parameters
fit <- refit(tune)
# Use the fitted model
coef(fit)
#> 14 x 1 sparse Matrix of class "dgCMatrix"
#>
#> [1,] -17.90166858
#> [2,] 0.06260030
#> [3,] -0.08747515
#> [4,] -0.06916324
#> [5,] -0.47295153
#> [6,] -0.02450362
#> [7,] 0.95438358
#> [8,] -0.20735962
#> [9,] 0.23861870
#> [10,] .
#> [11,] 0.17623141
#> [12,] 0.18072719
#> [13,] 0.45313625
#> [14,] -1.61828551
predict(fit, bodyfat$x)
#> [1] 16.139643 8.854446 18.526408 11.942982 27.248130 16.928360 16.732217
#> [8] 13.898629 9.698326 10.152638 9.007375 12.906763 17.828671 25.035750
#> [15] 24.095908 22.956413 23.522520 19.457456 16.742214 23.173032 21.113929
#> [22] 19.874146 9.570676 11.123846 8.159711 8.514990 9.100390 17.945034
#> [29] 6.353947 11.654778 14.617643 11.004363 6.164729 23.780478 32.277176
#> [36] 37.580856 24.123694 21.887995 44.069206 32.501427 36.752120 32.507224
#> [43] 34.249945 26.381148 10.903006 9.959683 7.791946 9.524868 17.799100
#> [50] 5.534489 14.738339 9.501581 14.239474 10.778245 7.683179 23.570203
#> [57] 25.850633 27.681092 28.648261 26.285008 25.359928 23.538922 27.488142
#> [64] 27.220192 30.092695 26.201061 15.447816 15.711660 8.725331 13.831383
#> [71] 19.518949 12.790986 11.061516 11.594232 16.812294 12.111769 8.941701
#> [78] 19.365862 23.181872 24.796183 22.166920 17.891136 22.975669 21.324738
#> [85] 27.193623 20.935835 17.570378 21.799607 12.693327 14.170962 21.707584
#> [92] 17.619516 11.032996 21.678398 14.756989 16.272946 16.832010 16.071511
#> [99] 17.823437 19.143158 18.496397 19.918184 17.299012 17.175852 23.906613
#> [106] 17.795954 25.864709 22.249589 12.448903 21.056253 19.245074 32.430690
#> [113] 20.879821 19.873612 20.128151 16.435153 16.879799 14.379338 18.169232
#> [120] 13.461487 20.376252 22.503293 14.069212 17.116086 15.483751 20.994288
#> [127] 21.503803 8.995305 18.656922 15.002011 18.321510 20.168636 24.806599
#> [134] 21.075208 16.057764 26.842409 16.672431 26.058536 17.897434 28.754020
#> [141] 21.165772 21.288280 18.908225 5.403932 9.316467 12.525066 22.463616
#> [148] 22.965092 6.071566 26.661079 8.507727 21.861490 4.080369 16.591689
#> [155] 21.538842 11.083046 28.605760 15.593220 11.755172 18.859646 11.800925
#> [162] 17.699618 15.509483 15.292181 26.996423 17.939004 17.781374 19.012161
#> [169] 37.496102 20.159652 11.661585 8.213422 16.667915 16.579756 21.344758
#> [176] 11.160335 15.938055 28.018352 20.680510 23.591328 25.033702 4.487452
#> [183] 16.279258 16.870933 17.903433 11.143347 27.501760 21.972031 22.635177
#> [190] 26.500992 10.372321 30.197561 17.952593 26.634735 16.791441 22.748896
#> [197] 17.079039 19.844833 5.764537 17.972267 15.562996 16.025733 27.503752
#> [204] 15.095785 35.730919 15.061169 22.883371 26.795652 13.811943 14.614956
#> [211] 12.823305 25.305974 15.383106 21.421555 14.243313 41.180148 11.505695
#> [218] 9.045411 23.815636 17.900713 20.845337 30.610957 17.285753 16.386652
#> [225] 20.317822 12.941494 19.095888 21.745429 17.251897 20.605982 20.032963
#> [232] 21.355682 16.458442 23.420039 21.154816 22.439702 21.499291 34.473354
#> [239] 14.272662 25.949047 15.003211 36.746875 27.974649 32.883280 29.422769
#> [246] 13.937602 30.703616 14.742476 25.841744 36.940533 24.546820 27.377814
