Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

harm

Create a basis of harmonic functions.


Description

Returns a matrix of harmonic functions usable for modeling periodic effects

Usage

harm(x, ord=1, per=1, verbose=FALSE )

Arguments

x

A numeric variable.

ord

Integer, the order of the harmonic.

per

Numeric, the length of the period on the x scale.

verbose

Logical: shall I tell what I do with dates?

Details

Columns are constructed under the assumption that the periodic function has period per on the x scale. Thus, the first columns is defined as sin(2*pi*x/per), cos(2*pi*x/per), sin(4*pi*x/per) etc.

Since sin and cos are periodic functions there is no requirement that x be in any particular range.

Value

A matrix with nrow(x) rows and 2*deg columns and columnnames sin1, cos1, sin2, cos2 etc.

Author(s)

Bendix Carstensen, http://bendixcarstensen.com

Examples

x <- seq(-1,1,0.01)
head( harm(x,ord=2) )
matplot( x, harm(x,ord=2), type="l", lty=1, lwd=3 )

Epi

Statistical Analysis in Epidemiology

v2.44
GPL-2
Authors
Bendix Carstensen [aut, cre], Martyn Plummer [aut], Esa Laara [ctb], Michael Hills [ctb]
Initial release
2021-02-28

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.