Learn R Programming

tuts (version 0.1.1)

plot.tuts_polyn: Plots and visual diagnostics of tuts_polyn objects

Description

plot.tuts_polyn generates plots and visual diagnostics of tuts_polyn objects.

Usage

# S3 method for tuts_polyn
plot(x, type, ...)

Arguments

x

A tuts_polyn object.

type

plot type with the following options: - 'predTUTS' plots one step predictions of the model. - 'GR' plots Gelman-Rubin diagnostics. - 'cv' plots 5-fold cross validation. - 'mcmc' plots diagnostics of MCMC/JAGS objects. - 'volatility' plots volatility realizations.

...

list of optional parameters: - burn: burn-in parameter ranging from 0 to 0.7 with default value set to 0. - CI: credible interval ranging from 0.3 to 1 with default value set to 0.95.

Examples

Run this code
# NOT RUN {
# Note: Most of models included in tuts package are computationally intensive. In the example
# below I set parameters to meet CRAN<U+2019>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 (simulation is chosen for illustrative purposes):
DATA=simtuts(N=10,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:
polyorder=2
n.sim=1000
PN=tupolyn(y=y,ti.mu=ti.mu,ti.sd=ti.sd,polyorder=polyorder,n.sim=n.sim,CV=TRUE,n.cores=2)

#3. Generate plots and diagnostics of the model (optional parameters are listed in brackets):
plot(PN,type='predTUTS',CI=0.95)          # One step out of salmple predictions (CI, burn).
plot(PN,type='cv',burn=0.3)               # 5 fold cross-validation (CI, burn).
plot(PN,type='GR',CI=0.95)                # Gelman-Rubin diagnostic (CI).
plot(PN,type='mcmc')                      # MCMC diagnostics.
plot(PN,type='volatility')                # Volatility realizaitons.
# }

Run the code above in your browser using DataLab