R Under development (unstable) (2024-03-05 r86054 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > #### > suppressMessages(library(cobs)) > > source(system.file("util.R", package = "cobs")) > (doExtra <- doExtras()) [1] FALSE > source(system.file("test-tools-1.R", package="Matrix", mustWork=TRUE)) Loading required package: tools > showProc.time() Time (user system elapsed): 0 0 0 > > options(digits = 5) > if(!dev.interactive(orNone=TRUE)) pdf("ex2.pdf") > > set.seed(821) > x <- round(sort(rnorm(200)), 3) # rounding -> multiple values > sum(duplicated(x)) # 9 [1] 3 > y <- (fx <- exp(-x)) + rt(200,4)/4 > summaryCobs(cxy <- cobs(x,y, "decrease")) qbsks2(): Performing general knot selection ... Deleting unnecessary knots ... List of 24 $ call : language cobs(x = x, y = y, constraint = "decrease") $ tau : num 0.5 $ degree : num 2 $ constraint : chr "decrease" $ ic : chr "AIC" $ pointwise : NULL $ select.knots : logi TRUE $ select.lambda: logi FALSE $ x : num [1:200] -2.56 -2.14 -1.9 -1.81 -1.78 ... $ y : num [1:200] 12.7 8.24 6.67 5.88 6.42 ... $ resid : num [1:200] 0.72 -0.149 0 -0.195 0.545 ... $ fitted : num [1:200] 11.98 8.39 6.67 6.07 5.87 ... $ coef : num [1:5] 11.9769 3.5917 1.0544 0.0295 0.0295 $ knots : num [1:4] -2.557 -0.813 0.418 2.573 $ k0 : num 5 $ k : num 5 $ x.ps :Formal class 'matrix.csr' [package "SparseM"] with 4 slots $ SSy : num 488 $ lambda : num 0 $ icyc : int 11 $ ifl : int 1 $ pp.lambda : NULL $ pp.sic : NULL $ i.mask : NULL cb.lo ci.lo fit ci.up cb.up 1 11.4448128 11.6875576 11.976923 12.26629 12.50903 2 10.9843366 11.2126114 11.484728 11.75684 11.98512 3 10.5344633 10.7489871 11.004712 11.26044 11.47496 4 10.0951784 10.2966768 10.536874 10.77707 10.97857 5 9.6664684 9.8556730 10.081215 10.30676 10.49596 6 9.2483213 9.4259693 9.637736 9.84950 10.02715 7 8.8407282 9.0075609 9.206435 9.40531 9.57214 8 8.4436848 8.6004453 8.787313 8.97418 9.13094 9 8.0571928 8.2046236 8.380369 8.55612 8.70355 10 7.6812627 7.8201015 7.985605 8.15111 8.28995 11 7.3159159 7.4468904 7.603020 7.75915 7.89012 12 6.9611870 7.0850095 7.232613 7.38022 7.50404 13 6.6171269 6.7344861 6.874385 7.01428 7.13164 14 6.2838041 6.3953578 6.528336 6.66131 6.77287 15 5.9613061 6.0676719 6.194466 6.32126 6.42763 16 5.6497392 5.7514863 5.872775 5.99406 6.09581 17 5.3492272 5.4468683 5.563262 5.67966 5.77730 18 5.0599086 5.1538933 5.265928 5.37796 5.47195 19 4.7819325 4.8726424 4.980774 5.08891 5.17961 20 4.5154542 4.6031999 4.707798 4.81240 4.90014 21 4.2606295 4.3456507 4.447001 4.54835 4.63337 22 4.0176099 4.1000771 4.198383 4.29669 4.37916 23 3.7865383 3.8665567 3.961943 4.05733 4.13735 24 3.5675443 3.6451602 3.737683 3.83021 3.90782 25 3.3607413 3.4359491 3.525601 3.61525 3.69046 26 3.1662231 3.2389744 3.325698 3.41242 3.48517 27 2.9840608 3.0542750 3.137974 3.22167 3.29189 28 2.8142997 2.8818753 2.962429 3.04298 3.11056 29 2.6569546 2.7217833 2.799063 2.87634 2.94117 30 2.5120031 2.5739870 2.647875 2.72176 2.78375 31 2.3793776 2.4384496 2.508867 2.57928 2.63836 32 2.2589520 2.3151025 2.382037 2.44897 2.50512 33 2.1505256 2.2038366 2.267386 2.33094 2.38425 34 2.0538038 2.1044916 2.164914 2.22534 2.27602 35 1.9677723 2.0162522 2.074043 2.13183 2.18031 36 1.8846710 1.9316617 1.987677 2.04369 2.09068 37 1.8024456 1.8486425 1.903712 1.95878 2.00498 38 1.7213655 1.7673410 1.822146 1.87695 1.92293 39 1.6417290 1.6879196 1.742982 1.79804 1.84423 40 1.5638322 1.6105393 1.666217 1.72189 1.76860 41 1.4879462 1.5353474 1.591852 1.64836 1.69576 42 1.4143040 1.4624707 1.519888 1.57731 1.62547 43 1.3430975 1.3920136 1.450324 1.50864 1.55755 44 1.2744792 1.3240589 1.383161 1.44226 1.49184 45 1.2085658 1.2586702 1.318397 1.37812 1.42823 46 1.1454438 1.1958944 1.256034 1.31617 1.36662 47 1.0851730 1.1357641 1.196072 1.25638 1.30697 48 1.0277900 1.0782992 1.138509 1.19872 1.24923 49 0.9733099 1.0235079 1.083347 1.14319 1.19338 50 0.9217268 0.9713870 1.030585 1.08978 1.13944 51 0.8730129 0.9219214 0.980223 1.03852 1.08743 52 0.8271160 0.8750827 0.932262 0.98944 1.03741 53 0.7839554 0.8308269 0.886700 0.94257 0.98945 54 0.7434158 0.7890916 0.843540 0.89799 0.94366 55 0.7053406 0.7497913 0.802779 0.85577 0.90022 56 0.6695233 0.7128138 0.764419 0.81602 0.85931 57 0.6357022 0.6780170 0.728459 0.77890 0.82121 58 0.6035616 0.6452289 0.694899 0.74457 0.78624 59 0.5724566 0.6139693 0.663455 0.71294 0.75445 60 0.5410437 0.5829503 0.632905 0.68286 0.72477 61 0.5094333 0.5521679 0.603110 0.65405 0.69679 62 0.4778879 0.5217649 0.574069 0.62637 0.67025 63 0.4466418 0.4918689 0.545782 0.59970 0.64492 64 0.4158910 0.4625864 0.518250 0.57391 0.62061 65 0.3857918 0.4340022 0.491472 0.54894 0.59715 66 0.3564634 0.4061813 0.465448 0.52471 0.57443 67 0.3279928 0.3791711 0.440179 0.50119 0.55236 68 0.3004403 0.3530042 0.415663 0.47832 0.53089 69 0.2738429 0.3277009 0.391903 0.45610 0.50996 70 0.2482184 0.3032707 0.368896 0.43452 0.48957 71 0.2235676 0.2797141 0.346644 0.41357 0.46972 72 0.1998762 0.2570233 0.325146 0.39327 0.45042 73 0.1771158 0.2351830 0.304402 0.37362 0.43169 74 0.1552452 0.2141706 0.284413 0.35466 0.41358 75 0.1342101 0.1939567 0.265178 0.33640 0.39615 76 0.1139444 0.1745054 0.246697 0.31889 0.37945 77 0.0943704 0.1557743 0.228971 0.30217 0.36357 78 0.0753996 0.1377153 0.211999 0.28628 0.34860 79 0.0569347 0.1202755 0.195781 0.27129 0.33463 80 0.0388708 0.1033980 0.180318 0.25724 0.32177 81 0.0210989 0.0870233 0.165609 0.24419 0.31012 82 0.0035089 0.0710917 0.151654 0.23222 0.29980 83 -0.0140062 0.0555449 0.138454 0.22136 0.29091 84 -0.0315470 0.0403283 0.126008 0.21169 0.28356 85 -0.0492034 0.0253928 0.114316 0.20324 0.27783 86 -0.0670524 0.0106968 0.103378 0.19606 0.27381 87 -0.0851561 -0.0037936 0.093195 0.19018 0.27155 88 -0.1035613 -0.0181039 0.083766 0.18564 0.27109 89 -0.1223000 -0.0322515 0.075091 0.18243 0.27248 90 -0.1413914 -0.0462467 0.067171 0.18059 0.27573 91 -0.1608432 -0.0600938 0.060005 0.18010 0.28085 92 -0.1806546 -0.0737923 0.053594 0.18098 0.28784 93 -0.2008180 -0.0873382 0.047936 0.18321 0.29669 94 -0.2213213 -0.1007247 0.043033 0.18679 0.30739 95 -0.2421494 -0.1139438 0.038884 0.19171 0.31992 96 -0.2632855 -0.1269863 0.035490 0.19797 0.33427 97 -0.2847123 -0.1398427 0.032850 0.20554 0.35041 98 -0.3064126 -0.1525038 0.030964 0.21443 0.36834 99 -0.3283696 -0.1649603 0.029833 0.22463 0.38804 100 -0.3505674 -0.1772037 0.029456 0.23611 0.40948 knots : [1] -2.557 -0.813 0.418 2.573 coef : [1] 11.976924 3.591747 1.054378 0.029456 0.029456 > 1 - sum(cxy $ resid ^ 2) / sum((y - mean(y))^2) # R^2 = 97.6% [1] 0.95969 > showProc.time() Time (user system elapsed): 0.36 0 0.36 > > if(doExtra) { + ## Interpolation + cxyI <- cobs(x,y, "decrease", knots = unique(x)) + ## takes quite long : 63 sec. (Pent. III, 700 MHz) --- this is because + ## each knot is added sequentially... {{improve!}} + + summaryCobs(cxyI)# only 7 knots remaining! + showProc.time() + } > > summaryCobs(cxy1 <- cobs(x,y, "decrease", lambda = 0.1)) List of 24 $ call : language cobs(x = x, y = y, constraint = "decrease", lambda = 0.1) $ tau : num 0.5 $ degree : num 2 $ constraint : chr "decrease" $ ic : NULL $ pointwise : NULL $ select.knots : logi TRUE $ select.lambda: logi FALSE $ x : num [1:200] -2.56 -2.14 -1.9 -1.81 -1.78 ... $ y : num [1:200] 12.7 8.24 6.67 5.88 6.42 ... $ resid : num [1:200] 0 -0.315 0 -0.161 0.586 ... $ fitted : num [1:200] 12.7 8.56 6.67 6.04 5.83 ... $ coef : num [1:22] 12.7 5.78 3.16 2.43 2.11 ... $ knots : num [1:20] -2.557 -1.34 -1.03 -0.901 -0.772 ... $ k0 : int 15 $ k : int 15 $ x.ps :Formal class 'matrix.csr' [package "SparseM"] with 4 slots $ SSy : num 488 $ lambda : num 0.1 $ icyc : int 23 $ ifl : int 1 $ pp.lambda : NULL $ pp.sic : NULL $ i.mask : NULL cb.lo ci.lo fit ci.up cb.up 1 12.0912847 12.4849933 12.6970034 12.90901 13.30272 2 11.5452819 11.9166521 12.1166331 12.31661 12.68798 3 11.0146966 11.3650966 11.5537853 11.74247 12.09287 4 10.4995535 10.8303355 11.0084599 11.18658 11.51737 5 9.9998870 10.3123808 10.4806571 10.64893 10.96143 6 9.5157430 9.8112485 9.9703768 10.12951 10.42501 7 9.0471805 9.3269594 9.4776191 9.62828 9.90806 8 8.5942728 8.8595392 9.0023838 9.14523 9.41049 9 8.1571088 8.4090188 8.5446710 8.68032 8.93223 10 7.7357927 7.9754347 8.1044808 8.23353 8.47317 11 7.3304438 7.5588289 7.6818131 7.80480 8.03318 12 6.9411951 7.1592477 7.2766679 7.39409 7.61214 13 6.5681906 6.7767415 6.8890452 7.00135 7.20990 14 6.2115819 6.4113636 6.5189450 6.62653 6.82631 15 5.8715240 6.0631680 6.1663674 6.26957 6.46121 16 5.5481704 5.7322086 5.8313123 5.93042 6.11445 17 5.2416676 5.4185366 5.5137796 5.60902 5.78589 18 4.9521494 5.1221988 5.2137695 5.30534 5.47539 19 4.6797308 4.8432355 4.9312819 5.01933 5.18283 20 4.4245017 4.5816781 4.6663169 4.75096 4.90813 21 4.1865199 4.3375470 4.4188743 4.50020 4.65123 22 3.9658032 4.1108482 4.1889542 4.26706 4.41211 23 3.7623206 3.9015710 3.9765567 4.05154 4.19079 24 3.5759813 3.7096836 3.7816817 3.85368 3.98738 25 3.4043771 3.5329043 3.6021155 3.67133 3.79985 26 3.2347309 3.3585931 3.4252922 3.49199 3.61585 27 3.0652721 3.1848437 3.2492325 3.31362 3.43319 28 2.8962030 3.0117271 3.0739363 3.13615 3.25167 29 2.7276530 2.8392885 2.8994037 2.95952 3.07115 30 2.5596612 2.6675415 2.7256346 2.78373 2.89161 31 2.3944947 2.4988186 2.5549966 2.61117 2.71550 32 2.2444821 2.3455939 2.4000421 2.45449 2.55560 33 2.1114672 2.2097080 2.2626102 2.31551 2.41375 34 1.9954176 2.0911496 2.1427009 2.19425 2.28998 35 1.8963846 1.9899366 2.0403140 2.09069 2.18424 36 1.8125024 1.9041996 1.9535781 2.00296 2.09465 37 1.7347658 1.8248332 1.8733340 1.92183 2.01190 38 1.6620975 1.7506630 1.7983550 1.84605 1.93461 39 1.5945123 1.6816941 1.7286411 1.77559 1.86277 40 1.5278221 1.6138190 1.6601279 1.70644 1.79243 41 1.4573347 1.5423451 1.5881227 1.63390 1.71891 42 1.3839943 1.4682138 1.5135655 1.55892 1.64314 43 1.3227219 1.4063482 1.4513806 1.49641 1.58004 44 1.2787473 1.3619265 1.4067181 1.45151 1.53469 45 1.2488624 1.3317463 1.3763789 1.42101 1.50390 46 1.2168724 1.2994789 1.3439621 1.38845 1.47105 47 1.1806389 1.2628708 1.3071522 1.35143 1.43367 48 1.1401892 1.2219316 1.2659495 1.30997 1.39171 49 1.0941843 1.1754044 1.2191410 1.26288 1.34410 50 1.0326549 1.1134412 1.1569442 1.20045 1.28123 51 0.9535058 1.0339215 1.0772249 1.12053 1.20094 52 0.8632281 0.9433870 0.9865521 1.02972 1.10988 53 0.7875624 0.8676441 0.9107678 0.95389 1.03397 54 0.7267897 0.8069673 0.8501425 0.89332 0.97350 55 0.6673925 0.7477244 0.7909827 0.83424 0.91457 56 0.6072642 0.6877460 0.7310850 0.77442 0.85491 57 0.5471548 0.6278279 0.6712700 0.71471 0.79539 58 0.4995140 0.5804770 0.6240752 0.66767 0.74864 59 0.4686435 0.5499607 0.5937495 0.63754 0.71886 60 0.4531016 0.5348803 0.5789177 0.62296 0.70473 61 0.4381911 0.5206110 0.5649937 0.60938 0.69180 62 0.4199957 0.5032331 0.5480561 0.59288 0.67612 63 0.4036491 0.4879280 0.5333117 0.57870 0.66297 64 0.3952493 0.4807890 0.5268517 0.57291 0.65845 65 0.3926229 0.4796600 0.5265291 0.57340 0.66044 66 0.3900185 0.4787485 0.5265291 0.57431 0.66304 67 0.3870480 0.4776752 0.5264774 0.57528 0.66591 68 0.3738545 0.4665585 0.5164792 0.56640 0.65910 69 0.3432056 0.4380737 0.4891596 0.54025 0.63511 70 0.2950830 0.3922142 0.4445189 0.49682 0.59395 71 0.2295290 0.3291123 0.3827373 0.43636 0.53595 72 0.1670195 0.2693294 0.3244228 0.37952 0.48183 73 0.1216565 0.2269375 0.2836308 0.34032 0.44561 74 0.0934100 0.2019260 0.2603613 0.31880 0.42731 75 0.0787462 0.1907702 0.2510947 0.31142 0.42344 76 0.0658428 0.1813823 0.2435998 0.30582 0.42136 77 0.0538230 0.1727768 0.2368329 0.30089 0.41984 78 0.0427388 0.1649719 0.2307938 0.29662 0.41885 79 0.0325663 0.1579592 0.2254827 0.29301 0.41840 80 0.0232151 0.1517072 0.2208995 0.29009 0.41858 81 0.0145359 0.1461634 0.2170442 0.28792 0.41955 82 0.0063272 0.1412575 0.2139168 0.28658 0.42151 83 -0.0016568 0.1369034 0.2115173 0.28613 0.42469 84 -0.0096967 0.1330028 0.2098457 0.28669 0.42939 85 -0.0180957 0.1294496 0.2089021 0.28835 0.43590 86 -0.0272134 0.1260791 0.2086264 0.29117 0.44447 87 -0.0387972 0.1210358 0.2071052 0.29317 0.45301 88 -0.0534279 0.1135207 0.2034217 0.29332 0.46027 89 -0.0709531 0.1035871 0.1975762 0.29157 0.46611 90 -0.0912981 0.0912612 0.1895684 0.28788 0.47043 91 -0.1144525 0.0765465 0.1793985 0.28225 0.47325 92 -0.1404576 0.0594287 0.1670665 0.27470 0.47459 93 -0.1693951 0.0398791 0.1525723 0.26527 0.47454 94 -0.2013769 0.0178586 0.1359159 0.25397 0.47321 95 -0.2365365 -0.0066795 0.1170974 0.24087 0.47073 96 -0.2750210 -0.0337868 0.0961167 0.22602 0.46725 97 -0.3169840 -0.0635170 0.0729738 0.20946 0.46293 98 -0.3625797 -0.0959240 0.0476688 0.19126 0.45792 99 -0.4119579 -0.1310604 0.0202016 0.17146 0.45236 100 -0.4652595 -0.1689754 -0.0094278 0.15012 0.44640 knots : [1] -2.557 -1.340 -1.030 -0.901 -0.772 -0.586 -0.448 -0.305 -0.092 0.054 [11] 0.163 0.329 0.481 0.606 0.722 0.859 1.065 1.244 1.837 2.573 coef : [1] 12.6970048 5.7788265 3.1620633 2.4291174 2.1069607 1.8462166 [7] 1.6371062 1.4304905 1.3348346 1.1758220 0.9413974 0.7863913 [13] 0.5998958 0.5697029 0.5265291 0.5265291 0.5265291 0.2707227 [19] 0.2086712 0.2086712 -0.0094278 6.5257497 > 1 - sum(cxy1 $ resid ^ 2) / sum((y - mean(y))^2) # R^2 = 98.2% [1] 0.96169 > > summaryCobs(cxy2 <- cobs(x,y, "decrease", lambda = 1e-2)) List of 24 $ call : language cobs(x = x, y = y, constraint = "decrease", lambda = 0.01) $ tau : num 0.5 $ degree : num 2 $ constraint : chr "decrease" $ ic : NULL $ pointwise : NULL $ select.knots : logi TRUE $ select.lambda: logi FALSE $ x : num [1:200] -2.56 -2.14 -1.9 -1.81 -1.78 ... $ y : num [1:200] 12.7 8.24 6.67 5.88 6.42 ... $ resid : num [1:200] 0 -0.146 0.1468 -0.0463 0.6868 ... $ fitted : num [1:200] 12.7 8.39 6.52 5.92 5.73 ... $ coef : num [1:22] 12.7 5.34 3.59 2.19 2.13 ... $ knots : num [1:20] -2.557 -1.34 -1.03 -0.901 -0.772 ... $ k0 : int 21 $ k : int 21 $ x.ps :Formal class 'matrix.csr' [package "SparseM"] with 4 slots $ SSy : num 488 $ lambda : num 0.01 $ icyc : int 35 $ ifl : int 1 $ pp.lambda : NULL $ pp.sic : NULL $ i.mask : NULL cb.lo ci.lo fit ci.up cb.up 1 12.0477594 12.4997491 12.6970071 12.89427 13.34625 2 11.4687308 11.8950752 12.0811411 12.26721 12.69355 3 10.9090823 11.3113523 11.4869116 11.66247 12.06474 4 10.3688404 10.7485883 10.9143185 11.08005 11.45980 5 9.8480420 10.2067945 10.3633618 10.51993 10.87868 6 9.3467363 9.6859859 9.8340417 9.98210 10.32135 7 8.8649866 9.1861815 9.3263579 9.46653 9.78773 8 8.4028715 8.7074055 8.8403106 8.97322 9.27775 9 7.9604861 8.2496865 8.3758998 8.50211 8.79131 10 7.5379421 7.8130586 7.9331254 8.05319 8.32831 11 7.1353676 7.3975607 7.5119874 7.62641 7.88861 12 6.7529050 7.0032361 7.1124859 7.22174 7.47207 13 6.3907086 6.6301316 6.7346209 6.83911 7.07853 14 6.0489410 6.2782966 6.3783923 6.47849 6.70784 15 5.7277684 5.9477816 6.0438001 6.13982 6.35983 16 5.4273551 5.6386366 5.7308444 5.82305 6.03433 17 5.1478583 5.3509094 5.4395252 5.52814 5.73119 18 4.8894214 5.0846433 5.1698424 5.25504 5.45026 19 4.6521676 4.8398760 4.9217960 5.00372 5.19142 20 4.4361933 4.6166367 4.6953861 4.77414 4.95458 21 4.2415605 4.4149443 4.4906127 4.56628 4.73966 22 4.0682883 4.2348044 4.3074756 4.38015 4.54666 23 3.9163432 4.0762071 4.1459751 4.21574 4.37561 24 3.7856282 3.9391227 4.0061110 4.07310 4.22659 25 3.6683774 3.8159306 3.8803259 3.94472 4.09227 26 3.5214653 3.6636629 3.7257209 3.78778 3.92998 27 3.3383583 3.4756303 3.5355387 3.59545 3.73272 28 3.1192735 3.2518988 3.3097793 3.36766 3.50028 29 2.8643493 2.9925103 3.0484425 3.10437 3.23254 30 2.5736278 2.6974778 2.7515286 2.80558 2.92943 31 2.2696062 2.3893733 2.4416422 2.49391 2.61368 32 2.0718959 2.1879754 2.2386350 2.28929 2.40537 33 1.9979346 2.1107181 2.1599392 2.20916 2.32194 34 1.9710324 2.0809358 2.1288999 2.17686 2.28677 35 1.9261503 2.0335510 2.0804229 2.12729 2.23470 36 1.8645775 1.9698487 2.0157914 2.06173 2.16701 37 1.7927585 1.8961587 1.9412848 1.98641 2.08981 38 1.7116948 1.8133707 1.8577443 1.90212 2.00379 39 1.6214021 1.7214896 1.7651699 1.80885 1.90894 40 1.5242004 1.6229275 1.6660141 1.70910 1.80783 41 1.4229217 1.5205162 1.5631086 1.60570 1.70330 42 1.3194940 1.4161806 1.4583766 1.50057 1.59726 43 1.2442053 1.3402109 1.3821098 1.42401 1.52001 44 1.2075941 1.3030864 1.3447613 1.38644 1.48193 45 1.2023778 1.2975311 1.3390581 1.38059 1.47574 46 1.1914924 1.2863272 1.3277152 1.36910 1.46394 47 1.1698641 1.2642688 1.3054691 1.34667 1.44107 48 1.1375221 1.2313649 1.2723199 1.31327 1.40712 49 1.0934278 1.1866710 1.2273643 1.26806 1.36130 50 1.0300956 1.1228408 1.1633168 1.20379 1.29654 51 0.9459780 1.0382977 1.0785880 1.11888 1.21120 52 0.8492712 0.9412961 0.9814577 1.02162 1.11364 53 0.7724392 0.8643755 0.9044985 0.94462 1.03656 54 0.7154255 0.8074718 0.8476428 0.88781 0.97986 55 0.6587891 0.7510125 0.7912608 0.83151 0.92373 56 0.5994755 0.6918710 0.7321944 0.77252 0.86491 57 0.5383570 0.6309722 0.6713915 0.71181 0.80443 58 0.4898228 0.5827709 0.6233354 0.66390 0.75685 59 0.4588380 0.5521926 0.5929345 0.63368 0.72703 60 0.4438719 0.5377564 0.5787296 0.61970 0.71359 61 0.4293281 0.5239487 0.5652432 0.60654 0.70116 62 0.4110511 0.5066103 0.5483143 0.59002 0.68558 63 0.3944126 0.4911673 0.5333932 0.57562 0.67237 64 0.3857958 0.4839980 0.5268556 0.56971 0.66792 65 0.3830000 0.4829213 0.5265291 0.57014 0.67006 66 0.3802084 0.4820731 0.5265291 0.57099 0.67285 67 0.3770181 0.4810608 0.5264673 0.57187 0.67592 68 0.3616408 0.4680678 0.5145149 0.56096 0.66739 69 0.3254129 0.4343244 0.4818557 0.52939 0.63830 70 0.2683149 0.3798245 0.4284897 0.47715 0.58866 71 0.1904294 0.3047541 0.3546478 0.40454 0.51887 72 0.1179556 0.2354105 0.2866704 0.33793 0.45539 73 0.0689088 0.1897746 0.2425231 0.29527 0.41614 74 0.0432569 0.1678366 0.2222059 0.27658 0.40115 75 0.0359906 0.1645977 0.2207246 0.27685 0.40546 76 0.0301934 0.1628364 0.2207246 0.27861 0.41126 77 0.0245630 0.1611257 0.2207246 0.28032 0.41689 78 0.0191553 0.1594827 0.2207246 0.28197 0.42229 79 0.0139446 0.1578996 0.2207246 0.28355 0.42750 80 0.0088340 0.1563468 0.2207246 0.28510 0.43262 81 0.0036634 0.1547759 0.2207246 0.28667 0.43779 82 -0.0017830 0.1531211 0.2207246 0.28833 0.44323 83 -0.0077688 0.1513025 0.2207246 0.29015 0.44922 84 -0.0145948 0.1492286 0.2207246 0.29222 0.45604 85 -0.0225859 0.1468007 0.2207246 0.29465 0.46404 86 -0.0321107 0.1438739 0.2206774 0.29748 0.47347 87 -0.0445016 0.1389916 0.2190720 0.29915 0.48265 88 -0.0601227 0.1315395 0.2151851 0.29883 0.49049 89 -0.0788103 0.1215673 0.2090164 0.29647 0.49684 90 -0.1004844 0.1090993 0.2005661 0.29203 0.50162 91 -0.1251339 0.0941388 0.1898342 0.28553 0.50480 92 -0.1528032 0.0766725 0.1768206 0.27697 0.50644 93 -0.1835797 0.0566736 0.1615253 0.26638 0.50663 94 -0.2175834 0.0341058 0.1439484 0.25379 0.50548 95 -0.2549574 0.0089256 0.1240898 0.23925 0.50314 96 -0.2958592 -0.0189149 0.1019496 0.22281 0.49976 97 -0.3404537 -0.0494657 0.0775277 0.20452 0.49551 98 -0.3889062 -0.0827771 0.0508241 0.18443 0.49055 99 -0.4413769 -0.1188979 0.0218389 0.16258 0.48505 100 -0.4980173 -0.1578738 -0.0094279 0.13902 0.47916 knots : [1] -2.557 -1.340 -1.030 -0.901 -0.772 -0.586 -0.448 -0.305 -0.092 0.054 [11] 0.163 0.329 0.481 0.606 0.722 0.859 1.065 1.244 1.837 2.573 coef : [1] 12.697009 5.337850 3.591398 2.187733 2.133993 1.936435 1.631856 [8] 1.340650 1.340650 1.185401 0.931750 0.789326 0.598245 0.570221 [15] 0.526529 0.526529 0.526529 0.220725 0.220725 0.220725 -0.009428 [22] 46.342964 > 1 - sum(cxy2 $ resid ^ 2) / sum((y - mean(y))^2) # R^2 = 98.2% (tiny bit better) [1] 0.96257 > > summaryCobs(cxy3 <- cobs(x,y, "decrease", lambda = 1e-6, nknots = 60)) List of 24 $ call : language cobs(x = x, y = y, constraint = "decrease", nknots = 60, lambda = 1e-06) $ tau : num 0.5 $ degree : num 2 $ constraint : chr "decrease" $ ic : NULL $ pointwise : NULL $ select.knots : logi TRUE $ select.lambda: logi FALSE $ x : num [1:200] -2.56 -2.14 -1.9 -1.81 -1.78 ... $ y : num [1:200] 12.7 8.24 6.67 5.88 6.42 ... $ resid : num [1:200] 0 0 0 -0.382 0.309 ... $ fitted : num [1:200] 12.7 8.24 6.67 6.26 6.11 ... $ coef : num [1:62] 12.7 7.69 6.09 4.35 3.73 3.73 2.74 2.57 2.57 2.25 ... $ knots : num [1:60] -2.56 -1.81 -1.73 -1.38 -1.23 ... $ k0 : int 61 $ k : int 61 $ x.ps :Formal class 'matrix.csr' [package "SparseM"] with 4 slots $ SSy : num 488 $ lambda : num 1e-06 $ icyc : int 46 $ ifl : int 1 $ pp.lambda : NULL $ pp.sic : NULL $ i.mask : NULL cb.lo ci.lo fit ci.up cb.up 1 12.0247124 12.56890432 12.6970139 12.825123 13.36932 2 11.3797843 11.89599414 12.0175164 12.139039 12.65525 3 10.7668218 11.25721357 11.3726579 11.488102 11.97849 4 10.1860204 10.65259986 10.7624385 10.872277 11.33886 5 9.6375946 10.08219388 10.1868581 10.291522 10.73612 6 9.1217734 9.54603927 9.6459167 9.745794 10.17006 7 8.6387946 9.04418136 9.1396144 9.235048 9.64043 8 8.1888978 8.57666578 8.6679512 8.759237 9.14700 9 7.7723156 8.14353686 8.2309270 8.318317 8.68954 10 7.3892646 7.74483589 7.8285418 7.912248 8.26782 11 7.0399352 7.38059913 7.4607957 7.540992 7.88166 12 6.7244802 7.05085572 7.1276886 7.204521 7.53090 13 6.4430029 6.75562533 6.8292205 6.902816 7.21544 14 6.1955428 6.49491547 6.5653915 6.635868 6.93524 15 5.9820595 6.26871848 6.3362016 6.403685 6.69034 16 5.7696526 6.04428975 6.1089428 6.173596 6.44823 17 5.4339991 5.69759119 5.7596440 5.821697 6.08529 18 5.0454361 5.29908138 5.3587927 5.418504 5.67215 19 4.6993977 4.94405130 5.0016458 5.059240 5.30389 20 4.3963458 4.63268699 4.6883247 4.743962 4.98030 21 4.1365583 4.36504142 4.4188292 4.472617 4.70110 22 3.9202312 4.14115193 4.1931594 4.245167 4.46609 23 3.7474595 3.96103662 4.0113153 4.061594 4.27517 24 3.6182953 3.82478434 3.8733944 3.922005 4.12849 25 3.5335861 3.73343196 3.7804782 3.827524 4.02737 26 3.4937186 3.68729597 3.7328665 3.778437 3.97201 27 3.4752667 3.66292175 3.7070981 3.751274 3.93893 28 3.3043525 3.48641351 3.5292729 3.572132 3.75419 29 2.9458452 3.12249549 3.1640812 3.205667 3.38232 30 2.4899112 2.66132542 2.7016785 2.742031 2.91345 31 2.3652956 2.53186083 2.5710724 2.610284 2.77685 32 2.2382402 2.40029503 2.4384448 2.476594 2.63865 33 2.0486975 2.20653724 2.2436947 2.280852 2.43869 34 2.0511798 2.20522276 2.2414864 2.277750 2.43179 35 2.0553528 2.20601792 2.2414864 2.276955 2.42762 36 2.0385642 2.18623332 2.2209965 2.255760 2.40343 37 1.8391470 1.98414706 2.0182819 2.052417 2.19742 38 1.6312788 1.77395114 1.8075380 1.841125 1.98380 39 1.5314449 1.67192652 1.7049976 1.738069 1.87855 40 1.5208780 1.65927041 1.6918497 1.724429 1.86282 41 1.4986364 1.63513027 1.6672626 1.699395 1.83589 42 1.4498027 1.58470514 1.6164629 1.648221 1.78312 43 1.2247043 1.35830771 1.3897596 1.421211 1.55481 44 1.1772885 1.30980813 1.3410049 1.372202 1.50472 45 1.1781750 1.30997706 1.3410049 1.372033 1.50383 46 1.1786125 1.31005757 1.3410014 1.371945 1.50339 47 1.1644262 1.29555858 1.3264288 1.357299 1.48843 48 1.1223208 1.25286982 1.2836027 1.314336 1.44488 49 1.0583227 1.18805529 1.2185960 1.249137 1.37887 50 1.0360396 1.16504088 1.1954094 1.225778 1.35478 51 1.0366880 1.16516444 1.1954094 1.225654 1.35413 52 0.9728290 1.10089058 1.1310379 1.161185 1.28925 53 0.6458992 0.77387319 0.8039998 0.834127 0.96210 54 0.6278378 0.75589463 0.7860408 0.816187 0.94424 55 0.6233664 0.75144260 0.7815933 0.811744 0.93982 56 0.6203139 0.74853170 0.7787158 0.808900 0.93712 57 0.4831205 0.61171664 0.6419898 0.672263 0.80086 58 0.4152141 0.54435194 0.5747526 0.605153 0.73429 59 0.4143942 0.54419570 0.5747526 0.605309 0.73511 60 0.4133407 0.54399495 0.5747526 0.605510 0.73616 61 0.3912541 0.52305164 0.5540784 0.585105 0.71690 62 0.3615872 0.49479624 0.5261553 0.557514 0.69072 63 0.3595156 0.49440150 0.5261553 0.557909 0.69279 64 0.3572502 0.49396981 0.5261553 0.558341 0.69506 65 0.3545874 0.49346241 0.5261553 0.558848 0.69772 66 0.3515435 0.49288238 0.5261553 0.559428 0.70077 67 0.3482098 0.49224713 0.5261553 0.560063 0.70410 68 0.3447026 0.49157882 0.5261553 0.560732 0.70761 69 0.3265062 0.47651151 0.5118246 0.547138 0.69714 70 0.2579257 0.41132297 0.4474346 0.483546 0.63694 71 0.2081857 0.36515737 0.4021105 0.439064 0.59604 72 0.1349572 0.29569526 0.3335350 0.371375 0.53211 73 0.0020438 0.16674762 0.2055209 0.244294 0.40900 74 -0.0243664 0.14460810 0.1843868 0.224166 0.39314 75 -0.0362635 0.13720915 0.1780468 0.218884 0.39236 76 -0.0421115 0.13609478 0.1780468 0.219999 0.39820 77 -0.0482083 0.13493301 0.1780468 0.221161 0.40430 78 -0.0546034 0.13371440 0.1780468 0.222379 0.41070 79 -0.0610386 0.13248816 0.1780468 0.223605 0.41713 80 -0.0674722 0.13126221 0.1780468 0.224831 0.42357 81 -0.0740291 0.13001276 0.1780468 0.226081 0.43012 82 -0.0809567 0.12869267 0.1780468 0.227401 0.43705 83 -0.0885308 0.12724941 0.1780468 0.228844 0.44462 84 -0.0966886 0.12569491 0.1780468 0.230399 0.45278 85 -0.1053882 0.12403716 0.1780468 0.232056 0.46148 86 -0.1147206 0.12225885 0.1780468 0.233835 0.47081 87 -0.1248842 0.12032213 0.1780468 0.235771 0.48098 88 -0.1360096 0.11820215 0.1780468 0.237891 0.49210 89 -0.1480747 0.11590310 0.1780468 0.240190 0.50417 90 -0.1611528 0.11337745 0.1780053 0.242633 0.51716 91 -0.1772967 0.10838384 0.1756366 0.242889 0.52857 92 -0.1976403 0.09964452 0.1696291 0.239614 0.53690 93 -0.2221958 0.08715720 0.1599828 0.232808 0.54216 94 -0.2510614 0.07090314 0.1466976 0.222492 0.54446 95 -0.2844042 0.05085051 0.1297736 0.208697 0.54395 96 -0.3224450 0.02695723 0.1092109 0.191465 0.54087 97 -0.3654434 -0.00082617 0.0850093 0.170845 0.53546 98 -0.4136843 -0.03255395 0.0571689 0.146892 0.52802 99 -0.4674640 -0.06828261 0.0256897 0.119662 0.51884 100 -0.5270786 -0.10806856 -0.0094284 0.089212 0.50822 knots : [1] -2.557 -1.812 -1.726 -1.384 -1.233 -1.082 -1.046 -1.009 -0.932 -0.902 [11] -0.877 -0.838 -0.813 -0.765 -0.707 -0.665 -0.568 -0.498 -0.460 -0.413 [21] -0.347 -0.333 -0.299 -0.274 -0.226 -0.089 -0.024 -0.011 0.063 0.094 [31] 0.118 0.136 0.231 0.285 0.328 0.392 0.460 0.473 0.517 0.551 [41] 0.602 0.623 0.692 0.715 0.742 0.787 0.812 0.892 0.934 0.988 [51] 1.070 1.162 1.178 1.276 1.402 1.655 1.877 1.988 2.047 2.573 coef : [1] 12.6970155 7.6878537 6.0937652 4.3540061 3.7259911 3.7259911 [7] 2.7408131 2.5727608 2.5727608 2.2478639 2.2414864 2.2414864 [13] 2.2414864 2.2414864 2.2414864 1.9875889 1.6964374 1.6964374 [19] 1.6623718 1.6623718 1.3410049 1.3410049 1.3410049 1.3410049 [25] 1.3410049 1.3410049 1.1954094 1.1954094 1.1954094 1.1954094 [31] 0.9829296 0.8091342 0.7815933 0.7815933 0.7815933 0.5747526 [37] 0.5747526 0.5747526 0.5747526 0.5747526 0.5261553 0.5261553 [43] 0.5261553 0.5261553 0.5261553 0.5261553 0.5261553 0.5261553 [49] 0.5261553 0.5261553 0.4273578 0.3741431 0.2060752 0.1780468 [55] 0.1780468 0.1780468 0.1780468 0.1780468 0.1780468 0.1780468 [61] -0.0094285 432.6957871 > 1 - sum(cxy3 $ resid ^ 2) / sum((y - mean(y))^2) # R^2 = 98.36% [1] 0.96502 > showProc.time() Time (user system elapsed): 0.14 0 0.14 > > cpuTime(cxy4 <- cobs(x,y, "decrease", lambda = 1e-6, nknots = 100))# ~ 3 sec. Time elapsed: 0.04 > 1 - sum(cxy4 $ resid ^ 2) / sum((y - mean(y))^2) # R^2 = 98.443% [1] 0.96603 > > cpuTime(cxy5 <- cobs(x,y, "decrease", lambda = 1e-6, nknots = 150))# ~ 8.7 sec. Time elapsed: 0.03 > 1 - sum(cxy5 $ resid ^ 2) / sum((y - mean(y))^2) # R^2 = 98.4396% [1] 0.96835 > showProc.time() Time (user system elapsed): 0.33 0 0.33 > > > ## regularly spaced x : > X <- seq(-1,1, len = 201) > xx <- c(seq(-1.1, -1, len = 11), X, + seq( 1, 1.1, len = 11)) > y <- (fx <- exp(-X)) + rt(201,4)/4 > summaryCobs(cXy <- cobs(X,y, "decrease")) qbsks2(): Performing general knot selection ... Deleting unnecessary knots ... List of 24 $ call : language cobs(x = X, y = y, constraint = "decrease") $ tau : num 0.5 $ degree : num 2 $ constraint : chr "decrease" $ ic : chr "AIC" $ pointwise : NULL $ select.knots : logi TRUE $ select.lambda: logi FALSE $ x : num [1:201] -1 -0.99 -0.98 -0.97 -0.96 -0.95 -0.94 -0.93 -0.92 -0.91 ... $ y : num [1:201] 2.67 2.77 3.46 3.14 1.79 ... $ resid : num [1:201] 0 0.125 0.84 0.555 -0.77 ... $ fitted : num [1:201] 2.67 2.64 2.62 2.59 2.56 ... $ coef : num [1:4] 2.672 1.556 0.7 0.356 $ knots : num [1:3] -1 -0.2 1 $ k0 : num 4 $ k : num 4 $ x.ps :Formal class 'matrix.csr' [package "SparseM"] with 4 slots $ SSy : num 100 $ lambda : num 0 $ icyc : int 9 $ ifl : int 1 $ pp.lambda : NULL $ pp.sic : NULL $ i.mask : NULL cb.lo ci.lo fit ci.up cb.up 1 2.46750 2.55064 2.67153 2.79242 2.87556 2 2.42251 2.50122 2.61568 2.73013 2.80884 3 2.37783 2.45240 2.56081 2.66923 2.74379 4 2.33345 2.40414 2.50694 2.60973 2.68043 5 2.28933 2.35645 2.45404 2.55164 2.61876 6 2.24548 2.30932 2.40214 2.49496 2.55879 7 2.20189 2.26274 2.35122 2.43970 2.50055 8 2.15855 2.21672 2.30129 2.38586 2.44402 9 2.11547 2.17124 2.25234 2.33344 2.38922 10 2.07265 2.12633 2.20438 2.28244 2.33611 11 2.03013 2.08199 2.15741 2.23283 2.28470 12 1.98791 2.03824 2.11142 2.18461 2.23494 13 1.94605 1.99510 2.06642 2.13775 2.18680 14 1.90459 1.95260 2.02241 2.09222 2.14023 15 1.86359 1.91078 1.97938 2.04799 2.09517 16 1.82311 1.86966 1.93734 2.00502 2.05157 17 1.78322 1.82929 1.89629 1.96328 2.00936 18 1.74397 1.78971 1.85622 1.92273 1.96847 19 1.70544 1.75096 1.81714 1.88332 1.92883 20 1.66769 1.71307 1.77904 1.84502 1.89039 21 1.63079 1.67608 1.74193 1.80779 1.85308 22 1.59478 1.64002 1.70581 1.77160 1.81684 23 1.55972 1.60493 1.67067 1.73642 1.78163 24 1.52564 1.57083 1.63653 1.70222 1.74741 25 1.49260 1.53773 1.60336 1.66899 1.71412 26 1.46062 1.50567 1.57118 1.63670 1.68175 27 1.42972 1.47466 1.53999 1.60533 1.65026 28 1.39994 1.44470 1.50979 1.57488 1.61964 29 1.37128 1.41581 1.48057 1.54533 1.58987 30 1.34375 1.38800 1.45234 1.51668 1.56093 31 1.31736 1.36126 1.42510 1.48893 1.53283 32 1.29211 1.33560 1.39884 1.46207 1.50556 33 1.26800 1.31101 1.37357 1.43612 1.47914 34 1.24500 1.28749 1.34928 1.41107 1.45356 35 1.22310 1.26502 1.32598 1.38694 1.42886 36 1.20228 1.24360 1.30367 1.36374 1.40505 37 1.18250 1.22319 1.28234 1.34150 1.38218 38 1.16372 1.20377 1.26200 1.32023 1.36028 39 1.14589 1.18532 1.24265 1.29998 1.33941 40 1.12894 1.16779 1.22428 1.28077 1.31962 41 1.11271 1.15106 1.20683 1.26259 1.30094 42 1.09639 1.13439 1.18963 1.24488 1.28287 43 1.07982 1.11760 1.17253 1.22747 1.26525 44 1.06303 1.10072 1.15553 1.21034 1.24803 45 1.04607 1.08378 1.13862 1.19346 1.23117 46 1.02898 1.06681 1.12181 1.17681 1.21463 47 1.01180 1.04982 1.10509 1.16037 1.19838 48 0.99458 1.03284 1.08847 1.14411 1.18237 49 0.97734 1.01589 1.07195 1.12801 1.16656 50 0.96011 0.99899 1.05552 1.11205 1.15092 51 0.94294 0.98216 1.03919 1.09621 1.13543 52 0.92585 0.96541 1.02295 1.08049 1.12005 53 0.90885 0.94877 1.00681 1.06485 1.10477 54 0.89197 0.93223 0.99076 1.04930 1.08956 55 0.87523 0.91581 0.97482 1.03382 1.07440 56 0.85865 0.89952 0.95896 1.01840 1.05928 57 0.84223 0.88337 0.94321 1.00304 1.04419 58 0.82598 0.86736 0.92755 0.98773 1.02911 59 0.80991 0.85150 0.91198 0.97246 1.01405 60 0.79403 0.83579 0.89651 0.95723 0.99899 61 0.77834 0.82023 0.88114 0.94205 0.98394 62 0.76284 0.80482 0.86586 0.92690 0.96888 63 0.74753 0.78956 0.85068 0.91180 0.95383 64 0.73241 0.77446 0.83559 0.89673 0.93878 65 0.71747 0.75950 0.82060 0.88171 0.92374 66 0.70271 0.74468 0.80571 0.86674 0.90871 67 0.68812 0.73001 0.79091 0.85182 0.89371 68 0.67368 0.71546 0.77621 0.83696 0.87874 69 0.65939 0.70104 0.76161 0.82217 0.86382 70 0.64523 0.68674 0.74710 0.80745 0.84896 71 0.63118 0.67254 0.73268 0.79282 0.83419 72 0.61722 0.65844 0.71836 0.77829 0.81951 73 0.60333 0.64441 0.70414 0.76388 0.80495 74 0.58948 0.63045 0.69002 0.74958 0.79055 75 0.57565 0.61654 0.67599 0.73544 0.77632 76 0.56181 0.60266 0.66205 0.72145 0.76230 77 0.54792 0.58879 0.64821 0.70764 0.74851 78 0.53395 0.57491 0.63447 0.69403 0.73500 79 0.51986 0.56100 0.62083 0.68065 0.72179 80 0.50563 0.54705 0.60728 0.66750 0.70892 81 0.49121 0.53302 0.59382 0.65462 0.69643 82 0.47657 0.51891 0.58046 0.64202 0.68435 83 0.46169 0.50468 0.56720 0.62972 0.67271 84 0.44652 0.49033 0.55403 0.61774 0.66155 85 0.43105 0.47584 0.54096 0.60609 0.65087 86 0.41526 0.46119 0.52799 0.59478 0.64072 87 0.39912 0.44638 0.51511 0.58383 0.63109 88 0.38264 0.43141 0.50233 0.57324 0.62202 89 0.36579 0.41626 0.48964 0.56302 0.61349 90 0.34858 0.40093 0.47705 0.55317 0.60552 91 0.33101 0.38542 0.46455 0.54368 0.59810 92 0.31307 0.36975 0.45215 0.53456 0.59123 93 0.29478 0.35390 0.43985 0.52580 0.58492 94 0.27615 0.33788 0.42764 0.51741 0.57914 95 0.25717 0.32170 0.41553 0.50936 0.57389 96 0.23787 0.30536 0.40352 0.50167 0.56917 97 0.21824 0.28888 0.39160 0.49431 0.56495 98 0.19830 0.27225 0.37977 0.48730 0.56125 99 0.17806 0.25547 0.36804 0.48062 0.55803 100 0.15752 0.23857 0.35641 0.47426 0.55531 knots : [1] -1.0 -0.2 1.0 coef : [1] 2.67153 1.55592 0.70045 0.35641 > 1 - sum(cXy $ resid ^ 2) / sum((y - mean(y))^2) # R^2 = 77.2% [1] 0.77644 > showProc.time() Time (user system elapsed): 0.09 0 0.1 > > (cXy.9 <- cobs(X,y, "decrease", tau = 0.9)) qbsks2(): Performing general knot selection ... Deleting unnecessary knots ... COBS regression spline (degree = 2) from call: cobs(x = X, y = y, constraint = "decrease", tau = 0.9) {tau=0.9}-quantile; dimensionality of fit: 6 from {6} x$knots[1:5]: -1.0, -0.6, -0.2, 0.2, 1.0 > (cXy.1 <- cobs(X,y, "decrease", tau = 0.1)) qbsks2(): Performing general knot selection ... WARNING! Since the number of 6 knots selected by AIC reached the upper bound during general knot selection, you might want to rerun cobs with a larger number of knots. Deleting unnecessary knots ... WARNING! Since the number of 6 knots selected by AIC reached the upper bound during general knot selection, you might want to rerun cobs with a larger number of knots. COBS regression spline (degree = 2) from call: cobs(x = X, y = y, constraint = "decrease", tau = 0.1) {tau=0.1}-quantile; dimensionality of fit: 4 from {4} x$knots[1:3]: -1.0, 0.6, 1.0 > (cXy.99<- cobs(X,y, "decrease", tau = 0.99)) qbsks2(): Performing general knot selection ... Deleting unnecessary knots ... COBS regression spline (degree = 2) from call: cobs(x = X, y = y, constraint = "decrease", tau = 0.99) {tau=0.99}-quantile; dimensionality of fit: 4 from {4} x$knots[1:3]: -1.0, -0.2, 1.0 > (cXy.01<- cobs(X,y, "decrease", tau = 0.01)) qbsks2(): Performing general knot selection ... Deleting unnecessary knots ... COBS regression spline (degree = 2) from call: cobs(x = X, y = y, constraint = "decrease", tau = 0.01) {tau=0.01}-quantile; dimensionality of fit: 6 from {6} x$knots[1:5]: -1.0, -0.6, -0.2, 0.2, 1.0 > plot(X,y, xlim = range(xx), + main = "cobs(*, \"decrease\"), N=201, tau = 50% (Med.), 1,10, 90,99%") > lines(predict(cXy, xx), col = 2) > lines(predict(cXy.1, xx), col = 3) > lines(predict(cXy.9, xx), col = 3) > lines(predict(cXy.01, xx), col = 4) > lines(predict(cXy.99, xx), col = 4) > > showProc.time() Time (user system elapsed): 0.39 0.01 0.4 > > ## Interpolation > cpuTime(cXyI <- cobs(X,y, "decrease", knots = unique(X))) qbsks2(): Performing general knot selection ... Deleting unnecessary knots ... Time elapsed: 2.64 Warning message: In cobs(X, y, "decrease", knots = unique(X)) : The number of knots can't be equal to the number of unique x for degree = 2. 'cobs' has automatically deleted the middle knot. > ## takes ~ 47 sec. (Pent. III, 700 MHz) > summaryCobs(cXyI)# only 7 knots remaining! List of 24 $ call : language cobs(x = X, y = y, constraint = "decrease", knots = unique(X)) $ tau : num 0.5 $ degree : num 2 $ constraint : chr "decrease" $ ic : chr "AIC" $ pointwise : NULL $ select.knots : logi TRUE $ select.lambda: logi FALSE $ x : num [1:201] -1 -0.99 -0.98 -0.97 -0.96 -0.95 -0.94 -0.93 -0.92 -0.91 ... $ y : num [1:201] 2.67 2.77 3.46 3.14 1.79 ... $ resid : num [1:201] 0.0199 0.1427 0.8557 0.568 -0.759 ... $ fitted : num [1:201] 2.65 2.63 2.6 2.58 2.55 ... $ coef : num [1:4] 2.652 1.368 0.669 0.346 $ knots : num [1:3] -1 0 1 $ k0 : num 4 $ k : num 4 $ x.ps :Formal class 'matrix.csr' [package "SparseM"] with 4 slots $ SSy : num 100 $ lambda : num 0 $ icyc : int 11 $ ifl : int 1 $ pp.lambda : NULL $ pp.sic : NULL $ i.mask : NULL cb.lo ci.lo fit ci.up cb.up 1 2.44586 2.52970 2.65161 2.77351 2.85735 2 2.40443 2.48418 2.60014 2.71611 2.79586 3 2.36325 2.43912 2.54944 2.65977 2.73564 4 2.32230 2.39451 2.49951 2.60450 2.67671 5 2.28158 2.35034 2.45033 2.55031 2.61908 6 2.24108 2.30662 2.40191 2.49721 2.56275 7 2.20077 2.26332 2.35426 2.44521 2.50775 8 2.16066 2.22044 2.30737 2.39430 2.45408 9 2.12073 2.17799 2.26124 2.34450 2.40175 10 2.08099 2.13595 2.21588 2.29580 2.35077 11 2.04143 2.09434 2.17127 2.24821 2.30112 12 2.00205 2.05314 2.12743 2.20172 2.25281 13 1.96287 2.01237 2.08435 2.15633 2.20583 14 1.92390 1.97204 2.04203 2.11203 2.16016 15 1.88517 1.93216 2.00048 2.06880 2.11578 16 1.84671 1.89275 1.95968 2.02662 2.07265 17 1.80856 1.85383 1.91965 1.98548 2.03074 18 1.77075 1.81542 1.88038 1.94534 1.99001 19 1.73333 1.77756 1.84187 1.90619 1.95042 20 1.69634 1.74026 1.80413 1.86799 1.91191 21 1.65985 1.70357 1.76714 1.83071 1.87444 22 1.62389 1.66750 1.73092 1.79434 1.83795 23 1.58851 1.63209 1.69546 1.75883 1.80241 24 1.55375 1.59736 1.66076 1.72417 1.76777 25 1.51966 1.56333 1.62683 1.69032 1.73399 26 1.48628 1.53003 1.59365 1.65727 1.70102 27 1.45364 1.49748 1.56124 1.62500 1.66884 28 1.42176 1.46570 1.52959 1.59348 1.63742 29 1.39068 1.43470 1.49870 1.56271 1.60672 30 1.36041 1.40449 1.46857 1.53266 1.57674 31 1.33099 1.37509 1.43921 1.50334 1.54744 32 1.30241 1.34650 1.41061 1.47472 1.51881 33 1.27470 1.31874 1.38277 1.44680 1.49084 34 1.24787 1.29180 1.35569 1.41958 1.46352 35 1.22191 1.26570 1.32937 1.39305 1.43684 36 1.19683 1.24043 1.30382 1.36721 1.41081 37 1.17264 1.21599 1.27903 1.34206 1.38542 38 1.14933 1.19239 1.25500 1.31761 1.36067 39 1.12688 1.16961 1.23173 1.29385 1.33658 40 1.10530 1.14765 1.20922 1.27080 1.31315 41 1.08456 1.12650 1.18748 1.24846 1.29040 42 1.06465 1.10615 1.16650 1.22685 1.26835 43 1.04554 1.08659 1.14628 1.20597 1.24702 44 1.02721 1.06780 1.12682 1.18584 1.22643 45 1.00962 1.04976 1.10812 1.16649 1.20663 46 0.99274 1.03245 1.09019 1.14793 1.18765 47 0.97651 1.01584 1.07302 1.13020 1.16953 48 0.96090 0.99990 1.05661 1.11332 1.15232 49 0.94584 0.98460 1.04096 1.09732 1.13608 50 0.93128 0.96991 1.02607 1.08224 1.12087 51 0.91706 0.95569 1.01186 1.06803 1.10665 52 0.90263 0.94139 0.99776 1.05412 1.09288 53 0.88796 0.92696 0.98367 1.04038 1.07938 54 0.87311 0.91243 0.96961 1.02680 1.06612 55 0.85812 0.89783 0.95557 1.01332 1.05303 56 0.84305 0.88319 0.94156 0.99992 1.04006 57 0.82795 0.86854 0.92756 0.98658 1.02717 58 0.81285 0.85390 0.91358 0.97327 1.01432 59 0.79778 0.83928 0.89963 0.95998 1.00148 60 0.78278 0.82471 0.88570 0.94668 0.98862 61 0.76786 0.81021 0.87178 0.93336 0.97571 62 0.75305 0.79577 0.85789 0.92002 0.96274 63 0.73835 0.78141 0.84402 0.90664 0.94970 64 0.72379 0.76714 0.83018 0.89321 0.93656 65 0.70936 0.75296 0.81635 0.87974 0.92334 66 0.69508 0.73887 0.80254 0.86622 0.91001 67 0.68093 0.72487 0.78876 0.85265 0.89658 68 0.66693 0.71096 0.77500 0.83903 0.88306 69 0.65306 0.69714 0.76125 0.82536 0.86945 70 0.63931 0.68341 0.74753 0.81166 0.85576 71 0.62567 0.66975 0.73383 0.79792 0.84199 72 0.61213 0.65615 0.72015 0.78416 0.82818 73 0.59867 0.64261 0.70650 0.77039 0.81433 74 0.58526 0.62910 0.69286 0.75662 0.80046 75 0.57188 0.61563 0.67925 0.74286 0.78662 76 0.55849 0.60216 0.66565 0.72915 0.77281 77 0.54507 0.58867 0.65208 0.71548 0.75909 78 0.53158 0.57516 0.63853 0.70190 0.74548 79 0.51797 0.56158 0.62500 0.68842 0.73203 80 0.50420 0.54792 0.61149 0.67506 0.71878 81 0.49022 0.53414 0.59800 0.66186 0.70578 82 0.47599 0.52022 0.58453 0.64885 0.69308 83 0.46146 0.50613 0.57109 0.63605 0.68072 84 0.44657 0.49184 0.55767 0.62349 0.66876 85 0.43129 0.47733 0.54426 0.61120 0.65723 86 0.41558 0.46256 0.53088 0.59920 0.64618 87 0.39939 0.44753 0.51752 0.58752 0.63565 88 0.38270 0.43220 0.50418 0.57616 0.62566 89 0.36548 0.41657 0.49086 0.56515 0.61625 90 0.34772 0.40063 0.47757 0.55450 0.60741 91 0.32940 0.38437 0.46429 0.54421 0.59918 92 0.31053 0.36778 0.45104 0.53429 0.59155 93 0.29109 0.35087 0.43780 0.52473 0.58452 94 0.27110 0.33365 0.42459 0.51554 0.57808 95 0.25056 0.31610 0.41140 0.50670 0.57224 96 0.22948 0.29825 0.39823 0.49822 0.56698 97 0.20788 0.28009 0.38508 0.49008 0.56229 98 0.18576 0.26163 0.37196 0.48228 0.55815 99 0.16313 0.24289 0.35885 0.47481 0.55457 100 0.14002 0.22386 0.34577 0.46767 0.55151 knots : [1] -1 0 1 coef : [1] 2.65161 1.36849 0.66935 0.34577 > > summaryCobs(cXy1 <- cobs(X,y, "decrease", lambda= 0.1)) List of 24 $ call : language cobs(x = X, y = y, constraint = "decrease", lambda = 0.1) $ tau : num 0.5 $ degree : num 2 $ constraint : chr "decrease" $ ic : NULL $ pointwise : NULL $ select.knots : logi TRUE $ select.lambda: logi FALSE $ x : num [1:201] -1 -0.99 -0.98 -0.97 -0.96 -0.95 -0.94 -0.93 -0.92 -0.91 ... $ y : num [1:201] 2.67 2.77 3.46 3.14 1.79 ... $ resid : num [1:201] 0 0.129 0.849 0.567 -0.755 ... $ fitted : num [1:201] 2.67 2.64 2.61 2.58 2.55 ... $ coef : num [1:22] 2.67 2.51 2.22 2 1.84 ... $ knots : num [1:20] -1 -0.9 -0.79 -0.69 -0.58 -0.48 -0.37 -0.27 -0.16 -0.06 ... $ k0 : int 9 $ k : int 9 $ x.ps :Formal class 'matrix.csr' [package "SparseM"] with 4 slots $ SSy : num 100 $ lambda : num 0.1 $ icyc : int 22 $ ifl : int 1 $ pp.lambda : NULL $ pp.sic : NULL $ i.mask : NULL cb.lo ci.lo fit ci.up cb.up 1 2.51414 2.60364 2.67153 2.73941 2.82892 2 2.45282 2.54054 2.60707 2.67361 2.76132 3 2.39361 2.47959 2.54481 2.61002 2.69600 4 2.33651 2.42080 2.48472 2.54865 2.63293 5 2.28152 2.36415 2.42683 2.48950 2.57213 6 2.22864 2.30966 2.37112 2.43257 2.51359 7 2.17786 2.25732 2.31759 2.37786 2.45733 8 2.12918 2.20713 2.26625 2.32538 2.40332 9 2.08261 2.15909 2.21710 2.27511 2.35158 10 2.03816 2.11321 2.17013 2.22706 2.30211 11 1.99581 2.06948 2.12535 2.18123 2.25489 12 1.95557 2.02790 2.08276 2.13762 2.20995 13 1.91743 1.98847 2.04235 2.09623 2.16727 14 1.88140 1.95119 2.00413 2.05706 2.12685 15 1.84748 1.91607 1.96809 2.02011 2.08870 16 1.81567 1.88309 1.93424 1.98538 2.05281 17 1.78537 1.85168 1.90198 1.95228 2.01859 18 1.75458 1.81982 1.86931 1.91880 1.98404 19 1.72314 1.78736 1.83607 1.88477 1.94899 20 1.69105 1.75428 1.80224 1.85020 1.91343 21 1.65832 1.72060 1.76784 1.81509 1.87737 22 1.62500 1.68638 1.73293 1.77948 1.84086 23 1.59293 1.65344 1.69934 1.74524 1.80575 24 1.56297 1.62266 1.66794 1.71321 1.77290 25 1.53513 1.59404 1.63872 1.68340 1.74230 26 1.50941 1.56757 1.61169 1.65580 1.71396 27 1.48580 1.54326 1.58684 1.63042 1.68788 28 1.46431 1.52110 1.56418 1.60726 1.66405 29 1.44495 1.50111 1.54370 1.58630 1.64246 30 1.42771 1.48327 1.52542 1.56756 1.62313 31 1.41260 1.46760 1.50931 1.55103 1.60603 32 1.39962 1.45409 1.49540 1.53671 1.59118 33 1.38731 1.44128 1.48222 1.52315 1.57712 34 1.37283 1.42634 1.46692 1.50751 1.56101 35 1.35611 1.40918 1.44944 1.48970 1.54278 36 1.33715 1.38982 1.42978 1.46973 1.52241 37 1.31594 1.36825 1.40793 1.44760 1.49991 38 1.29257 1.34454 1.38397 1.42339 1.47536 39 1.26717 1.31884 1.35803 1.39722 1.44889 40 1.23975 1.29113 1.33011 1.36909 1.42047 41 1.21030 1.26143 1.30021 1.33900 1.39013 42 1.17884 1.22974 1.26834 1.30695 1.35785 43 1.14543 1.19613 1.23458 1.27303 1.32372 44 1.11082 1.16134 1.19966 1.23797 1.28849 45 1.07517 1.12554 1.16374 1.20195 1.25232 46 1.03848 1.08873 1.12684 1.16495 1.21519 47 1.00075 1.05090 1.08894 1.12698 1.17712 48 0.96234 1.01242 1.05040 1.08838 1.13846 49 0.92562 0.97565 1.01360 1.05155 1.10159 50 0.89105 0.94106 0.97899 1.01692 1.06694 51 0.85862 0.90863 0.94656 0.98450 1.03451 52 0.82835 0.87838 0.91632 0.95427 1.00430 53 0.80022 0.85029 0.88827 0.92625 0.97632 54 0.77422 0.82437 0.86240 0.90043 0.95058 55 0.75037 0.80061 0.83872 0.87683 0.92707 56 0.72866 0.77902 0.81722 0.85542 0.90579 57 0.70908 0.75960 0.79791 0.83622 0.88674 58 0.69165 0.74234 0.78079 0.81923 0.86992 59 0.67635 0.72724 0.76585 0.80445 0.85535 60 0.66319 0.71432 0.75309 0.79187 0.84300 61 0.65218 0.70356 0.74253 0.78150 0.83288 62 0.64331 0.69496 0.73415 0.77333 0.82499 63 0.63657 0.68854 0.72795 0.76737 0.81933 64 0.63171 0.68401 0.72368 0.76335 0.81565 65 0.62775 0.68042 0.72037 0.76032 0.81299 66 0.62460 0.67767 0.71792 0.75818 0.81124 67 0.62227 0.67577 0.71635 0.75692 0.81042 68 0.62074 0.67470 0.71563 0.75656 0.81052 69 0.61966 0.67412 0.71542 0.75673 0.81119 70 0.61787 0.67287 0.71458 0.75629 0.81128 71 0.61532 0.67088 0.71301 0.75515 0.81071 72 0.61199 0.66814 0.71073 0.75332 0.80948 73 0.60788 0.66467 0.70774 0.75080 0.80759 74 0.60296 0.66041 0.70398 0.74755 0.80500 75 0.59620 0.65436 0.69847 0.74258 0.80074 76 0.58719 0.64609 0.69077 0.73545 0.79435 77 0.57593 0.63561 0.68089 0.72616 0.78585 78 0.56241 0.62292 0.66882 0.71471 0.77522 79 0.54678 0.60815 0.65471 0.70126 0.76264 80 0.53156 0.59385 0.64109 0.68833 0.75062 81 0.51769 0.58093 0.62889 0.67685 0.74009 82 0.50517 0.56939 0.61810 0.66681 0.73103 83 0.49398 0.55923 0.60873 0.65822 0.72347 84 0.48414 0.55046 0.60077 0.65107 0.71739 85 0.47436 0.54180 0.59295 0.64410 0.71154 86 0.46236 0.53096 0.58299 0.63503 0.70363 87 0.44809 0.51790 0.57085 0.62380 0.69360 88 0.43156 0.50262 0.55652 0.61042 0.68147 89 0.41277 0.48512 0.54000 0.59488 0.66724 90 0.39171 0.46541 0.52130 0.57720 0.65089 91 0.36839 0.44347 0.50042 0.55736 0.63244 92 0.34280 0.41931 0.47734 0.53538 0.61189 93 0.31495 0.39293 0.45208 0.51123 0.58922 94 0.28483 0.36433 0.42464 0.48494 0.56445 95 0.25288 0.33395 0.39544 0.45693 0.53800 96 0.22236 0.30504 0.36775 0.43047 0.51315 97 0.19395 0.27829 0.34226 0.40623 0.49056 98 0.16764 0.25368 0.31894 0.38420 0.47024 99 0.14345 0.23123 0.29782 0.36440 0.45218 100 0.12136 0.21093 0.27887 0.34681 0.43639 knots : [1] -1.00 -0.90 -0.79 -0.69 -0.58 -0.48 -0.37 -0.27 -0.16 -0.06 0.05 0.15 [13] 0.26 0.36 0.47 0.57 0.68 0.78 0.89 1.00 coef : [1] 2.67153 2.50930 2.22485 2.00227 1.83593 1.65328 1.52687 1.46233 1.34154 [10] 1.16477 0.96250 0.82208 0.73790 0.71559 0.71559 0.69529 0.61876 0.58223 [19] 0.48946 0.32747 0.27887 5.35615 > 1 - sum(cXy1 $ resid ^ 2) / sum((y - mean(y))^2) # R^2 = 79.53 % [1] 0.78505 > showProc.time() Time (user system elapsed): 2.5 0.31 2.81 > > summaryCobs(cXy2 <- cobs(X,y, "decrease", lambda= 1e-2)) List of 24 $ call : language cobs(x = X, y = y, constraint = "decrease", lambda = 0.01) $ tau : num 0.5 $ degree : num 2 $ constraint : chr "decrease" $ ic : NULL $ pointwise : NULL $ select.knots : logi TRUE $ select.lambda: logi FALSE $ x : num [1:201] -1 -0.99 -0.98 -0.97 -0.96 -0.95 -0.94 -0.93 -0.92 -0.91 ... $ y : num [1:201] 2.67 2.77 3.46 3.14 1.79 ... $ resid : num [1:201] -0.142 0 0.732 0.463 -0.846 ... $ fitted : num [1:201] 2.81 2.77 2.72 2.68 2.64 ... $ coef : num [1:22] 2.81 2.59 2.18 1.96 1.95 ... $ knots : num [1:20] -1 -0.9 -0.79 -0.69 -0.58 -0.48 -0.37 -0.27 -0.16 -0.06 ... $ k0 : int 19 $ k : int 19 $ x.ps :Formal class 'matrix.csr' [package "SparseM"] with 4 slots $ SSy : num 100 $ lambda : num 0.01 $ icyc : int 31 $ ifl : int 1 $ pp.lambda : NULL $ pp.sic : NULL $ i.mask : NULL cb.lo ci.lo fit ci.up cb.up 1 2.605489 2.74773 2.81374 2.87975 3.02199 2 2.519364 2.65877 2.72346 2.78816 2.92756 3 2.435965 2.57260 2.63602 2.69943 2.83607 4 2.355295 2.48924 2.55140 2.61356 2.74751 5 2.277355 2.40867 2.46962 2.53056 2.66188 6 2.202147 2.33091 2.39067 2.45043 2.57919 7 2.131576 2.25786 2.31647 2.37508 2.50136 8 2.067222 2.19110 2.24859 2.30608 2.42996 9 2.009088 2.13063 2.18704 2.24344 2.36498 10 1.957177 2.07645 2.13180 2.18716 2.30643 11 1.911487 2.02856 2.08289 2.13723 2.25430 12 1.872374 1.98732 2.04067 2.09402 2.20897 13 1.841293 1.95419 2.00658 2.05898 2.17188 14 1.818403 1.92932 1.98079 2.03227 2.14318 15 1.803705 1.91271 1.96329 2.01388 2.12288 16 1.797199 1.90436 1.95409 2.00382 2.11098 17 1.794311 1.89970 1.94861 1.99752 2.10291 18 1.779578 1.88327 1.93139 1.97951 2.08320 19 1.751740 1.85380 1.90116 1.94852 2.05058 20 1.710799 1.81129 1.85792 1.90456 2.00505 21 1.656757 1.75574 1.80168 1.84761 1.94659 22 1.590182 1.68772 1.73299 1.77826 1.87580 23 1.528397 1.62457 1.66920 1.71383 1.81000 24 1.479526 1.57439 1.61841 1.66244 1.75730 25 1.443573 1.53719 1.58064 1.62408 1.71770 26 1.420540 1.51297 1.55587 1.59877 1.69120 27 1.410036 1.50135 1.54373 1.58610 1.67742 28 1.404155 1.49441 1.53630 1.57818 1.66844 29 1.399777 1.48903 1.53045 1.57187 1.66113 30 1.396909 1.48521 1.52619 1.56718 1.65548 31 1.395552 1.48296 1.52352 1.56409 1.65149 32 1.395704 1.48226 1.52244 1.56261 1.64917 33 1.393671 1.47944 1.51925 1.55905 1.64482 34 1.382224 1.46726 1.50672 1.54619 1.63122 35 1.361180 1.44553 1.48468 1.52382 1.60818 36 1.330541 1.41426 1.45311 1.49196 1.57568 37 1.290305 1.37344 1.41202 1.45060 1.53373 38 1.247271 1.32987 1.36821 1.40654 1.48914 39 1.212662 1.29478 1.33288 1.37099 1.45311 40 1.186651 1.26832 1.30622 1.34412 1.42579 41 1.169241 1.25050 1.28821 1.32592 1.40718 42 1.160431 1.24132 1.27886 1.31640 1.39729 43 1.158304 1.23887 1.27626 1.31365 1.39421 44 1.146745 1.22703 1.26429 1.30155 1.38184 45 1.122114 1.20216 1.23931 1.27646 1.35651 46 1.084416 1.16427 1.20133 1.23838 1.31824 47 1.033648 1.11335 1.15033 1.18732 1.26701 48 0.972156 1.05174 1.08868 1.12561 1.20520 49 0.915883 0.99540 1.03230 1.06920 1.14872 50 0.867825 0.94731 0.98419 1.02108 1.10056 51 0.827986 0.90746 0.94435 0.98123 1.06071 52 0.796364 0.87587 0.91277 0.94967 1.02918 53 0.772952 0.85253 0.88946 0.92639 1.00597 54 0.752890 0.83258 0.86957 0.90655 0.98624 55 0.731786 0.81163 0.84869 0.88574 0.96559 56 0.709642 0.78968 0.82683 0.86398 0.94402 57 0.686458 0.76674 0.80399 0.84125 0.92153 58 0.662245 0.74280 0.78019 0.81758 0.89813 59 0.640091 0.72098 0.75851 0.79605 0.87694 60 0.622329 0.70358 0.74129 0.77900 0.86025 61 0.608963 0.69062 0.72851 0.76641 0.84807 62 0.599991 0.68209 0.72019 0.75829 0.84039 63 0.595409 0.67799 0.71632 0.75465 0.83723 64 0.594323 0.67744 0.71601 0.75459 0.83771 65 0.593466 0.67717 0.71601 0.75486 0.83856 66 0.592537 0.67687 0.71601 0.75515 0.83949 67 0.591535 0.67656 0.71601 0.75547 0.84049 68 0.590458 0.67622 0.71601 0.75581 0.84157 69 0.589298 0.67585 0.71601 0.75618 0.84273 70 0.588060 0.67546 0.71601 0.75657 0.84397 71 0.586747 0.67504 0.71601 0.75699 0.84528 72 0.585359 0.67460 0.71601 0.75743 0.84667 73 0.583894 0.67414 0.71601 0.75789 0.84814 74 0.582215 0.67352 0.71589 0.75826 0.84956 75 0.577189 0.66961 0.71251 0.75540 0.84782 76 0.567471 0.66108 0.70452 0.74797 0.84158 77 0.553063 0.64792 0.69194 0.73596 0.83082 78 0.533963 0.63013 0.67476 0.71939 0.81555 79 0.510470 0.60801 0.65328 0.69855 0.79609 80 0.487866 0.58685 0.63279 0.67873 0.77771 81 0.468074 0.56857 0.61521 0.66184 0.76234 82 0.451096 0.55316 0.60053 0.64789 0.74996 83 0.436930 0.54063 0.58875 0.63688 0.74058 84 0.425569 0.53097 0.57989 0.62880 0.73421 85 0.416479 0.52366 0.57340 0.62314 0.73031 86 0.408707 0.51773 0.56833 0.61893 0.72795 87 0.402237 0.51318 0.56467 0.61615 0.72709 88 0.397069 0.51000 0.56240 0.61481 0.72774 89 0.393199 0.50819 0.56155 0.61491 0.72990 90 0.385630 0.50275 0.55710 0.61146 0.72857 91 0.366831 0.48615 0.54153 0.59690 0.71623 92 0.336727 0.45832 0.51475 0.57118 0.69278 93 0.295317 0.41926 0.47677 0.53429 0.65823 94 0.242600 0.36895 0.42759 0.48623 0.61258 95 0.180789 0.30963 0.36942 0.42922 0.55806 96 0.126624 0.25803 0.31901 0.37999 0.51139 97 0.083560 0.21760 0.27980 0.34200 0.47604 98 0.051597 0.18833 0.25179 0.31525 0.45199 99 0.030734 0.17024 0.23499 0.29973 0.43924 100 0.020967 0.16332 0.22938 0.29545 0.43780 knots : [1] -1.00 -0.90 -0.79 -0.69 -0.58 -0.48 -0.37 -0.27 -0.16 -0.06 0.05 0.15 [13] 0.26 0.36 0.47 0.57 0.68 0.78 0.89 1.00 coef : [1] 2.81374 2.58680 2.18306 1.95827 1.94686 1.56729 1.52241 1.52241 [9] 1.27741 1.27741 0.94271 0.84198 0.71601 0.71601 0.71601 0.71601 [17] 0.59766 0.56154 0.56154 0.22938 0.22938 31.87536 > 1 - sum(cXy2 $ resid ^ 2) / sum((y - mean(y))^2) # R^2 = 80.004% [1] 0.79002 > > summaryCobs(cXy3 <- cobs(X,y, "decrease", lambda= 1e-6, nknots = 60)) List of 24 $ call : language cobs(x = X, y = y, constraint = "decrease", nknots = 60, lambda = 1e-06) $ tau : num 0.5 $ degree : num 2 $ constraint : chr "decrease" $ ic : NULL $ pointwise : NULL $ select.knots : logi TRUE $ select.lambda: logi FALSE $ x : num [1:201] -1 -0.99 -0.98 -0.97 -0.96 -0.95 -0.94 -0.93 -0.92 -0.91 ... $ y : num [1:201] 2.67 2.77 3.46 3.14 1.79 ... $ resid : num [1:201] -0.104 0 0.708 0.43 -0.872 ... $ fitted : num [1:201] 2.78 2.77 2.75 2.71 2.66 ... $ coef : num [1:62] 2.78 2.78 2.65 2.32 2.32 2.32 2.02 2.02 2.02 1.92 ... $ knots : num [1:60] -1 -0.97 -0.94 -0.9 -0.87 -0.84 -0.8 -0.77 -0.73 -0.7 ... $ k0 : int 61 $ k : int 61 $ x.ps :Formal class 'matrix.csr' [package "SparseM"] with 4 slots $ SSy : num 100 $ lambda : num 1e-06 $ icyc : int 45 $ ifl : int 1 $ pp.lambda : NULL $ pp.sic : NULL $ i.mask : NULL cb.lo ci.lo fit ci.up cb.up 1 2.5044764 2.72392 2.77558 2.82724 3.04669 2 2.4804655 2.69660 2.74747 2.79835 3.01448 3 2.3980118 2.61089 2.66100 2.71112 2.92400 4 2.2450703 2.45477 2.50413 2.55349 2.76319 5 2.1090546 2.31564 2.36427 2.41290 2.61948 6 2.0692878 2.27282 2.32074 2.36865 2.57219 7 2.0729687 2.27353 2.32074 2.36795 2.56850 8 2.0581607 2.25581 2.30233 2.34886 2.54650 9 1.9394896 2.13429 2.18015 2.22601 2.42081 10 1.8218037 2.01383 2.05904 2.10424 2.29627 11 1.7901080 1.97943 2.02400 2.06856 2.25789 12 1.7933678 1.98005 2.02400 2.06794 2.25463 13 1.7909791 1.97509 2.01843 2.06178 2.24589 14 1.7612657 1.94288 1.98563 2.02838 2.20999 15 1.7158848 1.89506 1.93724 1.97942 2.15859 16 1.7046338 1.88144 1.92306 1.96468 2.14149 17 1.7074707 1.88198 1.92306 1.96414 2.13866 18 1.7095965 1.88188 1.92244 1.96300 2.13528 19 1.7089720 1.87910 1.91915 1.95919 2.12932 20 1.6983160 1.86635 1.90590 1.94546 2.11349 21 1.6555611 1.82157 1.86065 1.89972 2.06573 22 1.5682552 1.73231 1.77092 1.80954 1.97359 23 1.4347952 1.59695 1.63513 1.67330 1.83546 24 1.3579969 1.51833 1.55607 1.59382 1.75415 25 1.3565324 1.51512 1.55245 1.58978 1.74836 26 1.3586097 1.51551 1.55245 1.58938 1.74628 27 1.3606050 1.51589 1.55245 1.58900 1.74429 28 1.3617752 1.51551 1.55170 1.58789 1.74162 29 1.3478358 1.50009 1.53593 1.57177 1.72402 30 1.3243716 1.47521 1.51072 1.54623 1.69707 31 1.3153625 1.46485 1.50004 1.53523 1.68472 32 1.3166567 1.46486 1.49975 1.53464 1.68284 33 1.3181552 1.46515 1.49975 1.53435 1.68135 34 1.3195652 1.46542 1.49975 1.53408 1.67994 35 1.3208903 1.46567 1.49975 1.53383 1.67861 36 1.3221387 1.46591 1.49975 1.53359 1.67736 37 1.3001185 1.44294 1.47656 1.51018 1.65301 38 1.2213523 1.36330 1.39672 1.43013 1.57208 39 1.1507001 1.29185 1.32508 1.35830 1.49945 40 1.1067605 1.24718 1.28023 1.31328 1.45370 41 1.0908554 1.23060 1.26350 1.29639 1.43614 42 1.0914765 1.23062 1.26337 1.29612 1.43526 43 1.0921367 1.23074 1.26337 1.29600 1.43460 44 1.0927190 1.23085 1.26337 1.29589 1.43402 45 1.0932246 1.23095 1.26337 1.29579 1.43351 46 1.0936432 1.23103 1.26337 1.29571 1.43310 47 1.0327751 1.16989 1.20217 1.23445 1.37157 48 0.8629538 0.99988 1.03211 1.06434 1.20126 49 0.7549845 0.89178 0.92398 0.95618 1.09297 50 0.7307027 0.86742 0.89961 0.93179 1.06851 51 0.7262972 0.86302 0.89520 0.92738 1.06411 52 0.7262144 0.86300 0.89520 0.92740 1.06419 53 0.7260569 0.86297 0.89520 0.92743 1.06435 54 0.7258163 0.86293 0.89520 0.92748 1.06459 55 0.7254864 0.86286 0.89520 0.92754 1.06492 56 0.7250674 0.86278 0.89520 0.92762 1.06533 57 0.7245663 0.86269 0.89520 0.92771 1.06584 58 0.7239901 0.86258 0.89520 0.92782 1.06641 59 0.7233300 0.86245 0.89520 0.92795 1.06707 60 0.7134907 0.85322 0.88611 0.91900 1.05873 61 0.6557286 0.79612 0.82917 0.86222 1.00261 62 0.5683298 0.70945 0.74268 0.77590 0.91702 63 0.5406779 0.68261 0.71601 0.74942 0.89135 64 0.5395974 0.68240 0.71601 0.74963 0.89243 65 0.5384304 0.68218 0.71601 0.74985 0.89360 66 0.5371860 0.68194 0.71601 0.75009 0.89484 67 0.5358615 0.68169 0.71601 0.75034 0.89617 68 0.5342546 0.68122 0.71582 0.75042 0.89739 69 0.5241943 0.67238 0.70726 0.74214 0.89033 70 0.5066514 0.65612 0.69131 0.72649 0.87596 71 0.4974737 0.64829 0.68379 0.71930 0.87011 72 0.4953270 0.64756 0.68339 0.71923 0.87146 73 0.4934922 0.64721 0.68339 0.71958 0.87330 74 0.4915755 0.64684 0.68339 0.71994 0.87521 75 0.4895794 0.64646 0.68339 0.72032 0.87721 76 0.4874971 0.64607 0.68339 0.72072 0.87929 77 0.4853265 0.64565 0.68339 0.72114 0.88146 78 0.4829775 0.64513 0.68330 0.72147 0.88363 79 0.4787766 0.64283 0.68144 0.72006 0.88411 80 0.4704266 0.63644 0.67551 0.71459 0.88060 81 0.4307911 0.59883 0.63839 0.67794 0.84598 82 0.3745174 0.54466 0.58471 0.62476 0.79489 83 0.3497748 0.52208 0.56264 0.60320 0.77550 84 0.3465407 0.52108 0.56216 0.60325 0.77778 85 0.3436950 0.52053 0.56216 0.60379 0.78063 86 0.3407623 0.51997 0.56216 0.60435 0.78356 87 0.3377445 0.51940 0.56216 0.60492 0.78658 88 0.3346446 0.51881 0.56216 0.60551 0.78968 89 0.3314601 0.51820 0.56216 0.60612 0.79286 90 0.3281895 0.51758 0.56216 0.60674 0.79613 91 0.3248353 0.51694 0.56216 0.60738 0.79949 92 0.3213975 0.51628 0.56216 0.60804 0.80292 93 0.3178740 0.51561 0.56216 0.60871 0.80645 94 0.2620115 0.46267 0.50991 0.55714 0.75780 95 0.1064903 0.31014 0.35808 0.40602 0.60967 96 0.0089419 0.21565 0.26431 0.31297 0.51968 97 -0.0078825 0.20195 0.25135 0.30074 0.51058 98 -0.0118286 0.20120 0.25135 0.30149 0.51452 99 -0.0158587 0.20043 0.25135 0.30226 0.51855 100 -0.0199722 0.19965 0.25135 0.30305 0.52267 knots : [1] -1.00 -0.97 -0.94 -0.90 -0.87 -0.84 -0.80 -0.77 -0.73 -0.70 -0.67 -0.63 [13] -0.60 -0.56 -0.53 -0.50 -0.46 -0.43 -0.39 -0.36 -0.33 -0.29 -0.26 -0.23 [25] -0.19 -0.16 -0.12 -0.09 -0.06 -0.02 0.01 0.05 0.08 0.11 0.15 0.18 [37] 0.22 0.25 0.28 0.32 0.35 0.38 0.42 0.45 0.49 0.52 0.55 0.59 [49] 0.62 0.66 0.69 0.72 0.76 0.79 0.83 0.86 0.89 0.93 0.96 1.00 coef : [1] 2.77558 2.77558 2.65160 2.32074 2.32074 2.32074 2.02400 [8] 2.02400 2.02400 1.92306 1.92306 1.92306 1.91336 1.81828 [15] 1.55245 1.55245 1.55245 1.55245 1.49975 1.49975 1.49975 [22] 1.49975 1.49975 1.35985 1.26337 1.26337 1.26337 1.26337 [29] 1.26337 0.91810 0.89520 0.89520 0.89520 0.89520 0.89520 [36] 0.89520 0.89520 0.71601 0.71601 0.71601 0.71601 0.71601 [43] 0.68339 0.68339 0.68339 0.68339 0.68339 0.68339 0.67516 [50] 0.56216 0.56216 0.56216 0.56216 0.56216 0.56216 0.56216 [57] 0.56216 0.25135 0.25135 0.25135 0.25135 328.83053 > 1 - sum(cXy3 $ resid ^ 2) / sum((y - mean(y))^2) # R^2 = 80.424% [1] 0.79665 > showProc.time() Time (user system elapsed): 0.06 0.02 0.08 > > cpuTime(cXy4 <- cobs(X,y, "decrease", lambda= 1e-6, nknots = 100))#~16.5" Time elapsed: 0.03 > ## not converged (in 4020 iter.) > 1 - sum(cXy4 $ resid ^ 2) / sum((y - mean(y))^2) # R^2 = 80.517% [1] 0.80082 > > cpuTime(cXy5 <- cobs(X,y, "decrease", lambda= 1e-6, nknots = 150))#~12.8" Time elapsed: 0.03 Warning message: In cobs(X, y, "decrease", lambda = 1e-06, nknots = 150) : drqssbc2(): Not all flags are normal (== 1), ifl : 18 > 1 - sum(cXy5 $ resid ^ 2) / sum((y - mean(y))^2) # R^2 = 81.329% [1] 0.80368 > > proc.time() user system elapsed 5.95 0.59 6.53