s                    package:gam                    R Documentation

_S_p_e_c_i_f_y _a _S_m_o_o_t_h_i_n_g _S_p_l_i_n_e _F_i_t _i_n _a _G_A_M _F_o_r_m_u_l_a

_D_e_s_c_r_i_p_t_i_o_n:

     A symbolic wrapper to indicate a smooth term in a formala argument
     to gam

_U_s_a_g_e:

     s(x, df=4, spar=1)
     gam.s(x, y, w, df, spar, xeval)

_A_r_g_u_m_e_n_t_s:

       x: the univariate predictor, or expression, that evaluates to a
          numeric vector. 

      df: the target equivalent degrees of freedom, used as a smoothing
          parameter. The real smoothing parameter ('spar' below) is
          found such that 'df=tr(S)-1', where 'S' is the implicit
          smoother matrix. Values for 'df' should be greater than '1',
          with 'df=1' implying a linear fit. If both 'df' and 'spar'
          are supplied, the former takes precedence.

    spar: can be used as smoothing parameter, with values typically in
          '(0,1]'. See 'smooth.spline' for more details.

       y: a response variable passed to 'gam.s' during backfitting

       w: weights

   xeval: If this argument is present, then 'gam.s' produces a
          prediction at 'xeval'.

_V_a_l_u_e:

     's' returns the vector 'x', endowed with a number of attributes.
     The vector itself is used in the construction of the model matrix,
     while the attributes are needed for the backfitting algorithms
     'all.wam' (weighted additive model) or 's.wam' (currently not
     implemented). Since smoothing splines reproduces linear fits, the
     linear part will be efficiently computed with the other parametric
     linear parts of the model.

     Note that 's' itself does no smoothing; it simply sets things up
     for 'gam'.

     One important attribute is named 'call'. For example, 's(x)' has a
     call component 'gam.s(data[["s(x)"]], z, w, spar = 1, df = 4)'.
     This is an expression that gets evaluated repeatedly in 'all.wam'
     (the backfitting algorithm).

     'gam.s' returns an object with components 

residuals: The residuals from the smooth fit. Note that the smoother
          removes the parametric part of the fit (using a linear fit in
          'x'), so these residual represent the nonlinear part of the
          fit.

   nl.df: the nonlinear degrees of freedom

     var: the pointwise variance for the nonlinear fit


     When 'gam.s' is evaluated with an 'xeval' argument, it returns a
     vector of predictions.

_A_u_t_h_o_r(_s):

     Written by Trevor Hastie, following closely the design in the
     "Generalized Additive Models" chapter (Hastie, 1992) in Chambers
     and Hastie (1992).

_R_e_f_e_r_e_n_c_e_s:

     Hastie, T. J. (1992) _Generalized additive models._ Chapter 7 of
     _Statistical Models in S_ eds J. M. Chambers and T. J. Hastie,
     Wadsworth & Brooks/Cole.

     Hastie, T. and Tibshirani, R. (1990) _Generalized Additive
     Models._ London: Chapman and Hall.

_S_e_e _A_l_s_o:

     'lo', 'smooth.spline', 'bs', 'ns', 'poly'

_E_x_a_m_p_l_e_s:

     # fit Start using a smoothing spline with 4 df.
     y ~ Age + s(Start, 4)
     # fit log(Start) using a smoothing spline with 5 df.
     y ~ Age + s(log(Start), df=5)

