poly                  package:stats                  R Documentation

_C_o_m_p_u_t_e _O_r_t_h_o_g_o_n_a_l _P_o_l_y_n_o_m_i_a_l_s

_D_e_s_c_r_i_p_t_i_o_n:

     Returns or evaluates orthogonal polynomials of degree 1 to
     'degree' over the specified set of points 'x'. These are all
     orthogonal to the constant polynomial of degree 0.  Alternatively,
     evaluate raw polynomials.

_U_s_a_g_e:

     poly(x, ..., degree = 1, coefs = NULL, raw = FALSE)
     polym(..., degree = 1, raw = FALSE)

     ## S3 method for class 'poly':
     predict(object, newdata, ...)

_A_r_g_u_m_e_n_t_s:

x, newdata: a numeric vector at which to evaluate the polynomial. 'x'
          can also be a matrix.  Missing values are not allowed in 'x'.

  degree: the degree of the polynomial

   coefs: for prediction, coefficients from a previous fit.

     raw: if true, use raw and not orthogonal polynomials.

  object: an object inheriting from class '"poly"', normally the result
          of a call to 'poly' with a single vector argument.

     ...: 'poly, polym': further vectors.
           'predict.poly': arguments to be passed to or from other
          methods. 

_D_e_t_a_i_l_s:

     Although formally 'degree' should be named (as it follows '...'),
     an unnamed second argument of length 1 will be interpreted as the
     degree.

     The orthogonal polynomial is summarized by the coefficients, which
     can be used to evaluate it via the three-term recursion given in
     Kennedy & Gentle (1980, pp. 343-4), and used in the "predict" part
     of the code.

_V_a_l_u_e:

     For 'poly' with a single vector argument:
      A matrix with rows corresponding to points in 'x' and columns
     corresponding to the degree, with attributes '"degree"' specifying
     the degrees of the columns and (unless 'raw = TRUE') '"coefs"'
     which contains the centering and normalization constants used in
     constructing the orthogonal polynomials.  The matrix has given
     class 'c("poly", "matrix")'.

     Other cases of 'poly' and 'polym', and 'predict.poly': a matrix.

_N_o_t_e:

     This routine is intended for statistical purposes such as
     'contr.poly': it does not attempt to orthogonalize to machine
     accuracy.

_R_e_f_e_r_e_n_c_e_s:

     Chambers, J. M. and Hastie, T. J. (1992) _Statistical Models in
     S_. Wadsworth & Brooks/Cole.

     Kennedy, W. J. Jr and Gentle, J. E. (1980) _Statistical Computing_
     Marcel Dekker.

_S_e_e _A_l_s_o:

     'contr.poly'.

     'cars' for an example of polynomial regression.

_E_x_a_m_p_l_e_s:

     (z <- poly(1:10, 3))
     predict(z, seq(2, 4, 0.5))
     poly(seq(4, 6, 0.5), 3, coefs = attr(z, "coefs"))

     polym(1:4, c(1, 4:6), degree=3) # or just poly()
     poly(cbind(1:4, c(1, 4:6)), degree=3)

