lo                    package:gam                    R Documentation

_S_p_e_c_i_f_y _a _l_o_e_s_s _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:

     lo(..., span=0.5, degree=1)
     gam.lo(x, y, w, span, degree, ncols, xeval)

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

     ...: the unspecified '...'  can be a comma-separated list of
          numeric vectors, numeric matrix, or expressions that evaluate
          to either of these. If it is a list of vectors, they must all
          have the same length.

    span: the number of observations in a neighborhood. This is the
          smoothing parameter for a 'loess' fit.

  degree: the degree of local polynomial to be fit; currently
          restricted to be '1' or '2'.

       x: for 'gam.lo', the appropriate basis of polynomials generated
          from the arguments to 'lo'. These are also the variables that
          receive linear coefficients in the GAM fit.

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

       w: weights

   ncols: for 'gam.lo' the number of columns in 'x' used as the
          smoothing inputs to local regression. For example, if
          'degree=2', then 'x' has two columns defining a degree-2
          polynomial basis. Both are needed for the parameteric part of
          the fit, but 'ncol=1' telling the local regression routine
          that the first column is the actually smoothing variable.

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

_D_e_t_a_i_l_s:

     A smoother in gam separates out the parametric part of the fit
     from the non-parametric part. For local regression, the parametric
     part of the fit is specified by the particular polynomial being
     fit locally. The workhorse function 'gam.lo' fits the local
     polynomial, then strips off this parametric part. All the
     parametric pieces from all the terms in the additive model are fit
     simultaneously in one operation for each loop of the backfitting
     algorithm.

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

     'lo' returns a numeric matrix.  The simplest case is when there is
     a single argument to 'lo' and 'degree=1'; a one-column matrix is
     returned, consisting of a normalized version of the vector.  If
     'degree=2' in this case, a two-column matrix is returned,
     consisting of a degree-2 polynomial basis.  Similarly, if there
     are two arguments, or the single argument is a two-column matrix,
     either a two-column matrix is returned if 'degree=1', or a
     five-column matrix consisting of powers and products up to degree
     '2'.  Any dimensional argument is allowed, but typically one or
     two vectors are used in practice.

     The matrix is endowed with a number of attributes; the matrix
     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 'lo.wam' (currently not implemented).
     Local-linear curve or surface fits reproduce linear responses,
     while local-quadratic fits reproduce quadratic curves or surfaces.
     These parts of the 'loess' fit are computed exactly together with
     the other parametric linear parts

     Note that 'lo' itself does no smoothing; it simply sets things up
     for 'gam'; 'gam.lo' does the actual smoothing. of the model.

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

     'gam.lo' 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
          with the columns 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.lo' is evaluated with an 'xeval' argument, it returns a
     matrix 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:

     's', 'bs', 'ns', 'poly', 'loess'

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

     y ~ Age + lo(Start, span=.5)
          # fit Start using a loess smooth with a span of 0.5.
     y ~ lo(Age) + lo(Start, Number) 
     y ~ lo(Age, 0.5) # the argument name for span is not needed.

