Learn R Programming

bspec (version 1.6)

likelihood: Prior, likelihood and posterior

Description

Prior density, likelihood, posterior density, and marginal likelihood functions for the posterior distributions specified through a bspec object.

Usage

dprior(x, ...)
likelihood(x, ...)
marglikelihood(x, ...)
dposterior(x, ...)
# S3 method for bspec
dprior(x, theta, two.sided=x$two.sided, log=FALSE, ...)
# S3 method for bspec
likelihood(x, theta, two.sided=x$two.sided, log=FALSE, ...)
# S3 method for bspec
marglikelihood(x, log=FALSE, ...)
# S3 method for bspec
dposterior(x, theta, two.sided=x$two.sided, log=FALSE, ...)

Arguments

x

a bspec object.

theta

a numeric vector of parameter values, corresponding to the Fourier frequencies in the x$freq element.

two.sided

a logical flag indicating whether the parameters theta correspond to the one-sided or two-sided spectrum.

log

a logical flag indicating whether to return logarithmic density (or likelihood) values.

...

currently unused.

Value

A numeric function value.

Details

Prior and posterior are both scaled inverse \(\chi^2\) distributions, and the likelihood is Normal.

References

Roever, C., Meyer, R., Christensen, N. Modelling coloured residual noise in gravitational-wave signal processing. Classical and Quantum Gravity, 28(1):015010, 2011. 10.1088/0264-9381/28/1/015010. See also arXiv preprint 0804.3853.

See Also

bspec, quantile.bspec, expectation

Examples

Run this code
# NOT RUN {
lhspec <- bspec(lh, priordf=1, priorscale=0.6)

# draw sample from posterior:
posteriorsample <- sample(lhspec)

# plot the sample:
plot(lhspec)
lines(lhspec$freq, posteriorsample, type="b", col="red")

# compute prior, likelihood, posterior:
print(c("prior"              = dprior(lhspec, posteriorsample),
        "likelihood"         = likelihood(lhspec, posteriorsample),
        "posterior"          = dposterior(lhspec, posteriorsample),
        "marginal likelihood"= marglikelihood(lhspec)))
# }

Run the code above in your browser using DataLab