[R] struccchange on zoo time series

Achim Zeileis Ach|m@Ze||e|@ @end|ng |rom u|bk@@c@@t
Sun May 1 16:56:18 CEST 2022


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_gurbuxani using 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 using 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 using 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.
>



More information about the R-help mailing list