smooth.spline             package:modreg             R Documentation

_F_i_t _a _S_m_o_o_t_h_i_n_g _S_p_l_i_n_e

_D_e_s_c_r_i_p_t_i_o_n:

     Fits a cubic smoothing spline to the supplied data.

_U_s_a_g_e:

     smooth.spline(x, y, w = rep(1, length(x)), df = 5, spar = 0,
                   cv = FALSE, all.knots = FALSE, df.offset = 0, penalty = 1)

_A_r_g_u_m_e_n_t_s:

       x: a vector giving the values of the predictor variable, or  a
          list or a two-column matrix specifying x and y. 

       y: responses. If `y' is missing, the responses are assumed to be
          specified by `x'.

       w: optional vector of weights

      df: the desired equivalent number of degrees of freedom (trace of
          the smoother matrix).

    spar: the coefficient lambda of the integral of the squared second
          derivative in the fit (penalized log likelihood) criterion.

      cv: ordinary (`TRUE') or `generalized' (`FALSE')
          cross-validation.

all.knots: if `TRUE', all points in `x' are uses as knots. If `FALSE',
          a suitably fine grid of knots is used.

df.offset: allows the degrees of freedom to be increased by `df.offset'
          in the GCV criterion.

 penalty: the coefficient of the penalty for degrees of freedom in the
          GCV criterion.

_D_e_t_a_i_l_s:

     The `x' vector should contain at least ten distinct values.

     If `spar' is missing or 0, the value of `df' is used to determine
     the degree of smoothing. If both are missing, leave-one-out
     cross-validation is used to determine lambda.

     The `generalized' cross-validation method will work correctly when
     there are duplicated points in `x'.  However, it is ambiguous what
     leave-one-out cross-validation means with duplicated points, and
     the internal code uses an approximation that involves leaving out
     groups of duplicated points.  `cv=TRUE' is best avoided in that
     case.

_V_a_l_u_e:

     An object of class `"smooth.spline"' with components 

       x: the distinct `x' values in increasing order.

       y: the fitted values corresponding to `x'.

       w: the weights used at the unique values of `x'.

     yin: the y values used at the unique `y' values.

     lev: leverages, the diagonal values of the smoother matrix.

 cv.crit: (generalized) cross-validation score.

pen.crit: penalized criterion

      df: equivalent degrees of freedom used.

    spar: the value of lambda chosen.

     fit: list for use by `predict.smooth.spline'.

    call: the matched call.

_A_u_t_h_o_r(_s):

     B.D. Ripley

_S_e_e _A_l_s_o:

     `predict.smooth.spline'

_E_x_a_m_p_l_e_s:

     data(cars)
     attach(cars)
     plot(speed, dist, main = "data(cars)  &  smoothing splines")
     cars.spl <- smooth.spline(speed, dist)
     (cars.spl)
     ## This example has duplicate points, so avoid cv=TRUE

     lines(cars.spl, col = "blue")
     lines(smooth.spline(speed, dist, df=10), lty=2, col = "red")
     legend(5,120,c(paste("default [C.V.] => df =",round(cars.spl$df,1)),
                    "s( * , df = 10)"), col = c("blue","red"), lty = 1:2,
            bg='bisque')
     detach()

