# \donttest{
## a TARMA(1,1,1,1) model
set.seed(13)
x <- TARMA.sim(n=200, phi1=c(0.5,-0.5), phi2=c(0.0,0.5), theta1=-0.5, theta2=0.7, d=1, thd=0.2)
fit1 <- TARMA.fit(x,tar1.lags=1, tar2.lags=1, tma1.lags=1, tma2.lags=1, d=1)
# }
## --------------------------------------------------------------------------
## In the following examples the threshold is fixed to speed up computations
## --------------------------------------------------------------------------
## --------------------------------------------------------------------------
## Least Squares fit
## --------------------------------------------------------------------------
set.seed(26)
n <- 200
y <- TARMA.sim(n=n, phi1=c(0.6,0.6), phi2=c(-1.0,0.4), theta1=-0.7, theta2=0.5, d=1, thd=0.2)
fit1 <- TARMA.fit(y,tar1.lags=1, tar2.lags=1, tma1.lags=1, tma2.lags=1, d=1, threshold=0.2)
fit1
## ---------------------------------------------------------------------------
## Contaminate the data with one additive outlier
## ---------------------------------------------------------------------------
x <- y # contaminated series
x[54] <- x[54] + 10
## ---------------------------------------------------------------------------
## Compare the non-robust LS fit with the robust fit
## ---------------------------------------------------------------------------
fitls <- TARMA.fit(x,tar1.lags=1, tar2.lags=1, tma1.lags=1, tma2.lags=1, d=1, threshold=0.2)
fitrob <- TARMA.fit(x,tar1.lags=1, tar2.lags=1, tma1.lags=1, tma2.lags=1, d=1,
method='robust',alpha=0.7,qu=c(0.1,0.95), threshold=0.2)
par.true <- c(0.6,0.6,-1,0.4,-0.7,0.5)
pnames <- c("int.1", "ar1.1", "int.2", "ar2.1", "ma1.1", "ma2.1")
names(par.true) <- pnames
par.ls <- round(fitls$fit$coef,2) # Least Squares
par.rob <- round(fitrob$fit$coef,2) # robust
rbind(par.true,par.ls,par.rob)
Run the code above in your browser using DataLab