Unless I am mistaken, it seems like the ljung_box feature requires manual specification for the dof and lag arguments outside of the defaults, which are 0 and 1 respectively. This can be an issue when your mable contains models which have varying parameter counts, in which case dof should be different for the respective models. In that case, you'd want the ljung_box feature to calculate the statistic and p-value based on each model.
Ex.)
# subset data for training
train <- aus_production %>%
filter_index("1992 Q1" ~ "2006 Q4")
# Create models
beer_fit <- train %>%
model(
Mean = MEAN(Beer),
`Seasonal naïve` = SNAIVE(Beer)
)
# check how many estimated parameters each model has, if any. Only `Mean` will show
# as having at least 1 parameter
beer_fit %>%
tidy() %>%
group_by(.model) %>%
count()
# get ljung box information
beer_fit %>%
augment() %>%
features(.innov,ljung_box)
Note that the last command in the code will produce ljung_box information but with both having a dof value of 0 when Mean should be 1 and Seasonal naïve should be 0.
I believe this can be fixed using a relatively simple mapply() function. (This could obviously be improved on, is just a rough draft) as follows:
If I am a bonehead and there is a way to do this already please let me know. If not, then I am open to suggestions on how this can be implemented/improved upon.
Unless I am mistaken, it seems like the
ljung_box
feature requires manual specification for thedof
andlag
arguments outside of the defaults, which are 0 and 1 respectively. This can be an issue when yourmable
contains models which have varying parameter counts, in which casedof
should be different for the respective models. In that case, you'd want theljung_box
feature to calculate the statistic and p-value based on each model. Ex.)Note that the last command in the code will produce
ljung_box
information but with both having adof
value of 0 whenMean
should be 1 andSeasonal naïve
should be 0.I believe this can be fixed using a relatively simple
mapply()
function. (This could obviously be improved on, is just a rough draft) as follows:If I am a bonehead and there is a way to do this already please let me know. If not, then I am open to suggestions on how this can be implemented/improved upon.