r - 从闰年的数据中引导/模拟
问题描述
新年快乐!
我有一些数据,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.385545,6.385545,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.139491,6.191294,6.647451))
# Add this to the simulated temperature:
temp <- append(tempsim, a, after = 1417)
当然,一个人只能使用 2016 年进行引导,但剩余年份的所有信息都会丢失。我希望有某种方法可以包含所有四年的数据并创建包含 8784 行的矩阵。任何帮助将不胜感激。
祝大家新年快乐!
解决方案
推荐阅读
- javascript - 当浏览器窗口处于睡眠模式时,LongPolling 错误“服务器响应状态为 504”
- excel - 为什么我的粘贴结果比它应该的要低 2x-1 行?
- python - 如何在已经存在的 MongoDb 文档中添加字段?
- arrays - 将 BigQuery 数组解析为列的最佳方法是什么
- kubernetes - OpenShift 4.1 | 水平 POD 自动缩放 (HPA) | 所有 PODS 均未使用最新图像进行更新
- c# - 使用 .NET Core SDK 3.5 从 CosmosDB 检索文档时出现 OutOfMemoryException
- ms-access - 将 MS Access 模式导入 Oracle
- submit - perforce 提交原子操作如何实际工作
- mysql - MYSQL 5.7 UPDATE 值与三元(执行真/假切换)
- javascript - Vanilla JS 类别选择器.removeAttribute 问题