1
我有一個數據幀,我想將其轉換爲ts並預測從DOC 3或SampleDate 2007-06-23開始的AvgWeight。 AvgWeight每週估計(DOC)。我想預測最後DOC(101)提前3周,所以我基本上想要預測DOC 108,115和122.此列表中的某人是否可以幫助我預測下面的這個小數據集?如何將數據幀轉換爲時間序列
DOC AvgWeight PondName SampleDate
1 3 1.000000 Pond01 2007-06-23
2 10 1.666667 Pond01 2007-06-30
3 17 2.066667 Pond01 2007-07-07
4 24 2.275000 Pond01 2007-07-14
5 31 3.833333 Pond01 2007-07-21
6 38 6.200000 Pond01 2007-07-28
7 45 7.400000 Pond01 2007-08-04
8 52 8.500000 Pond01 2007-08-11
9 59 10.250000 Pond01 2007-08-18
10 66 11.100000 Pond01 2007-08-25
11 73 13.625000 Pond01 2007-09-01
12 80 15.200000 Pond01 2007-09-08
13 87 16.375000 Pond01 2007-09-15
14 94 17.800000 Pond01 2007-09-22
15 101 21.500000 Pond01 2007-09-29
這裏是上面的數據集的dput被複制至R
wt <- structure(list(DOC = c(3, 10, 17, 24, 31, 38, 45, 52, 59, 66,
73, 80, 87, 94, 101), AvgWeight = c(1, 1.66666666666667, 2.06666666666667,
2.275, 3.83333333333333, 6.2, 7.4, 8.5, 10.25, 11.1, 13.625,
15.2, 16.375, 17.8, 21.5), PondName = structure(c(1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = "Pond01", class =
"factor"), SampleDate = structure(c(1182585600, 1183190400,
1183795200, 1184400000, 1185004800, 1185609600, 1186214400, 1186819200,
1187424000, 1188028800, 1188633600, 1189238400, 1189843200,
1190448000, 1191052800), class = c("POSIXct", "POSIXt"))), .Names =
c("DOC", "AvgWeight", "PondName", "SampleDate"), row.names = c(NA, 15L
), class = "data.frame")
wt$SampleDate <- as.Date(wt$SampleDate)
wt
我試圖;
library(forecast)
library(ggplot2)
pond <- ts(wt$AvgWeight,start=3,frequency=52,end=101)
autoplot(pond)
但我的電話是關閉的。我正在閱讀有關ts但尚未掌握的內容。我感謝任何幫助。
那豈不是相當爲2007年第25周開始= c(2007,25)?第三個整數23似乎無論如何都被忽略 –
對文檔有一絲不苟的看法 - 感謝指出@Aurèle! – CMichael
對於我的模型,我想嘗試ARIMA或HoltWinters,並希望製作此頁面的情節:http://rpubs.com/sinhrks/basics或這一個:https://robjhyndman.com/hyndsight/forecast7-ggplot2/ 。這兩個頁面似乎都使用ggplot2的autoplot。看看x軸,我如何顯示我的DOC值(3到101)加上我的3個預測(108,115和122)? – Salvador