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

mstl function in forecast package gives error #599

Closed
lgautier opened this issue Sep 23, 2019 · 2 comments
Closed

mstl function in forecast package gives error #599

lgautier opened this issue Sep 23, 2019 · 2 comments

Comments

@lgautier
Copy link
Member

Original report by Nils Holgersson (Bitbucket: [Nils Holgersson](https://bitbucket.org/Nils Holgersson), ).


When running the mstl function from the forecast package in R I am getting the following error:

R[write to console]: Error in `[.default`(x, , 1) : incorrect number of dimensions

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 14, in forecast
  File "/Users/ejohara/sandbox/python_envs/yuntao/lib/python3.6/site-packages/rpy2/robjects/functions.py", line 192, in __call__
    .__call__(*args, **kwargs))
  File "/Users/ejohara/sandbox/python_envs/yuntao/lib/python3.6/site-packages/rpy2/robjects/functions.py", line 121, in __call__
    res = super(Function, self).__call__(*new_args, **new_kwargs)
  File "/Users/ejohara/sandbox/python_envs/yuntao/lib/python3.6/site-packages/rpy2/rinterface_lib/conversion.py", line 28, in _
    cdata = function(*args, **kwargs)
  File "/Users/ejohara/sandbox/python_envs/yuntao/lib/python3.6/site-packages/rpy2/rinterface.py", line 785, in __call__
    raise embedded.RRuntimeError(_rinterface._geterrmessage())
rpy2.rinterface_lib.embedded.RRuntimeError: Error in `[.default`(x, , 1) : incorrect number of dimensions

All other forecast methods in the forecast package seem to work, so I am not sure why this one fails.

I am running rpy2 version 3.1.0 on Mac OS, R version 3.5.2.

The following code can be run to recreate this issue:

import rpy2.robjects as robjects
import numpy as np
import rpy2.robjects.numpy2ri
rpy2.robjects.numpy2ri.activate()

def forecast():
    robjects.r('''
        library(forecast)
        mstl_forec <- function(x, fh){
            data <- msts(x, seasonal.periods=c(24,168))
            model <- forecast::mstl(data)
            forecast::forecast(model, h=fh)$mean
        }
    ''')
    
    fh=24
    seriesdata = np.array(range(168*3))
    process_forecast_methods = robjects.r['mstl_forec']
    fcast = process_forecast_methods(x=seriesdata, fh=fh)
    return fcast 

res = forecast()

@lgautier lgautier transferred this issue from another repository Dec 27, 2019
@lgautier
Copy link
Member Author

lgautier commented Feb 2, 2020

I am not sure this is an issue with rpy2. This seems more like an operator error, in the sense the underlying R function called finds a parameter invalid. If truly the case, asking on a list or a place like StackOverflow might get more attention.

@lgautier
Copy link
Member Author

Likely an operator error. Closing.

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

1 participant