- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想在 R 中创建一个 xts
对象,然后将其分解为季节性和趋势。
> require(xts)
> require(lubridate)
> chicos$date <- ymd(chicos$date)
> ctr.ts <- xts(chicos[, 7], order.by = chicos[, 8], frequency = 365)
> plot(ctr.ts, main="Meaningful title")
当我尝试分解它时,我收到此错误消息..
> plot(decompose(ctr.ts))
Error in decompose(ctr.ts) : time series has no or less than 2 periods
我的观察是每天进行的,时间跨度为 2014 年 12 月 1 日至 2015 年 2 月 25 日。我是否设置了错误的频率
?
最佳答案
对于 xts 类型的时间序列的频率:默认情况下,xts 有每日频率,因此如果是每日,则无需包含任何频率:
ctr.xts <- xts(chicos[, 7], order.by = chicos[, 8])
R 函数 decompose() 仅适用于 ts 类型的对象。因此,您可能希望通过发出以下行将 xts 对象转换为 ts:
attr(ctr.xts, 'frequency') <- 7 # Set the frequency of the xts object to weekly
periodicity(ctr.xts) # check periodicity: weekly
plot(decompose(as.ts(ctr.xts))) # Decompose after conversion to ts
此外,您可能想尝试不同的频率:
希望这会有所帮助。
关于r - 在 xts 对象中设置频率,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28744218/
我如何使用 apply 系列函数,比如 apply.daily到多元 XTS? 例如: 时间,a,b ... 2012-02-11 16:21:24 4.7258 7.7258 2012-02-11
我有一个 xts 对象列表,这些对象具有共同的索引和列名。 我想按索引进行 rbind 并对列进行平均: dts = seq.POSIXt(from = Sys.time() - days(2), t
我正在使用 xts 时间序列在 R 中工作。 我有什么: 具有不等间隔时间步长的时间序列数据集。 我想得到什么: 具有等距时间步长的时间序列,其值对应于与时间步长重叠的原始值的比例(请参见下面的示例)
this = structure(c(-0.012, -0.028, -0.044, -0.033, -0.039, -0.042), .Dim = c(3L, 2L), .Dimnames
在 xts 对象中是否有一种方法可以执行与下面相同的操作,但对于具有多天盘中数据的 xts 对象?下面的工作就像一个时钟,但一天的数据。如果我从 22 日到 26 日通过 xts,它不会。似乎不可能一
library(xts) set.seed(1) x = xts( cbind(a=1:10,b=20:11) , Sys.Date()+1:10 ) y = xts( runif(10) , Sys
con = gzcon(url('http://www.systematicportfolio.com/sit.gz', 'rb')) source(con) close(con) load.pack
我有一个 list 。列表由 5 个 xts 对象组成。每个对象由 5 个 xts 系列组成。每个系列包含 183 个观察值。我想从所有这些系列中提取一个公共(public)系列。我要减去的系列名为
在将 rowSums 传递给 xts 对象时,是否可以保留 xts 对象的索引? 目前,我将结果重新转换为 xts 对象,但是如果 rowSums 能够简单地返回它的内容,这似乎并没有那么快已通过。
首先让我说一下,我看了一下 ?xts,意识到这是一个与时区相关的问题,似乎已经解决了,但我不明白为什么 它正在发生。所以:我有一个简单的价格数据数据框。当我将它转换为 xts 对象时,xts 对象的第
当我尝试执行以下工作时发生错误: # generate random integrals # data <- xts(floor(runif(100, 1,101)),as.Date("1973-02
这是输出: library(tseries) # for adf.test function adf.test(data) Augmented Dickey-Fuller Test data: da
如何删除 xts 图右上角的日期范围?例如,在下面 xts 图的右上角,我想删除文本“2007-01-02/2007-06-30”。 library(xts) data(sample_matrix)
我有一个不规则的时间序列并且正在使用 xts的 endpoints 获取我的时间序列的每小时索引。 endpoints(data, on="hours") 我正在使用它以这种方式计算每小时 perio
申请 split函数到 xts对象来自 weeks将行分组为每周块。组中的默认天数是 Monday至 Sunday .想要群里的天数来自Sunday怎么办?至 Saturday ? library(x
我在删除 xts 对象中的重复行时遇到问题。我有一个 R 脚本,它将下载货币的刻度财务数据并将其转换为 OHLC 格式的 xts 对象。该脚本还会每 15 分钟提取一次新数据。新数据从今天的第一笔交易
我真的很难在这里找到解决方案。如果您查看最后一行代码,您会明白我想在下次开盘时买入并在 5 天后卖出 (x = 5)。 问题是 xts 索引正在计算周末。因此,例如,您会在 7 月 12 日星期五获得
我有 3 个 xts 对象,它们的标记都是“日期”对象: > a a 1995-01-03 1.76 1995-01-04 1.69
我正在尝试按天比较不同的时间序列。 目前典型的 XTS 对象如下所示: > vwap.crs QUANTITY QUANTITY.1 2014-03-03 13
我在列表中有一些数据,如下所示: > y $ABMD.Rank ABMD.Rank $ATVI.Rank ATVI.Rank $ADBE.Rank ADBE.Rank $
我是一名优秀的程序员,十分优秀!