I just wanted to report some problem I had with modelData from Quantmod

I wanted to extract the data from the model, so I used the following
function (from package doc)

modelData(x, data.window = NULL, exclude.training = FALSE)

where data.window : a character vector of subset start and end dates to
return .... in Date format !!

my data.window was something like :

"2011-09-12 00:02:00 CEST" "2011-09-15 22:59:00 CEST"

then I got error/warning related to ("Ops.POSIXt", "Ops.Date") for ">="

I went into R code of modelData and I found that the following code
was probably causing the issue :

            start.date.index <-
index(model.data[which(index(model.data) >= as.Date(data.window[1],
origin = "1970-01-01"))])
            end.date.index <- index(model.data[which(index(model.data)
<= as.Date(data.window[2], origin = "1970-01-01"))])
            date.range <- as.Date(intersect(start.date.index,
end.date.index), origin = "1970-01-01")
            model.data <- model.data[date.range]


So I introduced some changes. here is the modified function :

My_modelData <- function (x, data.window = NULL, exclude.training = FALSE)
{
model.data <- x@model.data
if (!is.null(data.window)) {
if (length(data.window) > 2) {
model.data <- model.data[index(model.data) %in% data.window]
}
else {
start.date.index <- index(model.data[which(index(model.data) >=
data.window[1])])
end.date.index <- index(model.data[which(index(model.data) <=
data.window[2])])
date.range <- intersect(start.date.index, end.date.index)
model.data <- model.data[as.POSIXlt(date.range, origin="1970-01-01")]
}
}
if (exclude.training == TRUE) {
model.data <- model.data[!index(model.data) %in% x@training.data]
}
return(model.data)
}

I removed the as.Date in order to accept datetime format for data.window

That solved the issue ...

But still I wonder if this is the right thing to do and generally if
quantmod has restrictions about using datetime is xts timeseries

Thanks in advance for your support


Pierre

	[[alternative HTML version deleted]]

