Learn R Programming

basefun (version 1.2-1)

cyclic_basis: Cyclic Basis Function

Description

The cyclic basis function for modelling seasonal effects

Usage

cyclic_basis(var, order = 3, frequency)

Arguments

var

a numeric_var object

order

the order of the basis function

frequency

frequency

Details

cyclic_basis returns a set of sin and cosine functions for modelling seasonal effects, see Held and Paul (2012), Section 2.2.

For any choice of coefficients, the function returns the same value when evaluated at multiples of frequency.

References

Leonhard Held and Michaela Paul (2012), Modeling Seasonality in Space-time Infectious Disease Surveillance Data, Biometrical Journal, 54(6), 824--843, tools:::Rd_expr_doi("10.1002/bimj.201200037")

Examples

Run this code

  ### set-up basis
  cb <- cyclic_basis(numeric_var("x"), order = 3, frequency = 2 * pi)

  ### generate data + coefficients
  x <- data.frame(x = c(0, pi, 2 * pi))

  ### f(0) = f(2 * pi)
  cb(x) 

Run the code above in your browser using DataLab