BaSAR.post: Normalized posterior

Description Usage Arguments Details Value Author(s) References Examples

View source: R/BaSAR.R

Description

A normalised posterior of the frequency in the chosen range.

Usage

1
BaSAR.post(data, start, stop, nsamples, nbackg, tpoints)

Arguments

data

data as a 1-dimensional vector

start

lower limit of period of interest, in seconds

stop

upper limit of period of interest, in seconds

nsamples

number of samples within the interval start-stop

nbackg

number of background functions to be added to the model

tpoints

vector of time points, in seconds

Details

This function calculates the posterior probability distribution over a chosen range of omega (angular frequency), following Bretthorst (1988). It is based on a signal model of sines and cosines, and assumes uniform priors for model parameters such as amplitudes and noise models. The resulting distribution is then normalized over the range of omega.

If there is a background trend in the data, background functions can be added to the signal model to account for this. The Legendre polynomials are used for these background functions, and nbackg is the number of Legendre extension orders to be used.

To plot the output over period instead of omega, see BaSAR.plotperiod.

Value

A list containing:

normp

1D normalized posterior distribution over omega

omega

1D vector of the omega sampled

stats

list of statistics from the probability distribution

Author(s)

Emma Granqvist, Matthew Hartley and Richard J Morris.

References

Granqvist, E., Oldroyd, G. E. and Morris, R. J. (2011) Automated Bayesian model development for frequency detection in biological time series. BMC Syst Biol 5, 97.
http://dx.doi.org/10.1186/1752-0509-5-97

Bretthorst, G. L. (1988) Bayesian spectrum analysis and parameter estimation. Lecture notes in statistics. New York: Springer-Verlag.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# Create time series omega = 0.5
tpoints = seq(from=1, to=200, length=200)
dpoints = sin(0.5 * tpoints) + 0.1 * rnorm(200, 0, 1)
# Plot time series
plot(dpoints, type="l", col="blue", xlab="t", ylab="d(t)")
# Run BaSAR to get normalized posterior distirbution
r <- BaSAR.post(dpoints, 6, 600, 100, 0, tpoints)
# Plot the resulting posterior density function
plot(r$omega, r$normp, xlim=c(0:1), type="h", col="red", ylab="PDF",
xlab=expression(omega))

JIC-CSB/BaSAR documentation built on May 21, 2019, 1:41 p.m.