artfima(Nile) #Nile is a built in dataset in R
artfima(Nile, likAlg = "exact")
#
#fitting a high-order AR using recursion
## Not run:
# #This may take 3 to 6 hours if exact MLE used!
# #But Whittle MLE doesn't work properly for this example!!
# data(SB32)
# z <- SB32
# likAlg <- "exact"
# pmax <- 30
# startTime <- proc.time()[3]
# ic <- matrix(numeric(0), ncol=3, nrow=pmax+1)
# out <- artfima(z, arimaOrder=c(0,0,0), likAlg=likAlg)
# ic[1, 1] <- out$aic
# ic[1, 2] <- out$bic
# ic[1, 3] <- out$LL
# b1 <- c(out$b0, 0)
# for (i in 1:pmax) {
# out <- artfima(z, arimaOrder=c(i,0,0), b0=b1, likAlg=likAlg)
# b1 <- c(out$b0, 0)
# ic[i+1, 1] <- out$aic
# ic[i+1, 2] <- out$bic
# ic[i+1, 3] <- out$LL
# }
# endTime <- proc.time()[3]
# (totTime <- endTime-startTime)
# plot(0:pmax, ic[,1], xlab="AR order", ylab="AIC", pch=20, col="blue")
# indBest <- which.min(ic[,1])
# pBest <- indBest-1
# icBest <- ic[indBest,1]
# abline(h=icBest, col="brown")
# abline(v=pBest, col="brown")
# plot(0:pmax, ic[,2], xlab="AR order", ylab="BIC", pch=20, col="blue")
# indBest <- which.min(ic[,2])
# pBest <- indBest-1
# icBest <- ic[indBest,2]
# abline(h=icBest, col="brown")
# abline(v=pBest, col="brown")
# plot(0:pmax, ic[,3], xlab="AR order", ylab="log-lik", pch=20)
# ## End(Not run)#end dontrun
#
#setting new boundary limit
## Not run:
# data(SB32)
# #ARTFIMA(1,0,2) - MLE for d on boundar, dHat = 10
# artfima(SB32, arimaOrder=c(1,0,2))
# #note:
# #log-likelihood = -10901.14, AIC = 21816.29, BIC = 21862.41
# #Warning: estimates converged to boundary!
# #mean -0.5558988 8.443794e-02
# #d 9.9992097 1.396002e-05
# #lambda 2.9304658 8.050071e-02
# #phi(1) 0.9271892 6.862294e-03
# #theta(1) 0.8440911 1.709824e-02
# #theta(2) -0.3650004 2.744227e-02
# #
# #now reset upper limit dMax and lambdaMax
# #NOTE - there is only a very small improvement in the log-likelihood
# artfima(SB32, arimaOrder=c(1,0,2), lambdaMax=20, dMax=40)
# #ARTFIMA(1,0,2), MLE Algorithm: exact, optim: BFGS
# #snr = 4.665, sigmaSq = 3.38228734331338
# #log-likelihood = -10900.56, AIC = 21815.12, BIC = 21861.25
# # est. se(est.)
# #mean -0.5558988 0.08443794
# #d 27.0201256 36.94182328
# #lambda 3.9412050 1.38296970
# #phi(1) 0.9276901 0.00676589
# #theta(1) 0.8342879 0.01715041
# #theta(2) -0.3644787 0.02691869
# ## End(Not run)
Run the code above in your browser using DataLab