tp                   package:amer                   R Documentation

_G_e_n_e_r_a_t_e _a _t_r_u_n_c_a_t_e_d _p_o_w_e_r _b_a_s_i_s _f_o_r _p_e_n_a_l_i_z_e_d _s_p_l_i_n_e _s_m_o_o_t_h_i_n_g.

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

     Generate a truncated power basis for penalized spline smoothing.

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

     tp(x, degree=1, k=15, by, allPen=FALSE, varying, diag=FALSE,
         knots=seq(min(x), max(x), l = k - degree + 2)[-c(1, k -
         degree + 2)], centerscale=NULL, scaledknots=FALSE)

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

       x: covariate for the smooth function

  degree: integer: degree of truncated polynomials (0: piecewise
          constant, 1: piecewise linear etc..)

       k: integer: dimensionality of the basis (i.e.: number of knots +
          degree)

      by: factor variable: estimate separate functions for each level -
          this assumes standard treatment contrasts for the supplied
          factor.

  allPen: boolean: if TRUE, make design for group-specific curves with
          common smoothing parameter: all parameters (including the
          normally unpenalized basis functions in X) are penalized,
          every level of "by" has the same amount of smoothing  if
          FALSE, make design for separate curves for each by-level:
          separate smoothing parameters for every level of "by",
          unpenalized estimates for the coefficients associated with X

 varying: numeric: if not NULL, a varying coefficient model is fit:
          f(x,varying) = f(x)*varying

    diag: logical: force a diagonal covariance-matrix for the random
          effects for X if 'allPen=TRUE'?

   knots: vector of knot locations (optional). Defaults to equidistant
          knots. For quantile-based knots at the (i+1)/(k+2)-quantiles
          for i=1,...,k use 'knots=quantile(x, probs = (2:(k - degree +
          1))/(k - degree + 2))'

centerscale: numeric(2), center&scale x by these values if not NULL

scaledknots: boolean,     are knots given for the rescaled x-values?

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

     list with entries: '"X"': 'n x degree' design matrix for
     unpenalized part (without intercept) (or a list of those for every
     level of by if allPen=F),  '"Z"': 'n x (k-degree)' design matrix
     for penalized part (or a list of those for every level of by if
     allPen=F),

_N_o_t_e:

     Truncated power bases have 'degree' unpenalized basis functions,
     namely x^1,..., x^{degree} and k-'degree' penalized basis
     functions that contain the positive part (x-kappa_j)^degree for
     knots kappa_j, j=1,dots,k-'degree'. This function can be used as a
     reference when implementing other 'basisGenerators' that can be
     used for 'amer'-fits.  All such functions need to return a list of
     at least X (unpenalized basis functions, a matrix with zero
     columns if there are none of those), and Z (penalized basis
     functions) that has a 'call'-attribute with the expanded call
     returned by 'expand.call()'. All such functions need to have at
     least arguments 'x, by, allPen, diag' and 'varying'. See also
     section 4.4 in the vignette for an example on how to write your
     own basis-generating functions.

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

     Fabian Scheipl

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

     'tpU'

