On Sun, 1 May 2022, Eric Berger wrote:
Hi Achim,
My point was that tsbox (apparently) provides tools to convert zoo -->
ts which should help the OP.
Not necessarily, because ts can only represent regular and plain numeric
time indexes whereas zoo (and also xts and tsibble) can represent
irregular time indexes of different classes as well. Also, zoo (and also
xts and tsibble) can convert to many other time series classes (including
ts) directly, there is no need to go via tsbox for that.
In this particular case it would be possible, though, to convert back and
forth between ts and zoo because the data is simply monthly. This can be
done with as.ts() and as.zoo(), respectively.
dd.ocus <- efp(dd ~ dd.lag1 + dd.lag12, data = as.ts(na.trim(dd.z)),
type = "OLS-CUSUM")
On Sun, May 1, 2022 at 5:56 PM Achim Zeileis <achim.zeil...@uibk.ac.at> wrote:
On Sun, 1 May 2022, Eric Berger wrote:
Hi Naresh,
The tsbox package on CRAN -
https://cran.r-project.org/web/packages/tsbox/index.html - has the
following description:
tsbox: Class-Agnostic Time Series
Time series toolkit with identical behavior for all time series
classes: 'ts','xts', 'data.frame', 'data.table', 'tibble', 'zoo',
'timeSeries', 'tsibble', 'tis' or 'irts'. Also converts reliably
between these classes.
Hopefully this will provide you the necessary tools to solve your problem.
Not really because the code inside strucchange::efp does not use tsbox but
just ts directly.
Best,
Achim
Good luck,
Eric
On Sun, May 1, 2022 at 3:37 PM Naresh Gurbuxani
<naresh_gurbux...@hotmail.com> wrote:
I am trying to replicate empirical fluctuation process fit (efp) described in the book
"Applied Econometrics with R". This fit works when data input is an object of
class ts, but not when data input is object of class zoo. I prefer to use zoo because it
provides better housekeeping with dates. Is it possible to achieve the fit with zoo?
library(AER)
library(strucchange)
data(UKDriverDeaths)
dd <- log(UKDriverDeaths)
dd.z <- zoo(dd, order.by = as.yearmon(time(dd)))
dd.z <- merge(dd = dd.z, dd.lag1 = lag(dd.z, k = -1),
dd.lag12 = lag(dd.z, k = -12))
# Does not work
dd.ocus <- efp(dd ~ dd.lag1 + dd.lag12, data = na.trim(dd.z),
type = "OLS-CUSUM")
# Error message
# Error in eval(attr(mt, "variables")[[2]], data, env) :
# numeric 'envir' arg not of length one
# Works
dd.ocus <- efp(dd ~ dd.lag1 + dd.lag12, data = ts(na.trim(dd.z)),
type = "OLS-CUSUM")
# But time stamps are lost
plot(dd.ocus)
# Time indexed from 0 to 180
Thanks,
Naresh
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.