fourier | R Documentation |
Compute sine and cosine terms for describing annual or daily variations.
fourier(x, k.max = 1)
x |
a numeric vector where one unit specifies the period. See Details. Missing values are permitted. |
k.max |
the maximum number of paired sine and cosine terms specifying the order of the Fourier series. |
The argument x
can be expressed as decimal time, either annual or
diel; or it can be an object of class "Date," "POSIXct," or "POSIXlt" in
which case it will be converted to annual decimal time using the
dectime
function.
A matrix of the sine and cosine terms corresponding to the
value—two terms are computed for each value of k from 1 to k.max
: sine(k 2
pi x
) and cosine(k 2 pi x
). The value of k.max
is included as an attribute.
Water-quality data commonly follow a sinusoidal variation throughout a yearly cycle. A Fourier series of order one to three is generally enough to adequately describe that variation for many constituents.
dectime
# compute the sine and cosine terms for quarters of 2002 fourier(2002 + (0:3)/4) # sin(k=1) cos(k=1) # [1,] 3.54692e-014 1.00000e+000 # [2,] 1.00000e+000 7.08886e-013 # [3,] -3.65749e-013 -1.00000e+000 # [4,] -1.00000e+000 -3.78606e-013 # attr(, "k.max"): # [1] 1 # Compare to 2 cycles per year: fourier(2002 + (0:3)/4, 2) # sin(k=1) cos(k=1) sin(k=2) cos(k=2) #[ 1,] 3.546924e-14 1.000000e+00 7.093848e-14 1 # [2,] 1.000000e+00 7.088855e-13 1.417771e-12 -1 # [3,] -3.657492e-13 -1.000000e+00 7.314983e-13 1 # [4,] -1.000000e+00 -3.786056e-13 7.572112e-13 -1 # attr(,"k.max") # [1] 2
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.