微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

从闰年数据引导/模拟

如何解决从闰年数据引导/模拟

新年快乐!

我有一些数据,x(温度)我想引导/模拟并用于预测。

Length(x) = 35064,or 366*24 + 3*365*24. 

问题是数据包括闰年 - 2016 年的值,我想用它来预测 2020 年(很多人想忘记的年份)。我无法从此数据创建行号 = 8784 的矩阵,因为原始数据中的年份长度为 365.25*24,因此我必须手动包含 2 月 29 日。 到目前为止,这是我的代码

library(tidyverse)
library(tsibble)
library(fable)
library(feasts)
library(lubridate)


# Remove February 29 from data
tmp <- x %>% 
filter(datetime <= "2016-02-28 23:30" | datetime >= "2016-03-01 00:00")
# Bootstrap data
tempsim <- forecast::bld.mbb.bootstrap(tmp$temp1,num = 100,block_size = 24)

# Create matrix and compute the means
tempsim <- sapply(tempsim,unlist)
tempsim <- matrix(tempsim,nrow = 8760)
tempsim <- rowMeans(tempsim)

# Add February 29th
a <- matrix(c(6.631599,6.733649,6.385545,6.087687,6.139491,6.297789,6.841701,7.195739,7.441793,7.758391,7.600092,7.302234,7.910756,8.054760,7.948265,8.000068,7.297858,7.437417,6.191294,6.647451))

# Add this to the simulated temperature:
temp <- append(tempsim,a,after = 1417)

当然,只能使用 2016 年进行引导,但随后剩余年份的所有信息都会丢失。我希望有某种方法可以包含所有四年的数据并创建具有 8784 行的矩阵。任何帮助将不胜感激。

祝大家新年快乐!

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。