Skip to content

Commit

Permalink
version 2.0-11
Browse files Browse the repository at this point in the history
  • Loading branch information
angusian authored and gaborcsardi committed Apr 11, 2013
1 parent 49dc9db commit 8952195
Show file tree
Hide file tree
Showing 103 changed files with 465 additions and 92 deletions.
8 changes: 4 additions & 4 deletions DESCRIPTION 100755 → 100644
@@ -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
Expand All @@ -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
26 changes: 15 additions & 11 deletions MD5
@@ -1,5 +1,5 @@
b9e5ae5bf7de708ca0daea5ba6a045bf *DESCRIPTION
601160f446dc426c0d61bb47613bf908 *NAMESPACE
cb28d1eb38c894db9cbd77f2cdf19066 *DESCRIPTION
e3c595c2cf411596b4abfdce4bfcd789 *NAMESPACE
bbdf261659630d1896b67be196486ea5 *NEWS
b834c996deb14ac0ba270e839cdd415f *R/ARToPacf.R
cfb49e32b1bbe8aaf7d5c8a33cf46d6b *R/Boot.FitFGN.R
Expand All @@ -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
Expand All @@ -35,29 +35,32 @@ 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
71cbbbe670e61502320bbfb39092c65b *inst/doc/v23i05_table15a.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
Expand All @@ -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
Expand All @@ -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
3 changes: 2 additions & 1 deletion NAMESPACE 100755 → 100644
Expand Up @@ -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",
Expand Down
Empty file modified NEWS 100755 → 100644
Empty file.
Empty file modified R/ARToPacf.R 100755 → 100644
Empty file.
Empty file modified R/Boot.FitFGN.R 100755 → 100644
Empty file.
Empty file modified R/Boot.R 100755 → 100644
Empty file.
Empty file modified R/FitFGN.R 100755 → 100644
Empty file.
Empty file modified R/FitRegressionFGN.R 100755 → 100644
Empty file.
Empty file modified R/GetFitFD.R 100755 → 100644
Empty file.
Empty file modified R/GetFitFGN.R 100755 → 100644
Empty file.
Empty file modified R/GetFitPLA.R 100755 → 100644
Empty file.
Empty file modified R/GetFitPLS.R 100755 → 100644
Empty file.
Empty file modified R/HurstK.R 100755 → 100644
Empty file.
Empty file modified R/InvertibleQ.R 100755 → 100644
Empty file.
Empty file modified R/LLFD.R 100755 → 100644
Empty file.
Empty file modified R/LLFGN.R 100755 → 100644
Empty file.
Empty file modified R/LLPLA.R 100755 → 100644
Empty file.
Empty file modified R/LLPLS.R 100755 → 100644
Empty file.
Empty file modified R/PacfToAR.R 100755 → 100644
Empty file.
Empty file modified R/Reimann.R 100755 → 100644
Empty file.
Empty file modified R/SimulateFD.R 100755 → 100644
Empty file.
Empty file modified R/SimulateFGN.R 100755 → 100644
Empty file.
Empty file modified R/WLoglikelihood.R 100755 → 100644
Empty file.
Empty file modified R/acvfFD.R 100755 → 100644
Empty file.
Empty file modified R/acvfFGN.R 100755 → 100644
Empty file.
Empty file modified R/acvfPLA.R 100755 → 100644
Empty file.
Empty file modified R/acvfPLSA.R 100755 → 100644
Empty file.
Empty file modified R/coef.FitFGN.R 100755 → 100644
Empty file.
26 changes: 17 additions & 9 deletions R/earfima.R 100755 → 100644
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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)
}
Empty file modified R/plot.FitFGN.R 100755 → 100644
Empty file.
Empty file modified R/predict.FitFGN.R 100755 → 100644
Empty file.
Empty file modified R/print.FitFGN.R 100755 → 100644
Empty file.
Empty file modified R/residuals.FitFGN.R 100755 → 100644
Empty file.
Empty file modified R/sdfFD.R 100755 → 100644
Empty file.
Empty file modified R/sdfFGN.R 100755 → 100644
Empty file.
Empty file modified R/sdfPLA.R 100755 → 100644
Empty file.
Empty file modified R/sdfPLS.R 100755 → 100644
Empty file.
5 changes: 3 additions & 2 deletions R/sdfarma.R 100755 → 100644
@@ -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 {
Expand All @@ -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
Expand Down
Empty file modified R/sdfhd.R 100755 → 100644
Empty file.
Empty file modified R/summary.FitFGN.R 100755 → 100644
Empty file.
Empty file modified R/tacf.R 100755 → 100644
Empty file.
23 changes: 10 additions & 13 deletions R/warfima.R 100755 → 100644
Expand Up @@ -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)
}
Empty file modified data/NileFlowCMS.rda 100755 → 100644
Empty file.
Empty file modified data/NileMin.rda 100755 → 100644
Empty file.
Empty file modified data/SeriesB.rda 100755 → 100644
Empty file.
Empty file modified data/globtp.rda 100755 → 100644
Empty file.
Empty file modified inst/CITATION 100755 → 100644
Empty file.
Binary file added inst/doc/NileMin.pdf
Binary file not shown.
Binary file added inst/doc/SeriesB.pdf
Binary file not shown.
157 changes: 157 additions & 0 deletions 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

0 comments on commit 8952195

Please sign in to comment.