

   SSmmooootthhiinngg sspplliinnee rreeggrreessssiioonn

        spreg(x, y, lambda, xgrid, weight=rep(1, length(x)), derivative=0,
        Adiag=T, cost=1)

   AArrgguummeennttss::

          x: Vector of x values

          y: Vector of y values

     lambda: Smoothing parameter. If omitted this is estimated
             by GCV.

      xgrid: Vector of points to evaluate the estimated curve.
             Default is unique sorted x's.

     weight: A vector that is proportional to the standard
             deviation of the errors.

   derivative: If equal to 1 or 2 returns the estimated first
             or second derivative of the estimate

      Adiag: If true will compute leverage values for the esti-
             mate

       cost: Cost value to be used in the GCV criterion.

   DDeessccrriippttiioonn::

        A smoothing spline is a locally weighted average of the
        data y's based on the relative locations of the x val-
        ues. Formally the estimate is the curve that minimizes
        the criterion: (1/n) sum(k=1,n) ( Y_k - f( X_k))**2  +
        lambda* R(f) where R(f) is the integral of the squared
        second derivative of f over the range of the X values.
        The solution is a piecewise cubic polynomial with the
        join points at the unique set of X values. The polyno-
        mial segments are constructed so that the entire curve
        has continuous first and second derivatives and the
        second and third derivatives are zero at the bound-
        aries.  The smoothing parameter has the range [0,infin-
        ity]. Lambda equal to  zero gives a cubic spline inter-
        polation of  the data. As lambda diverges to infinity (
        e.g lambda =1e20) the estimate will converge to the
        straight line estimated by least squares.

        The values of the estimated function at the data points
        can be expressed in the matrix form:

        predicted.values= A(lambda)Y where A is an nXn symmet-
        ric matrix that does NOT depend on Y.  The diagonal
        elements are the leverage values for the estimate and
        the sum of these  (trace(A(lambda)) can be interpreted
        as the effective number of parameters that are used to
        define the spline function.

   VVaalluuee::

        A list of class spreg. The values of the GCV function
        and the effective number of parameters are tabulated in
        the component gcv.grid.  The component predicted is a
        two column matrix that contains the values from xgrid
        (or sorted unique x's) and the estimated curve at these
        points.

   RReeffeerreenncceess::

        Additive Models by Hastie and Tibishirani

   SSeeee AAllssoo::

        predict.spreg, splint, tpsreg

   EExxaammpplleess::

        spreg( auto.paint$thick, auto.paint$DOI)-> out
        plot(out)
        lines(out$predicted)

