home *** CD-ROM | disk | FTP | other *** search
/ Big Green CD 8 / BGCD_8_Dev.iso / NEXTSTEP / UNIX / Educational / R-0.49-MI / R-0.49-I / help / splines / ns < prev    next >
Encoding:
Text File  |  1997-09-13  |  2.4 KB  |  63 lines

  1.     
  2.     _G_e_n_e_r_a_t_e _a _B_a_s_i_s _M_a_t_r_i_x _f_o_r _N_a_t_u_r_a_l _C_u_b_i_c _S_p_l_i_n_e_s
  3.     
  4.          ns(x, df, knots, intercept=F, Boundary.knots)
  5.     
  6.     _A_r_g_u_m_e_n_t_s:
  7.     
  8.                 x:
  9.          the predictor variable.
  10.     
  11.                df:
  12.          degrees of freedom. One can supply df rather than
  13.          knots; ns() then chooses df-1-intercept knots at suit-
  14.          ably chosen quantiles of x.
  15.     
  16.             knots:
  17.          breakpoints that define the spline. The default is no
  18.          knots; together with the natural boundary conditions
  19.          this results in a basis for linear regression on x.
  20.          Typical values are the mean or median for one knot,
  21.          quantiles for more knots. See also Boundary.knots.
  22.     
  23.         intercept:
  24.          if TRUE, an intercept is included in the basis; default
  25.          is FALSE.
  26.     
  27.     Boundary.knots:
  28.          boundary points at which to impose the natural boundary
  29.          conditions and anchor the B-spline basis (default the
  30.          range of the data). If both knots and Boundary.knots
  31.          are supplied, the basis parameters do not depend on x.
  32.          Data can extend beyond Boundary.knots
  33.     
  34.          Value:
  35.     
  36.          a matrix of dimension length(x) * df where either df
  37.          was supplied or if knots were supplied, df =
  38.          length(knots) + 1 + intercept.  Attributes are returned
  39.          that correspond to the arguments to ns, and explicitly
  40.          give the knots, Boundary.knots etc for use by
  41.          predict.ns().  ns() is based on the function
  42.          spline.des() written by Douglas Bates.  It generates a
  43.          basis matrix for representing the family of piecewise-
  44.          cubic splines with the specified sequence of interior
  45.          knots, and the natural boundary conditions. These
  46.          enforce the constraint that the function is linear
  47.          beyond the boundary knots, which can either be sup-
  48.          plied, else default to the extremes of the data.  A
  49.          primary use is in modeling formula to directly specify
  50.          a natural spline term in a model. Beware of making
  51.          predictions with new x values when df is used as an
  52.          argument. Either use safe.predict.gam(), or else
  53.          specify knots and Boundary.knots.SA bs, poly, lo, s,
  54.          predict.ns
  55.     
  56.     _E_x_a_m_p_l_e_s:
  57.     
  58.          lsfit(ns(x,5),y)
  59.          lm(y ~ ns(age, 4) + ns(income, 4)) # an additive model
  60.          fit <- lm(y ~ ns(age, knots=c(20,30), B=c(10,60)))
  61.          predict(fit, new.age) #safe predictions because explicit knot sequence was supplied.
  62.     
  63.