The goal of myTridge is to show that ridge esti- mators can be modified such that tuning parameters can be avoided altogether and apply the t-ridge estimator to generalized linear models.
You can install the released version of myTridge from CRAN with:
install.packages("myTridge")And the development version from GitHub with:
# install.packages("devtools")
devtools::install_github("mohan-zhao/myTridge")This is a basic example which shows you how to solve a common problem:
library(myTridge)
#>
#> Attaching package: 'myTridge'
#> The following object is masked from 'package:stats':
#>
#> qnorm
devtools::load_all()
#> Loading myTridge
## Here "gaussian" is from three most common cases for the distribution F: Gaussian,Poisson, and Binomial.
### X and y are matrix and vector under gaussian distribution in data folder
### dimension of X :100x300
### generate a tridge estimator
TridgeEst(X=X_gau,y=y_gau,family ="gaussian")
#> [1] 0.435434138 -0.542402671 -0.703389164 -0.116783578 -0.443919973
#> [6] -0.201824883 0.275614284 0.198815170 -0.461305878 -0.494063805
#> [11] -0.513223286 -0.475848113 0.610854162 0.383985408 -0.194239938
#> [16] -0.028196902 -0.479625361 0.003051664 -0.165866323 -0.302801263
#> [21] -0.205073372 -1.366762159 0.469795095 0.124910240 0.055181547
#> [26] -0.834859471 -1.296942226 0.219813801 0.513128814 1.122715807
#> [31] -0.126632707 0.336135222 -0.421935574 -0.451267031 -0.113397193
#> [36] -0.561064794 0.552938343 -0.830662244 1.173031263 -0.972557088
#> [41] -0.154689375 -0.547295786 0.412606294 -0.630529494 0.248807183
#> [46] -0.143354433 -0.420389228 -0.066785772 0.296212733 0.187035030
#> [51] 0.055354910 0.869052500 0.906788529 0.477479748 0.183840300
#> [56] -0.174177787 0.529047497 -0.266642172 1.132624361 0.525957352
#> [61] -0.107891433 -0.815619057 -0.750863586 -0.643414285 -0.697276246
#> [66] 0.588223135 -0.100251200 -0.148393890 0.221205326 0.063166487
#> [71] -0.176305088 -0.330173965 0.031343984 -0.489411513 -0.601025769
#> [76] 0.211400571 -0.029557977 0.512670029 -0.475256044 0.046102712
#> [81] -0.060074438 -0.186750052 0.158349686 -0.002166041 0.463157074
#> [86] 0.377157643 -0.183990468 -1.520083659 0.120500573 -1.155254655
#> [91] -0.644344839 -0.581244357 -0.822958998 -0.636998171 -0.588055726
#> [96] -0.594755317 0.381484308 -0.704021575 0.133980647 -0.864120358
#> [101] -0.977518616 0.382208028 -0.436140720 -0.670427483 0.814359013
#> [106] -0.317265432 -0.292138102 0.026661451 -0.053721634 -0.756754970
#> [111] 0.135462769 0.474419557 -0.212569357 -0.021277520 -1.561352588
#> [116] -0.342636827 0.302798788 0.458109376 -0.013620540 0.884626643
#> [121] 0.579490235 0.212774209 -1.386080844 0.654553745 0.688244371
#> [126] -0.199966536 -0.900188141 1.179636893 -0.154167893 -0.591960215
#> [131] 0.545749496 0.282244439 0.731096984 -0.281264569 0.205098756
#> [136] -0.318915421 0.021404801 0.541447353 0.382199983 1.207252588
#> [141] -0.019376199 -0.120550991 1.050806887 -0.795158551 0.397073049
#> [146] 0.956468699 -0.349859491 -1.226888067 -0.749090786 -0.784950707
#> [151] 0.862159646 1.486432151 0.081050504 0.753798206 0.321942917
#> [156] -1.423040281 -1.294156462 -0.656295390 0.882034602 -0.290903600
#> [161] 0.037308174 -0.594478457 -0.014301973 0.123331381 0.415147848
#> [166] -0.392759074 -0.277186550 1.089325374 -0.706149650 0.399536742
#> [171] 0.554292771 0.080510986 -0.207653301 -1.373227450 -0.485303196
#> [176] -0.250029095 -0.719641100 -0.292615012 -0.644358894 -0.479951936
#> [181] 0.249805869 0.055705310 0.679108634 0.717836167 0.471379045
#> [186] -0.795838762 -0.700326827 -0.950287613 0.067168649 0.587882488
#> [191] 0.454202539 0.618597273 -1.572675024 -0.139101727 -0.551426281
#> [196] 0.750324661 -0.657166596 0.602021083 -0.232022835 -0.651882563
#> [201] -0.809259265 0.032341449 0.809785691 0.953466356 -0.593133725
#> [206] -0.238697006 -0.301034654 -0.772756057 -0.272546173 -0.016734099
#> [211] 0.231752734 0.123135574 -1.044669515 -0.693127814 0.141369720
#> [216] 0.541776009 0.080244952 -0.022485278 1.378130967 -0.501444980
#> [221] 1.128714755 0.171416636 -0.005203042 -0.135794063 0.145569072
#> [226] -0.107519920 -1.020443081 -1.068863098 -0.344789180 0.608773529
#> [231] 1.064065200 -0.610265447 0.555392340 -0.255962808 -0.015109608
#> [236] 0.162386929 0.941692122 1.019103684 1.620249153 -0.156788570
#> [241] 0.308029297 -0.168199953 0.190067867 -0.738206267 0.155123306
#> [246] -0.784670407 0.626302014 -0.416093221 0.456584015 -0.325758419
#> [251] 0.801482408 0.029666834 -0.765385231 0.469953646 2.001295982
#> [256] -1.038311753 -0.114352854 0.203565866 -0.663036566 0.692850829
#> [261] -0.021270314 -0.362274951 1.573344440 0.411029439 1.137488294
#> [266] 1.658058765 -1.375586914 0.473300347 -0.324049428 -0.098248980
#> [271] 0.308497488 0.342381440 0.875308937 0.928327960 -1.118636181
#> [276] 0.495094033 -0.686222142 -0.162355222 0.065812371 0.413599100
#> [281] -0.052977115 -0.519116954 -0.127112804 -0.580698918 -0.458774705
#> [286] 0.537154615 0.347916939 -0.043180008 -0.517136687 0.639155809
#> [291] 0.824214247 0.132032128 0.111648901 0.495362538 0.286546588
#> [296] -0.438243070 -0.583215872 -0.272264542 0.397212267 0.206809383### You can also use genDataList() function in this package to generate a high dimensional matrix X and y randomly then generate a tridge estimator
list<-genDataList(n=100,mu=rep(0,300),p=300, rho=0.,beta=rnorm(300, mean = 0, sd = 1),SNR=NaN,family="binomial")
X<-list$normData
y<-list$y
myTridge::TridgeEst(X=X,y=y,family ="binomial")
#> [1] 0.1742622607 0.3191009469 0.0093121590 -0.1949104210 -0.1843115170
#> [6] 0.1245389425 0.1634347989 -0.0637737609 0.0616966545 -0.2104387973
#> [11] 0.3910355378 -0.1810758811 0.0418138846 -0.1603593964 -0.2009366218
#> [16] -0.1257762493 -0.1902926988 0.1032240779 -0.1000098659 0.0894510438
#> [21] -0.0940507402 -0.1976380276 0.2296428997 -0.2373061027 -0.0438537954
#> [26] 0.0428432155 -0.1258958670 -0.1959696511 0.0429692645 -0.0787258629
#> [31] 0.0457045071 -0.1202493554 -0.0912182075 0.1625519164 -0.0465362036
#> [36] -0.1957979683 -0.1677315856 0.1957948041 0.0176978755 0.1065602694
#> [41] -0.1823489638 -0.0028357159 -0.1756119501 -0.1085887790 -0.0630610689
#> [46] 0.0355119947 -0.1448641898 0.0338364479 -0.0205705270 0.0118439992
#> [51] 0.0088974227 -0.2253061268 -0.2508605632 0.0792863598 -0.0510659155
#> [56] 0.0339196714 0.0820692172 0.0377606479 0.4156613062 -0.1296265814
#> [61] -0.2458312850 -0.0274982844 -0.1703615161 0.1320414383 0.2074743033
#> [66] 0.1512273187 -0.0992810978 0.2933941129 -0.2445155374 0.0260490621
#> [71] -0.0657292981 -0.4173449410 0.1402532586 0.2166440797 0.1316518753
#> [76] -0.2947418366 -0.2151525623 0.0793468446 0.2834117946 0.0079416503
#> [81] -0.0917129069 -0.0153104226 -0.1851492513 0.3912882471 0.2481763252
#> [86] 0.1074528116 -0.2189501156 -0.0272523979 -0.0461639903 -0.1019339615
#> [91] 0.0396568118 0.0759616326 0.3023778533 -0.0335954492 0.2189125836
#> [96] -0.0699227687 -0.0706290587 -0.0416442498 -0.0325054600 0.0068737875
#> [101] -0.0294059509 -0.0640346355 -0.0145877808 -0.0277874675 0.1692637137
#> [106] -0.2402930089 0.3116630891 0.2125156116 -0.0673005341 -0.1617167043
#> [111] 0.0773546351 -0.1898196258 0.3185099174 0.1536020953 -0.1341985053
#> [116] -0.0962634847 0.0589921686 -0.3436839629 0.2497407649 -0.2476776766
#> [121] 0.1393726601 0.2517382716 -0.0818222147 -0.2543300382 -0.1323699753
#> [126] 0.3101739641 -0.2876282930 0.1505226138 0.0212833040 -0.2079080382
#> [131] 0.1550813882 0.1092389285 0.0703084236 -0.1402424156 0.4718760559
#> [136] -0.4923345343 0.4099733953 0.0482234897 -0.0216056046 -0.0255285959
#> [141] -0.3044152427 0.1542531743 0.0267863313 0.1200243643 -0.1084016515
#> [146] 0.2109573498 -0.1077510415 -0.0841015835 0.1610001274 -0.0527786502
#> [151] 0.1505655873 -0.1126193327 0.0366120646 -0.2752248042 0.2109139614
#> [156] 0.1284026476 0.0286049987 -0.3165258979 -0.0434796751 -0.0322696274
#> [161] -0.1276761556 0.0116378277 -0.0043529238 0.0872380088 -0.2953478019
#> [166] 0.0873716782 0.1143213074 0.0917548135 0.2560462795 0.4315721751
#> [171] 0.4335258060 0.1861229835 0.0263337522 -0.1357868169 -0.0803769517
#> [176] 0.0151030359 -0.2401370546 0.1874362910 -0.2500732348 0.0371410126
#> [181] 0.3460885014 0.2356033165 0.0700295608 0.1297730829 0.0295646092
#> [186] 0.1609293653 -0.2546558731 0.1324705375 -0.3753183194 -0.2138414065
#> [191] -0.0700234796 -0.2377774067 0.4065337841 -0.1091429647 0.0964099527
#> [196] 0.3713564518 0.2307610887 -0.2278400913 0.3174386336 0.0580932622
#> [201] 0.1208024238 0.3615600685 -0.1305069117 0.1005404146 0.4713170860
#> [206] -0.2159416554 -0.2135509011 0.0752733260 -0.0406227537 -0.1266245375
#> [211] 0.3541791867 -0.0001155565 -0.0498129812 0.1354741406 -0.0220537864
#> [216] -0.2687720413 -0.4245931031 -0.2928332719 -0.5512629928 0.0804008778
#> [221] -0.0520899325 0.5039033359 0.0429015915 -0.2063450516 -0.1873786620
#> [226] -0.1042031158 -0.1311979299 0.1315261103 -0.0961645169 0.1187664341
#> [231] 0.1604854634 -0.0180572591 0.0886660840 0.2624720394 -0.0529840423
#> [236] 0.1630566153 0.0375786659 -0.2541698964 0.1110519468 0.0140291700
#> [241] -0.2179486955 0.5945942453 -0.0956344756 -0.0114380331 0.1181095542
#> [246] 0.5340650794 -0.1126003950 0.0153243390 0.3709797059 -0.2490275892
#> [251] 0.1316063778 -0.1621880340 -0.2144768572 0.1180748540 0.3299257325
#> [256] -0.4158593466 -0.1740438787 -0.0301533419 -0.0393179347 0.3081629706
#> [261] -0.1417073492 0.4961918393 0.1468977586 -0.0745632176 0.2044623169
#> [266] -0.0423533017 0.0313644679 -0.1030280558 0.1215989164 -0.0613979825
#> [271] 0.2193988681 0.4521512234 -0.2206316591 0.1443564500 0.2372145775
#> [276] 0.2497594399 0.1306447768 0.0405369483 0.2429653742 -0.3789270410
#> [281] -0.4405177872 -0.0582374786 0.3851644049 -0.0753364184 0.2730625286
#> [286] -0.0004251335 -0.0323680225 0.0137853977 0.3083740167 -0.5005501954
#> [291] 0.2389064793 0.3337465343 0.2702493663 0.2527879805 -0.0980062556
#> [296] -0.1386420549 -0.3785498698 -0.1573617483 -0.6577706130 -0.1705910319#> run 1 out of 5 runs
#> -> Perform the K-fold cross validation pipeline... -> compute T-ridge estimators... -> compute errors... run 2 out of 5 runs
#> -> Perform the K-fold cross validation pipeline... -> compute T-ridge estimators... -> compute errors... run 3 out of 5 runs
#> -> Perform the K-fold cross validation pipeline... -> compute T-ridge estimators... -> compute errors... run 4 out of 5 runs
#> -> Perform the K-fold cross validation pipeline... -> compute T-ridge estimators... -> compute errors... run 5 out of 5 runs
#> -> Perform the K-fold cross validation pipeline... -> compute T-ridge estimators... -> compute errors...
|
(n,p,k,K)=(100,300,0,10) |
|||||
|
(\frac{||X\hat{\beta}{T-ridge} - X\beta^{*}||{2}}{||X\beta^{*}||_{2}}) |
|
(\frac{||\hat{\beta}{T-ridge} - \beta^{*}||{2}}{||\beta^{*}||_{2}}) |
|||
|---|---|---|---|---|---|
|
T-ridge |
K-fold CV |
|
T-ridge |
K-fold CV |
|
|
Case : gaussian |
|||||
|
Mean relative errors |
0.32 |
0.53 |
|
0.38 |
0.6 |
You’ll still need to render README.Rmd regularly, to keep README.md
up-to-date.