Learn R Programming

NHMSAR (version 1.0)

valid_all: Statistics plotting for validation of MSAR models

Description

plots some functional statistics to help to valid MSAR models: qqplot, covariance function, mean duration of sojourn over and under a threshold. For each of them the empirical statistic of the observed time series is plotted as well as the simulated one with $(1-\alpha)$-fluctuation intervals.

Usage

valid_all(data, simu, root.filename = " ", path = NULL, title = "", 
  id = 1, alpha = 0.05, save = FALSE)

Arguments

data
observed (or reference) time series, array of dimension T*N.samples*d
simu
simulated time series, array of dimension T*N.sim*d. N.sim have to be K*N.samples with K large enough (for instance, K=100)
title
title of plots
id
component to be considered when the data is multivariate (d>1). Default d=1.
alpha
level for the $(1-\alpha)$-fluctuation intervals
save
if save=TRUE plots are saved into .eps files
root.filename
root file name for saving plots
path
path of folder where to save the files

Value

  • Returns plots

Examples

Run this code
data(meteo.data)
data = array(meteo.data$temperature,c(31,41,1)) 
k = 40
plot(data[,k,1],typ="l",xlab=("time (days)"),ylab=("temperature (degrees C)"))
T = dim(data)[1]
N.samples = dim(data)[2]
d = dim(data)[3]
# Fit Homogeneous MS-AR models
M = 2
order = 1
theta.init = init.theta.MSAR(data,M=M,order=order,label="HH") 
mod.hh = fit.MSAR(data,theta.init,verbose=TRUE,MaxIter=10)
# Simulation
yT = 31
Bsim = 10
Ksim = Bsim*N.samples
Y0 = array(data[1:2,sample(1:dim(data)[2],Ksim,replace=T),],c(2,Ksim,1))
Y.sim = simule.nh.MSAR(mod.hh$theta,Y0 = Y0,T,N.samples = Ksim) 
valid_all(data,Y.sim$Y)

Run the code above in your browser using DataLab