diff --git a/DESCRIPTION b/DESCRIPTION old mode 100755 new mode 100644 index 2ffb0bc..f998b50 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: FGN -Version: 2.0-5 -Date: 2013-04-02 +Version: 2.0-11 +Date: 2013-04-11 Title: Fractional Gaussian Noise and hyperbolic decay time series model fitting Author: A.I. McLeod and Justin Veenstra @@ -15,7 +15,7 @@ LazyLoad: yes LazyData: yes License: CC BY-NC-SA 3.0 URL: http://www.stats.uwo.ca/faculty/aim -Packaged: 2013-04-02 18:43:59 UTC; Aim +Packaged: 2013-04-13 03:16:21 UTC; Aim NeedsCompilation: yes Repository: CRAN -Date/Publication: 2013-04-02 21:57:12 +Date/Publication: 2013-04-13 06:54:26 diff --git a/MD5 b/MD5 index 6fa6f62..37865da 100644 --- a/MD5 +++ b/MD5 @@ -1,5 +1,5 @@ -b9e5ae5bf7de708ca0daea5ba6a045bf *DESCRIPTION -601160f446dc426c0d61bb47613bf908 *NAMESPACE +cb28d1eb38c894db9cbd77f2cdf19066 *DESCRIPTION +e3c595c2cf411596b4abfdce4bfcd789 *NAMESPACE bbdf261659630d1896b67be196486ea5 *NEWS b834c996deb14ac0ba270e839cdd415f *R/ARToPacf.R cfb49e32b1bbe8aaf7d5c8a33cf46d6b *R/Boot.FitFGN.R @@ -26,7 +26,7 @@ b5717727508fef59300c2a572d56540d *R/acvfFGN.R e294fa616ca8e97529ce72b537ade626 *R/acvfPLA.R affa8ca353982d8bc6467807f3cc81e3 *R/acvfPLSA.R 0052fa030a9d0ef0785daf1366ed1411 *R/coef.FitFGN.R -ce5eb4d06d95cc86f5d7fb6a70275ae3 *R/earfima.R +7d1973a22fa92c4096dc6807b52a57f5 *R/earfima.R f638720000b1401c6333ad085cd7cb34 *R/plot.FitFGN.R 640cf7f5d682447e746fdfb090d172cb *R/predict.FitFGN.R 4bd6e768e68fab8bdb79bdabbe2dfe54 *R/print.FitFGN.R @@ -35,21 +35,24 @@ f638720000b1401c6333ad085cd7cb34 *R/plot.FitFGN.R 6eba875379217f71854e9811c757b31a *R/sdfFGN.R 9c2740679621ff0fcba12c846473f84d *R/sdfPLA.R 3f9598f9af247411657e8082484c0419 *R/sdfPLS.R -4565fe84482cd26f6551c418ee0c4205 *R/sdfarma.R +da8604626436fa000bf31d8313dfdd8c *R/sdfarma.R 09cadf380cb853e51d5bf49c64435154 *R/sdfhd.R 758e97148aab910686c504d157d1a780 *R/summary.FitFGN.R 6df07ceddbbec6beabc28ce40e0b7ecd *R/tacf.R -dd4d66323129f51f7523100873f1aab4 *R/warfima.R +f5a8863b675a3908fb2a90b652dc4320 *R/warfima.R 5f8d2d4fe369d57c038386dc77491821 *data/NileFlowCMS.rda 560728c6cc3b74c995c191a734c9b3ac *data/NileMin.rda e918f7c41e84a05a6b4181b0edce462b *data/SeriesB.rda b7663e7d42f5b3970d4a1f7d88cc02cc *data/globtp.rda 38cd3e0b2aacd4818e5cf9474572823d *inst/CITATION -3555586e9baccf804d2ba40680541d43 *inst/doc/index.html +6a3c7a135af791a7ca21613438bcbe6a *inst/doc/NileMin.pdf +abfa279ebc5856547c5afbab06ee5829 *inst/doc/SeriesB.pdf +37b075279a317ca8e369ac4a124ab537 *inst/doc/eNileMin.R +4ae2abe50356814d07509085b41dc0b7 *inst/doc/eSeriesB.R +b3a276dbbbe606cc55a9fb94e6ebc9ad *inst/doc/index.html 6b7a472a22fbdbff4b2b08ddb4f43735 *inst/doc/index_files/colorschememapping.xml -d86f71dcbb40f094b962a26e835b5cd0 *inst/doc/index_files/filelist.xml -d2ea643e2693aa428cee4699f122a5ae *inst/doc/index_files/preview.wmf -1d712df30aaae149416bfc0da166f00a *inst/doc/index_files/themedata.thmx +4ae76a0f61497ff725933ec6ab36375c *inst/doc/index_files/filelist.xml +bd0afa44338931df7c6a6590f8dfb7c4 *inst/doc/index_files/themedata.thmx f50369fac85b2e3d22f4f4b3634cec97 *inst/doc/v23i05.pdf edf2ad5de4ea660c8d1b29ddecea419b *inst/doc/v23i05_table12.R 03dfc3b96ca165312ece4f08ae9cdd9c *inst/doc/v23i05_table14.R @@ -57,7 +60,7 @@ edf2ad5de4ea660c8d1b29ddecea419b *inst/doc/v23i05_table12.R 13b2384fdf9804d4dca40935bc63fa5c *inst/doc/v23i05_table15b.R 1c5073d9dd8bd443197ede3c5992054e *man/Boot.FitFGN.Rd a7e4c5cc4ef2b7bc69dceaa1f58fd093 *man/Boot.Rd -8d226cbb339a039d525362599aa79211 *man/FGN-package.Rd +69e88a25ed0bda5d7eee9eb01830cbdb *man/FGN-package.Rd c8243c44bd59fe7fba70f5ee744b44a2 *man/FitFGN.Rd 65911d58148bbd61c8fa880550cae4e7 *man/FitRegressionFGN.Rd 7af77ce4d328fbec6bcd37f5050b56b4 *man/GetFitFD.Rd @@ -81,6 +84,7 @@ e3278c2d3c708788dbebf3797fec010a *man/WLoglikelihood.Rd 4d8cb860dcaaf47d73f6a8251a10f927 *man/acvfPLA.Rd effb341cc53dfc1ad6ebf1ad16d064c3 *man/acvfPLS.Rd d723458958bc58fd548f5bd7d5d39dba *man/coef.FitFGN.Rd +b3f455081e6de863c7c4156c254cb5d4 *man/earfima.Rd acb682b37599f8d86db9d32cfeb6433c *man/globtp.Rd 415fcf55b6461f49ebcbf674d37434b2 *man/plot.FitFGN.Rd e687cc9c8e11a577839eebb76c49efd0 *man/predict.FitFGN.Rd @@ -93,6 +97,6 @@ ccc078af00486b96516cb780b272fe97 *man/sdfPLA.Rd a191b29ed46da52184fe8834c468b148 *man/sdfarma.Rd de3398fa8395c7024850c4975d5cf6cd *man/sdfhd.Rd 880cbcefc7461be5ccedbeb931ad1b29 *man/summary.FitFGN.Rd -3d9188d755aac2e0190cc9a995c9733e *man/warfima.Rd +b1c51f3faa74346daf29cfe89f7d7cee *man/warfima.Rd d9cf118d94dfc5a2d09eeb47b1b7320b *src/Makevars 0e0aca6610678156d51c2c44163b498c *src/tacf.c diff --git a/NAMESPACE b/NAMESPACE old mode 100755 new mode 100644 index c0524f0..f3e6ae0 --- a/NAMESPACE +++ b/NAMESPACE @@ -7,7 +7,8 @@ export( "sdfFGN", "sdfFD", "sdfPLA", "sdfPLS", "LLFGN", "LLFD", "LLPLA", "LLPLS", "GetFitFGN", "GetFitPLA", "GetFitFD", "GetFitPLS", -"sdfarma", "sdfhd", "warfima", "WLoglikelihood", +"sdfarma", "sdfhd", "warfima", "WLoglikelihood", +"earfima", "FitFGN", "Reimann", "Boot.FitFGN", diff --git a/NEWS b/NEWS old mode 100755 new mode 100644 diff --git a/R/ARToPacf.R b/R/ARToPacf.R old mode 100755 new mode 100644 diff --git a/R/Boot.FitFGN.R b/R/Boot.FitFGN.R old mode 100755 new mode 100644 diff --git a/R/Boot.R b/R/Boot.R old mode 100755 new mode 100644 diff --git a/R/FitFGN.R b/R/FitFGN.R old mode 100755 new mode 100644 diff --git a/R/FitRegressionFGN.R b/R/FitRegressionFGN.R old mode 100755 new mode 100644 diff --git a/R/GetFitFD.R b/R/GetFitFD.R old mode 100755 new mode 100644 diff --git a/R/GetFitFGN.R b/R/GetFitFGN.R old mode 100755 new mode 100644 diff --git a/R/GetFitPLA.R b/R/GetFitPLA.R old mode 100755 new mode 100644 diff --git a/R/GetFitPLS.R b/R/GetFitPLS.R old mode 100755 new mode 100644 diff --git a/R/HurstK.R b/R/HurstK.R old mode 100755 new mode 100644 diff --git a/R/InvertibleQ.R b/R/InvertibleQ.R old mode 100755 new mode 100644 diff --git a/R/LLFD.R b/R/LLFD.R old mode 100755 new mode 100644 diff --git a/R/LLFGN.R b/R/LLFGN.R old mode 100755 new mode 100644 diff --git a/R/LLPLA.R b/R/LLPLA.R old mode 100755 new mode 100644 diff --git a/R/LLPLS.R b/R/LLPLS.R old mode 100755 new mode 100644 diff --git a/R/PacfToAR.R b/R/PacfToAR.R old mode 100755 new mode 100644 diff --git a/R/Reimann.R b/R/Reimann.R old mode 100755 new mode 100644 diff --git a/R/SimulateFD.R b/R/SimulateFD.R old mode 100755 new mode 100644 diff --git a/R/SimulateFGN.R b/R/SimulateFGN.R old mode 100755 new mode 100644 diff --git a/R/WLoglikelihood.R b/R/WLoglikelihood.R old mode 100755 new mode 100644 diff --git a/R/acvfFD.R b/R/acvfFD.R old mode 100755 new mode 100644 diff --git a/R/acvfFGN.R b/R/acvfFGN.R old mode 100755 new mode 100644 diff --git a/R/acvfPLA.R b/R/acvfPLA.R old mode 100755 new mode 100644 diff --git a/R/acvfPLSA.R b/R/acvfPLSA.R old mode 100755 new mode 100644 diff --git a/R/coef.FitFGN.R b/R/coef.FitFGN.R old mode 100755 new mode 100644 diff --git a/R/earfima.R b/R/earfima.R old mode 100755 new mode 100644 index f299bf4..0ef2679 --- a/R/earfima.R +++ b/R/earfima.R @@ -4,7 +4,8 @@ earfima <- function(z, order=c(0,0,0), lmodel=c("FD", "FGN", "PLA", "NONE")) { d <- order[2] q <- order[3] stopifnot(p >= 0, q >= 0, d >= 0) - is.wholenumber <- function(x, tol = .Machine$double.eps^0.5) abs(x - round(x)) < tol + is.wholenumber <- function(x, tol = .Machine$double.eps^0.5) + abs(x - round(x)) < tol stopifnot(is.wholenumber(p), is.wholenumber(d), is.wholenumber(q)) w <- if(d>0) diff(z, differences=d) else z w <- w-mean(w) @@ -25,15 +26,22 @@ earfima <- function(z, order=c(0,0,0), lmodel=c("FD", "FGN", "PLA", "NONE")) { FGN=tacvfARFIMA(phi = phi, theta = theta, H = 1-alpha/2, maxlag = n-1), PLA=tacvfARFIMA(phi = phi, theta = theta, alpha = alpha, maxlag = n-1), NONE=tacvfARFIMA(phi = phi, theta = theta, maxlag = n-1) ) - LL <- -DLLoglikelihood(r, w) +#needed in some cases, eg. NileMin with p=1, q=3, lmodel="FGN" + LL <- try(-DLLoglikelihood(r, w), silent=TRUE) + LL <- ifelse(is.numeric(LL), LL, -penaltyLoglikelihood) } LL - } - if (p+q>0 || lmodel!="NONE") { - ans<-optim(par=binit, fn=Entropy, p=p, q=q, method="L-BFGS-B", lower=c(0.01,rep(-0.99,p+q)), upper=c(1.99,rep(0.99,p+q)), control=list(trace=0)) + } + if (p+q>0 || lmodel!="NONE") { + ans<-optim(par=binit, fn=Entropy, p=p, q=q, method="L-BFGS-B", + lower=c(0.01,rep(-0.99,p+q)), upper=c(1.99,rep(0.99,p+q)), control=list(trace=0)) if(ans$convergence != 0) {#convergence problem. Use Nelder-Mead with penalty function alg<-2 - ans<-optim(par=binit, fn=Entropy, method="Nelder-Mead") + ans<-optim(par=binit, fn=Entropy, p=p, q=q, method="Nelder-Mead") + if(ans$convergence != 0) {#convergence problem. Use SANN with penalty function + alg<-3 + ans<-optim(par=binit, fn=Entropy, p=p, q=q, method="SANN") + } } bHat <- ans$par LL <- -ans$value @@ -42,11 +50,11 @@ earfima <- function(z, order=c(0,0,0), lmodel=c("FD", "FGN", "PLA", "NONE")) { bHat <- numeric(0) LL <- -Entropy(1, 0, 0) convergence <- 0 - } + } alphaHat <- bHat[1] HHat <- 1-alphaHat/2 dHat <- HHat - 0.5 phiHat <- thetaHat <- numeric(0) - ans<-list(bHat=bHat, alphaHat=alphaHat, HHat = HHat, dHat=dHat, phiHat=phiHat, thetaHat=thetaHat, LL=LL, convergence=convergence) - unlist(ans) + list(bHat=bHat, alphaHat=alphaHat, HHat = HHat, dHat=dHat, phiHat=phiHat, thetaHat=thetaHat, + LL=LL, convergence=convergence, algorithm=alg) } diff --git a/R/plot.FitFGN.R b/R/plot.FitFGN.R old mode 100755 new mode 100644 diff --git a/R/predict.FitFGN.R b/R/predict.FitFGN.R old mode 100755 new mode 100644 diff --git a/R/print.FitFGN.R b/R/print.FitFGN.R old mode 100755 new mode 100644 diff --git a/R/residuals.FitFGN.R b/R/residuals.FitFGN.R old mode 100755 new mode 100644 diff --git a/R/sdfFD.R b/R/sdfFD.R old mode 100755 new mode 100644 diff --git a/R/sdfFGN.R b/R/sdfFGN.R old mode 100755 new mode 100644 diff --git a/R/sdfPLA.R b/R/sdfPLA.R old mode 100755 new mode 100644 diff --git a/R/sdfPLS.R b/R/sdfPLS.R old mode 100755 new mode 100644 diff --git a/R/sdfarma.R b/R/sdfarma.R old mode 100755 new mode 100644 index 6f99a09..92c01f9 --- a/R/sdfarma.R +++ b/R/sdfarma.R @@ -1,8 +1,8 @@ sdfarma <- function(n, phi=numeric(0), theta=numeric(0)) { lams <- 2*pi*seq(from=1/n, to=1/2, by=1/n) nf <- length(lams) - a <- outer(lams, 1:length(theta)) if (length(theta)>0) { + a <- outer(lams, 1:length(theta)) C <- cbind(1, cos(a))%*% c(1, -theta) S <- sin(a) %*% theta } else { @@ -11,8 +11,9 @@ sdfarma <- function(n, phi=numeric(0), theta=numeric(0)) { } num <- as.vector(C*C + S*S)/(2*pi) if (length(phi)>0) { + a <- outer(lams, 1:length(phi)) C <- cbind(1, cos(a))%*% c(1, -phi) - S <- sin(a) %*% theta + S <- sin(a) %*% phi } else { C <- 1 S <- 0 diff --git a/R/sdfhd.R b/R/sdfhd.R old mode 100755 new mode 100644 diff --git a/R/summary.FitFGN.R b/R/summary.FitFGN.R old mode 100755 new mode 100644 diff --git a/R/tacf.R b/R/tacf.R old mode 100755 new mode 100644 diff --git a/R/warfima.R b/R/warfima.R old mode 100755 new mode 100644 index e4eb74f..fa691be --- a/R/warfima.R +++ b/R/warfima.R @@ -31,29 +31,26 @@ warfima <- function(z, order=c(0,0,0), lmodel=c("FD", "FGN", "PLA", "PLS", "NONE ans<-optim(par=binit, fn=Entropy, p=p, q=q, method="L-BFGS-B", lower=c(0.01,rep(-0.99,p+q)), upper=c(1.99,rep(0.99,p+q)), control=list(trace=0)) if(ans$convergence != 0) {#convergence problem. Use Nelder-Mead with penalty function alg<-2 - ans<-optim(par=binit, fn=Entropy, method="Nelder-Mead") - } + ans<-optim(par=binit, fn=Entropy, p=p, q=q, method="Nelder-Mead") + if(ans$convergence != 0) {#convergence problem. Use SANN with penalty function + alg<-3 + ans<-optim(par=binit, fn=Entropy, p=p, q=q, method="SANN") + } + } bHat <- ans$par wLL <- -ans$value convergence <- ans$convergence - } else { + } else { #pure white noise bHat <- numeric(0) wLL <- -Entropy(1, 0, 0) convergence <- 0 - } + } alphaHat <- bHat[1] HHat <- 1-alphaHat/2 dHat <- HHat - 0.5 phiHat <- thetaHat <- numeric(0) if (p>0) phiHat <- PacfToAR(bHat[2:(p+1)]) if (q>0) thetaHat <- PacfToAR(bHat[(2+p):(1+p+q)]) - if (identical(lmodel,"PLS")) LL <- NA else { - r <- switch(lmodel, - FD=tacvfARFIMA(phi = phiHat, theta = thetaHat, dfrac = dHat, maxlag = n-1), - FGN=tacvfARFIMA(phi = phiHat, theta = thetaHat, H = HHat, maxlag = n-1), - PLA=tacvfARFIMA(phi = phiHat, theta = thetaHat, alpha = alphaHat, maxlag = n-1), - NONE=tacvfARFIMA(phi = phiHat, theta = thetaHat, maxlag = n-1) ) - LL <- DLLoglikelihood(r, w) - } - list(bHat=bHat, alphaHat=alphaHat, HHat = HHat, dHat=dHat, phiHat=phiHat, thetaHat=thetaHat, wLL=wLL, LL=LL, convergence=convergence) + list(bHat=bHat, alphaHat=alphaHat, HHat = HHat, dHat=dHat, phiHat=phiHat, thetaHat=thetaHat, + LL=wLL, convergence=convergence, algorithm=alg) } diff --git a/data/NileFlowCMS.rda b/data/NileFlowCMS.rda old mode 100755 new mode 100644 diff --git a/data/NileMin.rda b/data/NileMin.rda old mode 100755 new mode 100644 diff --git a/data/SeriesB.rda b/data/SeriesB.rda old mode 100755 new mode 100644 diff --git a/data/globtp.rda b/data/globtp.rda old mode 100755 new mode 100644 diff --git a/inst/CITATION b/inst/CITATION old mode 100755 new mode 100644 diff --git a/inst/doc/NileMin.pdf b/inst/doc/NileMin.pdf new file mode 100644 index 0000000..f237314 Binary files /dev/null and b/inst/doc/NileMin.pdf differ diff --git a/inst/doc/SeriesB.pdf b/inst/doc/SeriesB.pdf new file mode 100644 index 0000000..ce2da1e Binary files /dev/null and b/inst/doc/SeriesB.pdf differ diff --git a/inst/doc/eNileMin.R b/inst/doc/eNileMin.R new file mode 100644 index 0000000..e0ad9e5 --- /dev/null +++ b/inst/doc/eNileMin.R @@ -0,0 +1,157 @@ +#eNileMin.R +#NileMin dataset +#Exact MLE. Best Model. +#> TotalTimes +# FD FGN PLA NONE +#14.82 40.44 38.93 30.85 +#> sum(TotalTimes) +#[1] 125.04 +# +require("FGN") +z <- NileMin +#z <- abs(diff(log(SeriesB))) +z <- z - mean(z) +n <- length(z) +P <- Q <- 3 + +TotalTimes <- numeric(4) +names(TotalTimes) <- c("FD", "FGN", "PLA", "NONE") +#FD +numMod <- (P+1)*(Q+1) +outMod <- vector("list", numMod) +ii <- 0 +#takes about 42 seconds on unit +startTime <- proc.time() +for (p in 0:P) + for (q in 0:Q) { + ii <- ii+1 + k <- p+q+2 + order <- c(p,0,q) + ans <- earfima(z, order=order, lmodel="FD") + Le <- ans$LL + bice <- -2*Le+k*log(n) + out <- c(p,q,Le,bice) + names(out) <- c("p","q","Le","bice") + outMod[[ii]] <- out + } +endTime <- proc.time() +totalTime <- endTime-startTime +TotalTimes[1] <- totalTime[1] +m<-matrix(unlist(outMod),byrow=TRUE,ncol=4) +dimnames(m)[[2]]<- c("p","q","Le","bice") +ind1 <- which.min(m[,"bice"]) +mc<-rep(" ", 16) +mc[ind1]<-"*" +dimnames(m)[[1]]<-mc +mFD<-m +# + +#FGN +numMod <- (P+1)*(Q+1) +outMod <- vector("list", numMod) +ii <- 0 +#takes about 42 seconds on unit +startTime <- proc.time() +for (p in 0:P) + for (q in 0:Q) { + ii <- ii+1 + k <- p+q+2 + order <- c(p,0,q) + ans <- earfima(z, order=order, lmodel="FGN") + Le <- ans$LL + bice <- -2*Le+k*log(n) + out <- c(p,q,Le,bice) + names(out) <- c("p","q","Le","bice") + outMod[[ii]] <- out + } +endTime <- proc.time() +totalTime <- endTime-startTime +TotalTimes[2] <- totalTime[1] +m<-matrix(unlist(outMod),byrow=TRUE,ncol=4) +dimnames(m)[[2]]<- c("p","q","Le","bice") +ind1 <- which.min(m[,"bice"]) +mc<-rep(" ", 16) +mc[ind1]<-"*" +dimnames(m)[[1]]<-mc +mFGN<-m +# +#PLA +numMod <- (P+1)*(Q+1) +outMod <- vector("list", numMod) +ii <- 0 +#takes about 42 seconds on unit +startTime <- proc.time() +for (p in 0:P) + for (q in 0:Q) { + ii <- ii+1 + k <- p+q+2 + order <- c(p,0,q) + ans <- earfima(z, order=order, lmodel="PLA") + Le <- ans$LL + bice <- -2*Le+k*log(n) + out <- c(p,q,Le,bice) + names(out) <- c("p","q","Le","bice") + outMod[[ii]] <- out + } +endTime <- proc.time() +totalTime <- endTime-startTime +TotalTimes[3] <- totalTime[1] +m<-matrix(unlist(outMod),byrow=TRUE,ncol=4) +dimnames(m)[[2]]<- c("p","q","Le","bice") +ind1 <- which.min(m[,"bice"]) +mc<-rep(" ", 16) +mc[ind1]<-"*" +dimnames(m)[[1]]<-mc +mPLA<-m +# +# +#NONE +numMod <- (P+1)*(Q+1) +outMod <- vector("list", numMod) +ii <- 0 +#takes about 42 seconds on unit +startTime <- proc.time() +for (p in 0:P) + for (q in 0:Q) { + ii <- ii+1 + k <- p+q+2 + order <- c(p,0,q) + ans <- earfima(z, order=order, lmodel="NONE") + Le <- ans$LL + bice <- -2*Le+k*log(n) + out <- c(p,q,Le,bice) + names(out) <- c("p","q","Le","bice") + outMod[[ii]] <- out + } +endTime <- proc.time() +totalTime <- endTime-startTime +TotalTimes[4] <- totalTime[1] +m<-matrix(unlist(outMod),byrow=TRUE,ncol=4) +dimnames(m)[[2]]<- c("p","q","Le","bice") +ind1 <- which.min(m[,"bice"]) +mc<-rep(" ", 16) +mc[ind1]<-"*" +dimnames(m)[[1]]<-mc +mNONE<-m +# +LLs <- c(mFD["*",3],mFGN["*",3],mPLA["*",3],mNONE["*",3]) +LLmax <- max(LLs) +RLs <- exp(LLs-LLmax) +names(RLs) <- c("FD","FGN","PLA","NONE") +# +bics <- c(mFD["*",4],mFGN["*",4],mPLA["*",4],mNONE["*",4]) +bicmin <- min(bics) +RELs <- exp(-0.5*(bics-bicmin)) +names(RELs) <- c("FD","FGN","PLA","NONE") +tb <- matrix(c(RLs,RELs)*100, byrow=TRUE, nrow=2) +dimnames(tb) <- list(c("RL","REL"), names(RELs)) +tb +tbNileMin <- tb +dump("tbNileMin", file="d:/R/CRAN/FGN/vig/tbNileMin.R") +# +TotalTimes +# +mFD +mFGN +mPLA +mNONE diff --git a/inst/doc/eSeriesB.R b/inst/doc/eSeriesB.R new file mode 100644 index 0000000..71a6150 --- /dev/null +++ b/inst/doc/eSeriesB.R @@ -0,0 +1,153 @@ +#eSeriesB.R +#SeriesB dataset +#Exact MLE. Best Model. +#> TotalTimes +# FD FGN PLA NONE +# 5.19 17.64 5.71 1.68 +#> sum(TotalTimes) +#[1] 30.22 +# +require("FGN") +#z <- NileMin +z <- abs(diff(log(SeriesB))) +z <- z - mean(z) +n <- length(z) +P <- Q <- 3 + +TotalTimes <- numeric(4) +names(TotalTimes) <- c("FD", "FGN", "PLA", "NONE") +#FD +numMod <- (P+1)*(Q+1) +outMod <- vector("list", numMod) +ii <- 0 +startTime <- proc.time() +for (p in 0:P) + for (q in 0:Q) { + ii <- ii+1 + k <- p+q+2 + order <- c(p,0,q) + ans <- earfima(z, order=order, lmodel="FD") + Le <- ans$LL + bice <- -2*Le+k*log(n) + out <- c(p,q,Le,bice) + names(out) <- c("p","q","Le","bice") + outMod[[ii]] <- out + } +endTime <- proc.time() +totalTime <- endTime-startTime +TotalTimes[1] <- totalTime[1] +m<-matrix(unlist(outMod),byrow=TRUE,ncol=4) +dimnames(m)[[2]]<- c("p","q","Le","bice") +ind1 <- which.min(m[,"bice"]) +mc<-rep(" ", 16) +mc[ind1]<-"*" +dimnames(m)[[1]]<-mc +mFD<-m +# + +#FGN +numMod <- (P+1)*(Q+1) +outMod <- vector("list", numMod) +ii <- 0 +startTime <- proc.time() +for (p in 0:P) + for (q in 0:Q) { + ii <- ii+1 + k <- p+q+2 + order <- c(p,0,q) + ans <- earfima(z, order=order, lmodel="FGN") + Le <- ans$LL + bice <- -2*Le+k*log(n) + out <- c(p,q,Le,bice) + names(out) <- c("p","q","Le","bice") + outMod[[ii]] <- out + } +endTime <- proc.time() +totalTime <- endTime-startTime +TotalTimes[2] <- totalTime[1] +m<-matrix(unlist(outMod),byrow=TRUE,ncol=4) +dimnames(m)[[2]]<- c("p","q","Le","bice") +ind1 <- which.min(m[,"bice"]) +mc<-rep(" ", 16) +mc[ind1]<-"*" +dimnames(m)[[1]]<-mc +mFGN<-m +# +#PLA +numMod <- (P+1)*(Q+1) +outMod <- vector("list", numMod) +ii <- 0 +startTime <- proc.time() +for (p in 0:P) + for (q in 0:Q) { + ii <- ii+1 + k <- p+q+2 + order <- c(p,0,q) + ans <- earfima(z, order=order, lmodel="PLA") + Le <- ans$LL + bice <- -2*Le+k*log(n) + out <- c(p,q,Le,bice) + names(out) <- c("p","q","Le","bice") + outMod[[ii]] <- out + } +endTime <- proc.time() +totalTime <- endTime-startTime +TotalTimes[3] <- totalTime[1] +m<-matrix(unlist(outMod),byrow=TRUE,ncol=4) +dimnames(m)[[2]]<- c("p","q","Le","bice") +ind1 <- which.min(m[,"bice"]) +mc<-rep(" ", 16) +mc[ind1]<-"*" +dimnames(m)[[1]]<-mc +mPLA<-m +# +# +#NONE +numMod <- (P+1)*(Q+1) +outMod <- vector("list", numMod) +ii <- 0 +startTime <- proc.time() +for (p in 0:P) + for (q in 0:Q) { + ii <- ii+1 + k <- p+q+2 + order <- c(p,0,q) + ans <- earfima(z, order=order, lmodel="NONE") + Le <- ans$LL + bice <- -2*Le+k*log(n) + out <- c(p,q,Le,bice) + names(out) <- c("p","q","Le","bice") + outMod[[ii]] <- out + } +endTime <- proc.time() +totalTime <- endTime-startTime +TotalTimes[4] <- totalTime[1] +m<-matrix(unlist(outMod),byrow=TRUE,ncol=4) +dimnames(m)[[2]]<- c("p","q","Le","bice") +ind1 <- which.min(m[,"bice"]) +mc<-rep(" ", 16) +mc[ind1]<-"*" +dimnames(m)[[1]]<-mc +mNONE<-m +# +LLs <- c(mFD["*",3],mFGN["*",3],mPLA["*",3],mNONE["*",3]) +LLmax <- max(LLs) +RLs <- exp(LLs-LLmax) +names(RLs) <- c("FD","FGN","PLA","NONE") +# +bics <- c(mFD["*",4],mFGN["*",4],mPLA["*",4],mNONE["*",4]) +bicmin <- min(bics) +RELs <- exp(-0.5*(bics-bicmin)) +names(RELs) <- c("FD","FGN","PLA","NONE") +tb <- matrix(c(RLs,RELs)*100, byrow=TRUE, nrow=2) +dimnames(tb) <- list(c("RL","REL"), names(RELs)) +tb +tbSeriesB <- tb +dump("tbSeriesB", file="d:/R/CRAN/FGN/vig/tbSeriesB.R") +# +TotalTimes +# +mFD +mFGN +mPLA +mNONE diff --git a/inst/doc/index.html b/inst/doc/index.html old mode 100755 new mode 100644 index b6c7c7c..739f2a2 --- a/inst/doc/index.html +++ b/inst/doc/index.html @@ -7,32 +7,32 @@ - - + + - 'ltsa' and 'FGN' additional documentation - +
-

Additional Documentation for the -Packages ‘ltsa’ and ‘FGN’

+

Additional +Documentation for the Packages ‘ltsa’ and ‘FGN’

-

v23i05.pdf           Reprint of  Algorithms for Linear Time Series -Analysis: With R Package",  Journal -of Statistical Software 23(5).  v23i05.pdf           Reprint +of  Algorithms +for Linear Time Series Analysis: With R Package",  Journal +of Statistical Software 23(5).  http://www.jstatsoft.org/v23/i05/.  McLeod, Yu and Krougly (2007).

+class=SpellE>Krougly (2007).

+ +

v23i05_table12.R, v23i05_table14.R, +v23i05_table15a.R, v23i05_table15b.R         script files for tables

+ +

Computational +details for fitting models to NileMin and SeriesB datasets: NileMin.pdf  SeriesB.pdf

-

v23i05_table12.R, v23i05_table14.R, v23i05_table15a.R, -v23i05_table15b.R           script files for tables

+

R scripts +for fitting models to NileMin and SeriesB +datasets: eNileMin.R  +eSeriesB.R 

-

 

+

 

diff --git a/inst/doc/index_files/colorschememapping.xml b/inst/doc/index_files/colorschememapping.xml old mode 100755 new mode 100644 diff --git a/inst/doc/index_files/filelist.xml b/inst/doc/index_files/filelist.xml old mode 100755 new mode 100644 index bc96a8f..a014245 --- a/inst/doc/index_files/filelist.xml +++ b/inst/doc/index_files/filelist.xml @@ -1,6 +1,5 @@ - diff --git a/inst/doc/index_files/preview.wmf b/inst/doc/index_files/preview.wmf deleted file mode 100755 index d32277f..0000000 Binary files a/inst/doc/index_files/preview.wmf and /dev/null differ diff --git a/inst/doc/index_files/themedata.thmx b/inst/doc/index_files/themedata.thmx old mode 100755 new mode 100644 index 55426d8..65c8e98 Binary files a/inst/doc/index_files/themedata.thmx and b/inst/doc/index_files/themedata.thmx differ diff --git a/inst/doc/v23i05_table12.R b/inst/doc/v23i05_table12.R old mode 100755 new mode 100644 diff --git a/inst/doc/v23i05_table14.R b/inst/doc/v23i05_table14.R old mode 100755 new mode 100644 diff --git a/inst/doc/v23i05_table15a.R b/inst/doc/v23i05_table15a.R old mode 100755 new mode 100644 diff --git a/inst/doc/v23i05_table15b.R b/inst/doc/v23i05_table15b.R old mode 100755 new mode 100644 diff --git a/man/Boot.FitFGN.Rd b/man/Boot.FitFGN.Rd old mode 100755 new mode 100644 diff --git a/man/Boot.Rd b/man/Boot.Rd old mode 100755 new mode 100644 diff --git a/man/FGN-package.Rd b/man/FGN-package.Rd old mode 100755 new mode 100644 index 240722d..7c9723a --- a/man/FGN-package.Rd +++ b/man/FGN-package.Rd @@ -15,8 +15,8 @@ Simulation and regression supported for FGN. \tabular{ll}{ Package: \tab FGN\cr Type: \tab Package\cr - Version: \tab 2.0-5\cr - Date: \tab 2013-04-02\cr + Version: \tab 2.0-11\cr + Date: \tab 2013-04-11\cr License: \tab CC BY-NC-SA 3.0\cr LazyLoad: \tab yes\cr LazyData: \tab yes\cr diff --git a/man/FitFGN.Rd b/man/FitFGN.Rd old mode 100755 new mode 100644 diff --git a/man/FitRegressionFGN.Rd b/man/FitRegressionFGN.Rd old mode 100755 new mode 100644 diff --git a/man/GetFitFD.Rd b/man/GetFitFD.Rd old mode 100755 new mode 100644 diff --git a/man/GetFitFGN.Rd b/man/GetFitFGN.Rd old mode 100755 new mode 100644 diff --git a/man/GetFitPLA.Rd b/man/GetFitPLA.Rd old mode 100755 new mode 100644 diff --git a/man/GetFitPLS.Rd b/man/GetFitPLS.Rd old mode 100755 new mode 100644 diff --git a/man/HurstK.Rd b/man/HurstK.Rd old mode 100755 new mode 100644 diff --git a/man/LLFD.Rd b/man/LLFD.Rd old mode 100755 new mode 100644 diff --git a/man/LLFGN.Rd b/man/LLFGN.Rd old mode 100755 new mode 100644 diff --git a/man/LLPLA.Rd b/man/LLPLA.Rd old mode 100755 new mode 100644 diff --git a/man/LLPLS.Rd b/man/LLPLS.Rd old mode 100755 new mode 100644 diff --git a/man/NileFlowCMS.Rd b/man/NileFlowCMS.Rd old mode 100755 new mode 100644 diff --git a/man/NileMin.Rd b/man/NileMin.Rd old mode 100755 new mode 100644 diff --git a/man/Reimann.Rd b/man/Reimann.Rd old mode 100755 new mode 100644 diff --git a/man/SeriesB.Rd b/man/SeriesB.Rd old mode 100755 new mode 100644 diff --git a/man/SimulateFD.Rd b/man/SimulateFD.Rd old mode 100755 new mode 100644 diff --git a/man/SimulateFGN.Rd b/man/SimulateFGN.Rd old mode 100755 new mode 100644 diff --git a/man/WLoglikelihood.Rd b/man/WLoglikelihood.Rd old mode 100755 new mode 100644 diff --git a/man/acvfFD.Rd b/man/acvfFD.Rd old mode 100755 new mode 100644 diff --git a/man/acvfFGN.Rd b/man/acvfFGN.Rd old mode 100755 new mode 100644 diff --git a/man/acvfPLA.Rd b/man/acvfPLA.Rd old mode 100755 new mode 100644 diff --git a/man/acvfPLS.Rd b/man/acvfPLS.Rd old mode 100755 new mode 100644 diff --git a/man/coef.FitFGN.Rd b/man/coef.FitFGN.Rd old mode 100755 new mode 100644 diff --git a/man/earfima.Rd b/man/earfima.Rd new file mode 100644 index 0000000..1e5d2ca --- /dev/null +++ b/man/earfima.Rd @@ -0,0 +1,44 @@ +\name{earfima} +\alias{earfima} +\title{Exact MLE for ARFIMA} + +\description{ +The time series is corrected for the sample mean and then exact MLE is +used for the other parameters. +} + +\usage{ +earfima(z, order = c(0, 0, 0), lmodel = c("FD", "FGN", "PLA", "NONE")) +} + +\arguments{ + \item{z}{time series} + \item{order}{(p,d,q) where p=order AR, d=regular difference, q=order MA} + \item{lmodel}{type of long-memory component: FD, FGN, PLA or NONE} +} + +\details{The sample mean is asymptotically efficient.} + +\value{ +list with components: + \item{bHat}{transformed optimal parameters} + \item{alphaHat}{estimate of alpha} + \item{HHat}{estimate of H} + \item{dHat}{estimate of d} + \item{phiHat}{estimate of phi} + \item{thetaHat}{estimate of theta} + \item{wLL}{optimized value of Whittle approximate log-likelihood} + \item{LL}{corresponding exact log-likelihood} + \item{convergence}{convergence indicator} + \item{algorithm}{optimization algorithm used, 1 for L-BFGS-B, 2 for Nelder-Mead, 3 for SANN } +} + +\author{Justin Veenstra and A. I. McLeod} + + +\examples{ +z <- rnorm(100) +earfima(z, lmodel="FGN") +} + +\keyword{ ts} diff --git a/man/globtp.Rd b/man/globtp.Rd old mode 100755 new mode 100644 diff --git a/man/plot.FitFGN.Rd b/man/plot.FitFGN.Rd old mode 100755 new mode 100644 diff --git a/man/predict.FitFGN.Rd b/man/predict.FitFGN.Rd old mode 100755 new mode 100644 diff --git a/man/print.FitFGN.Rd b/man/print.FitFGN.Rd old mode 100755 new mode 100644 diff --git a/man/residuals.FitFGN.Rd b/man/residuals.FitFGN.Rd old mode 100755 new mode 100644 diff --git a/man/sdfFD.Rd b/man/sdfFD.Rd old mode 100755 new mode 100644 diff --git a/man/sdfFGN.Rd b/man/sdfFGN.Rd old mode 100755 new mode 100644 diff --git a/man/sdfPLA.Rd b/man/sdfPLA.Rd old mode 100755 new mode 100644 diff --git a/man/sdfPLS.Rd b/man/sdfPLS.Rd old mode 100755 new mode 100644 diff --git a/man/sdfarma.Rd b/man/sdfarma.Rd old mode 100755 new mode 100644 diff --git a/man/sdfhd.Rd b/man/sdfhd.Rd old mode 100755 new mode 100644 diff --git a/man/summary.FitFGN.Rd b/man/summary.FitFGN.Rd old mode 100755 new mode 100644 diff --git a/man/warfima.Rd b/man/warfima.Rd old mode 100755 new mode 100644 index 9a2fb5d..82acfa8 --- a/man/warfima.Rd +++ b/man/warfima.Rd @@ -26,9 +26,9 @@ list with components: \item{dHat}{estimate of d} \item{phiHat}{estimate of phi} \item{thetaHat}{estimate of theta} - \item{wLL}{optimized value of Whittle approximate log-likelihood} - \item{LL}{corresponding exact log-likelihood} + \item{LL}{optimized value of Whittle approximate log-likelihood} \item{convergence}{convergence indicator} + \item{algorithm}{optimization algorithm used, 1 for L-BFGS-B, 2 for Nelder-Mead, 3 for SANN } } \author{ diff --git a/src/Makevars b/src/Makevars old mode 100755 new mode 100644 diff --git a/src/tacf.c b/src/tacf.c old mode 100755 new mode 100644