tsboot
Adrian Trapletti
Adrian.Trapletti@wu-wien.ac.at
Thu, 09 Dec 1999 09:18:14 +0000
Fritz,
I have slightly adapted (didn't work before) "tsboot" from the "boot"
library to the current time series conventions of R. The following patch
will do that. I suggest to apply this patch to the file
"boot/R/bootfuns.q" of the "boot" library at CRAN.
best
Adrian
--- bootfuns.orig.q Thu Dec 9 10:07:23 1999
+++ bootfuns.q Thu Dec 9 10:06:51 1999
@@ -3267,8 +3267,8 @@
# post-blackened), model-based resampling and phase scrambling.
#
tscl <- class(tseries)
- if (!is.null(tscl) && (any(tscl == "its")))
- stop("Irregular time series cannot be bootstrapped")
+# if (!is.null(tscl) && (any(tscl == "its")))
+# stop("Irregular time series cannot be bootstrapped")
if (R<=0) stop("R must be positive")
R <- floor(R)
call <- match.call()
@@ -3283,29 +3283,32 @@
ts.orig <- as.matrix(tseries)
else ts.orig <- tseries
n <- nrow(ts.orig)
- class(ts.orig) <- tscl[(tscl!="cts")&(tscl != "rts")]
+# class(ts.orig) <- tscl[(tscl!="cts")&(tscl != "rts")]
+ class(ts.orig) <- tscl # change, A.Trapletti
if ((sim=="model") || (sim=="scramble"))
l <- NULL
else if ((is.null(l) || (l <= 0) || (l > n)))
stop("Invalid value of l")
st <- start(tseries)
freq <- frequency(tseries)
- un <- units(tseries)
- k.un <- attr(tseries, "tspar")$k.units
+# un <- units(tseries)
+# k.un <- attr(tseries, "tspar")$k.units
tsnames <- names(tseries)
if (sim == "geom") endcorr <- T
if (sim == "scramble") {
# Phase scrambling
for (r in 1:R) {
ts.b <- scramble(tseries,norm)
- t <- rbind(t, statistic(ts.b, ...))
+ tmp <- statistic(ts.b, ...) # change,
A.Trapletti
+ t <- rbind(t, tmp) # change, A.Trapletti
}
}
else if (sim == "model") {
# Model-based resampling
for (r in 1:R) {
ts.b <- ran.gen(tseries, n.sim, ran.args)
- t <- rbind(t, statistic(ts.b, ...))
+ tmp <- statistic(ts.b, ...) # change,
A.Trapletti
+ t <- rbind(t, tmp) # change, A.Trapletti
}
}
else if ((sim=="fixed") || (sim=="geom")) {
@@ -3327,18 +3330,22 @@
if (is.null(tscl))
ts.b <- ts(ts.orig[inds,], start=st,
frequency=freq,names=tsnames)
- else if (any(tscl == "cts"))
- ts.b <- cts(ts.orig[inds,], start=st,
- units=un, k.units=k.un,
- frequency=freq,names=tsnames)
- else if (is.null(un))
- ts.b <- rts(ts.orig[inds,], start=st,
+# else if (any(tscl == "cts"))
+# ts.b <- cts(ts.orig[inds,], start=st,
+# units=un, k.units=k.un,
+# frequency=freq,names=tsnames)
+# else if (is.null(un))
+# ts.b <- rts(ts.orig[inds,], start=st,
+# frequency=freq,names=tsnames)
+ else # change, A.Trapletti
+ ts.b <- ts(ts.orig[inds,], start=st,
frequency=freq,names=tsnames)
- else ts.b <- rts(ts.orig[inds,], start=st,
- units=un, frequency=freq,
- names=tsnames)
+# else ts.b <- rts(ts.orig[inds,], start=st,
+# units=un, frequency=freq,
+# names=tsnames)
ts.b <- ran.gen(ts.b, n.sim, ran.args)
- t <- rbind(t, statistic(ts.b, ...))
+ tmp <- statistic(ts.b, ...) # change,
A.Trapletti
+ t <- rbind(t, tmp) # change, A.Trapletti
}
}
else stop("Unrecognized value of sim")
--
Adrian Trapletti, Vienna University of Economics and Business
Administration, Augasse 2-6, A-1090 Vienna, Austria
Phone: ++43 1 31336 4561, Fax: ++43 1 31336 708,
Email: adrian.trapletti@wu-wien.ac.at
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._