How to use the Holt winters function() correctly

I am trying to get the Holt winters method working .
Is there anyone who could help me with that?

David, thanks for your advise to throw it into the community and see if there is someone who can correct the Holt winters code.

if using the following code, would that work? I am trying to have the below connected to my table.sales1
My 2 reprex's are shown below.The 1st reprex has the incorrect Chronbachs alpha.

#reprex 2:
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()

#I would need to use the package Holtwinters() i guess?
#How do i get the ABG shown in my table per separate line?

1th reprex:


#Number of rows before to take into account
rolling = 2

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

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


Still not quite a reprex. That would be a copy, paste and run, meaning that all of the necessary :x: data is included.

Please see the FAQ: What's a reproducible example (`reprex`) and how do I do one? Using a reprex, complete with representative data will attract quicker and more answers.

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