Last data update: 2014.03.03

R: Spectral density
fdensityR Documentation

Spectral density

Description

Returns theoretical spectral density evaluated in ARMA and ARFIMA processes.

Usage

fdensity(ar = numeric(), ma = numeric(), d = 0, sd = 1, lambda = NULL)

Arguments

ar, ma

AR or MA vector, respectively. If the time serie doesn't have AR (or MA) term then omit it. To more details see examples.

d

d is a long-memory parameter. If d is zero, then the process is ARMA(p,q)

sd

Noise scale factor, by default is 1.

lambda

λ parameter on which the spectral density is calculated/computed. If lambda=NULL then it is considered a sequence between 0 and π.

Details

The spectral density of an ARFIMA(p,d,q) processes is

f(λ) = frac{σ^2}{2π} cdot igg(2, \textmd{sin}(λ/2)igg)^{-2d} cdot frac{igg|θigg(\textmd{exp}igg(-iλigg)igg)igg|^2}{igg|φigg(\textmd{exp}igg(-iλigg)igg)igg|^2}

with -π ≤ λ ≤ π and -1 < d < 1/2. |x| is the Mod of x. fdensity returns the values corresponding to f(λ). When d is zero, the spectral density corresponds to an ARMA(p,q).

Author(s)

Ricardo Olea <raolea@uc.cl>

References

Brockwell, Peter J., and Richard A. Davis. Introduction to time series and forecasting. 2002. ISBN-13: 978-0387953519.

Palma W. Long-Memory Time Series. Theory and Methods. 1st ed. New Jersey: John Wiley & Sons, Inc.; 2007. 285 p.

Examples

## Example 1: Spectral Density AR(1)
lambda = seq(0,pi,0.01)
f = fdensity(ar = 0.5, lambda = lambda)
plot(f~lambda, bty = "n", type = "l", las = 1, xlab = expression("Frequency"),
     ylab = expression("Spectral Density"))


## Example 2: Spectral Density AR(2)
lambda = seq(0,pi,0.01)
f = fdensity(ar = c(1.3,-0.6), lambda = lambda, sd=10)
plot(f~lambda, bty = "n", type = "l", las = 1, xlab = expression("Frequency"),
     ylab = expression("Spectral Density"))


## Spectral Density ARMA(1,1)
lambda = seq(0,pi,0.01)
f = fdensity(ar = 0.5, ma = 0.8, lambda = lambda)
plot(f~lambda, bty = "n", type = "l", las = 1, xlab = expression("Frequency"),
     ylab = expression("Spectral Density"))


## Spectral Density ARFIMA(1,d,1)
lambda = seq(0,pi,0.01)
f = fdensity(ar = 0.5, ma = 0.8, d = 0.2, lambda = lambda)
plot(f~lambda, bty = "n", type = "l", las = 1, xlab = expression("Frequency"),
     ylab = expression("Spectral Density"))

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(LSTS)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/LSTS/fdensity.Rd_%03d_medium.png", width=480, height=480)
> ### Name: fdensity
> ### Title: Spectral density
> ### Aliases: fdensity spectral
> ### Keywords: density spectral timeseries
> 
> ### ** Examples
> 
> ## Example 1: Spectral Density AR(1)
> lambda = seq(0,pi,0.01)
> f = fdensity(ar = 0.5, lambda = lambda)
> plot(f~lambda, bty = "n", type = "l", las = 1, xlab = expression("Frequency"),
+      ylab = expression("Spectral Density"))
> 
> 
> ## Example 2: Spectral Density AR(2)
> lambda = seq(0,pi,0.01)
> f = fdensity(ar = c(1.3,-0.6), lambda = lambda, sd=10)
> plot(f~lambda, bty = "n", type = "l", las = 1, xlab = expression("Frequency"),
+      ylab = expression("Spectral Density"))
> 
> 
> ## Spectral Density ARMA(1,1)
> lambda = seq(0,pi,0.01)
> f = fdensity(ar = 0.5, ma = 0.8, lambda = lambda)
> plot(f~lambda, bty = "n", type = "l", las = 1, xlab = expression("Frequency"),
+      ylab = expression("Spectral Density"))
> 
> 
> ## Spectral Density ARFIMA(1,d,1)
> lambda = seq(0,pi,0.01)
> f = fdensity(ar = 0.5, ma = 0.8, d = 0.2, lambda = lambda)
> plot(f~lambda, bty = "n", type = "l", las = 1, xlab = expression("Frequency"),
+      ylab = expression("Spectral Density"))
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>