Help with creating dummy variable

Hi I am making an arima() model with x = price with hourly data from 2000-2018. I have grouped by year and now have other regressors (3 of them) which I have used as xreg in arima().

I am new to dummy variables and not exactly sure how they work, meaning I am wanting to use a dummy variable for before 2014 and after 2014. I am not sure if I need just one variable for this or if I need one variable for every year of the data?

So as of now, I have used the function dummy_cols() and set select_comuns = c("Year") which now returned variables from 2000 -2018 with Year_ before it. When I include these in with x_reg I get an error of "non-finite value supplied by optim".

Is there a way to make one dummy variable for values before 2014 and after 2014?

Thank You in advance!

As always, screenshots are seldom helpful. 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.

The best I can offer is to create a new column variable, which I'll denote fence with 1 signifying pre-2014 and the other 2014 and following. The details will depend on the class of the YEAR column.

your_df %>% mutate(fence = ifelse(YEAR < 2014,0,1)) -> your_df

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