sample.bspec {bspec}R Documentation

Posterior sampling

Description

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

Usage

  ## S3 method for class '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.

Details

The posterior distribution is a product of independent scaled inverse chi-squared distributions.

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.

Author(s)

Christian Roever, christian.roever@med.uni-goettingen.de

See Also

bspec, ppsample

Examples

# 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")

[Package bspec version 1.5 Index]