1

I am trying to get the HoltWinters Alpha function added. I have a Table called Sales1 and the code should refer to this table. Is there anyone who can correct or amend my code below ,so i get the Holtwinters Alpha instead of the Chronbachs Alpha?

Holt winters calc (need this probably amended)

library(forecast)
library(Metrics

)

read_file(sales1)
x <- sales

x = c(Sales1)  
mSES = HoltWinters(x, alpha = 0.5, beta = FALSE, gamma = FALSE)  
mHW = HoltWinters(x, alpha = 0.5, beta = FALSE, gamma = FALSE)
mSES$SSE  
mHW$SSE

HoltWinters(x, alpha = NULL, beta = NULL, gamma = NULL,
            seasonal = c("additive", "multiplicative"),
            start.periods = 2, l.start = NULL, b.start = NULL,
            s.start = NULL,
            optim.start = c(alpha = 0.3, beta = 0.1, gamma = 0.1),
            optim.control = list())

chronbachs alpha calc

read_file(sales1)
library(tidyverse)
library(psy)

Number of rows before to take into account

rolling = 2

sales1 <- sales::sales(  ~date, ~sales,)
#Lag
sales1 = sales1 %>%  mutate(lagsales = lag(sales))

#Rolling Chronbachs Alpha.:( I need the Holtwinter Alpha here )

sales1$alpha = c(  rep(NA, rolling), 
  map_dbl((rolling + 1):nrow(sales1), function(x){
    cronbach(sales1 %>% select(sales, lagsales) %>% slice((x-rolling):x))$alpha
  })
)
sales1

tibbet from Sales1 table:

df <- tibble::tribble( ~seq, ~date, ~sales, 1, "3/01/2017", 40, 2, "4/01/2017", 2, 3, "5/01/2017", 2, 4, "6/01/2017", 2, 5, "7/01/2017", 30, 6, "8/01/2017", 2, 7, "1/02/2017", 9, 8, "2/02/2017", 5, 9, "3/02/2017", 65, 10, "4/02/2017", 3, 11, "5/02/2017", 65

ron4
  • 11
  • 3

0 Answers0