# spec.lomb: Lomb-Scargle Periodigram In spectral: Common Methods of Spectral Data Analysis

## Description

The Lomb-Scargle periodigram represents an statistical estimator for the amplitude and phase for a given frequency.

## Usage

 ```1 2``` ```spec.lomb(y = stop("Missing y-Value"), x = stop("Missing x-Value"), f = NULL, ofac = 4) ```

## Arguments

 `y` data vector `x` sampling vector `f` frequeny vector `ofac` in case `f=NULL` this value controlls the amount of frequency oversampling.

## Details

A given time series does not need to be evenly sampled. This means a time series mainly consists of data pairs `x` and `y`, which store the data and the sampling position (e.g. in time). Additionally, this method enables the user to analyse the data with respect to a given frequency vector, which can be artifical dense.

`ofac`

If the user does not provide a corresponding frequency vector, the `ofac` parameter causes the function to estimate

nf = ofac*length(x)/2

equidistant frequencies.

`p`-value

The `p`-value gives the probability, wheater the estimated amplitude is NOT significant. However, if `p` tends to zero the amplidutde is significant. The user must decide which maximum value is acceptable, until an amplitude is not valid.

## Value

The `spec.lomb` function returns an object of the type `lomb`, which is a `list` containg the following parameters:

`A`

A vector with amplitude spectrum

`f`

corresponding frequency vector

`phi`

phase vector

`x,y`

original data

p

p-value as statistical measure

## References

A. Mathias, F. Grond, R. Guardans, D. Seese, M. Canela, H. H. Diebner, und G. Baiocchi, "Algorithms for spectral analysis of irregularly sampled time series", Journal of Statistical Software, 11(2), pp. 1–30, 2004.

J. D. Scargle, "Studies in astronomical time series analysis. II - Statistical aspects of spectral analysis of unevenly spaced data", The Astrophysical Journal, 263, pp. 835–853, 1982.

`filter.lomb`
 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25``` ```# create two sin-functions x_orig <- seq(0,1,by=1e-2) y_orig <- sin(10*2*pi*x_orig) + 0.3*sin(2*2*pi*x_orig) # make a 10% gap i <- round(length(x_orig)*0.2) : round(length(x_orig)*0.3) x <- x_orig y <- y_orig x[i] <- NA y[i] <- NA # calculating the lomb periodogram l <- spec.lomb(x = x, y = y) # select a frequency range m <- rbind(c(9,11)) # select and reconstruct the most significant component l2 = filter.lomb(l, x_orig, filt=m) # plot everything par(mfrow=c(2,1),mar = c(4,4,2,4)) plot(x,y,"l", main = "Gapped signal") lines(l2\$x, l2\$y,lty=2) legend("bottomleft",c("gapped","10Hz component"),lty=c(1,2)) plot(l,main = "Spectrum") ```