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.

QUESTION:
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:

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))

#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
})
)
sales1

cheers

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 create 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.