Weekly Time series Prediction

I am having a weekly data and want to forecast values based on available actuals in R using timeseries model.

I tried to convert the data to a timeseries data using (ts) but couldnt.

Weekly Income
1/8/2018 1220
1/15/2018 2200
1/22/2018 8800
1/29/2018 7743
2/5/2018 4432
2/12/2018 56789
2/19/2018 95643
2/26/2018 2200
3/5/2018 23400
3/12/2018 3340
3/19/2018 2098
3/26/2018 12098
4/2/2018 12060
4/9/2018 10980
4/16/2018 202987
4/23/2018 40003
4/30/2018 30009
5/7/2018 3480
5/14/2018 40090
5/21/2018 6800
5/28/2018 40088
t_data<-ts(mydata1_subset2$income,frequency = 52,start = c(2018,1))
``
any idea how to convert the data set to a timeseries data based on weekly and any model to predict the value for future.

I would recommend starting with tsibbles and fable.

1 Like

The trick with time series is that you just need a vector of the variables other than date.

my_ts <- ts(c(1220,2200,8800,7743,4432,56789,95643,2200,23400,3340,2098,12098,12060,10980,202987,40003,30009,3480,40090,6800,40088), start = c(2018,1,3), frequency = 52)
my_ts
#> Time Series:
#> Start = c(2018, 1) 
#> End = c(2018, 21) 
#> Frequency = 52 
#>  [1]   1220   2200   8800   7743   4432  56789  95643   2200  23400   3340
#> [11]   2098  12098  12060  10980 202987  40003  30009   3480  40090   6800
#> [21]  40088
1 Like

Thanks, I tried the same early and also created ts using vector as per suggestion but the output am getting is like

[1] 2001 -2398 3468 7869 34786 23567 23468 2134 112224
[10] 34598 2348 2654 12389 23478 1234 4580 2098 123459
[19] 2001 -2398 3468 7869 34786 23567 23468 2134 112224
[28] 34598 2348 2654 12389 23478 1234 4580 2098 123459
[37] 2001 -2398 3468 7869 34786 23567 23468 2134 112224
[46] 34598 2348 2654 12389 23478 1234 4580 2098 123459

I am not sure how to include this in model, even when we put this in a time series model either Arima or Tbats
the result is totally different . Any idea

Hi!

To help us help you, could you please prepare a reproducible example (reprex) illustrating your issue? Please have a look at this guide, to see how to create one:

The data below gives me weekly time series but which would be a good model to fit this weekly data and predict the value for next 12 months weekly prediction.

[1] 2001 -2398 3468 7869 34786 23567 23468 2134 112224
[10] 34598 2348 2654 12389 23478 1234 4580 2098 123459
[19] 2001 -2398 3468 7869 34786 23567 23468 2134 112224
[28] 34598 2348 2654 12389 23478 1234 4580 2098 123459
[37] 2001 -2398 3468 7869 34786 23567 23468 2134 112224
[46] 34598 2348 2654 12389 23478 1234 4580 2098 123459

When I paste that into my R session, I get errors immediately...

> [1] 2001 -2398 3468 7869 34786 23567 23468 2134 112224
Error: unexpected '[' in "["
> [10] 34598 2348 2654 12389 23478 1234 4580 2098 123459
Error: unexpected '[' in "["
> [19] 2001 -2398 3468 7869 34786 23567 23468 2134 112224
Error: unexpected '[' in "["
> [28] 34598 2348 2654 12389 23478 1234 4580 2098 123459
Error: unexpected '[' in "["
> [37] 2001 -2398 3468 7869 34786 23567 23468 2134 112224
Error: unexpected '[' in "["
> [46] 34598 2348 2654 12389 23478 1234 4580 2098 123459
Error: unexpected '[' in "["
> 

You should get errors because you are trying to run the output from the console, not code.

I was hoping that ksasi would realise he didnt share the data in the recommended way, which I previously pointed him to. It seemed a reasonable way to justify reading the guide...

Thanks nigrahamuk for your support. I tried exporting the timeseries dataset but it is not in correct format hence I just provided the data directly. Meanwhile I learned that Frequency =52 plays trick in weekly timeseries. Hence I able to understand the TS data now.. but anyone can suggest, how "Holt winters" method works to predict immediate week from actual data.

Example:
I am giving timeseries data from 2018 Jan to 2020 Aug on weekly basis and I want to predict from 2020 Sept to next 60 weeks.

Whether Holt winters is good or any other method will do

Unless your data has very small variability, for a forecast horizon of 60 weeks none of the models will be satisfactory. This is because the confidence intervals will quickly grow beyond the range of historical data and may even become negative.

1 Like

Thanks Technocrat, Any idea for getting accurate model and predicting for future weeks

Check out:

2 Likes

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.