tubfs: Bayesian Frequency Selection of time-uncertain data sets

Description Usage Arguments Examples

View source: R/a_tubfs.R

Description

tubfs performs spectral analysis of time-uncertain time series using the Bayesian Frequency Selection method described in the paper Frequency selection in paleoclimate time series: A model-based approach incorporating possible time uncertainty by P. Franke, Prof B. Huntley, Dr A. Parnell.

Usage

1
tubfs(y, ti.mu, ti.sd, n.sim, CV = FALSE, ...)

Arguments

y

A vector of observations.

ti.mu

A vector of estimates/observed timings of observations.

ti.sd

A vector of standard deviations of timings.

n.sim

A number of simulations.

CV

TRUE/FALSE cross-validation indicator.

...

optional arguments:
- n.chains: number of MCMC chains, the default number of chains is set to 2.
- Thin: thinning factor, the default values is set to 4.
- m: maximum number of significant frequencies in the data, the default value is set to 5.
- polyorder: the polynomial regression component, the default odrer is set to 3.
- freqs: set to a positive integer k returns a vector of k equally spaced frequencies in the Nyquist range. freqs can be provided as a vector of custom frequencies of interest. Set to 'internal' (the default value) generates a vector of equally spaced frequencies in the Nyquist range. - n.cores: number of cores used in cross-validation. No value or 'MAX' applies all the available cores in computation.

Examples

 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
26
# Note: Most of models included in tuts package are computationally intensive. In the example
# below I set parameters to meet CRAN<e2><80><99>s testing requirement of maximum 5 sec per example.
# A more practical example would contain N=50 in the first line of the code and n.sim=10000.

#1. Import or simulate the data (a simulation is chosen for illustrative purposes):
DATA=simtuts(N=8,Harmonics=c(4,0,0), sin.ampl=c(10,0, 0), cos.ampl=c(0,0,0),
            trend=0,y.sd=2, ti.sd=0.2)
y=DATA$observed$y.obs
ti.mu=DATA$observed$ti.obs.tnorm
ti.sd= rep(0.2, length(ti.mu))

#2. Fit the model:
n.sim=10
BFS=tubfs(y=y,ti.mu=ti.mu,ti.sd=ti.sd,freqs='internal',n.sim=n.sim,n.chains=2,CV=TRUE,n.cores=2)

#3. Generate summary results (optional parameters are listed in brackets):
summary(BFS)                               # Summary results (CI, burn).
summary(BFS,burn=0.2)                      # Results after 20% of burn-in (CI).

#4. Generate plots and diagnostics of the model (optional parameters are listed in brackets):
plot(BFS,type='periodogram')               # spectral analysis (CI, burn).
plot(BFS,type='predTUTS', CI=0.99)         # One step predictions (CI, burn).
plot(BFS,type='cv')                        # 5 fold cross validation plot (CI, burn).
plot(BFS,type='GR')                        # Gelman-Rubin diagnostics (CI, burn).
plot(BFS,type='mcmc')                      # mcmc diagnostics.
plot(BFS,type='volatility')                # Volatility realizaitons.

tuts documentation built on May 1, 2019, 7:56 p.m.

Related to tubfs in tuts...