【发布时间】:2021-05-17 11:07:42
【问题描述】:
亲爱的
我正在尝试使用 R 将季度数据分解为月度数据。我不关心日期,因为我可以毫无问题地生成与值相对应的月份向量。问题在于值向量和估算缺失数据。请看下面的例子:
Quarter Value
2010-Q1 10
2010-Q2 15
2010-Q3 18
2010-Q4 12
新的数据集应该如下所示
Month Value
2010-3 10
2010-4 11.67
2010-5 13.34
2010-6 15
2010-7 16
2010-8 17
2010-9 18
2010-10 16
2010-11 14
2010-12 12
现在,使用以下公式填充每个季度内的月份
The first month of the quarter[i] = The previous quarter value [i-1] + ((The difference between the quarter [i] and [i-1])/3)
The second month of the quarter[i] = The previous quarter value [i-1] + 2*((The difference between the quarter [i] and [i-1])/3)
例如:
2020 年第一季度 = 10
2020 年第二季度 = 15
差/3 = 5/3
2020 年至 4 月 = 10 + 差异
2020 年 5 月 = 10 + 2*差异
2020-6 月 = 15(季度末保持不变)或可以计算为 10 + 3*diff
我想知道如何生成一个可以分解上述值的新变量。
谢谢
【问题讨论】:
-
声称的副本没有任何答案可以回答上述问题。
标签: r time-series data-manipulation