predict_ridge.Rd
Title
predict_ridge(obj, newx, cv = TRUE)
n <- 100 ; p <- 10
X <- matrix(rnorm(n * p), n, p) # no intercept!
y <- rnorm(n)
fit_obj <- after::fit_ridge(X, y)
n_test <- 10
predict_ridge(fit_obj, newx=matrix(rnorm(n_test * p), n_test, p),
cv=TRUE)
#> [1] -0.1184286 -0.1184286 -0.1184286 -0.1184286 -0.1184286 -0.1184286
#> [7] -0.1184286 -0.1184286 -0.1184286 -0.1184286
predict_ridge(fit_obj, newx=matrix(rnorm(n_test * p), n_test, p),
cv=FALSE)
#> 1e-10 1.59228279334109e-10 2.53536449397012e-10
#> [1,] 0.433902164 0.433902164 0.433902164
#> [2,] -0.259458032 -0.259458032 -0.259458032
#> [3,] -0.331969832 -0.331969832 -0.331969832
#> [4,] 0.752461066 0.752461066 0.752461066
#> [5,] 0.002910314 0.002910314 0.002910314
#> [6,] -0.332795665 -0.332795665 -0.332795665
#> [7,] -0.151044047 -0.151044047 -0.151044047
#> [8,] -0.005174801 -0.005174801 -0.005174801
#> [9,] -0.016006877 -0.016006877 -0.016006877
#> [10,] 0.108479218 0.108479218 0.108479218
#> 4.03701725859655e-10 6.42807311728432e-10 1.02353102189903e-09
#> [1,] 0.433902164 0.433902164 0.433902164
#> [2,] -0.259458032 -0.259458032 -0.259458032
#> [3,] -0.331969832 -0.331969832 -0.331969832
#> [4,] 0.752461066 0.752461066 0.752461066
#> [5,] 0.002910314 0.002910314 0.002910314
#> [6,] -0.332795665 -0.332795665 -0.332795665
#> [7,] -0.151044047 -0.151044047 -0.151044047
#> [8,] -0.005174801 -0.005174801 -0.005174801
#> [9,] -0.016006877 -0.016006877 -0.016006877
#> [10,] 0.108479218 0.108479218 0.108479218
#> 1.62975083462065e-09 2.59502421139973e-09 4.13201240011533e-09
#> [1,] 0.433902164 0.433902164 0.433902164
#> [2,] -0.259458032 -0.259458032 -0.259458032
#> [3,] -0.331969832 -0.331969832 -0.331969832
#> [4,] 0.752461066 0.752461066 0.752461066
#> [5,] 0.002910314 0.002910314 0.002910314
#> [6,] -0.332795665 -0.332795665 -0.332795665
#> [7,] -0.151044047 -0.151044047 -0.151044047
#> [8,] -0.005174801 -0.005174801 -0.005174801
#> [9,] -0.016006877 -0.016006877 -0.016006877
#> [10,] 0.108479218 0.108479218 0.108479218
#> 6.57933224657568e-09 1.04761575278967e-08 1.66810053720006e-08
#> [1,] 0.433902164 0.433902164 0.433902164
#> [2,] -0.259458032 -0.259458032 -0.259458032
#> [3,] -0.331969832 -0.331969832 -0.331969832
#> [4,] 0.752461066 0.752461066 0.752461066
#> [5,] 0.002910314 0.002910314 0.002910314
#> [6,] -0.332795665 -0.332795665 -0.332795665
#> [7,] -0.151044047 -0.151044047 -0.151044047
#> [8,] -0.005174801 -0.005174801 -0.005174801
#> [9,] -0.016006877 -0.016006877 -0.016006877
#> [10,] 0.108479218 0.108479218 0.108479218
#> 2.65608778294668e-08 4.2292428743895e-08 6.73415065775083e-08
#> [1,] 0.433902164 0.433902164 0.433902164
#> [2,] -0.259458032 -0.259458032 -0.259458032
#> [3,] -0.331969832 -0.331969831 -0.331969831
#> [4,] 0.752461066 0.752461066 0.752461065
#> [5,] 0.002910314 0.002910314 0.002910314
#> [6,] -0.332795665 -0.332795665 -0.332795665
#> [7,] -0.151044047 -0.151044047 -0.151044047
#> [8,] -0.005174801 -0.005174801 -0.005174801
#> [9,] -0.016006877 -0.016006877 -0.016006877
#> [10,] 0.108479218 0.108479217 0.108479217
#> 1.07226722201032e-07 1.70735264747069e-07 2.71858824273294e-07
#> [1,] 0.433902163 0.433902163 0.433902162
#> [2,] -0.259458032 -0.259458032 -0.259458032
#> [3,] -0.331969831 -0.331969831 -0.331969831
#> [4,] 0.752461065 0.752461064 0.752461063
#> [5,] 0.002910314 0.002910314 0.002910314
#> [6,] -0.332795665 -0.332795664 -0.332795664
#> [7,] -0.151044047 -0.151044047 -0.151044047
#> [8,] -0.005174801 -0.005174801 -0.005174802
#> [9,] -0.016006877 -0.016006878 -0.016006878
#> [10,] 0.108479217 0.108479217 0.108479216
#> 4.32876128108306e-07 6.8926121043497e-07 1.09749876549306e-06
#> [1,] 0.433902161 0.433902159 0.433902155
#> [2,] -0.259458031 -0.259458031 -0.259458031
#> [3,] -0.331969830 -0.331969829 -0.331969828
#> [4,] 0.752461061 0.752461058 0.752461053
#> [5,] 0.002910313 0.002910313 0.002910312
#> [6,] -0.332795664 -0.332795663 -0.332795662
#> [7,] -0.151044047 -0.151044047 -0.151044047
#> [8,] -0.005174802 -0.005174802 -0.005174803
#> [9,] -0.016006878 -0.016006878 -0.016006879
#> [10,] 0.108479216 0.108479214 0.108479212
#> 1.74752840000768e-06 2.78255940220713e-06 4.43062145758388e-06
#> [1,] 0.433902150 0.433902141 0.433902128
#> [2,] -0.259458030 -0.259458029 -0.259458027
#> [3,] -0.331969825 -0.331969821 -0.331969815
#> [4,] 0.752461044 0.752461032 0.752461011
#> [5,] 0.002910311 0.002910309 0.002910306
#> [6,] -0.332795660 -0.332795658 -0.332795654
#> [7,] -0.151044046 -0.151044046 -0.151044045
#> [8,] -0.005174804 -0.005174806 -0.005174809
#> [9,] -0.016006880 -0.016006881 -0.016006884
#> [10,] 0.108479209 0.108479204 0.108479196
#> 7.05480231071865e-06 1.12332403297803e-05 1.78864952905743e-05
#> [1,] 0.433902106 0.433902072 0.433902018
#> [2,] -0.259458024 -0.259458020 -0.259458013
#> [3,] -0.331969806 -0.331969790 -0.331969766
#> [4,] 0.752460979 0.752460927 0.752460844
#> [5,] 0.002910301 0.002910293 0.002910281
#> [6,] -0.332795647 -0.332795637 -0.332795620
#> [7,] -0.151044044 -0.151044042 -0.151044039
#> [8,] -0.005174814 -0.005174822 -0.005174834
#> [9,] -0.016006888 -0.016006894 -0.016006903
#> [10,] 0.108479183 0.108479163 0.108479130
#> 2.8480358684358e-05 4.53487850812858e-05 7.22080901838546e-05
#> [1,] 0.433901931 0.433901792 0.433901572
#> [2,] -0.259458002 -0.259457985 -0.259457956
#> [3,] -0.331969726 -0.331969664 -0.331969565
#> [4,] 0.752460713 0.752460503 0.752460170
#> [5,] 0.002910262 0.002910231 0.002910182
#> [6,] -0.332795594 -0.332795552 -0.332795485
#> [7,] -0.151044034 -0.151044026 -0.151044013
#> [8,] -0.005174854 -0.005174885 -0.005174934
#> [9,] -0.016006919 -0.016006943 -0.016006982
#> [10,] 0.108479078 0.108478995 0.108478864
#> 0.000114975699539774 0.000183073828029537 0.000291505306282518
#> [1,] 0.433901222 0.433900663 0.433899775
#> [2,] -0.259457912 -0.259457841 -0.259457728
#> [3,] -0.331969407 -0.331969155 -0.331968755
#> [4,] 0.752459639 0.752458794 0.752457448
#> [5,] 0.002910103 0.002909979 0.002909780
#> [6,] -0.332795378 -0.332795209 -0.332794939
#> [7,] -0.151043993 -0.151043961 -0.151043910
#> [8,] -0.005175013 -0.005175138 -0.005175337
#> [9,] -0.016007044 -0.016007143 -0.016007301
#> [10,] 0.108478654 0.108478320 0.108477789
#> 0.000464158883361278 0.000739072203352578 0.001176811952435
#> [1,] 0.433898359 0.433896106 0.433892517
#> [2,] -0.259457548 -0.259457261 -0.259456804
#> [3,] -0.331968117 -0.331967101 -0.331965484
#> [4,] 0.752455305 0.752451893 0.752446460
#> [5,] 0.002909464 0.002908960 0.002908158
#> [6,] -0.332794508 -0.332793823 -0.332792733
#> [7,] -0.151043829 -0.151043700 -0.151043495
#> [8,] -0.005175655 -0.005176161 -0.005176966
#> [9,] -0.016007551 -0.016007950 -0.016008586
#> [10,] 0.108476942 0.108475595 0.108473449
#> 0.00187381742286038 0.00298364724028334 0.00475081016210279
#> [1,] 0.433886804 0.433877707 0.433863222
#> [2,] -0.259456077 -0.259454919 -0.259453075
#> [3,] -0.331962909 -0.331958810 -0.331952282
#> [4,] 0.752437809 0.752424035 0.752402104
#> [5,] 0.002906881 0.002904848 0.002901611
#> [6,] -0.332790996 -0.332788231 -0.332783829
#> [7,] -0.151043168 -0.151042647 -0.151041818
#> [8,] -0.005178248 -0.005180289 -0.005183539
#> [9,] -0.016009598 -0.016011210 -0.016013776
#> [10,] 0.108470032 0.108464592 0.108455930
#> 0.00756463327554629 0.0120450354025878 0.0191791026167248
#> [1,] 0.433840161 0.433803445 0.433744994
#> [2,] -0.259450140 -0.259445466 -0.259438024
#> [3,] -0.331941889 -0.331925343 -0.331899002
#> [4,] 0.752367185 0.752311591 0.752223087
#> [5,] 0.002896458 0.002888253 0.002875191
#> [6,] -0.332776820 -0.332765660 -0.332747895
#> [7,] -0.151040497 -0.151038395 -0.151035048
#> [8,] -0.005188714 -0.005196954 -0.005210071
#> [9,] -0.016017861 -0.016024366 -0.016034722
#> [10,] 0.108442140 0.108420184 0.108385233
#> 0.0305385550883341 0.0486260158006535 0.0774263682681128
#> [1,] 0.433651955 0.433503885 0.433268308
#> [2,] -0.259426177 -0.259407318 -0.259377299
#> [3,] -0.331857074 -0.331790348 -0.331684194
#> [4,] 0.752082203 0.751857981 0.751501217
#> [5,] 0.002854401 0.002821315 0.002768683
#> [6,] -0.332719615 -0.332674606 -0.332602994
#> [7,] -0.151029720 -0.151021239 -0.151007742
#> [8,] -0.005230952 -0.005264187 -0.005317074
#> [9,] -0.016051208 -0.016077451 -0.016119218
#> [10,] 0.108329602 0.108241075 0.108100246
#> 0.123284673944206 0.196304065004027 0.312571584968824 0.497702356433211
#> [1,] 0.432893687 0.432298411 0.431353658 0.429857137
#> [2,] -0.259329529 -0.259253537 -0.259132719 -0.258940799
#> [3,] -0.331515396 -0.331247204 -0.330821634 -0.330147703
#> [4,] 0.750933812 0.750032023 0.748600363 0.746331444
#> [5,] 0.002685000 0.002552063 0.002341170 0.002007334
#> [6,] -0.332489101 -0.332308092 -0.332020737 -0.331565355
#> [7,] -0.150986269 -0.150952123 -0.150897867 -0.150811766
#> [8,] -0.005401201 -0.005534942 -0.005747358 -0.006084226
#> [9,] -0.016185670 -0.016291351 -0.016459296 -0.016725877
#> [10,] 0.107876345 0.107520681 0.106956512 0.106063601
#> 0.792482898353919 1.26185688306602 2.00923300256505 3.19926713779738
#> [1,] 0.427493794 0.4237793726 0.4179850639 0.409050540
#> [2,] -0.258636365 -0.2581545275 -0.2573945876 -0.256202647
#> [3,] -0.329083880 -0.3274130468 -0.3248094727 -0.320801757
#> [4,] 0.742745519 0.7371026999 0.7282834453 0.714644905
#> [5,] 0.001480693 0.0006543569 -0.0006313642 -0.002606098
#> [6,] -0.330845696 -0.3297133441 -0.3279437402 -0.325207193
#> [7,] -0.150675398 -0.1504600912 -0.1501218299 -0.149594521
#> [8,] -0.006617195 -0.0074572509 -0.0087734641 -0.010816440
#> [9,] -0.017148240 -0.0178154344 -0.0188643857 -0.020501024
#> [10,] 0.104655381 0.1024468079 0.0990131341 0.093746716
#> 5.09413801481639 8.11130830789686 12.9154966501488 20.5651230834865
#> [1,] 0.395515750 0.375546103 0.34718136 0.30894114
#> [2,] -0.254349216 -0.251505388 -0.24722939 -0.24098957
#> [3,] -0.314746660 -0.305849364 -0.29329056 -0.27651881
#> [4,] 0.693893392 0.663080584 0.61892840 0.55873412
#> [5,] -0.005580173 -0.009931884 -0.01604523 -0.02418089
#> [6,] -0.321042311 -0.314851162 -0.30595098 -0.29372071
#> [7,] -0.148782455 -0.147555194 -0.14575297 -0.14321752
#> [8,] -0.013941139 -0.018612583 -0.02535844 -0.03461404
#> [9,] -0.023023670 -0.026837098 -0.03242793 -0.04024889
#> [10,] 0.085835329 0.074314826 0.05828065 0.03732522
#> 32.7454916287773 52.1400828799967 83.0217568131974 132.194114846603
#> [1,] 0.26073839 0.20464992 0.14484793 0.08646813
#> [2,] -0.23226451 -0.22075258 -0.20665526 -0.19087144
#> [3,] -0.25567770 -0.23194665 -0.20745432 -0.18463517
#> [4,] 0.48189344 0.39143503 0.29430520 0.19956702
#> [5,] -0.03431293 -0.04603249 -0.05860275 -0.07111835
#> [6,] -0.27784180 -0.25854737 -0.23674404 -0.21393389
#> [7,] -0.13986532 -0.13579919 -0.13139282 -0.12722734
#> [8,] -0.04643003 -0.06014597 -0.07433238 -0.08725995
#> [9,] -0.05046532 -0.06262565 -0.07552760 -0.08757838
#> [10,] 0.01210890 -0.01532451 -0.04197533 -0.06502979
#> 210.490414451202 335.160265093883 533.66992312063 849.753435908644
#> [1,] 0.03406430 -0.009486898 -0.043285276 -0.06803584
#> [2,] -0.17487508 -0.160228341 -0.148024449 -0.13863873
#> [3,] -0.16536448 -0.150435266 -0.139638185 -0.13221069
#> [4,] 0.11535090 0.046497766 -0.005937359 -0.04366326
#> [5,] -0.08267834 -0.092569644 -0.100430882 -0.10628560
#> [6,] -0.19193590 -0.172428627 -0.156477792 -0.14433783
#> [7,] -0.12384119 -0.121473107 -0.120025387 -0.11923009
#> [8,] -0.09766328 -0.105179517 -0.110186418 -0.11335442
#> [9,] -0.09750741 -0.104845820 -0.109842802 -0.11307055
#> [10,] -0.08293562 -0.095649677 -0.104104647 -0.10950235
#> 1353.04777457981 2154.43469003189 3430.46928631491 5462.27721768434
#> [1,] -0.08534109 -0.09702829 -0.10472914 -0.1097186
#> [2,] -0.13185983 -0.12718448 -0.12406224 -0.1220220
#> [3,] -0.12727098 -0.12405631 -0.12199242 -0.1206784
#> [4,] -0.06966283 -0.08703393 -0.09839393 -0.1057169
#> [5,] -0.11042441 -0.11323888 -0.11510125 -0.1163111
#> [6,] -0.13561922 -0.12962460 -0.12562820 -0.1230193
#> [7,] -0.11882433 -0.11862559 -0.11852931 -0.1184820
#> [8,] -0.11530801 -0.11650311 -0.11723528 -0.1176861
#> [9,] -0.11509788 -0.11635707 -0.11713758 -0.1176223
#> [10,] -0.11287783 -0.11497310 -0.11627305 -0.1170813
#> 8697.49002617783 13848.8637139387 22051.3073990304 35111.9173421513
#> [1,] -0.1129155 -0.1149490 -0.1162365 -0.1170491
#> [2,] -0.1207078 -0.1198690 -0.1193368 -0.1190004
#> [3,] -0.1198461 -0.1193206 -0.1189895 -0.1187812
#> [4,] -0.1103933 -0.1133614 -0.1152380 -0.1164215
#> [5,] -0.1170875 -0.1175818 -0.1178950 -0.1180928
#> [6,] -0.1213397 -0.1202681 -0.1195883 -0.1191587
#> [7,] -0.1184581 -0.1184455 -0.1184385 -0.1184346
#> [8,] -0.1179652 -0.1181388 -0.1182470 -0.1183148
#> [9,] -0.1179241 -0.1181126 -0.1182304 -0.1183043
#> [10,] -0.1175852 -0.1179000 -0.1180971 -0.1182206
#> 55908.1018251222 89021.5085445039 141747.41629268 225701.971963392
#> [1,] -0.1175612 -0.1178834 -0.1180860 -0.1182134
#> [2,] -0.1187882 -0.1186547 -0.1185707 -0.1185178
#> [3,] -0.1186501 -0.1185678 -0.1185160 -0.1184835
#> [4,] -0.1171668 -0.1176356 -0.1179304 -0.1181156
#> [5,] -0.1182174 -0.1182958 -0.1183452 -0.1183762
#> [6,] -0.1188878 -0.1187173 -0.1186100 -0.1185426
#> [7,] -0.1184322 -0.1184308 -0.1184300 -0.1184294
#> [8,] -0.1183572 -0.1183838 -0.1184004 -0.1184109
#> [9,] -0.1183506 -0.1183796 -0.1183978 -0.1184093
#> [10,] -0.1182980 -0.1183466 -0.1183771 -0.1183963
#> 359381.366380463 572236.765935022 911162.756115487 1450828.77849594
#> [1,] -0.1182934 -0.1183437 -0.1183753 -0.1183951
#> [2,] -0.1184847 -0.1184638 -0.1184507 -0.1184425
#> [3,] -0.1184631 -0.1184502 -0.1184422 -0.1184371
#> [4,] -0.1182320 -0.1183051 -0.1183510 -0.1183799
#> [5,] -0.1183957 -0.1184079 -0.1184156 -0.1184204
#> [6,] -0.1185002 -0.1184736 -0.1184568 -0.1184463
#> [7,] -0.1184291 -0.1184289 -0.1184288 -0.1184287
#> [8,] -0.1184175 -0.1184216 -0.1184242 -0.1184258
#> [9,] -0.1184165 -0.1184210 -0.1184238 -0.1184256
#> [10,] -0.1184083 -0.1184158 -0.1184206 -0.1184236
#> 2310129.70008316 3678379.77182862 5857020.81805667 9326033.46883218
#> [1,] -0.1184075 -0.1184154 -0.1184203 -0.1184234
#> [2,] -0.1184373 -0.1184341 -0.1184320 -0.1184307
#> [3,] -0.1184339 -0.1184319 -0.1184307 -0.1184299
#> [4,] -0.1183980 -0.1184094 -0.1184165 -0.1184210
#> [5,] -0.1184235 -0.1184254 -0.1184266 -0.1184273
#> [6,] -0.1184397 -0.1184356 -0.1184330 -0.1184313
#> [7,] -0.1184287 -0.1184286 -0.1184286 -0.1184286
#> [8,] -0.1184269 -0.1184275 -0.1184279 -0.1184282
#> [9,] -0.1184267 -0.1184274 -0.1184278 -0.1184281
#> [10,] -0.1184254 -0.1184266 -0.1184273 -0.1184278
#> 14849682.6225447 23644894.1264541 37649358.0679246 59948425.0318942
#> [1,] -0.1184253 -0.1184265 -0.1184273 -0.1184278
#> [2,] -0.1184299 -0.1184294 -0.1184291 -0.1184289
#> [3,] -0.1184294 -0.1184291 -0.1184289 -0.1184288
#> [4,] -0.1184238 -0.1184256 -0.1184267 -0.1184274
#> [5,] -0.1184278 -0.1184281 -0.1184283 -0.1184284
#> [6,] -0.1184303 -0.1184297 -0.1184293 -0.1184290
#> [7,] -0.1184286 -0.1184286 -0.1184286 -0.1184286
#> [8,] -0.1184283 -0.1184284 -0.1184285 -0.1184285
#> [9,] -0.1184283 -0.1184284 -0.1184285 -0.1184285
#> [10,] -0.1184281 -0.1184283 -0.1184284 -0.1184285
#> 95454845.6661833 151991108.295293 242012826.479438 385352859.371052
#> [1,] -0.1184281 -0.1184283 -0.1184284 -0.1184285
#> [2,] -0.1184288 -0.1184287 -0.1184287 -0.1184286
#> [3,] -0.1184287 -0.1184287 -0.1184286 -0.1184286
#> [4,] -0.1184278 -0.1184281 -0.1184283 -0.1184284
#> [5,] -0.1184285 -0.1184285 -0.1184285 -0.1184285
#> [6,] -0.1184288 -0.1184287 -0.1184287 -0.1184286
#> [7,] -0.1184286 -0.1184286 -0.1184286 -0.1184286
#> [8,] -0.1184285 -0.1184286 -0.1184286 -0.1184286
#> [9,] -0.1184285 -0.1184286 -0.1184286 -0.1184286
#> [10,] -0.1184285 -0.1184285 -0.1184285 -0.1184286
#> 613590727.341319 977009957.299225 1555676143.93047 2477076355.99171
#> [1,] -0.1184285 -0.1184285 -0.1184285 -0.1184286
#> [2,] -0.1184286 -0.1184286 -0.1184286 -0.1184286
#> [3,] -0.1184286 -0.1184286 -0.1184286 -0.1184286
#> [4,] -0.1184285 -0.1184285 -0.1184285 -0.1184286
#> [5,] -0.1184286 -0.1184286 -0.1184286 -0.1184286
#> [6,] -0.1184286 -0.1184286 -0.1184286 -0.1184286
#> [7,] -0.1184286 -0.1184286 -0.1184286 -0.1184286
#> [8,] -0.1184286 -0.1184286 -0.1184286 -0.1184286
#> [9,] -0.1184286 -0.1184286 -0.1184286 -0.1184286
#> [10,] -0.1184286 -0.1184286 -0.1184286 -0.1184286
#> 3944206059.43765 6280291441.83427 1e+10
#> [1,] -0.1184286 -0.1184286 -0.1184286
#> [2,] -0.1184286 -0.1184286 -0.1184286
#> [3,] -0.1184286 -0.1184286 -0.1184286
#> [4,] -0.1184286 -0.1184286 -0.1184286
#> [5,] -0.1184286 -0.1184286 -0.1184286
#> [6,] -0.1184286 -0.1184286 -0.1184286
#> [7,] -0.1184286 -0.1184286 -0.1184286
#> [8,] -0.1184286 -0.1184286 -0.1184286
#> [9,] -0.1184286 -0.1184286 -0.1184286
#> [10,] -0.1184286 -0.1184286 -0.1184286