简体   繁体   English

在R中将xts转换为ts对象时了解频率参数

[英]Understand frequency parameter while converting xts to ts object in R

What is the meaning of frequency below; 下面的频率是什么意思; when I have converted my xts object to ts object and tried printing ts object I got below information. 当我将xts对象转换为ts对象并尝试打印ts对象时,得到以下信息。 My data is hourly data. 我的数据是每小时数据。 But I could not understand how this below frequency is calculated. 但是我不明白这个低于频率的频率是如何计算的。 I want to make sure my ts object is treating my data as hourly data. 我想确保我的ts对象将我的数据视为每小时数据。

Time Series:
Start = 1 
End = 15548401 
Frequency = 0.000277777777777778 (how this is equivalent to hourly frequency?)

So, My dataframe looks like below intitally: 因此,我的数据框看起来像下面这样:

                   y
1484337600  19.22819            
1484341200  19.28906            
1484344800  19.28228            
1484348400  19.21669            
1484352000  19.32759            
1484355600  19.21833            
1484359200  19.20626            
1484362800  19.28737            
1484366400  19.20651            
1484370000  19.18424 

It has epoch times and values. 它具有时代性和价值。 Epoch times are row.names in this dataframe. 纪元时间是此数据框中的row.names。

Now, I converted into xts object using -- 现在,我使用-转换为xts对象

xts_dataframe <- xts(x = dataframe$y,
  order.by = as.POSIXct(as.numeric(row.names(dataframe)), origin="1970-01-01")) 

ts_dataframe <- as.ts(xts_dataframe)

Please suggest what I'm doing wrong? 请指出我做错了什么? Basically I want to convert my initial dataframe to ts() object as I need to apply ARIMA on it. 基本上我想将我的初始数据帧转换为ts()对象,因为我需要对其应用ARIMA。 This data is per hour data. 该数据是每小时数据。 I'm really facing hard time to work with it. 我真的很难与它合作。

The frequency is equivalent to 1/deltat , where deltat is the fraction of the sampling period between successive observations. frequency等于1/deltat ,其中deltat是连续观察之间的采样周期的分数。 ?frequency gives the example that deltat would be "1/12 for monthly data". ?frequency举例说明deltat将为“ 1/12每月数据”。

In the case of hourly data, deltat is 3600, since there are 3600 seconds in an hour. 对于小时数据,由于一小时中有3600秒,因此deltat为3600。 Since frequency = 1 / deltat , that means frequency = 1 / 3600 , or 0.0002777778 . 由于frequency = 1 / deltat ,这意味着frequency = 1 / 3600 0.00027777780.0002777778

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM