Learn R Programming

bspec (version 1.6)

sample.bspec: Posterior sampling

Description

Function to generate samples from the spectrum's posterior distribution specified through the supplied bspec object argument.

Usage

# S3 method for bspec
sample(x, size = 1, two.sided = x$two.sided, ...)

Arguments

x

a bspec object.

size

the sample size.

two.sided

a logical flag indicating whether the drawn samples are supposed to correspond to the one-sided or two-sided spectrum.

...

currently unused.

Value

A (numerical) vector of samples from the posterior distribution of the spectral parameters, of the same length as and corresponding to the $freq element of the supplied bspec object.

Details

The posterior distribution is a product of independent scaled inverse \(\chi^2\) distributions.

See Also

bspec, ppsample

Examples

Run this code
# NOT RUN {
# determine spectrum's posterior distribution:
lhspec <- bspec(lh)

# plot 95 percent central intervals and medians:
plot(lhspec)

# draw and plot two samples from posterior distribution:
lines(lhspec$freq, sample(lhspec), type="b", pch=20, col="red")
lines(lhspec$freq, sample(lhspec), type="b", pch=20, col="green")
# }

Run the code above in your browser using DataLab