R/poly.R

Defines functions poly

Documented in poly

###
### R routines for the R package dlnm (c)
#
poly <-
function(x, degree=1, scale, intercept=FALSE) {
#
################################################################################
#
  nx <- names(x)
  x <- as.vector(x)
#
  # TRANSFORMATION
  if(missing(scale)) scale <- max(abs(x),na.rm=TRUE)
  basis <- outer(x/scale,(1-intercept):(degree),"^")
#
  # NAMES AND ATTRIBUTES
  dimnames(basis) <- list(nx,seq(ncol(basis)))
  attributes(basis) <- c(attributes(basis),list(degree=degree,scale=scale,
    intercept=intercept))
#
  class(basis) <- c("poly","matrix")
#
  return(basis)
}

Try the dlnm package in your browser

Any scripts or data that you put into this service are public.

dlnm documentation built on Oct. 7, 2021, 5:09 p.m.