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

Dynamically specifying the formula says 'No supported inverse for this function' #28

Closed
ashraaghav opened this issue Jul 20, 2018 · 3 comments

Comments

@ashraaghav
Copy link

Hi, Great work on the package by the way.

I want to generate my formula dynamically from a list of variable names. So I tried to paste them into a string and convert that into a formula. However, this is throwing an error saying "No supported inverse for this function"

Example:

# Preparing the data
airquality %>% mutate(
    date = as.Date(paste('2018', Month, Day, sep = '-')), 
    Ozone = round(imputeTS::na.interpolation(Ozone, option = 'stine')),
    Solar.R = round(imputeTS::na.interpolation(Solar.R, option = 'stine'))
  ) %>% 
  as_tsibble()

# Creating formula
f <- as.formula('y ~ Wind + Temp + Solar.R + trig(12) + poly(1) + ARMA(1, 1)')

# Building fasster without formula parsing
fsModel <- FASSTER(data = train, 
    formula = y ~ Wind + Temp + Solar.R + trig(12) + poly(1) + ARMA(1, 1))

# Building fasster - throws an error 
fsModel <- FASSTER(data = train, formula = f)

I am not sure if I am doing anything wrong here. The same formula when passed directly worked perfectly fine.

@mitchelloharawild
Copy link
Member

Working on a fix now, something is not correct with the parsing of the formula.


A few changes to your example:

  • Ozone should be the response instead of y, it probably worked for you because you had y somewhere in your environment
  • ARMA is used with the coefficients for the AR and MA terms, so this would have the AR and MA coefficients both as 1 (unlikely what you intended, but this is something I intend to change).
  • Save the prepared data as train

library(fasster)
library(fable)
library(tsibble)

# Preparing the data
train <- airquality %>% mutate(
  date = as.Date(paste('2018', Month, Day, sep = '-')), 
  Ozone = round(imputeTS::na.interpolation(Ozone, option = 'stine')),
  Solar.R = round(imputeTS::na.interpolation(Solar.R, option = 'stine'))
) %>% 
  as_tsibble()

# Creating formula
f <- as.formula('Ozone ~ Wind + Temp + Solar.R + trig(12) + poly(1) + ARMA(1, 1)')

# Building fasster without formula parsing
fsModel <- FASSTER(data = train, 
                   formula = Ozone ~ Wind + Temp + Solar.R + trig(12) + poly(1) + ARMA(1, 1))

# Building fasster - throws an error 
fsModel <- FASSTER(data = train, formula = f)

@mitchelloharawild
Copy link
Member

mitchelloharawild commented Jul 30, 2018

Resolved in tidyverts/fable@4e1521f

@ashraaghav
Copy link
Author

Apologies for the typo. Thanks for the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants