R Under development (unstable) (2024-02-23 r85978 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)) > > #### Example 1 of He and Ng (1999) : > #### ------------------------------- > if(!dev.interactive(orNone=TRUE)) pdf("temp.pdf", width=10) > > data(globtemp) > str(globtemp)## time series T=113, 1880:1992 Time-Series [1:113] from 1880 to 1992: -0.32 -0.32 -0.4 -0.39 -0.65 -0.43 -0.4 -0.52 -0.3 -0.12 ... > > ## require(ts)# later for plotting > ## At the moment forget about all time-series stuff; use num.vectors: > str(year <- as.vector(time(globtemp))) num [1:113] 1880 1881 1882 1883 1884 ... > str(temp <- as.vector(globtemp)) num [1:113] -0.32 -0.32 -0.4 -0.39 -0.65 -0.43 -0.4 -0.52 -0.3 -0.12 ... > > ## Codes for Figure 1a > a50 <- cobs(year, temp, knots.add = TRUE, degree = 1, constraint = "increase", + ic = "SIC") # = previous default 'ic' qbsks2(): Performing general knot selection ... Deleting unnecessary knots ... Searching for missing knots ... > summary(a50) COBS regression spline (degree = 1) from call: cobs(x = year, y = temp, constraint = "increase", degree = 1, ic = "SIC", knots.add = TRUE) {tau=0.5}-quantile; dimensionality of fit: 4 from {4} x$knots[1:4]: 1880, 1936, 1964, 1992 coef[1:4]: -0.47054145, -0.01648649, -0.01648649, 0.27562279 R^2 = 70.37% ; empirical tau (over all): 56/113 = 0.4955752 (target tau= 0.5) > ## As suggested in the warning message, we increase the number of knots to 9 > a50 <- cobs(year, temp, nknots = 9, knots.add = TRUE, degree = 1, + constraint = "increase", ic = "SIC") # = previous default 'ic' qbsks2(): Performing general knot selection ... Deleting unnecessary knots ... Searching for missing knots ... > summary(a50) COBS regression spline (degree = 1) from call: cobs(x = year, y = temp, constraint = "increase", nknots = 9, degree = 1, ic = "SIC", knots.add = TRUE) {tau=0.5}-quantile; dimensionality of fit: 4 from {4} x$knots[1:4]: 1880, 1936, 1964, 1992 coef[1:4]: -0.47054145, -0.01648649, -0.01648649, 0.27562279 R^2 = 70.37% ; empirical tau (over all): 56/113 = 0.4955752 (target tau= 0.5) > ## Here, we use the same knots sequence chosen for the 50th percentile > a10 <- cobs(year, temp, nknots = length(a50$knots), knots = a50$knot, + degree = 1, tau = 0.1, constraint = "increase", ic = "SIC") > summary(a10) COBS regression spline (degree = 1) from call: cobs(x = year, y = temp, constraint = "increase", knots = a50$knot, nknots = length(a50$knots), degree = 1, tau = 0.1, ic = "SIC") {tau=0.1}-quantile; dimensionality of fit: 4 from {4} x$knots[1:4]: 1880, 1936, 1964, 1992 coef[1:4]: -0.5700016, -0.1700000, -0.1700000, 0.1300024 empirical tau (over all): 12/113 = 0.1061947 (target tau= 0.1) > a90 <- cobs(year, temp, nknots = length(a50$knots), knots = a50$knot, + degree = 1, tau = 0.9, constraint = "increase", ic = "SIC") > summary(a90) COBS regression spline (degree = 1) from call: cobs(x = year, y = temp, constraint = "increase", knots = a50$knot, nknots = length(a50$knots), degree = 1, tau = 0.9, ic = "SIC") {tau=0.9}-quantile; dimensionality of fit: 4 from {4} x$knots[1:4]: 1880, 1936, 1964, 1992 coef[1:4]: -0.2576939, 0.1300000, 0.1300000, 0.4961568 empirical tau (over all): 104/113 = 0.920354 (target tau= 0.9) > > which(hot.idx <- temp >= a90$fit) [1] 10 18 21 22 47 61 74 102 111 > which(cold.idx <- temp <= a10$fit) [1] 5 8 25 28 38 39 85 86 92 95 97 113 > normal.idx <- !hot.idx & !cold.idx > > (pa50 <- predict(a50,year,interval = "both")) z fit cb.lo cb.up ci.lo ci.up [1,] 1880 -0.470540541 -0.580395233 -0.360685849 -0.541226637 -0.399854444 [2,] 1881 -0.462432432 -0.569650451 -0.355214414 -0.531421959 -0.393442906 [3,] 1882 -0.454324324 -0.558928137 -0.349720511 -0.521631738 -0.387016910 [4,] 1883 -0.446216216 -0.548230020 -0.344202412 -0.511857087 -0.380575346 [5,] 1884 -0.438108108 -0.537557989 -0.338658227 -0.502099220 -0.374116996 [6,] 1885 -0.430000000 -0.526914115 -0.333085885 -0.492359472 -0.367640528 [7,] 1886 -0.421891892 -0.516300667 -0.327483116 -0.482639300 -0.361144484 [8,] 1887 -0.413783784 -0.505720132 -0.321847435 -0.472940307 -0.354627261 [9,] 1888 -0.405675676 -0.495175238 -0.316176113 -0.463264247 -0.348087105 [10,] 1889 -0.397567568 -0.484668976 -0.310466159 -0.453613044 -0.341522091 [11,] 1890 -0.389459459 -0.474204626 -0.304714293 -0.443988810 -0.334930108 [12,] 1891 -0.381351351 -0.463785782 -0.298916920 -0.434393857 -0.328308845 [13,] 1892 -0.373243243 -0.453416379 -0.293070107 -0.424830717 -0.321655770 [14,] 1893 -0.365135135 -0.443100719 -0.287169552 -0.415302157 -0.314968113 [15,] 1894 -0.357027027 -0.432843496 -0.281210558 -0.405811200 -0.308242854 [16,] 1895 -0.348918919 -0.422649821 -0.275188017 -0.396361132 -0.301476706 [17,] 1896 -0.340810811 -0.412525238 -0.269096384 -0.386955521 -0.294666101 [18,] 1897 -0.332702703 -0.402475737 -0.262929668 -0.377598222 -0.287807183 [19,] 1898 -0.324594595 -0.392507759 -0.256681430 -0.368293379 -0.280895810 [20,] 1899 -0.316486486 -0.382628180 -0.250344793 -0.359045416 -0.273927557 [21,] 1900 -0.308378378 -0.372844288 -0.243912468 -0.349859024 -0.266897733 [22,] 1901 -0.300270270 -0.363163733 -0.237376807 -0.340739124 -0.259801417 [23,] 1902 -0.292162162 -0.353594450 -0.230729874 -0.331690821 -0.252633503 [24,] 1903 -0.284054054 -0.344144557 -0.223963551 -0.322719340 -0.245388768 [25,] 1904 -0.275945946 -0.334822217 -0.217069675 -0.313829934 -0.238061958 [26,] 1905 -0.267837838 -0.325635470 -0.210040206 -0.305027774 -0.230647901 [27,] 1906 -0.259729730 -0.316592032 -0.202867427 -0.296317828 -0.223141632 [28,] 1907 -0.251621622 -0.307699075 -0.195544168 -0.287704708 -0.215538535 [29,] 1908 -0.243513514 -0.298962989 -0.188064038 -0.279192527 -0.207834500 [30,] 1909 -0.235405405 -0.290389150 -0.180421661 -0.270784743 -0.200026067 [31,] 1910 -0.227297297 -0.281981702 -0.172612893 -0.262484025 -0.192110570 [32,] 1911 -0.219189189 -0.273743385 -0.164634993 -0.254292134 -0.184086245 [33,] 1912 -0.211081081 -0.265675409 -0.156486753 -0.246209849 -0.175952313 [34,] 1913 -0.202972973 -0.257777400 -0.148168546 -0.238236929 -0.167709017 [35,] 1914 -0.194864865 -0.250047417 -0.139682313 -0.230372126 -0.159357604 [36,] 1915 -0.186756757 -0.242482039 -0.131031475 -0.222613238 -0.150900276 [37,] 1916 -0.178648649 -0.235076516 -0.122220781 -0.214957209 -0.142340088 [38,] 1917 -0.170540541 -0.227824968 -0.113256113 -0.207400255 -0.133680826 [39,] 1918 -0.162432432 -0.220720606 -0.104144259 -0.199938008 -0.124926856 [40,] 1919 -0.154324324 -0.213755974 -0.094892674 -0.192565671 -0.116082978 [41,] 1920 -0.146216216 -0.206923176 -0.085509256 -0.185278162 -0.107154270 [42,] 1921 -0.138108108 -0.200214092 -0.076002124 -0.178070257 -0.098145959 [43,] 1922 -0.130000000 -0.193620560 -0.066379440 -0.170936704 -0.089063296 [44,] 1923 -0.121891892 -0.187134533 -0.056649251 -0.163872326 -0.079911458 [45,] 1924 -0.113783784 -0.180748200 -0.046819367 -0.156872096 -0.070695472 [46,] 1925 -0.105675676 -0.174454074 -0.036897277 -0.149931196 -0.061420156 [47,] 1926 -0.097567568 -0.168245056 -0.026890080 -0.143045058 -0.052090077 [48,] 1927 -0.089459459 -0.162114471 -0.016804448 -0.136209390 -0.042709529 [49,] 1928 -0.081351351 -0.156056093 -0.006646610 -0.129420182 -0.033282521 [50,] 1929 -0.073243243 -0.150064140 0.003577654 -0.122673716 -0.023812771 [51,] 1930 -0.065135135 -0.144133276 0.013863006 -0.115966557 -0.014303713 [52,] 1931 -0.057027027 -0.138258588 0.024204534 -0.109295545 -0.004758509 [53,] 1932 -0.048918919 -0.132435569 0.034597732 -0.102657780 0.004819942 [54,] 1933 -0.040810811 -0.126660095 0.045038473 -0.096050607 0.014428985 [55,] 1934 -0.032702703 -0.120928393 0.055522988 -0.089471600 0.024066194 [56,] 1935 -0.024594595 -0.115237021 0.066047832 -0.082918542 0.033729353 [57,] 1936 -0.016486486 -0.109582838 0.076609865 -0.076389415 0.043416442 [58,] 1937 -0.016486486 -0.105401253 0.072428280 -0.073698770 0.040725797 [59,] 1938 -0.016486486 -0.101403226 0.068430253 -0.071126236 0.038153263 [60,] 1939 -0.016486486 -0.097615899 0.064642926 -0.068689277 0.035716305 [61,] 1940 -0.016486486 -0.094070136 0.061097163 -0.066407753 0.033434780 [62,] 1941 -0.016486486 -0.090800520 0.057827547 -0.064303916 0.031330943 [63,] 1942 -0.016486486 -0.087845022 0.054872049 -0.062402198 0.029429225 [64,] 1943 -0.016486486 -0.085244160 0.052271187 -0.060728671 0.027755698 [65,] 1944 -0.016486486 -0.083039523 0.050066550 -0.059310095 0.026337122 [66,] 1945 -0.016486486 -0.081271575 0.048298602 -0.058172508 0.025199535 [67,] 1946 -0.016486486 -0.079976806 0.047003833 -0.057339388 0.024366415 [68,] 1947 -0.016486486 -0.079184539 0.046211566 -0.056829602 0.023856629 [69,] 1948 -0.016486486 -0.078913907 0.045940934 -0.056655464 0.023682491 [70,] 1949 -0.016486486 -0.079171667 0.046198694 -0.056821320 0.023848347 [71,] 1950 -0.016486486 -0.079951382 0.046978409 -0.057323028 0.024350055 [72,] 1951 -0.016486486 -0.081234197 0.048261224 -0.058148457 0.025175484 [73,] 1952 -0.016486486 -0.082991006 0.050018033 -0.059278877 0.026305904 [74,] 1953 -0.016486486 -0.085185454 0.052212481 -0.060690897 0.027717924 [75,] 1954 -0.016486486 -0.087777140 0.054804167 -0.062358519 0.029385546 [76,] 1955 -0.016486486 -0.090724471 0.057751498 -0.064254982 0.031282009 [77,] 1956 -0.016486486 -0.093986883 0.061013910 -0.066354184 0.033381211 [78,] 1957 -0.016486486 -0.097526332 0.064553359 -0.068631645 0.035658672 [79,] 1958 -0.016486486 -0.101308145 0.068335172 -0.071065056 0.038092083 [80,] 1959 -0.016486486 -0.105301366 0.072328393 -0.073634498 0.040661525 [81,] 1960 -0.016486486 -0.109478765 0.076505793 -0.076322449 0.043349476 [82,] 1961 -0.016486486 -0.113816631 0.080843658 -0.079113653 0.046140680 [83,] 1962 -0.016486486 -0.118294454 0.085321481 -0.081994911 0.049021938 [84,] 1963 -0.016486486 -0.122894566 0.089921593 -0.084954858 0.051981885 [85,] 1964 -0.016486486 -0.127601781 0.094628808 -0.087983719 0.055010746 [86,] 1965 -0.006054054 -0.111440065 0.099331957 -0.073864774 0.061756666 [87,] 1966 0.004378378 -0.095541433 0.104298190 -0.059915111 0.068671868 [88,] 1967 0.014810811 -0.079951422 0.109573043 -0.046164030 0.075785651 [89,] 1968 0.025243243 -0.064723125 0.115209611 -0.032645694 0.083132181 [90,] 1969 0.035675676 -0.049917365 0.121268716 -0.019399240 0.090750592 [91,] 1970 0.046108108 -0.035602017 0.127818233 -0.006468342 0.098684559 [92,] 1971 0.056540541 -0.021849988 0.134931069 0.006100087 0.106980994 [93,] 1972 0.066972973 -0.008735416 0.142681362 0.018258345 0.115687601 [94,] 1973 0.077405405 0.003672103 0.151138707 0.029961648 0.124849163 [95,] 1974 0.087837838 0.015314778 0.160360898 0.041172812 0.134502863 [96,] 1975 0.098270270 0.026154092 0.170386449 0.051867053 0.144673488 [97,] 1976 0.108702703 0.036176523 0.181228883 0.062035669 0.155369736 [98,] 1977 0.119135135 0.045395695 0.192874575 0.071687429 0.166582842 [99,] 1978 0.129567568 0.053850212 0.205284923 0.080847170 0.178287965 [100,] 1979 0.140000000 0.061597925 0.218402075 0.089552117 0.190447883 [101,] 1980 0.150432432 0.068708461 0.232156404 0.097847072 0.203017792 [102,] 1981 0.160864865 0.075255962 0.246473767 0.105779742 0.215949987 [103,] 1982 0.171297297 0.081313324 0.261281271 0.113397031 0.229197563 [104,] 1983 0.181729730 0.086948395 0.276511065 0.120742598 0.242716862 [105,] 1984 0.192162162 0.092221970 0.292102355 0.127855559 0.256468766 [106,] 1985 0.202594595 0.097187112 0.308002077 0.134770059 0.270419130 [107,] 1986 0.213027027 0.101889333 0.324164721 0.141515381 0.284538673 [108,] 1987 0.223459459 0.106367224 0.340551695 0.148116359 0.298802560 [109,] 1988 0.233891892 0.110653299 0.357130484 0.154593913 0.313189871 [110,] 1989 0.244324324 0.114774857 0.373873791 0.160965608 0.327683041 [111,] 1990 0.254756757 0.118754798 0.390758715 0.167246179 0.342267335 [112,] 1991 0.265189189 0.122612348 0.407766030 0.173447997 0.356930381 [113,] 1992 0.275621622 0.126363680 0.424879564 0.179581470 0.371661774 > (pa10 <- predict(a10,year,interval = "both")) z fit cb.lo cb.up ci.lo ci.up [1,] 1880 -0.570000000 -0.7989007 -0.3410992837 -0.71728636 -0.422713636 [2,] 1881 -0.562857143 -0.7862639 -0.3394503795 -0.70660842 -0.419105867 [3,] 1882 -0.555714286 -0.7736739 -0.3377546582 -0.69596060 -0.415467975 [4,] 1883 -0.548571429 -0.7611343 -0.3360085204 -0.68534522 -0.411797641 [5,] 1884 -0.541428571 -0.7486491 -0.3342080272 -0.67476481 -0.408092333 [6,] 1885 -0.534285714 -0.7362226 -0.3323488643 -0.66422216 -0.404349273 [7,] 1886 -0.527142857 -0.7238594 -0.3304263043 -0.65372029 -0.400565421 [8,] 1887 -0.520000000 -0.7115648 -0.3284351643 -0.64326256 -0.396737440 [9,] 1888 -0.512857143 -0.6993445 -0.3263697605 -0.63285261 -0.392861675 [10,] 1889 -0.505714286 -0.6872047 -0.3242238599 -0.62249446 -0.388934114 [11,] 1890 -0.498571429 -0.6751522 -0.3219906288 -0.61219250 -0.384950360 [12,] 1891 -0.491428571 -0.6631946 -0.3196625782 -0.60195155 -0.380905594 [13,] 1892 -0.484285714 -0.6513399 -0.3172315093 -0.59177689 -0.376794541 [14,] 1893 -0.477142857 -0.6395973 -0.3146884583 -0.58167428 -0.372611433 [15,] 1894 -0.470000000 -0.6279764 -0.3120236430 -0.57165002 -0.368349976 [16,] 1895 -0.462857143 -0.6164879 -0.3092264155 -0.56171097 -0.364003318 [17,] 1896 -0.455714286 -0.6051433 -0.3062852230 -0.55186455 -0.359564026 [18,] 1897 -0.448571429 -0.5939553 -0.3031875831 -0.54211879 -0.355024067 [19,] 1898 -0.441428571 -0.5829371 -0.2999200783 -0.53248233 -0.350374809 [20,] 1899 -0.434285714 -0.5721031 -0.2964683783 -0.52296440 -0.345607030 [21,] 1900 -0.427142857 -0.5614684 -0.2928172976 -0.51357475 -0.340710959 [22,] 1901 -0.420000000 -0.5510491 -0.2889508980 -0.50432366 -0.335676342 [23,] 1902 -0.412857143 -0.5408616 -0.2848526441 -0.49522175 -0.330492537 [24,] 1903 -0.405714286 -0.5309229 -0.2805056214 -0.48627991 -0.325148662 [25,] 1904 -0.398571429 -0.5212500 -0.2758928205 -0.47750909 -0.319633772 [26,] 1905 -0.391428571 -0.5118597 -0.2709974894 -0.46892006 -0.313937087 [27,] 1906 -0.384285714 -0.5027679 -0.2658035488 -0.46052317 -0.308048262 [28,] 1907 -0.377142857 -0.4939897 -0.2602960562 -0.45232803 -0.301957682 [29,] 1908 -0.370000000 -0.4855383 -0.2544616963 -0.44434322 -0.295656778 [30,] 1909 -0.362857143 -0.4774250 -0.2482892691 -0.43657594 -0.289138345 [31,] 1910 -0.355714286 -0.4696584 -0.2417701364 -0.42903175 -0.282396824 [32,] 1911 -0.348571429 -0.4622443 -0.2348985912 -0.42171431 -0.275428543 [33,] 1912 -0.341428571 -0.4551850 -0.2276721117 -0.41462526 -0.268231879 [34,] 1913 -0.334285714 -0.4484800 -0.2200914777 -0.40776409 -0.260807334 [35,] 1914 -0.327142857 -0.4421250 -0.2121607344 -0.40112820 -0.253157511 [36,] 1915 -0.320000000 -0.4361130 -0.2038870084 -0.39471301 -0.245286995 [37,] 1916 -0.312857143 -0.4304341 -0.1952801960 -0.38851213 -0.237202155 [38,] 1917 -0.305714286 -0.4250760 -0.1863525523 -0.38251770 -0.228910875 [39,] 1918 -0.298571429 -0.4200246 -0.1771182205 -0.37672060 -0.220422257 [40,] 1919 -0.291428571 -0.4152644 -0.1675927388 -0.37111085 -0.211746298 [41,] 1920 -0.284285714 -0.4107789 -0.1577925583 -0.36567785 -0.202893584 [42,] 1921 -0.277142857 -0.4065511 -0.1477346004 -0.36041071 -0.193875002 [43,] 1922 -0.270000000 -0.4025641 -0.1374358695 -0.35529850 -0.184701495 [44,] 1923 -0.262857143 -0.3988012 -0.1269131329 -0.35033043 -0.175383852 [45,] 1924 -0.255714286 -0.3952459 -0.1161826679 -0.34549603 -0.165932545 [46,] 1925 -0.248571429 -0.3918828 -0.1052600744 -0.34078524 -0.156357614 [47,] 1926 -0.241428571 -0.3886970 -0.0941601449 -0.33618857 -0.146668575 [48,] 1927 -0.234285714 -0.3856746 -0.0828967845 -0.33169705 -0.136874376 [49,] 1928 -0.227142857 -0.3828027 -0.0714829715 -0.32730235 -0.126983369 [50,] 1929 -0.220000000 -0.3800693 -0.0599307484 -0.32299670 -0.117003301 [51,] 1930 -0.212857143 -0.3774630 -0.0482512378 -0.31877296 -0.106941331 [52,] 1931 -0.205714286 -0.3749739 -0.0364546744 -0.31462453 -0.096804042 [53,] 1932 -0.198571429 -0.3725924 -0.0245504487 -0.31054538 -0.086597478 [54,] 1933 -0.191428571 -0.3703100 -0.0125471577 -0.30652997 -0.076327171 [55,] 1934 -0.184285714 -0.3681188 -0.0004526588 -0.30257325 -0.065998175 [56,] 1935 -0.177142857 -0.3660116 0.0117258745 -0.29867061 -0.055615108 [57,] 1936 -0.170000000 -0.3639819 0.0239818977 -0.29481782 -0.045182180 [58,] 1937 -0.170000000 -0.3552689 0.0152688616 -0.28921141 -0.050788591 [59,] 1938 -0.170000000 -0.3469383 0.0069383006 -0.28385110 -0.056148897 [60,] 1939 -0.170000000 -0.3390468 -0.0009532311 -0.27877329 -0.061226710 [61,] 1940 -0.170000000 -0.3316586 -0.0083414258 -0.27401935 -0.065980650 [62,] 1941 -0.170000000 -0.3248458 -0.0151542191 -0.26963565 -0.070364348 [63,] 1942 -0.170000000 -0.3186875 -0.0213124962 -0.26567310 -0.074326897 [64,] 1943 -0.170000000 -0.3132682 -0.0267318303 -0.26218603 -0.077813972 [65,] 1944 -0.170000000 -0.3086744 -0.0313255619 -0.25923019 -0.080769813 [66,] 1945 -0.170000000 -0.3049906 -0.0350093787 -0.25685983 -0.083140168 [67,] 1946 -0.170000000 -0.3022928 -0.0377072467 -0.25512389 -0.084876113 [68,] 1947 -0.170000000 -0.3006419 -0.0393580695 -0.25406166 -0.085938337 [69,] 1948 -0.170000000 -0.3000780 -0.0399219767 -0.25369882 -0.086301183 [70,] 1949 -0.170000000 -0.3006151 -0.0393848898 -0.25404441 -0.085955594 [71,] 1950 -0.170000000 -0.3022398 -0.0377602233 -0.25508980 -0.084910201 [72,] 1951 -0.170000000 -0.3049127 -0.0350872623 -0.25680972 -0.083190282 [73,] 1952 -0.170000000 -0.3085733 -0.0314266558 -0.25916514 -0.080834862 [74,] 1953 -0.170000000 -0.3131458 -0.0268541535 -0.26210732 -0.077892681 [75,] 1954 -0.170000000 -0.3185461 -0.0214539408 -0.26558209 -0.074417909 [76,] 1955 -0.170000000 -0.3246873 -0.0153126807 -0.26953369 -0.070466310 [77,] 1956 -0.170000000 -0.3314851 -0.0085148970 -0.27390773 -0.066092271 [78,] 1957 -0.170000000 -0.3388601 -0.0011398598 -0.27865320 -0.061346797 [79,] 1958 -0.170000000 -0.3467402 0.0067401824 -0.28372362 -0.056276377 [80,] 1959 -0.170000000 -0.3550607 0.0150607304 -0.28907749 -0.050922513 [81,] 1960 -0.170000000 -0.3637650 0.0237650445 -0.29467829 -0.045321714 [82,] 1961 -0.170000000 -0.3728037 0.0328037172 -0.30049423 -0.039505772 [83,] 1962 -0.170000000 -0.3821340 0.0421340134 -0.30649781 -0.033502185 [84,] 1963 -0.170000000 -0.3917191 0.0517191202 -0.31266536 -0.027334640 [85,] 1964 -0.170000000 -0.4015274 0.0615273928 -0.31897650 -0.021023499 [86,] 1965 -0.159285714 -0.3788752 0.0603037544 -0.30058075 -0.017990680 [87,] 1966 -0.148571429 -0.3567712 0.0596282943 -0.28253772 -0.014605137 [88,] 1967 -0.137857143 -0.3353102 0.0595958975 -0.26490847 -0.010805813 [89,] 1968 -0.127142857 -0.3146029 0.0603171930 -0.24776419 -0.006521525 [90,] 1969 -0.116428571 -0.2947761 0.0619189162 -0.23118642 -0.001670726 [91,] 1970 -0.105714286 -0.2759711 0.0645424939 -0.21526616 0.003837587 [92,] 1971 -0.095000000 -0.2583398 0.0683398431 -0.20010116 0.010101164 [93,] 1972 -0.084285714 -0.2420369 0.0734654391 -0.18579083 0.017219402 [94,] 1973 -0.073571429 -0.2272072 0.0800643002 -0.17242847 0.025285614 [95,] 1974 -0.062857143 -0.2139711 0.0882568427 -0.16009157 0.034377282 [96,] 1975 -0.052142857 -0.2024090 0.0981233226 -0.14883176 0.044546046 [97,] 1976 -0.041428571 -0.1925491 0.1096919157 -0.13866718 0.055810037 [98,] 1977 -0.030714286 -0.1843628 0.1229342326 -0.12957956 0.068150987 [99,] 1978 -0.020000000 -0.1777698 0.1377698370 -0.12151714 0.081517138 [100,] 1979 -0.009285714 -0.1726496 0.1540781875 -0.11440236 0.095830930 [101,] 1980 0.001428571 -0.1688571 0.1717142023 -0.10814187 0.110999008 [102,] 1981 0.012142857 -0.1662377 0.1905233955 -0.10263625 0.126921969 [103,] 1982 0.022857143 -0.1646396 0.2103538775 -0.09778779 0.143502079 [104,] 1983 0.033571429 -0.1639214 0.2310642722 -0.09350551 0.160648370 [105,] 1984 0.044285714 -0.1639565 0.2525279044 -0.08970790 0.178279332 [106,] 1985 0.055000000 -0.1646342 0.2746342071 -0.08632382 0.196323821 [107,] 1986 0.065714286 -0.1658598 0.2972883534 -0.08329225 0.214720820 [108,] 1987 0.076428571 -0.1675528 0.3204099260 -0.08056144 0.233418585 [109,] 1988 0.087142857 -0.1696455 0.3439311798 -0.07808781 0.252373526 [110,] 1989 0.097857143 -0.1720809 0.3677952332 -0.07583476 0.271549041 [111,] 1990 0.108571429 -0.1748115 0.3919543697 -0.07377157 0.290914428 [112,] 1991 0.119285714 -0.1777971 0.4163685288 -0.07187248 0.310443909 [113,] 1992 0.130000000 -0.1810040 0.4410040109 -0.07011580 0.330115800 > (pa90 <- predict(a90,year,interval = "both")) z fit cb.lo cb.up ci.lo ci.up [1,] 1880 -0.257692308 -3.867500e-01 -0.128634653 -0.340734568 -0.174650048 [2,] 1881 -0.250769231 -3.767293e-01 -0.124809149 -0.331818355 -0.169720107 [3,] 1882 -0.243846154 -3.667351e-01 -0.120957249 -0.322919126 -0.164773181 [4,] 1883 -0.236923077 -3.567692e-01 -0.117076923 -0.314038189 -0.159807965 [5,] 1884 -0.230000000 -3.468340e-01 -0.113165951 -0.305176970 -0.154823030 [6,] 1885 -0.223076923 -3.369319e-01 -0.109221900 -0.296337036 -0.149816810 [7,] 1886 -0.216153846 -3.270656e-01 -0.105242105 -0.287520102 -0.144787590 [8,] 1887 -0.209230769 -3.172379e-01 -0.101223643 -0.278728048 -0.139733491 [9,] 1888 -0.202307692 -3.074521e-01 -0.097163311 -0.269962936 -0.134652449 [10,] 1889 -0.195384615 -2.977116e-01 -0.093057593 -0.261227027 -0.129542204 [11,] 1890 -0.188461539 -2.880204e-01 -0.088902637 -0.252522800 -0.124400277 [12,] 1891 -0.181538462 -2.783827e-01 -0.084694220 -0.243852973 -0.119223950 [13,] 1892 -0.174615385 -2.688030e-01 -0.080427720 -0.235220519 -0.114010250 [14,] 1893 -0.167692308 -2.592865e-01 -0.076098083 -0.226628691 -0.108755924 [15,] 1894 -0.160769231 -2.498387e-01 -0.071699793 -0.218081038 -0.103457424 [16,] 1895 -0.153846154 -2.404655e-01 -0.067226847 -0.209581422 -0.098110886 [17,] 1896 -0.146923077 -2.311734e-01 -0.062672732 -0.201134035 -0.092712119 [18,] 1897 -0.140000000 -2.219696e-01 -0.058030409 -0.192743405 -0.087256595 [19,] 1898 -0.133076923 -2.128615e-01 -0.053292314 -0.184414399 -0.081739447 [20,] 1899 -0.126153846 -2.038573e-01 -0.048450366 -0.176152218 -0.076155475 [21,] 1900 -0.119230769 -1.949655e-01 -0.043496005 -0.167962369 -0.070499170 [22,] 1901 -0.112307692 -1.861951e-01 -0.038420244 -0.159850635 -0.064764750 [23,] 1902 -0.105384615 -1.775555e-01 -0.033213760 -0.151823015 -0.058946216 [24,] 1903 -0.098461539 -1.690561e-01 -0.027867017 -0.143885645 -0.053037432 [25,] 1904 -0.091538462 -1.607065e-01 -0.022370423 -0.136044696 -0.047032227 [26,] 1905 -0.084615385 -1.525162e-01 -0.016714535 -0.128306245 -0.040924524 [27,] 1906 -0.077692308 -1.444943e-01 -0.010890287 -0.120676126 -0.034708490 [28,] 1907 -0.070769231 -1.366492e-01 -0.004889253 -0.113159760 -0.028378702 [29,] 1908 -0.063846154 -1.289884e-01 0.001296074 -0.105761977 -0.021930331 [30,] 1909 -0.056923077 -1.215182e-01 0.007672008 -0.098486840 -0.015359314 [31,] 1910 -0.050000000 -1.142434e-01 0.014243419 -0.091337484 -0.008662516 [32,] 1911 -0.043076923 -1.071674e-01 0.021013527 -0.084315978 -0.001837868 [33,] 1912 -0.036153846 -1.002914e-01 0.027983751 -0.077423239 0.005115546 [34,] 1913 -0.029230769 -9.361519e-02 0.035153653 -0.070658982 0.012197443 [35,] 1914 -0.022307692 -8.713634e-02 0.042520952 -0.064021740 0.019406355 [36,] 1915 -0.015384615 -8.085086e-02 0.050081630 -0.057508928 0.026739697 [37,] 1916 -0.008461538 -7.475318e-02 0.057830107 -0.051116955 0.034193878 [38,] 1917 -0.001538462 -6.883640e-02 0.065759473 -0.044841376 0.041764453 [39,] 1918 0.005384615 -6.309252e-02 0.073861755 -0.038677059 0.049446290 [40,] 1919 0.012307692 -5.751281e-02 0.082128191 -0.032618368 0.057233753 [41,] 1920 0.019230769 -5.208797e-02 0.090549507 -0.026659334 0.065120873 [42,] 1921 0.026153846 -4.680847e-02 0.099116161 -0.020793819 0.073101511 [43,] 1922 0.033076923 -4.166472e-02 0.107818567 -0.015015652 0.081169499 [44,] 1923 0.040000000 -3.664727e-02 0.116647271 -0.009318753 0.089318753 [45,] 1924 0.046923077 -3.174694e-02 0.125593095 -0.003697214 0.097543368 [46,] 1925 0.053846154 -2.695494e-02 0.134647244 0.001854623 0.105837685 [47,] 1926 0.060769231 -2.226292e-02 0.143801377 0.007342124 0.114196337 [48,] 1927 0.067692308 -1.766304e-02 0.153047656 0.012770335 0.122614280 [49,] 1928 0.074615385 -1.314799e-02 0.162378762 0.018143964 0.131086806 [50,] 1929 0.081538462 -8.710982e-03 0.171787905 0.023467379 0.139609544 [51,] 1930 0.088461538 -4.345738e-03 0.181268815 0.028744616 0.148178461 [52,] 1931 0.095384615 -4.649065e-05 0.190815721 0.033979388 0.156789843 [53,] 1932 0.102307692 4.192055e-03 0.200423329 0.039175101 0.165440284 [54,] 1933 0.109230769 8.374747e-03 0.210086792 0.044334874 0.174126664 [55,] 1934 0.116153846 1.250601e-02 0.219801679 0.049461559 0.182846134 [56,] 1935 0.123076923 1.658990e-02 0.229563945 0.054557757 0.191596090 [57,] 1936 0.130000000 2.063010e-02 0.239369902 0.059625842 0.200374158 [58,] 1937 0.130000000 2.554264e-02 0.234457361 0.062786820 0.197213180 [59,] 1938 0.130000000 3.023953e-02 0.229760466 0.065809042 0.194190958 [60,] 1939 0.130000000 3.468890e-02 0.225311102 0.068671989 0.191328011 [61,] 1940 0.130000000 3.885447e-02 0.221145527 0.071352331 0.188647669 [62,] 1941 0.130000000 4.269563e-02 0.217304372 0.073823926 0.186176074 [63,] 1942 0.130000000 4.616776e-02 0.213832244 0.076058070 0.183941930 [64,] 1943 0.130000000 4.922326e-02 0.210776742 0.078024136 0.181975864 [65,] 1944 0.130000000 5.181327e-02 0.208186727 0.079690683 0.180309317 [66,] 1945 0.130000000 5.389026e-02 0.206109736 0.081027125 0.178972875 [67,] 1946 0.130000000 5.541136e-02 0.204588637 0.082005877 0.177994123 [68,] 1947 0.130000000 5.634212e-02 0.203657879 0.082604774 0.177395226 [69,] 1948 0.130000000 5.666006e-02 0.203339939 0.082809352 0.177190648 [70,] 1949 0.130000000 5.635724e-02 0.203642757 0.082614504 0.177385496 [71,] 1950 0.130000000 5.544123e-02 0.204558768 0.082025096 0.177974904 [72,] 1951 0.130000000 5.393418e-02 0.206065824 0.081055380 0.178944620 [73,] 1952 0.130000000 5.187027e-02 0.208129729 0.079727358 0.180272642 [74,] 1953 0.130000000 4.929223e-02 0.210707774 0.078068513 0.181931487 [75,] 1954 0.130000000 4.624751e-02 0.213752495 0.076109385 0.183890615 [76,] 1955 0.130000000 4.278497e-02 0.217215029 0.073881414 0.186118586 [77,] 1956 0.130000000 3.895228e-02 0.221047722 0.071415265 0.188584735 [78,] 1957 0.130000000 3.479412e-02 0.225205878 0.068739695 0.191260305 [79,] 1958 0.130000000 3.035124e-02 0.229648764 0.065880916 0.194119084 [80,] 1959 0.130000000 2.565999e-02 0.234340014 0.062862328 0.197137672 [81,] 1960 0.130000000 2.075236e-02 0.239247637 0.059704514 0.200295486 [82,] 1961 0.130000000 1.565622e-02 0.244343776 0.056425398 0.203574602 [83,] 1962 0.130000000 1.039566e-02 0.249604337 0.053040486 0.206959514 [84,] 1963 0.130000000 4.991436e-03 0.255008564 0.049563131 0.210436869 [85,] 1964 0.130000000 -5.386147e-04 0.260538615 0.046004815 0.213995185 [86,] 1965 0.143076923 1.926909e-02 0.266884757 0.063412665 0.222741181 [87,] 1966 0.156153846 3.876772e-02 0.273539971 0.080621643 0.231686050 [88,] 1967 0.169230769 5.790379e-02 0.280557753 0.097597325 0.240864213 [89,] 1968 0.182307692 7.661491e-02 0.288000479 0.114299577 0.250315807 [90,] 1969 0.195384615 9.482963e-02 0.295939602 0.130682422 0.260086809 [91,] 1970 0.208461538 1.124682e-01 0.304454863 0.146694551 0.270228526 [92,] 1971 0.221538461 1.294450e-01 0.313631914 0.162280850 0.280796073 [93,] 1972 0.234615385 1.456729e-01 0.323557850 0.177385278 0.291845491 [94,] 1973 0.247692308 1.610702e-01 0.334314435 0.191955225 0.303429390 [95,] 1974 0.260769231 1.755689e-01 0.345969561 0.205947004 0.315591457 [96,] 1975 0.273846154 1.891238e-01 0.358568478 0.219331501 0.328360807 [97,] 1976 0.286923077 2.017191e-01 0.372127073 0.232098492 0.341747662 [98,] 1977 0.300000000 2.133707e-01 0.386629338 0.244258277 0.355741722 [99,] 1978 0.313076923 2.241239e-01 0.402029922 0.255840039 0.370313807 [100,] 1979 0.326153846 2.340468e-01 0.418260863 0.266887506 0.385420186 [101,] 1980 0.339230769 2.432212e-01 0.435240360 0.277453314 0.401008224 [102,] 1981 0.352307692 2.517341e-01 0.452881314 0.287593508 0.417021876 [103,] 1982 0.365384615 2.596711e-01 0.471098085 0.297363192 0.433406039 [104,] 1983 0.378461538 2.671121e-01 0.489810964 0.306813654 0.450109423 [105,] 1984 0.391538461 2.741284e-01 0.508948530 0.315990851 0.467086072 [106,] 1985 0.404615384 2.807823e-01 0.528448443 0.324934896 0.484295873 [107,] 1986 0.417692308 2.871274e-01 0.548257238 0.333680190 0.501704425 [108,] 1987 0.430769231 2.932089e-01 0.568329576 0.342255907 0.519282554 [109,] 1988 0.443846154 2.990650e-01 0.588627259 0.350686626 0.537005682 [110,] 1989 0.456923077 3.047279e-01 0.609118218 0.358992981 0.554853173 [111,] 1990 0.470000000 3.102244e-01 0.629775550 0.367192284 0.572807716 [112,] 1991 0.483076923 3.155772e-01 0.650576667 0.375299067 0.590854778 [113,] 1992 0.496153846 3.208051e-01 0.671502569 0.383325558 0.608982134 > > plot(year, temp, type = "n", ylab = "Temperature (C)", ylim = c(-.7,.6)) > lines(pa50, col = 2) > lines(pa10, col = 3) > lines(pa90, col = 3) > points(year, temp, pch = c(1,3)[2 - normal.idx]) > > text(year[hot.idx], temp[hot.idx] + .03, labels = year[hot.idx]) > text(year[cold.idx],temp[cold.idx]- .03, labels = year[cold.idx]) > > ### Codes for Figure 1b. -- UNconstrained > > ## (Pin Ng. had these commented out) > > a50 <- cobs(year, temp, knots.add = TRUE, degree = 1, constraint = "none", + ic = "SIC") qbsks2(): Performing general knot selection ... Deleting unnecessary knots ... Searching for missing knots ... > ## As suggested in the warning message, we increase the number of knots to 9 > a50 <- cobs(year, temp, nknots = 9, knots.add = TRUE, degree = 1, + constraint = "none", ic = "SIC") qbsks2(): Performing general knot selection ... Deleting unnecessary knots ... Searching for missing knots ... > summary(a50) COBS regression spline (degree = 1) from call: cobs(x = year, y = temp, constraint = "none", nknots = 9, degree = 1, ic = "SIC", knots.add = TRUE) {tau=0.5}-quantile; dimensionality of fit: 5 from {5} x$knots[1:5]: 1880, 1908, 1936, 1964, 1992 coef[1:5]: -0.40655906, -0.31473700, 0.05651823, -0.05681818, 0.28681956 R^2 = 72.56% ; empirical tau (over all): 54/113 = 0.4778761 (target tau= 0.5) > ## Here, we use the same knots sequence chosen for the 50th percentile > (a10 <- cobs(year, temp, nknots = length(a50$knots), knots = a50$knot, + degree = 1, tau = 0.1, constraint = "none", ic = "SIC")) COBS regression spline (degree = 1) from call: cobs(x = year, y = temp, constraint = "none", knots = a50$knot, nknots = length(a50$knots), degree = 1, tau = 0.1, ic = "SIC") {tau=0.1}-quantile; dimensionality of fit: 5 from {5} x$knots[1:5]: 1880, 1908, 1936, 1964, 1992 > (a90 <- cobs(year, temp, nknots = length(a50$knots), knots = a50$knot, + degree = 1, tau = 0.9, constraint = "none", ic = "SIC")) COBS regression spline (degree = 1) from call: cobs(x = year, y = temp, constraint = "none", knots = a50$knot, nknots = length(a50$knots), degree = 1, tau = 0.9, ic = "SIC") {tau=0.9}-quantile; dimensionality of fit: 5 from {5} x$knots[1:5]: 1880, 1908, 1936, 1964, 1992 > which(hot.idx <- temp >= a90$fit) [1] 10 18 21 22 47 61 68 74 78 79 102 111 > which(cold.idx <- temp <= a10$fit) [1] 5 8 25 38 39 50 54 77 85 97 113 > normal.idx <- (temp < a90$fit ) & (temp > a10$fit) > > pa50 <- predict(a50,year,interval = "none") > pa10 <- predict(a10,year,interval = "none") > pa90 <- predict(a90,year,interval = "none") > > plot(year, temp, type = "n",xlab = "Year", ylab = "Temperature (C)", + ylim = c(-.7,.6)) > lines(pa50, col = 2) > lines(pa10, col = 3) > lines(pa90, col = 3) > points(year[normal.idx],temp[normal.idx]) > points(year[!normal.idx],temp[!normal.idx],pch = 3) > text(year[hot.idx], temp[hot.idx] + .03, labels = year[hot.idx]) > text(year[cold.idx],temp[cold.idx] - .03, labels = year[cold.idx]) > > > cat('Time elapsed: ', proc.time(),'\n') # for ``statistical reasons'' Time elapsed: 2.06 0.21 2.28 NA NA > > proc.time() user system elapsed 2.06 0.21 2.28