<?xml-stylesheet type="text/xsl" href="../styles/pmathml.xsl"?>
<!-- saved from url=(0014)about:internet -->
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:dsi="http://www.w3.org/1999/xlink" xmlns:m="http://www.w3.org/1998/Math/MathML" xml:space="preserve"><head><meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"/><title>G10ABF : NAG Library, Mark 22</title><link rel="stylesheet" href="../styles/libdoc.css" type="text/css"/><script type="text/javascript">
   function showLevel(_levelId){
    var thisLevel = document.getElementById(_levelId);
    var thisplus = document.getElementById( _levelId.concat('plus'));
    var thisminus = document.getElementById( _levelId.concat('minus'));
    if(thisLevel.style.display != "block"){
     thisLevel.style.display = "block";
     thisplus.style.display = "none";
     thisminus.style.display = "inline";
     }
    else{
     thisLevel.style.display = "none";
     thisminus.style.display = "none";
     thisplus.style.display = "inline";
     }
    }
  </script></head><body><hr/><div><a class="rout" href="../../pdf/G10/g10abf.pdf">G10ABF (PDF version)</a></div><div><a class="chap" href="g10conts.xml">G10 Chapter Contents</a></div><div><a class="chapint" href="g10intro.xml">G10 Chapter Introduction</a></div>
<div><a class="htmltoc" href="../FRONTMATTER/manconts.xml">NAG Library Manual</a></div><hr/><h1 class="libdoc">NAG Library Routine Document<br/><br/>G10ABF</h1><div class="paramtext"><div class="header"><b>Note:</b>&#160; before using this routine, please read the Users' Note for your implementation to check the interpretation of <span class="bitalic">bold italicised</span> terms and other implementation-dependent details.</div></div> 
<div class="htmltoc">
<h2 class="htmltoc"><span class="htmltochead" onclick="showLevel('htmltoc');"><span class="htmltocplus" id="htmltocplus">+</span><span class="htmltocminus" id="htmltocminus">&#8722;</span></span>&#160;Contents</h2>
<div class="htmltocitem" id="htmltoc">
<div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#purpose">1&#160;&#160;<b>Purpose</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#specification">2&#160;&#160;<b>Specification</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#description">3&#160;&#160;<b>Description</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#references">4&#160;&#160;<b>References</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#parameters">5&#160;&#160;<b>Parameters</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#errors">6&#160;&#160;<b>Error Indicators and Warnings</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#accuracy">7&#160;&#160;<b>Accuracy</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#fcomments">8&#160;&#160;<b>Further Comments</b></a>
</div><div class="htmltoc">
<span class="htmltoc" onclick="showLevel('tocexample');"><span class="htmltocplus" id="tocexampleplus">+</span><span class="htmltocminus" id="tocexampleminus">&#8722;</span></span>
<a class="htmltoc" href="#example">9&#160;&#160;<b>Example</b></a>
<div class="htmltocitem" id="tocexample">
<div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#examtext">9.1&#160;&#160;<b>Program Text</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#examdata">9.2&#160;&#160;<b>Program Data</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#examresults">9.3&#160;&#160;<b>Program Results</b></a>
</div>
</div>
</div>
</div>
</div><h2 class="standard"><a class="sec" name="purpose" id="purpose"/>1&#160;&#160;Purpose</h2>
<div class="paramtext">G10ABF fits a cubic smoothing spline for a given smoothing parameter.</div><h2 class="standard"><a class="sec" name="specification" id="specification"/>2&#160;&#160;Specification</h2>
<table class="fspec"><tr><td class="tdfspec1">SUBROUTINE&#160;G10ABF&#160;(</td><td class="tdfspec2"><a class="arg" href="#MODE">MODE</a>, <a class="arg" href="#WEIGHT">WEIGHT</a>, <a class="arg" href="#N">N</a>, <a class="arg" href="#X">X</a>, <a class="arg" href="#Y">Y</a>, <a class="arg" href="#WT">WT</a>, <a class="arg" href="#RHO">RHO</a>, <a class="arg" href="#YHAT">YHAT</a>, <a class="arg" href="#C">C</a>, <a class="arg" href="#LDC">LDC</a>, <a class="arg" href="#RSS">RSS</a>, <a class="arg" href="#DF">DF</a>, <a class="arg" href="#RES">RES</a>, <a class="arg" href="#H">H</a>, <a class="arg" href="#WK">WK</a>, <a class="arg" href="#IFAIL">IFAIL</a>)</td></tr><tr><td class="tdfspec1">INTEGER</td><td class="tdfspec2">N, LDC, IFAIL</td></tr><tr><td class="tdfspec1"><b><i>double&#160;precision</i></b></td><td class="tdfspec2">X(N), Y(N), WT(*), RHO, YHAT(N), C(LDC,3), RSS, DF, RES(N), H(N), WK(9*N+14)</td></tr><tr><td class="tdfspec1">CHARACTER*1</td><td class="tdfspec2">MODE, WEIGHT</td></tr></table><h2 class="standard"><a class="sec" name="description" id="description"/>3&#160;&#160;Description</h2>
<div class="paramtext">G10ABF fits a cubic smoothing spline to a set of <m:math><m:mi>n</m:mi></m:math>&#160;observations (<m:math><m:msub><m:mi>x</m:mi><m:mi>i</m:mi></m:msub></m:math>, <m:math><m:msub><m:mi>y</m:mi><m:mi>i</m:mi></m:msub></m:math>), for  <m:math><m:mi>i</m:mi><m:mo>=</m:mo><m:mn>1</m:mn><m:mo>,</m:mo><m:mn>2</m:mn><m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo><m:mi>n</m:mi></m:math>.  The spline provides a flexible smooth function for situations in which a simple polynomial or nonlinear regression model is unsuitable.</div><div class="paramtext">Cubic smoothing splines arise as the unique real-valued solution function <m:math><m:mi>f</m:mi></m:math>, with absolutely continuous first derivative and squared-integrable second derivative, which minimizes:

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
<m:munderover><m:mo>&#8721;</m:mo><m:mrow><m:mi>i</m:mi><m:mo>=</m:mo><m:mn>1</m:mn></m:mrow><m:mi>n</m:mi></m:munderover><m:msub><m:mi>w</m:mi><m:mi>i</m:mi></m:msub><m:msup><m:mfenced separators=""><m:msub><m:mi>y</m:mi><m:mi>i</m:mi></m:msub><m:mo>-</m:mo><m:mi>f</m:mi><m:mfenced separators=""><m:msub><m:mi>x</m:mi><m:mi>i</m:mi></m:msub></m:mfenced></m:mfenced><m:mn>2</m:mn></m:msup><m:mo>+</m:mo><m:mi>&#961;</m:mi>   <m:munderover><m:mo>&#8747;</m:mo><m:mrow><m:mo>-</m:mo><m:mi>&#8734;</m:mi></m:mrow><m:mi>&#8734;</m:mi></m:munderover><m:msup><m:mfenced separators=""><m:msup><m:mi>f</m:mi><m:mrow><m:mo>&#8242;</m:mo><m:mo>&#8242;</m:mo></m:mrow></m:msup><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced></m:mfenced><m:mn>2</m:mn></m:msup><m:mrow><m:mi>d</m:mi><m:mi>x</m:mi></m:mrow><m:mtext>,</m:mtext>
</m:math></td><td class="formula2"/></tr></table></div>

where <m:math><m:msub><m:mi>w</m:mi><m:mi>i</m:mi></m:msub></m:math>&#160;is the (optional) weight for the  <m:math><m:mi>i</m:mi></m:math>th observation and <m:math><m:mi>&#961;</m:mi></m:math>&#160;is the smoothing parameter.  This criterion consists of two parts: the first measures the fit of the curve, and the second the smoothness of the curve.  The value of the smoothing parameter <m:math><m:mi>&#961;</m:mi></m:math>&#160;weights these two aspects;  larger values of <m:math><m:mi>&#961;</m:mi></m:math>&#160;give a smoother fitted curve but,  in general, a poorer fit.  For details of how the cubic spline can be estimated see <a class="ref" href="#ref503">Hutchinson and de Hoog (1985)</a> and <a class="ref" href="#ref073">Reinsch (1967)</a>.</div><div class="paramtext">The fitted values,  <m:math>
 <m:mover><m:mi>y</m:mi><m:mo>^</m:mo></m:mover>
 <m:mo>=</m:mo>
 <m:msup><m:mfenced separators=""><m:msub><m:mover><m:mi>y</m:mi><m:mo>^</m:mo></m:mover><m:mn>1</m:mn></m:msub><m:mo>,</m:mo><m:msub><m:mover><m:mi>y</m:mi><m:mo>^</m:mo></m:mover><m:mn>2</m:mn></m:msub><m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo><m:msub><m:mover><m:mi>y</m:mi><m:mo>^</m:mo></m:mover><m:mi>n</m:mi></m:msub></m:mfenced><m:mi mathvariant="normal">T</m:mi></m:msup>
</m:math>,  and weighted residuals, <m:math><m:msub><m:mi>r</m:mi><m:mi>i</m:mi></m:msub></m:math>, can be written as

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
<m:mover><m:mi>y</m:mi><m:mo>^</m:mo></m:mover><m:mo>=</m:mo><m:mi>H</m:mi><m:mi>y</m:mi><m:mtext>&#8195; and &#8195;</m:mtext><m:msub><m:mi>r</m:mi><m:mi>i</m:mi></m:msub><m:mo>=</m:mo><m:msqrt><m:msub><m:mi>w</m:mi><m:mi>i</m:mi></m:msub></m:msqrt><m:mfenced separators=""><m:msub><m:mi>y</m:mi><m:mi>i</m:mi></m:msub><m:mo>-</m:mo><m:msub><m:mover><m:mi>y</m:mi><m:mo>^</m:mo></m:mover><m:mi>i</m:mi></m:msub></m:mfenced>
</m:math></td><td class="formula2"/></tr></table></div>

for a matrix <m:math><m:mi>H</m:mi></m:math>.  The residual degrees of freedom for the spline is <m:math><m:mi mathvariant="normal">trace</m:mi><m:mfenced separators=""><m:mi>I</m:mi><m:mo>-</m:mo><m:mi>H</m:mi></m:mfenced></m:math>&#160;and the diagonal elements of  <m:math><m:mi>H</m:mi></m:math>, <m:math><m:msub><m:mi>h</m:mi><m:mrow><m:mi>i</m:mi><m:mi>i</m:mi></m:mrow></m:msub></m:math>, are the leverages.</div><div class="paramtext">The parameter <m:math><m:mi>&#961;</m:mi></m:math>&#160;can be chosen in a number of ways.  The fit can be inspected for a number of different values of <m:math><m:mi>&#961;</m:mi></m:math>.  Alternatively the degrees of freedom for the spline, which determines the value of <m:math><m:mi>&#961;</m:mi></m:math>, can be specified, or the (generalized)  cross-validation can be minimized to give <m:math><m:mi>&#961;</m:mi></m:math>; see <a class="rout" href="../G10/g10acf.xml">G10ACF</a>  for further details.</div><div class="paramtext">G10ABF requires the <m:math><m:msub><m:mi>x</m:mi><m:mi>i</m:mi></m:msub></m:math>&#160;to be strictly increasing.  If two or more observations have the same <m:math><m:msub><m:mi>x</m:mi><m:mi>i</m:mi></m:msub></m:math>-value then they should be replaced by a single observation with <m:math><m:msub><m:mi>y</m:mi><m:mi>i</m:mi></m:msub></m:math>&#160;equal to the (weighted) mean of the <m:math><m:mi>y</m:mi></m:math>&#160;values and weight,  <m:math><m:msub><m:mi>w</m:mi><m:mi>i</m:mi></m:msub></m:math>, equal to the sum of the weights.  This operation can be performed by <a class="rout" href="../G10/g10zaf.xml">G10ZAF</a>.</div><div class="paramtext">The computation is split into three phases.
<table class="standard-100"><tr>
<td style="width:2.1em;" valign="baseline"><a name="item1" id="item1"/>(i)</td>
<td valign="top">Compute matrices needed to fit spline.</td>
</tr><tr>
<td style="width:2.1em;" valign="baseline"><a name="item2" id="item2"/>(ii)</td>
<td valign="top">Fit spline for a given value of <m:math><m:mi>&#961;</m:mi></m:math>.</td>
</tr><tr>
<td style="width:2.1em;" valign="baseline"><a name="item3" id="item3"/>(iii)</td>
<td valign="top">Compute spline coefficients.</td>
</tr></table>
</div><div class="paramtext">When fitting the spline for several different values of <m:math><m:mi>&#961;</m:mi></m:math>,  phase <a class="item" href="#item1">(i)</a> need only be carried out once and then phase <a class="item" href="#item2">(ii)</a> repeated for different values of <m:math><m:mi>&#961;</m:mi></m:math>.  If the spline is being fitted as part of an iterative weighted least-squares procedure phases <a class="item" href="#item1">(i)</a> and <a class="item" href="#item2">(ii)</a> have to be repeated for each set of weights.  In either case, phase <a class="item" href="#item3">(iii)</a> will often only have to be performed after the final fit has been computed.</div><div class="paramtext">The algorithm is based on <a class="ref" href="#ref502">Hutchinson (1986)</a>.</div><h2 class="standard"><a class="sec" name="references" id="references"/>4&#160;&#160;References</h2><div class="paramtext"><a name="ref501" id="ref501"/>Hastie T J and Tibshirani R J (1990)  <i>Generalized Additive Models</i> Chapman and Hall </div>
<div class="paramtext"><a name="ref502" id="ref502"/>Hutchinson M F (1986)  Algorithm 642: A fast procedure for calculating minimum cross-validation cubic smoothing splines <i>ACM Trans. Math. Software</i> <b>12</b> 150&#8211;153 </div>
<div class="paramtext"><a name="ref503" id="ref503"/>Hutchinson M F and de Hoog F R (1985)  Smoothing noisy data with spline functions <i>Numer. Math.</i> <b>47</b> 99&#8211;106 </div>
<div class="paramtext"><a name="ref073" id="ref073"/>Reinsch C H (1967)  Smoothing by spline functions <i>Numer. Math.</i> <b>10</b> 177&#8211;183 </div><h2 class="standard"><a class="sec" name="parameters" id="parameters"/>5&#160;&#160;Parameters</h2>
<dl><dt class="paramhead"><a name="MODE" id="MODE"/>1: &#160;&#160;&#8194; MODE &#8211; CHARACTER*1<span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: indicates in which mode the routine is to be used.

<dl>
<dt class="paramval"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#MODE"><m:mi mathcolor="#EE0000" mathvariant="bold">MODE</m:mi></m:maction><m:mo>=</m:mo><m:mtext>'P'</m:mtext></m:math></dt>
<dd>Initialization and fitting is performed. This partial fit can be used in an iterative weighted least-squares context where the weights are changing at each call to G10ABF or when the coefficients are not required.</dd>
<dt class="paramval"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#MODE"><m:mi mathcolor="#EE0000" mathvariant="bold">MODE</m:mi></m:maction><m:mo>=</m:mo><m:mtext>'Q'</m:mtext></m:math></dt>
<dd>Fitting only is performed. Initialization must have been performed previously by a call to G10ABF with <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#MODE"><m:mi mathcolor="#EE0000" mathvariant="bold">MODE</m:mi></m:maction><m:mo>=</m:mo><m:mtext>'P'</m:mtext></m:math>. This quick fit may be called repeatedly with different values of <a class="arg" href="#RHO">RHO</a> without re-initialization.</dd>
<dt class="paramval"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#MODE"><m:mi mathcolor="#EE0000" mathvariant="bold">MODE</m:mi></m:maction><m:mo>=</m:mo><m:mtext>'F'</m:mtext></m:math></dt>
<dd>Initialization and full fitting is performed and the function coefficients are calculated.</dd></dl>
</div><div class="paramtext"><i>Constraint</i>:
  <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#MODE"><m:mi mathcolor="#EE0000" mathvariant="bold">MODE</m:mi></m:maction><m:mo>=</m:mo><m:mtext>'P'</m:mtext></m:math>, <m:math><m:mtext>'Q'</m:mtext></m:math>&#160;or <m:math><m:mtext>'F'</m:mtext></m:math>.
</div></dd><dt class="paramhead"><a name="WEIGHT" id="WEIGHT"/>2: &#160;&#160;&#8194; WEIGHT &#8211; CHARACTER*1<span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: indicates whether user-defined weights are to be used.

<dl>
<dt class="paramval"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#WEIGHT"><m:mi mathcolor="#EE0000" mathvariant="bold">WEIGHT</m:mi></m:maction><m:mo>=</m:mo><m:mtext>'W'</m:mtext></m:math></dt>
<dd>User-defined weights should be supplied in <a class="arg" href="#WT">WT</a>.</dd>
<dt class="paramval"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#WEIGHT"><m:mi mathcolor="#EE0000" mathvariant="bold">WEIGHT</m:mi></m:maction><m:mo>=</m:mo><m:mtext>'U'</m:mtext></m:math></dt>
<dd>The data is treated as unweighted.</dd></dl>
</div><div class="paramtext"><i>Constraint</i>:
  <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#WEIGHT"><m:mi mathcolor="#EE0000" mathvariant="bold">WEIGHT</m:mi></m:maction><m:mo>=</m:mo><m:mtext>'W'</m:mtext></m:math>&#160;or <m:math><m:mtext>'U'</m:mtext></m:math>.
</div></dd><dt class="paramhead"><a name="N" id="N"/>3: &#160;&#160;&#8194; N &#8211; INTEGER<span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: 

<m:math><m:mi>n</m:mi></m:math>, the number of distinct observations.</div><div class="paramtext"><i>Constraint</i>:
  <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#N"><m:mi mathcolor="#EE0000" mathvariant="bold">N</m:mi></m:maction><m:mo>&#8805;</m:mo><m:mn>3</m:mn></m:math>.
</div></dd><dt class="paramhead"><a name="X" id="X"/>4: &#160;&#160;&#8194; X(<a class="arg" href="#N">N</a>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: the distinct and ordered values <m:math><m:msub><m:mi>x</m:mi><m:mi>i</m:mi></m:msub></m:math>&#160;for <m:math><m:mi>i</m:mi><m:mo>=</m:mo><m:mn>1</m:mn><m:mo>,</m:mo><m:mn>2</m:mn><m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo><m:mi>n</m:mi></m:math>.</div><div class="paramtext"><i>Constraint</i>:
  <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#X"><m:mi mathcolor="#EE0000" mathvariant="bold">X</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi mathvariant="italic">i</m:mi></m:mfenced></m:mrow><m:mo>&lt;</m:mo><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#X"><m:mi mathcolor="#EE0000" mathvariant="bold">X</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mrow><m:mi mathvariant="italic">i</m:mi><m:mo>+</m:mo><m:mn>1</m:mn></m:mrow></m:mfenced></m:mrow></m:math>,  for <m:math><m:mi mathvariant="italic">i</m:mi><m:mo>=</m:mo><m:mn>1</m:mn><m:mo>,</m:mo><m:mn>2</m:mn><m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo><m:mi>n</m:mi><m:mo>-</m:mo><m:mn>1</m:mn></m:math>.</div></dd><dt class="paramhead"><a name="Y" id="Y"/>5: &#160;&#160;&#8194; Y(<a class="arg" href="#N">N</a>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: the values <m:math><m:msub><m:mi>y</m:mi><m:mi>i</m:mi></m:msub></m:math>, for <m:math><m:mi>i</m:mi><m:mo>=</m:mo><m:mn>1</m:mn><m:mo>,</m:mo><m:mn>2</m:mn><m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo><m:mi>n</m:mi></m:math>.</div></dd><dt class="paramhead"><a name="WT" id="WT"/>6: &#160;&#160;&#8194; WT(<m:math><m:mo>*</m:mo></m:math>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Input</span></dt><dd><div class="paramtext"><b>Note:</b> the dimension of the array <a class="arg" href="#WT">WT</a>
must be at least
<m:math><m:mn>1</m:mn></m:math>&#160;if <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#WEIGHT"><m:mi mathcolor="#EE0000" mathvariant="bold">WEIGHT</m:mi></m:maction><m:mo>=</m:mo><m:mtext>'U'</m:mtext></m:math>&#160;and at least <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#N"><m:mi mathcolor="#EE0000" mathvariant="bold">N</m:mi></m:maction></m:math>&#160;if <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#WEIGHT"><m:mi mathcolor="#EE0000" mathvariant="bold">WEIGHT</m:mi></m:maction><m:mo>=</m:mo><m:mtext>'W'</m:mtext></m:math>.</div>
<div class="paramtext"><i>On entry</i>: if <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#WEIGHT"><m:mi mathcolor="#EE0000" mathvariant="bold">WEIGHT</m:mi></m:maction><m:mo>=</m:mo><m:mtext>'W'</m:mtext></m:math>, <a class="arg" href="#WT">WT</a> must contain the <m:math><m:mi>n</m:mi></m:math>&#160;weights. 
<div class="paramtext">If <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#WEIGHT"><m:mi mathcolor="#EE0000" mathvariant="bold">WEIGHT</m:mi></m:maction><m:mo>=</m:mo><m:mtext>'U'</m:mtext></m:math>, <a class="arg" href="#WT">WT</a> is not referenced and unit weights are assumed.</div>
</div><div class="paramtext"><i>Constraint</i>:
  
if <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#WEIGHT"><m:mi mathcolor="#EE0000" mathvariant="bold">WEIGHT</m:mi></m:maction><m:mo>=</m:mo><m:mtext>'W'</m:mtext></m:math>, <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#WT"><m:mi mathcolor="#EE0000" mathvariant="bold">WT</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi></m:mfenced></m:mrow><m:mo>&gt;</m:mo><m:mn>0.0</m:mn></m:math>,  for <m:math><m:mi mathvariant="italic">i</m:mi><m:mo>=</m:mo><m:mn>1</m:mn><m:mo>,</m:mo><m:mn>2</m:mn><m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo><m:mi>n</m:mi></m:math>.</div></dd><dt class="paramhead"><a name="RHO" id="RHO"/>7: &#160;&#160;&#8194; RHO &#8211; <span class="bitalic">double precision</span><span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: <m:math><m:mi>&#961;</m:mi></m:math>, the smoothing parameter.</div><div class="paramtext"><i>Constraint</i>:
  <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#RHO"><m:mi mathcolor="#EE0000" mathvariant="bold">RHO</m:mi></m:maction><m:mo>&#8805;</m:mo><m:mn>0.0</m:mn></m:math>.
</div></dd><dt class="paramhead"><a name="YHAT" id="YHAT"/>8: &#160;&#160;&#8194; YHAT(<a class="arg" href="#N">N</a>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Output</span></dt><dd>
<div class="paramtext"><i>On exit</i>: the fitted values, <m:math><m:msub><m:mover><m:mi>y</m:mi><m:mo>^</m:mo></m:mover><m:mi>i</m:mi></m:msub></m:math>, for <m:math><m:mi>i</m:mi><m:mo>=</m:mo><m:mn>1</m:mn><m:mo>,</m:mo><m:mn>2</m:mn><m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo><m:mi>n</m:mi></m:math>.</div></dd><dt class="paramhead"><a name="C" id="C"/>9: &#160;&#160;&#8194; C(<a class="arg" href="#LDC">LDC</a>,<m:math><m:mn>3</m:mn></m:math>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Input/Output</span></dt><dd><div class="paramtext"><i>On entry</i>: if <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#MODE"><m:mi mathcolor="#EE0000" mathvariant="bold">MODE</m:mi></m:maction><m:mo>=</m:mo><m:mtext>'Q'</m:mtext></m:math>, <a class="arg" href="#C">C</a> must be unaltered from the previous call to G10ABF with <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#MODE"><m:mi mathcolor="#EE0000" mathvariant="bold">MODE</m:mi></m:maction><m:mo>=</m:mo><m:mtext>'P'</m:mtext></m:math>. Otherwise <a class="arg" href="#C">C</a> need not be set.</div>
<div class="paramtext"><i>On exit</i>: if <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#MODE"><m:mi mathcolor="#EE0000" mathvariant="bold">MODE</m:mi></m:maction><m:mo>=</m:mo><m:mtext>'F'</m:mtext></m:math>, <a class="arg" href="#C">C</a> contains the spline coefficients. More precisely, the value of the spline at <m:math><m:mi>t</m:mi></m:math>&#160;is given by <m:math><m:mfenced separators=""><m:mfenced separators=""><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#C"><m:mi mathcolor="#EE0000" mathvariant="bold">C</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi><m:mn>3</m:mn></m:mfenced></m:mrow><m:mo>&#215;</m:mo><m:mi>d</m:mi><m:mo>+</m:mo><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#C"><m:mi mathcolor="#EE0000" mathvariant="bold">C</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi><m:mn>2</m:mn></m:mfenced></m:mrow></m:mfenced><m:mo>&#215;</m:mo><m:mi>d</m:mi><m:mo>+</m:mo><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#C"><m:mi mathcolor="#EE0000" mathvariant="bold">C</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi><m:mn>1</m:mn></m:mfenced></m:mrow></m:mfenced><m:mo>&#215;</m:mo><m:mi>d</m:mi><m:mo>+</m:mo><m:msub><m:mover><m:mi>y</m:mi><m:mo>^</m:mo></m:mover><m:mi>i</m:mi></m:msub></m:math>, where <m:math><m:msub><m:mi>x</m:mi><m:mi>i</m:mi></m:msub><m:mo>&#8804;</m:mo><m:mi>t</m:mi><m:mo>&lt;</m:mo><m:msub><m:mi>x</m:mi><m:mrow><m:mi>i</m:mi><m:mo>+</m:mo><m:mn>1</m:mn></m:mrow></m:msub></m:math>&#160;and <m:math><m:mi>d</m:mi><m:mo>=</m:mo><m:mi>t</m:mi><m:mo>-</m:mo><m:msub><m:mi>x</m:mi><m:mi>i</m:mi></m:msub></m:math>.
<div class="paramtext">If <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#MODE"><m:mi mathcolor="#EE0000" mathvariant="bold">MODE</m:mi></m:maction><m:mo>=</m:mo><m:mtext>'P'</m:mtext></m:math>&#160;or <m:math><m:mtext>'Q'</m:mtext></m:math>, <a class="arg" href="#C">C</a> contains information that will be used in a subsequent call to G10ABF with <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#MODE"><m:mi mathcolor="#EE0000" mathvariant="bold">MODE</m:mi></m:maction><m:mo>=</m:mo><m:mtext>'Q'</m:mtext></m:math>.</div>
</div></dd><dt class="paramhead"><a name="LDC" id="LDC"/>10: &#8194; LDC &#8211; INTEGER<span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: the first dimension of the array <a class="arg" href="#C">C</a> as declared in the (sub)program from which G10ABF is called.</div>
<div class="paramtext"><i>Constraint</i>:
  <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#LDC"><m:mi mathcolor="#EE0000" mathvariant="bold">LDC</m:mi></m:maction><m:mo>&#8805;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#N"><m:mi mathcolor="#EE0000" mathvariant="bold">N</m:mi></m:maction><m:mo>-</m:mo><m:mn>1</m:mn></m:math>.
</div></dd><dt class="paramhead"><a name="RSS" id="RSS"/>11: &#8194; RSS &#8211; <span class="bitalic">double precision</span><span class="pclass">Output</span></dt><dd>
<div class="paramtext"><i>On exit</i>: the (weighted) residual sum of squares.</div></dd><dt class="paramhead"><a name="DF" id="DF"/>12: &#8194; DF &#8211; <span class="bitalic">double precision</span><span class="pclass">Output</span></dt><dd><div class="paramtext"><i>On exit</i>: the residual degrees of freedom.</div></dd><dt class="paramhead"><a name="RES" id="RES"/>13: &#8194; RES(<a class="arg" href="#N">N</a>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Output</span></dt><dd>
<div class="paramtext"><i>On exit</i>: the (weighted) residuals, <m:math><m:msub><m:mi>r</m:mi><m:mi>i</m:mi></m:msub></m:math>, for <m:math><m:mi>i</m:mi><m:mo>=</m:mo><m:mn>1</m:mn><m:mo>,</m:mo><m:mn>2</m:mn><m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo><m:mi>n</m:mi></m:math>.</div></dd><dt class="paramhead"><a name="H" id="H"/>14: &#8194; H(<a class="arg" href="#N">N</a>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Output</span></dt><dd>
<div class="paramtext"><i>On exit</i>: the leverages, <m:math><m:msub><m:mi>h</m:mi><m:mrow><m:mi>i</m:mi><m:mi>i</m:mi></m:mrow></m:msub></m:math>, for <m:math><m:mi>i</m:mi><m:mo>=</m:mo><m:mn>1</m:mn><m:mo>,</m:mo><m:mn>2</m:mn><m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo><m:mi>n</m:mi></m:math>.</div></dd><dt class="paramhead"><a name="WK" id="WK"/>15: &#8194; WK(<m:math><m:mn>9</m:mn><m:mo>&#215;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#N"><m:mi mathcolor="#EE0000" mathvariant="bold">N</m:mi></m:maction><m:mo>+</m:mo><m:mn>14</m:mn></m:math>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Input/Output</span></dt><dd><div class="paramtext"><i>On entry</i>: if <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#MODE"><m:mi mathcolor="#EE0000" mathvariant="bold">MODE</m:mi></m:maction><m:mo>=</m:mo><m:mtext>'Q'</m:mtext></m:math>, <a class="arg" href="#WK">WK</a> must be unaltered from the previous call to G10ABF with <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#MODE"><m:mi mathcolor="#EE0000" mathvariant="bold">MODE</m:mi></m:maction><m:mo>=</m:mo><m:mtext>'P'</m:mtext></m:math>. Otherwise <a class="arg" href="#WK">WK</a> is used as workspace and need not be set.</div>
<div class="paramtext"><i>On exit</i>: if <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#MODE"><m:mi mathcolor="#EE0000" mathvariant="bold">MODE</m:mi></m:maction><m:mo>=</m:mo><m:mtext>'P'</m:mtext></m:math>&#160;or <m:math><m:mtext>'Q'</m:mtext></m:math>, <a class="arg" href="#WK">WK</a> contains information that will be used in a subsequent call to G10ABF with <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#MODE"><m:mi mathcolor="#EE0000" mathvariant="bold">MODE</m:mi></m:maction><m:mo>=</m:mo><m:mtext>'Q'</m:mtext></m:math>.</div></dd><dt class="paramhead"><a name="IFAIL" id="IFAIL"/>16: &#8194; IFAIL &#8211; INTEGER<span class="pclass">Input/Output</span></dt><dd>
<div class="paramtext"><i>On entry</i>: <a class="arg" href="#IFAIL">IFAIL</a> must be set to <m:math><m:mn>0</m:mn></m:math>, <m:math><m:mrow><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow><m:mtext>&#8203; or &#8203;</m:mtext><m:mn>1</m:mn></m:math>. If you are unfamiliar with this parameter you should refer to <a class="sec" href="../GENINT/essint.xml#library3">Section 3.3</a> in  the Essential Introduction for details.</div>
<div class="paramtext"><i>On exit</i>: <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#errors"><m:mn mathcolor="#003399" mathvariant="bold">0</m:mn></m:maction></m:math>&#160;unless the routine detects an error (see <a class="sec" href="#errors">Section 6</a>). <div class="paramtext">For environments where it might be inappropriate to halt program execution when an error is detected, the value <m:math><m:mrow><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow><m:mtext>&#8203; or &#8203;</m:mtext><m:mn>1</m:mn></m:math>&#160;is recommended.  If the output of error messages is undesirable, then the value <m:math><m:mn>1</m:mn></m:math>&#160;is recommended.  Otherwise, if you are not familiar with this parameter, the recommended value is <m:math><m:mn>0</m:mn></m:math>.  <b>When the value <m:math><m:mrow><m:mo>-</m:mo><m:mn mathvariant="bold">1</m:mn></m:mrow><m:mtext>&#8203; or &#8203;</m:mtext><m:mn mathvariant="bold">1</m:mn></m:math>&#160;is used it is essential to test the value of <a class="arg" href="#IFAIL">IFAIL</a> on exit.</b></div></div></dd></dl><h2 class="standard"><a class="sec" name="errors" id="errors"/>6&#160;&#160;Error Indicators and Warnings</h2>
<div class="paramtext">If on entry <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#errors"><m:mn mathcolor="#003399" mathvariant="bold">0</m:mn></m:maction></m:math>&#160;or <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#errors"><m:mn mathcolor="#003399" mathvariant="bold">-1</m:mn></m:maction></m:math>, explanatory error messages are output on the current error message unit (as defined by <a class="rout" href="../X04/x04aaf.xml">X04AAF</a>).</div><div class="paramtext">Errors or warnings detected by the routine:</div>
<dl class="ifail">
<dt class="errorhead"><a name="IFeq1" id="IFeq1"/><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:mn>1</m:mn></m:math></dt>
<dd>
<table class="ifail"><tr><td class="ifail1">On&#160;entry,</td><td class="ifail2-90"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#N"><m:mi mathcolor="#EE0000" mathvariant="bold">N</m:mi></m:maction><m:mo>&lt;</m:mo><m:mn>3</m:mn></m:math>,</td></tr><tr><td class="ifail1">or</td><td class="ifail2-90"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#LDC"><m:mi mathcolor="#EE0000" mathvariant="bold">LDC</m:mi></m:maction><m:mo>&lt;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#N"><m:mi mathcolor="#EE0000" mathvariant="bold">N</m:mi></m:maction><m:mo>-</m:mo><m:mn>1</m:mn></m:math>,</td></tr><tr><td class="ifail1">or</td><td class="ifail2-90"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#RHO"><m:mi mathcolor="#EE0000" mathvariant="bold">RHO</m:mi></m:maction><m:mo>&lt;</m:mo><m:mn>0.0</m:mn></m:math>,</td></tr><tr><td class="ifail1">or</td><td class="ifail2-90"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#MODE"><m:mi mathcolor="#EE0000" mathvariant="bold">MODE</m:mi></m:maction><m:mo>&#8800;</m:mo><m:mtext>'Q'</m:mtext></m:math>, <m:math><m:mtext>'P'</m:mtext></m:math>&#160;or <m:math><m:mtext>'F'</m:mtext></m:math>,</td></tr><tr><td class="ifail1">or</td><td class="ifail2-90"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#WEIGHT"><m:mi mathcolor="#EE0000" mathvariant="bold">WEIGHT</m:mi></m:maction><m:mo>&#8800;</m:mo><m:mtext>'W'</m:mtext></m:math>&#160;or <m:math><m:mtext>'U'</m:mtext></m:math>.</td></tr></table>
</dd>
</dl><dl class="ifail">
<dt class="errorhead"><a name="IFeq2" id="IFeq2"/><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:mn>2</m:mn></m:math></dt>
<dd>
<table class="ifail"><tr><td class="ifail1">On&#160;entry,</td><td class="ifail2-90"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#WEIGHT"><m:mi mathcolor="#EE0000" mathvariant="bold">WEIGHT</m:mi></m:maction><m:mo>=</m:mo><m:mtext>'W'</m:mtext></m:math>&#160;and at least one element of <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#WT"><m:mi mathcolor="#EE0000" mathvariant="bold">WT</m:mi></m:maction><m:mo>&#8804;</m:mo><m:mn>0.0</m:mn></m:math>.</td></tr></table></dd>
</dl><dl class="ifail">
<dt class="errorhead"><a name="IFeq3" id="IFeq3"/><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:mn>3</m:mn></m:math></dt>
<dd>
<table class="ifail"><tr><td class="ifail1">On&#160;entry,</td><td class="ifail2-90"><m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#X"><m:mi mathcolor="#EE0000" mathvariant="bold">X</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi></m:mfenced></m:mrow><m:mo>&#8805;</m:mo><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#X"><m:mi mathcolor="#EE0000" mathvariant="bold">X</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mrow><m:mi>i</m:mi><m:mo>+</m:mo><m:mn>1</m:mn></m:mrow></m:mfenced></m:mrow></m:math>, for some <m:math><m:mi>i</m:mi></m:math>, <m:math><m:mi>i</m:mi><m:mo>=</m:mo><m:mn>1</m:mn><m:mo>,</m:mo><m:mn>2</m:mn><m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo><m:mi>n</m:mi><m:mo>-</m:mo><m:mn>1</m:mn></m:math>.</td></tr></table></dd>
</dl><h2 class="standard"><a class="sec" name="accuracy" id="accuracy"/>7&#160;&#160;Accuracy</h2>
<div class="paramtext">Accuracy depends on the value of <m:math><m:mi>&#961;</m:mi></m:math>&#160;and the position of the <m:math><m:mi>x</m:mi></m:math>&#160;values.  The values of <m:math><m:msub><m:mi>x</m:mi><m:mi>i</m:mi></m:msub><m:mo>-</m:mo><m:msub><m:mi>x</m:mi><m:mrow><m:mi>i</m:mi><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow></m:msub></m:math>&#160;and <m:math><m:msub><m:mi>w</m:mi><m:mi>i</m:mi></m:msub></m:math>&#160;are scaled and <m:math><m:mi>&#961;</m:mi></m:math>&#160;is transformed to avoid underflow and overflow problems.</div><h2 class="standard"><a class="sec" name="fcomments" id="fcomments"/>8&#160;&#160;Further Comments</h2>
<div class="paramtext">The time taken by G10ABF is of order <m:math><m:mi>n</m:mi></m:math>.</div><div class="paramtext">Regression splines with a small <m:math><m:mfenced separators=""><m:mo>&lt;</m:mo><m:mi>n</m:mi></m:mfenced></m:math>&#160;number of knots can be fitted by <a class="rout" href="../E02/e02baf.xml">E02BAF</a> and <a class="rout" href="../E02/e02bef.xml">E02BEF</a>.</div><h2 class="standard"><a class="sec" name="example" id="example"/>9&#160;&#160;Example</h2>
<div class="paramtext">The data, given by <a class="ref" href="#ref501">Hastie and Tibshirani (1990)</a>, is the age,  <m:math><m:msub><m:mi>x</m:mi><m:mi>i</m:mi></m:msub></m:math>, and C-peptide concentration (pmol/ml),  <m:math><m:msub><m:mi>y</m:mi><m:mi>i</m:mi></m:msub></m:math>, from a study of the factors affecting insulin-dependent diabetes mellitus in children.  The data is input, reduced to a strictly ordered set by <a class="rout" href="../G10/g10zaf.xml">G10ZAF</a> and a spline is fitted by G10ABF with <m:math><m:mi>&#961;</m:mi><m:mo>=</m:mo><m:mn>10.0</m:mn></m:math>.  The fitted values and residuals are printed.</div><h3 class="standard"><a class="sec" name="examtext" id="examtext"/>9.1&#160;&#160;Program Text</h3>
<p><a class="verbatimref" href="../../examples/source/g10abfe.f">Program Text (g10abfe.f)</a></p><h3 class="standard"><a class="sec" name="examdata" id="examdata"/>9.2&#160;&#160;Program Data</h3>
<p><a class="verbatimref" href="../../examples/data/g10abfe.d">Program&#160;Data (g10abfe.d)</a></p><h3 class="standard"><a class="sec" name="examresults" id="examresults"/>9.3&#160;&#160;Program Results</h3>
<p><a class="verbatimref" href="../../examples/baseresults/g10abfe.r">Program Results (g10abfe.r)</a></p>
<hr/><div><a class="rout" href="../../pdf/G10/g10abf.pdf">G10ABF (PDF version)</a></div><div><a class="chap" href="g10conts.xml">G10 Chapter Contents</a></div><div><a class="chapint" href="g10intro.xml">G10 Chapter Introduction</a></div>
<div><a class="htmltoc" href="../FRONTMATTER/manconts.xml">NAG Library Manual</a></div>
<div><hr/><a class="genint" href="../FRONTMATTER/copyright.xml">&#169; The Numerical Algorithms Group Ltd, Oxford, UK. 2009</a></div></body></html>
