<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Publishing DTD v1.0 20120330//EN" "JATS-journalpublishing1.dtd">
<article xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink" article-type="research-article">
<front>
<journal-meta>
<journal-id journal-id-type="publisher-id">JDS</journal-id>
<journal-title-group><journal-title>Journal of Data Science</journal-title></journal-title-group>
<issn pub-type="epub">1683-8602</issn><issn pub-type="ppub">1680-743X</issn><issn-l>1680-743X</issn-l>
<publisher>
<publisher-name>School of Statistics, Renmin University of China</publisher-name>
</publisher>
</journal-meta>
<article-meta>
<article-id pub-id-type="publisher-id">JDS1020</article-id>
<article-id pub-id-type="doi">10.6339/21-JDS1020</article-id>
<article-categories><subj-group subj-group-type="heading">
<subject>Computing in Data Science</subject></subj-group></article-categories>
<title-group>
<article-title>Shape-Restricted Regression Splines with <sans-serif>R</sans-serif> Package <italic>splines2</italic></article-title>
</title-group>
<contrib-group>
<contrib contrib-type="author">
<contrib-id contrib-id-type="orcid">https://orcid.org/0000-0003-0363-3180</contrib-id>
<name><surname>Wang</surname><given-names>Wenjie</given-names></name><email xlink:href="mailto:wang@wwenjie.org">wang@wwenjie.org</email><xref ref-type="aff" rid="j_jds1020_aff_001">1</xref><xref ref-type="corresp" rid="cor1">∗</xref>
</contrib>
<contrib contrib-type="author">
<contrib-id contrib-id-type="orcid">https://orcid.org/0000-0003-4401-7296</contrib-id>
<name><surname>Yan</surname><given-names>Jun</given-names></name><xref ref-type="aff" rid="j_jds1020_aff_002">2</xref>
</contrib>
<aff id="j_jds1020_aff_001"><label>1</label><institution>Eli Lilly and Company</institution>, Indianapolis, Indiana, <country>USA</country></aff>
<aff id="j_jds1020_aff_002"><label>2</label>Department of Statistics, <institution>University of Connecticut</institution>, Storrs, Connecticut, <country>USA</country></aff>
</contrib-group>
<author-notes>
<corresp id="cor1"><label>∗</label>Corresponding Author. Email: <ext-link ext-link-type="uri" xlink:href="mailto:wang@wwenjie.org">wang@wwenjie.org</ext-link>.</corresp>
</author-notes>
<pub-date pub-type="ppub"><year>2021</year></pub-date><pub-date pub-type="epub"><day>12</day><month>8</month><year>2021</year></pub-date><volume>19</volume><issue>3</issue><fpage>498</fpage><lpage>517</lpage><supplementary-material id="S1" content-type="document" xlink:href="jds1020_s001.pdf" mimetype="application" mime-subtype="pdf">
<caption>
<title>Supplementary Material</title>
<p>We review the generalized Bernstein polynomials, B-splines, and Natural cubic splines implemented in the package <italic>splines2</italic> but not covered in the main text. We also provide the <sans-serif>R</sans-serif> code that produced the micro-benchmark results.</p>
</caption>
</supplementary-material><history><date date-type="received"><day>20</day><month>7</month><year>2021</year></date><date date-type="accepted"><day>20</day><month>7</month><year>2021</year></date></history>
<permissions><copyright-statement>2021 The Author(s). Published by the School of Statistics and the Center for Applied Statistics, Renmin University of China.</copyright-statement><copyright-year>2021</copyright-year>
<license license-type="open-access" xlink:href="https://creativecommons.org/licenses/by/4.0/">
<license-p>Open access article under the <ext-link ext-link-type="uri" xlink:href="https://creativecommons.org/licenses/by/4.0/">CC BY</ext-link> license.</license-p></license></permissions>
<abstract>
<p>Splines are important tools for the flexible modeling of curves and surfaces in regression analyses. Functions for constructing spline basis functions are available in <sans-serif>R</sans-serif> through the base package <italic>splines</italic>. When the curves to be modeled have known characteristics in monotonicity or curvature, more efficient statistical inferences are possible with shape-restricted splines. Such splines, however, are not available in the <sans-serif>R</sans-serif> package <italic>splines</italic>. The package <italic>splines2</italic> provides easy-to-use shape-restricted spline basis functions, along with their derivatives and integrals which are important tools in many inference scenarios. It also provides additional splines and features that are not available in the <italic>splines</italic> package, such as periodic splines and generalized Bernstein polynomials. The usages of the functions are illustrated with shape-restricted regression, recurrent event data analysis, and extreme-value copulas.</p>
</abstract>
<kwd-group>
<label>Keywords</label>
<kwd>Cox–de Boor algorithm</kwd>
<kwd>derivatives</kwd>
<kwd>integrals</kwd>
<kwd>monotone regression</kwd>
<kwd>periodic splines</kwd>
</kwd-group>
</article-meta>
</front>
<back>
<ref-list id="j_jds1020_reflist_001">
<title>References</title>
<ref id="j_jds1020_ref_001">
<mixed-citation publication-type="other"> <string-name><surname>Chen</surname> <given-names>F</given-names></string-name> (2018). <italic>ibs: Integral of B-Spline Functions</italic>. R package version 1.4.</mixed-citation>
</ref>
<ref id="j_jds1020_ref_002">
<mixed-citation publication-type="journal"> <string-name><surname>Cormier</surname> <given-names>E</given-names></string-name>, <string-name><surname>Genest</surname> <given-names>C</given-names></string-name>, <string-name><surname>Nešlehová</surname> <given-names>JG</given-names></string-name> (<year>2014</year>). <article-title>Using B-splines for nonparametric inference on bivariate extreme-value copulas</article-title>. <source>Extremes</source>, <volume>17</volume>(<issue>4</issue>): <fpage>633</fpage>–<lpage>659</lpage>.</mixed-citation>
</ref>
<ref id="j_jds1020_ref_003">
<mixed-citation publication-type="journal"> <string-name><surname>Curry</surname> <given-names>HB</given-names></string-name>, <string-name><surname>Schoenberg</surname> <given-names>IJ</given-names></string-name> (<year>1966</year>). <article-title>On Pólya frequency functions IV: The fundamental spline functions and their limits</article-title>. <source>Journal d’Analyse Mathématique</source>, <volume>17</volume>(<issue>1</issue>): <fpage>71</fpage>–<lpage>107</lpage>.</mixed-citation>
</ref>
<ref id="j_jds1020_ref_004">
<mixed-citation publication-type="book"> <string-name><surname>De Boor</surname> <given-names>C</given-names></string-name> (<year>1978</year>). <source>A Practical Guide to Splines</source>, volume <volume>27</volume>. <publisher-name>Springer-Verlag</publisher-name>, <publisher-loc>New York</publisher-loc>.</mixed-citation>
</ref>
<ref id="j_jds1020_ref_005">
<mixed-citation publication-type="book"> <string-name><surname>Eddelbuettel</surname> <given-names>D</given-names></string-name> (<year>2013</year>). <source>Seamless R and C++ Integration with Rcpp</source>. <publisher-name>Springer</publisher-name>.</mixed-citation>
</ref>
<ref id="j_jds1020_ref_006">
<mixed-citation publication-type="journal"> <string-name><surname>Eddelbuettel</surname> <given-names>D</given-names></string-name>, <string-name><surname>Sanderson</surname> <given-names>C</given-names></string-name> (<year>2014</year>). <article-title>RcppArmadillo: Accelerating R with high-performance C++ linear algebra</article-title>. <source>Computational Statistics and Data Analysis</source>, <volume>71</volume>: <fpage>1054</fpage>–<lpage>1063</lpage>.</mixed-citation>
</ref>
<ref id="j_jds1020_ref_007">
<mixed-citation publication-type="journal"> <string-name><surname>Eilers</surname> <given-names>PHC</given-names></string-name>, <string-name><surname>Marx</surname> <given-names>BD</given-names></string-name> (<year>1996</year>). <article-title>Flexible smoothing with B-splines and penalties</article-title>. <source>Statistical Science</source>, <volume>11</volume>(<issue>2</issue>): <fpage>89</fpage>–<lpage>102</lpage>.</mixed-citation>
</ref>
<ref id="j_jds1020_ref_008">
<mixed-citation publication-type="book"> <string-name><surname>Farin</surname> <given-names>G</given-names></string-name>, <string-name><surname>Hansford</surname> <given-names>D</given-names></string-name> (<year>2000</year>). <source>The Essentials of CAGD</source>. <publisher-name>CRC Press</publisher-name>.</mixed-citation>
</ref>
<ref id="j_jds1020_ref_009">
<mixed-citation publication-type="journal"> <string-name><surname>Fu</surname> <given-names>H</given-names></string-name>, <string-name><surname>Luo</surname> <given-names>J</given-names></string-name>, <string-name><surname>Qu</surname> <given-names>Y</given-names></string-name> (<year>2016</year>). <article-title>Hypoglycemic events analysis via recurrent time-to-event (HEART) models</article-title>. <source>Journal of Biopharmaceutical Statistics</source>, <volume>26</volume>(<issue>2</issue>): <fpage>280</fpage>–<lpage>298</lpage>.</mixed-citation>
</ref>
<ref id="j_jds1020_ref_010">
<mixed-citation publication-type="other"> <string-name><surname>Hofert</surname> <given-names>M</given-names></string-name>, <string-name><surname>Kojadinovic</surname> <given-names>I</given-names></string-name>, <string-name><surname>Maechler</surname> <given-names>M</given-names></string-name>, <string-name><surname>Yan</surname> <given-names>J</given-names></string-name> (2020). <italic>copula: Multivariate Dependence with Copulas</italic>. R package version 1.0-1.</mixed-citation>
</ref>
<ref id="j_jds1020_ref_011">
<mixed-citation publication-type="book"> <string-name><surname>Hofert</surname> <given-names>M</given-names></string-name>, <string-name><surname>Kojadinovic</surname> <given-names>I</given-names></string-name>, <string-name><surname>Mächler</surname> <given-names>M</given-names></string-name>, <string-name><surname>Yan</surname> <given-names>J</given-names></string-name> (<year>2018</year>). <source>Elements of Copula Modeling with R</source>. <publisher-name>Springer</publisher-name>.</mixed-citation>
</ref>
<ref id="j_jds1020_ref_012">
<mixed-citation publication-type="other"> <string-name><surname>Khoudraji</surname> <given-names>A</given-names></string-name> (1995). <italic>Contributions à l’étude des copules et à la modélisation de valeurs extrêmes bivariées</italic>, Ph.D. thesis, Université Laval, Québec, Canada.</mixed-citation>
</ref>
<ref id="j_jds1020_ref_013">
<mixed-citation publication-type="journal"> <string-name><surname>Koenker</surname> <given-names>R</given-names></string-name>, <string-name><surname>Ng</surname> <given-names>P</given-names></string-name>, <string-name><surname>Portnoy</surname> <given-names>S</given-names></string-name> (<year>1994</year>). <article-title>Quantile smoothing splines</article-title>. <source>Biometrika</source>, <volume>81</volume>(<issue>4</issue>): <fpage>673</fpage>–<lpage>680</lpage>.</mixed-citation>
</ref>
<ref id="j_jds1020_ref_014">
<mixed-citation publication-type="other"> <string-name><surname>Mersmann</surname> <given-names>O</given-names></string-name> (2019). <italic>microbenchmark: Accurate Timing Functions</italic>. R package version 1.4-7.</mixed-citation>
</ref>
<ref id="j_jds1020_ref_015">
<mixed-citation publication-type="journal"> <string-name><surname>Meyer</surname> <given-names>MC</given-names></string-name> (<year>2008</year>). <article-title>Inference using shape-restricted regression splines</article-title>. <source>The Annals of Applied Statistics</source>, <volume>2</volume>(<issue>3</issue>): <fpage>1013</fpage>–<lpage>1033</lpage>.</mixed-citation>
</ref>
<ref id="j_jds1020_ref_016">
<mixed-citation publication-type="journal"> <string-name><surname>Mogstad</surname> <given-names>M</given-names></string-name>, <string-name><surname>Santos</surname> <given-names>A</given-names></string-name>, <string-name><surname>Torgovitsky</surname> <given-names>A</given-names></string-name> (<year>2018</year>). <article-title>Using instrumental variables for inference about policy relevant treatment parameters</article-title>. <source>Econometrica</source>, <volume>86</volume>(<issue>5</issue>): <fpage>1589</fpage>–<lpage>1619</lpage>.</mixed-citation>
</ref>
<ref id="j_jds1020_ref_017">
<mixed-citation publication-type="journal"> <string-name><surname>Ng</surname> <given-names>P</given-names></string-name>, <string-name><surname>Maechler</surname> <given-names>M</given-names></string-name> (<year>2007</year>). <article-title>A fast and efficient implementation of qualitatively constrained quantile smoothing splines</article-title>. <source>Statistical Modelling</source>, <volume>7</volume>(<issue>4</issue>): <fpage>315</fpage>–<lpage>328</lpage>.</mixed-citation>
</ref>
<ref id="j_jds1020_ref_018">
<mixed-citation publication-type="other"> <string-name><surname>Ng</surname> <given-names>PT</given-names></string-name>, <string-name><surname>Maechler</surname> <given-names>M</given-names></string-name> (2020). <italic>COBS – Constrained B-Splines (Sparse Matrix Based)</italic>. R package version 1.3-4.</mixed-citation>
</ref>
<ref id="j_jds1020_ref_019">
<mixed-citation publication-type="journal"> <string-name><surname>Perperoglou</surname> <given-names>A</given-names></string-name>, <string-name><surname>Sauerbrei</surname> <given-names>W</given-names></string-name>, <string-name><surname>Abrahamowicz</surname> <given-names>M</given-names></string-name>, <string-name><surname>Schmid</surname> <given-names>M</given-names></string-name> (<year>2019</year>). <article-title>A review of spline function procedures in R</article-title>. <source>BMC Medical Research Methodology</source>, <volume>19</volume>(<issue>1</issue>): <fpage>46</fpage>.</mixed-citation>
</ref>
<ref id="j_jds1020_ref_020">
<mixed-citation publication-type="chapter"> <string-name><surname>Pickands</surname> <given-names>J</given-names></string-name> (<year>1981</year>). <chapter-title>Multivariate extreme value distribution (with discussion)</chapter-title>. In: <source>Proceedings 43th, Session of International Statistical Institution</source>, volume <volume>2</volume>, <fpage>859</fpage>–<lpage>878</lpage>, <comment>894–902</comment>. <publisher-name>Buenos Aires</publisher-name>.</mixed-citation>
</ref>
<ref id="j_jds1020_ref_021">
<mixed-citation publication-type="book"> <string-name><surname>Piegl</surname> <given-names>L</given-names></string-name>, <string-name><surname>Tiller</surname> <given-names>W</given-names></string-name> (<year>1997</year>). <source>The NURBS Book</source>. <publisher-name>Springer Science &amp; Business Media</publisher-name>, <edition>2</edition> edition.</mixed-citation>
</ref>
<ref id="j_jds1020_ref_022">
<mixed-citation publication-type="book"> <string-name><surname>Prautzsch</surname> <given-names>H</given-names></string-name>, <string-name><surname>Boehm</surname> <given-names>W</given-names></string-name>, <string-name><surname>Paluszny</surname> <given-names>M</given-names></string-name> (<year>2002</year>). <source>Bézier and B-Spline Techniques</source>. <publisher-name>Springer Science &amp; Business Media</publisher-name>.</mixed-citation>
</ref>
<ref id="j_jds1020_ref_023">
<mixed-citation publication-type="book"> <collab>R Core Team</collab> (<year>2020</year>). <source>R: A Language and Environment for Statistical Computing</source>. <publisher-name>R Foundation for Statistical Computing</publisher-name>, <publisher-loc>Vienna, Austria</publisher-loc>.</mixed-citation>
</ref>
<ref id="j_jds1020_ref_024">
<mixed-citation publication-type="journal"> <string-name><surname>Ramsay</surname> <given-names>JO</given-names></string-name> (<year>1988</year>). <article-title>Monotone regression splines in action</article-title>. <source>Statistical Science</source>, <volume>3</volume>(<issue>4</issue>): <fpage>425</fpage>–<lpage>441</lpage>.</mixed-citation>
</ref>
<ref id="j_jds1020_ref_025">
<mixed-citation publication-type="other"> <string-name><surname>Redd</surname> <given-names>A</given-names></string-name> (2015). <italic>orthogonalsplinebasis: Orthogonal B-Spline Basis Functions</italic>. R package version 0.1.6.</mixed-citation>
</ref>
<ref id="j_jds1020_ref_026">
<mixed-citation publication-type="journal"> <string-name><surname>Rosenberg</surname> <given-names>PS</given-names></string-name> (<year>1995</year>). <article-title>Hazard function estimation using B-splines</article-title>. <source>Biometrics</source>, <volume>51</volume>(<issue>3</issue>): <fpage>874</fpage>–<lpage>887</lpage>.</mixed-citation>
</ref>
<ref id="j_jds1020_ref_027">
<mixed-citation publication-type="book"> <string-name><surname>Ruppert</surname> <given-names>D</given-names></string-name>, <string-name><surname>Wand</surname> <given-names>MP</given-names></string-name>, <string-name><surname>Carroll</surname> <given-names>RJ</given-names></string-name> (<year>2003</year>). <source>Semiparametric Regression. 12</source>. <publisher-name>Cambridge University Press</publisher-name>.</mixed-citation>
</ref>
<ref id="j_jds1020_ref_028">
<mixed-citation publication-type="book"> <string-name><surname>Schumaker</surname> <given-names>L</given-names></string-name> (<year>2007</year>). <source>Spline Functions: Basic Theory</source>. <publisher-name>Cambridge University Press</publisher-name>. <edition>3</edition> edition.</mixed-citation>
</ref>
<ref id="j_jds1020_ref_029">
<mixed-citation publication-type="other"> <string-name><surname>Shea</surname> <given-names>J</given-names></string-name>, <string-name><surname>Torgovitsky</surname> <given-names>A</given-names></string-name> (2020). <italic>ivmte: An R Package for Implementing Marginal Treatment Effect Methods</italic>. University of Chicago. Becker Friedman Institute for Economics. Working Paper (2020-01).</mixed-citation>
</ref>
<ref id="j_jds1020_ref_030">
<mixed-citation publication-type="other"> <string-name><surname>Turlach</surname> <given-names>BA</given-names></string-name>, <string-name><surname>Weingessel</surname> <given-names>A</given-names></string-name> (2019). <italic>quadprog: Functions to Solve Quadratic Programming Problems</italic>. R package version 1.5-8.</mixed-citation>
</ref>
<ref id="j_jds1020_ref_031">
<mixed-citation publication-type="other"> <string-name><surname>Wand</surname> <given-names>M</given-names></string-name> (2018). <italic>SemiPar: Semiparametic Regression</italic>. R package version 1.0-4.2.</mixed-citation>
</ref>
<ref id="j_jds1020_ref_032">
<mixed-citation publication-type="journal"> <string-name><surname>Wang</surname> <given-names>J</given-names></string-name>, <string-name><surname>Ghosh</surname> <given-names>SK</given-names></string-name> (<year>2012</year>). <article-title>Shape restricted nonparametric regression with Bernstein polynomials</article-title>. <source>Computational Statistics &amp; Data Analysis</source>, <volume>56</volume>(<issue>9</issue>): <fpage>2729</fpage>–<lpage>2741</lpage>.</mixed-citation>
</ref>
<ref id="j_jds1020_ref_033">
<mixed-citation publication-type="other"> <string-name><surname>Wang</surname> <given-names>S</given-names></string-name> (2013). <italic>pbs: Periodic B-Splines</italic>. R package version 1.1.</mixed-citation>
</ref>
<ref id="j_jds1020_ref_034">
<mixed-citation publication-type="other"> <string-name><surname>Wang</surname> <given-names>W</given-names></string-name>, <string-name><surname>Fu</surname> <given-names>H</given-names></string-name>, <string-name><surname>Yan</surname> <given-names>J</given-names></string-name> (2020). <italic>reda: Recurrent Event Data Analysis</italic>. R package version 0.5.2.</mixed-citation>
</ref>
</ref-list>
</back>
</article>
