Syntax issue with tso function in tsoutliers package










0















I have a data frame (3575 observations long) with two columns, Date and Oxygen Concentration. Date is in YYYY-MM-DD format for 25 years and oxygen values are numbers running anywhere from 0.05 to 7.5. I'm trying to locate outliers in my dataset using the tsoutliers package and my problem is with the syntax and not the values of the data themselves.



I first used the auto.arima function with this code:



auto.arima(Site7$Oxygen, seasonal = TRUE, stepwise = FALSE)


I'm sorry about not being able to give a minimum reproducible example but given the scale of the data and tests, it would be quite difficult to put it all in here.



For the results I got:



Series: Date$Oxygen 
ARIMA(3,1,2)

Coefficients:
ar1 ar2 ar3 ma1 ma2
0.2988 0.2439 0.1431 -0.4348 -0.5259
s.e. 0.0947 0.0686 0.0316 0.0948 0.0772

sigma^2 estimated as 0.5999: log likelihood=-4145.53
AIC=8303.06 AICc=8303.09 BIC=8340.15


Now, as I'm trying to visualize Additive Outliers I used the tso() command with this code:



AOoutliers <- tso(Date$Oxygen,types = "AO", maxit = 10, tsmethod = c("arima"), args.tsmethod = list(order =c(3,1,2)))


I now have this error which I can't seem to figure out:




Error in tso0(x = y, xreg = xreg, cval = cval, delta = delta, n.start
= n.start, : trying to get slot "y" from an object of a basic class ("numeric") with no slots




Any help would be greatly appreciated. Thank you.










share|improve this question

















  • 1





    i think it might be a problem with your date. check the structure of your Date variable it might be numeric. use str() to check the structure , if it is Numeric convert it to date using library(lubridate) and ymd(Date) this will convert your variable to date format .

    – Hunaidkhan
    Nov 15 '18 at 3:52











  • @Hunaidkhan The date is already a Date variable, so this isn't the issue. Thank you for trying to help nonetheless. :)

    – SecretBeach
    Nov 15 '18 at 15:20






  • 1





    The input data passed through argument y must be a ts object. It seems there is some issue with the format of the data. class(Date$Oxygen) should return ts. Check it out or post the output from dput(head(Date$Oxygen)).

    – javlacalle
    Nov 15 '18 at 16:11











  • @javlacalle thank you, this is exactly what I need!

    – SecretBeach
    Nov 15 '18 at 18:54






  • 1





    Possible duplicate of Syntax error with tsoutliers package using Nile dataset

    – javlacalle
    Nov 15 '18 at 21:45















0















I have a data frame (3575 observations long) with two columns, Date and Oxygen Concentration. Date is in YYYY-MM-DD format for 25 years and oxygen values are numbers running anywhere from 0.05 to 7.5. I'm trying to locate outliers in my dataset using the tsoutliers package and my problem is with the syntax and not the values of the data themselves.



I first used the auto.arima function with this code:



auto.arima(Site7$Oxygen, seasonal = TRUE, stepwise = FALSE)


I'm sorry about not being able to give a minimum reproducible example but given the scale of the data and tests, it would be quite difficult to put it all in here.



For the results I got:



Series: Date$Oxygen 
ARIMA(3,1,2)

Coefficients:
ar1 ar2 ar3 ma1 ma2
0.2988 0.2439 0.1431 -0.4348 -0.5259
s.e. 0.0947 0.0686 0.0316 0.0948 0.0772

sigma^2 estimated as 0.5999: log likelihood=-4145.53
AIC=8303.06 AICc=8303.09 BIC=8340.15


Now, as I'm trying to visualize Additive Outliers I used the tso() command with this code:



AOoutliers <- tso(Date$Oxygen,types = "AO", maxit = 10, tsmethod = c("arima"), args.tsmethod = list(order =c(3,1,2)))


I now have this error which I can't seem to figure out:




Error in tso0(x = y, xreg = xreg, cval = cval, delta = delta, n.start
= n.start, : trying to get slot "y" from an object of a basic class ("numeric") with no slots




Any help would be greatly appreciated. Thank you.










share|improve this question

















  • 1





    i think it might be a problem with your date. check the structure of your Date variable it might be numeric. use str() to check the structure , if it is Numeric convert it to date using library(lubridate) and ymd(Date) this will convert your variable to date format .

    – Hunaidkhan
    Nov 15 '18 at 3:52











  • @Hunaidkhan The date is already a Date variable, so this isn't the issue. Thank you for trying to help nonetheless. :)

    – SecretBeach
    Nov 15 '18 at 15:20






  • 1





    The input data passed through argument y must be a ts object. It seems there is some issue with the format of the data. class(Date$Oxygen) should return ts. Check it out or post the output from dput(head(Date$Oxygen)).

    – javlacalle
    Nov 15 '18 at 16:11











  • @javlacalle thank you, this is exactly what I need!

    – SecretBeach
    Nov 15 '18 at 18:54






  • 1





    Possible duplicate of Syntax error with tsoutliers package using Nile dataset

    – javlacalle
    Nov 15 '18 at 21:45













0












0








0








I have a data frame (3575 observations long) with two columns, Date and Oxygen Concentration. Date is in YYYY-MM-DD format for 25 years and oxygen values are numbers running anywhere from 0.05 to 7.5. I'm trying to locate outliers in my dataset using the tsoutliers package and my problem is with the syntax and not the values of the data themselves.



I first used the auto.arima function with this code:



auto.arima(Site7$Oxygen, seasonal = TRUE, stepwise = FALSE)


I'm sorry about not being able to give a minimum reproducible example but given the scale of the data and tests, it would be quite difficult to put it all in here.



For the results I got:



Series: Date$Oxygen 
ARIMA(3,1,2)

Coefficients:
ar1 ar2 ar3 ma1 ma2
0.2988 0.2439 0.1431 -0.4348 -0.5259
s.e. 0.0947 0.0686 0.0316 0.0948 0.0772

sigma^2 estimated as 0.5999: log likelihood=-4145.53
AIC=8303.06 AICc=8303.09 BIC=8340.15


Now, as I'm trying to visualize Additive Outliers I used the tso() command with this code:



AOoutliers <- tso(Date$Oxygen,types = "AO", maxit = 10, tsmethod = c("arima"), args.tsmethod = list(order =c(3,1,2)))


I now have this error which I can't seem to figure out:




Error in tso0(x = y, xreg = xreg, cval = cval, delta = delta, n.start
= n.start, : trying to get slot "y" from an object of a basic class ("numeric") with no slots




Any help would be greatly appreciated. Thank you.










share|improve this question














I have a data frame (3575 observations long) with two columns, Date and Oxygen Concentration. Date is in YYYY-MM-DD format for 25 years and oxygen values are numbers running anywhere from 0.05 to 7.5. I'm trying to locate outliers in my dataset using the tsoutliers package and my problem is with the syntax and not the values of the data themselves.



I first used the auto.arima function with this code:



auto.arima(Site7$Oxygen, seasonal = TRUE, stepwise = FALSE)


I'm sorry about not being able to give a minimum reproducible example but given the scale of the data and tests, it would be quite difficult to put it all in here.



For the results I got:



Series: Date$Oxygen 
ARIMA(3,1,2)

Coefficients:
ar1 ar2 ar3 ma1 ma2
0.2988 0.2439 0.1431 -0.4348 -0.5259
s.e. 0.0947 0.0686 0.0316 0.0948 0.0772

sigma^2 estimated as 0.5999: log likelihood=-4145.53
AIC=8303.06 AICc=8303.09 BIC=8340.15


Now, as I'm trying to visualize Additive Outliers I used the tso() command with this code:



AOoutliers <- tso(Date$Oxygen,types = "AO", maxit = 10, tsmethod = c("arima"), args.tsmethod = list(order =c(3,1,2)))


I now have this error which I can't seem to figure out:




Error in tso0(x = y, xreg = xreg, cval = cval, delta = delta, n.start
= n.start, : trying to get slot "y" from an object of a basic class ("numeric") with no slots




Any help would be greatly appreciated. Thank you.







r syntax time-series outliers arima






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 15 '18 at 3:19









SecretBeachSecretBeach

728




728







  • 1





    i think it might be a problem with your date. check the structure of your Date variable it might be numeric. use str() to check the structure , if it is Numeric convert it to date using library(lubridate) and ymd(Date) this will convert your variable to date format .

    – Hunaidkhan
    Nov 15 '18 at 3:52











  • @Hunaidkhan The date is already a Date variable, so this isn't the issue. Thank you for trying to help nonetheless. :)

    – SecretBeach
    Nov 15 '18 at 15:20






  • 1





    The input data passed through argument y must be a ts object. It seems there is some issue with the format of the data. class(Date$Oxygen) should return ts. Check it out or post the output from dput(head(Date$Oxygen)).

    – javlacalle
    Nov 15 '18 at 16:11











  • @javlacalle thank you, this is exactly what I need!

    – SecretBeach
    Nov 15 '18 at 18:54






  • 1





    Possible duplicate of Syntax error with tsoutliers package using Nile dataset

    – javlacalle
    Nov 15 '18 at 21:45












  • 1





    i think it might be a problem with your date. check the structure of your Date variable it might be numeric. use str() to check the structure , if it is Numeric convert it to date using library(lubridate) and ymd(Date) this will convert your variable to date format .

    – Hunaidkhan
    Nov 15 '18 at 3:52











  • @Hunaidkhan The date is already a Date variable, so this isn't the issue. Thank you for trying to help nonetheless. :)

    – SecretBeach
    Nov 15 '18 at 15:20






  • 1





    The input data passed through argument y must be a ts object. It seems there is some issue with the format of the data. class(Date$Oxygen) should return ts. Check it out or post the output from dput(head(Date$Oxygen)).

    – javlacalle
    Nov 15 '18 at 16:11











  • @javlacalle thank you, this is exactly what I need!

    – SecretBeach
    Nov 15 '18 at 18:54






  • 1





    Possible duplicate of Syntax error with tsoutliers package using Nile dataset

    – javlacalle
    Nov 15 '18 at 21:45







1




1





i think it might be a problem with your date. check the structure of your Date variable it might be numeric. use str() to check the structure , if it is Numeric convert it to date using library(lubridate) and ymd(Date) this will convert your variable to date format .

– Hunaidkhan
Nov 15 '18 at 3:52





i think it might be a problem with your date. check the structure of your Date variable it might be numeric. use str() to check the structure , if it is Numeric convert it to date using library(lubridate) and ymd(Date) this will convert your variable to date format .

– Hunaidkhan
Nov 15 '18 at 3:52













@Hunaidkhan The date is already a Date variable, so this isn't the issue. Thank you for trying to help nonetheless. :)

– SecretBeach
Nov 15 '18 at 15:20





@Hunaidkhan The date is already a Date variable, so this isn't the issue. Thank you for trying to help nonetheless. :)

– SecretBeach
Nov 15 '18 at 15:20




1




1





The input data passed through argument y must be a ts object. It seems there is some issue with the format of the data. class(Date$Oxygen) should return ts. Check it out or post the output from dput(head(Date$Oxygen)).

– javlacalle
Nov 15 '18 at 16:11





The input data passed through argument y must be a ts object. It seems there is some issue with the format of the data. class(Date$Oxygen) should return ts. Check it out or post the output from dput(head(Date$Oxygen)).

– javlacalle
Nov 15 '18 at 16:11













@javlacalle thank you, this is exactly what I need!

– SecretBeach
Nov 15 '18 at 18:54





@javlacalle thank you, this is exactly what I need!

– SecretBeach
Nov 15 '18 at 18:54




1




1





Possible duplicate of Syntax error with tsoutliers package using Nile dataset

– javlacalle
Nov 15 '18 at 21:45





Possible duplicate of Syntax error with tsoutliers package using Nile dataset

– javlacalle
Nov 15 '18 at 21:45












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53311911%2fsyntax-issue-with-tso-function-in-tsoutliers-package%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53311911%2fsyntax-issue-with-tso-function-in-tsoutliers-package%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

How to read a connectionString WITH PROVIDER in .NET Core?

Node.js Script on GitHub Pages or Amazon S3

Museum of Modern and Contemporary Art of Trento and Rovereto