Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

arch_lm perfect fit #85

Closed
mitchelloharawild opened this issue Jan 6, 2020 · 3 comments
Closed

arch_lm perfect fit #85

mitchelloharawild opened this issue Jan 6, 2020 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@mitchelloharawild
Copy link
Member

@robjhyndman
What would you expect from this feature's output?

Issue with this series is that it drops to zero after 12 observations.

library(tsibbledata)
library(feasts)
#> Loading required package: fabletools
library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
PBS %>% 
  filter(ATC2 == "D04", Concession == "General", Type == "Co-payments") %>% 
  features(Cost, stat_arch_lm)
#> Warning in summary.lm(fit): essentially perfect fit: summary may be unreliable
#> # A tibble: 1 x 5
#>   Concession Type        ATC1  ATC2  stat_arch_lm
#>   <chr>      <chr>       <chr> <chr>        <dbl>
#> 1 General    Co-payments D     D04            NaN

Created on 2020-01-06 by the reprex package (v0.3.0)

@mitchelloharawild mitchelloharawild added the bug Something isn't working label Jan 6, 2020
@mitchelloharawild mitchelloharawild self-assigned this Jan 6, 2020
@robjhyndman
Copy link
Member

It's a perfect fit, so R^2 should be 1. Therefore return 1.

@mitchelloharawild
Copy link
Member Author

Thought as much.

I also noticed that the condition is length(x) <= 13, shouldn't this be lag+1? This is something copied over from tsfeatures.
Further, do you think a better handling of default lags would be useful for small sample sizes?

feasts/R/features.R

Lines 18 to 22 in 8dd8103

stat_arch_lm <- function(x, lags = 12, demean = TRUE)
{
if (length(x) <= 13) {
return(c(arch_lm = NA_real_))
}

@robjhyndman
Copy link
Member

Yes, that it should be lags+1. I'm not familiar with this test (and I didn't write the code) so I'm not sure what is recommended for small sample sizes. I'm also not sure where the default of 12 came from. The original paper is Engle (1982) [https://www.jstor.org/stable/1912773].

mitchelloharawild added a commit to robjhyndman/tsfeatures that referenced this issue Jan 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants