Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

R version 4.1.

2 (2021-11-01) -- "Bird Hippie"


Copyright (C) 2021 The R Foundation for Statistical Computing
Platform: aarch64-apple-darwin20 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.


You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

Natural language support but running in an English locale

R is a collaborative project with many contributors.


Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or


'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

[R.app GUI 1.77 (8007) aarch64-apple-darwin20]

[Workspace restored from /Users/rajeshsinha/.RData]


[History restored from /Users/rajeshsinha/.Rapp.history]

> MH <- read.csv("/Users/rajeshsinha/Library/Mobile Documents/com~apple~CloudDocs/Marriott Hamilton csv.csv",


header = TRUE)
>
> head(MH)
CODE WEEK DOW.INDICATOR1 DEMAND TUESDAY.BOOKINGS PICKUP.RATIO DOW.INDEX
1 1 1 1 1470 1512 0.9722222 0.8647725
2 1 1 2 870 864 1.0069444 0.9105852
3 1 1 3 986 827 1.1922612 0.9728832
4 1 1 4 1247 952 1.3098740 1.0125249
5 1 1 5 1109 740 1.4986486 1.0678813
6 1 1 6 1197 908 1.3182819 1.1227265
>
> MH$Adjusted_Pickup <- MH[,6]/MH[,7]
>
> head(MH)
CODE WEEK DOW.INDICATOR1 DEMAND TUESDAY.BOOKINGS PICKUP.RATIO DOW.INDEX Adjusted_Pickup
1 1 1 1 1470 1512 0.9722222 0.8647725 1.124252
2 1 1 2 870 864 1.0069444 0.9105852 1.105821
3 1 1 3 986 827 1.1922612 0.9728832 1.225493
4 1 1 4 1247 952 1.3098740 1.0125249 1.293671
5 1 1 5 1109 740 1.4986486 1.0678813 1.403385
6 1 1 6 1197 908 1.3182819 1.1227265 1.174179
>
> plot(MH[,8], type = "l")
> lines(MH[,6], lty = 2, col = "red")
>
>
> MHD <- MH[,8]
> DD <- MH[,4]
> MHDts <- ts(MHD, frequency = 7, start = c(1,1), end = c(11,7))
> DDt <- ts(DD, frequency = 7, start = c(1,1), end = c(13,3))
>
> MHDtsDC <- decompose(MHDts)
> plot(MHDtsDC)
>
> DHW <- HoltWinters(MHDts)
> plot(DHW)
>
> DHW.pred <- predict(DHW, 10, prediction.interval = TRUE, level=0.95)
>
> # convert back to unadjusted pick-up ratio = adjusted pickup * DOWI
>
> Reverse <- DHW.pred[,1]*MH[c(78:87),7]
> ReverseUP <- DHW.pred[,2]*MH[c(78:87),7]
> ReverseLR <- DHW.pred[,3]*MH[c(78:87),7]
>
> # Calculating demand
>
> DemandP <- Reverse * MH[c(78:87),5]
> DemandPUP <- ReverseUP * MH[c(78:87),5]
> DemandPLR <- ReverseLR * MH[c(78:87),5]
>
>
> plot(DDt, xlim = c(12,14), type = "l")
>
> lines(DemandP, col="blue")
> lines(DemandPUP, lty=2, col="orange")
> lines(DemandPLR, lty=2, col="orange")
>

You might also like