[R] Time-series moving average question

Bill Poling B|||@Po||ng @end|ng |rom ze||@@com
Fri Jun 1 19:42:31 CEST 2018


Hi Don, wow, you are so right. I picked that piece up from the bloggers tutorial and since I am R naive yet, I thought it was all one step

moving_average = forecast(ma(tdat[1:31], order=2), h=5)

Truly, I usually print and check at every step I can, as painful as it is sometimes.
Great lesson for this novice usR.

So the first and last values are NA in each case? Do you know why? Should I replace the NA with a value, say the average of the others?

Also, I have 5 series of data I am working with using this script and of course each gave me that warning, but only the one series had the same 8 Point Forecast values, is that coincidental you think?

Terrific of you to help, I really appreciate it.

WHP


From: MacQueen, Don [mailto:macqueen1 using llnl.gov]
Sent: Friday, June 01, 2018 12:54 PM
To: Bill Poling <Bill.Poling using zelis.com>; r-help (r-help using r-project.org) <r-help using r-project.org>
Subject: Re: [R] Time-series moving average question

You are right that there are no NAs in the practice data. But there are NAs in the moving average data.

To see this, break your work into two separate steps, like this:

tnr.ma<http://tnr.ma> <- ma(dat3[1:28], order=3)
TNR_moving_average <- forecast(tnr.ma<http://tnr.ma>, h=8)

I think you will find that the warning comes from the second step.

Print tnr.ma<http://tnr.ma> and you will see some NAs.

-Don

--
Don MacQueen
Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062
Lab cell 925-724-7509



From: Bill Poling <Bill.Poling using zelis.com<mailto:Bill.Poling using zelis.com>>
Date: Friday, June 1, 2018 at 8:58 AM
To: "MacQueen, Don" <macqueen1 using llnl.gov<mailto:macqueen1 using llnl.gov>>, array R-help <r-help using r-project.org<mailto:r-help using r-project.org>>
Subject: RE: [R] Time-series moving average question

Hello Don, thank you for your response. I appreciate your help.

I am using the forecast package, originally I found it following a forecasting example on bloggers.com<http://bloggers.com>

https://www.r-bloggers.com/time-series-analysis-using-r-forecast-package/<https://www.r-bloggers.com/time-series-analysis-using-r-forecast-package/>

And subsequently located the complete pdf https://cran.r-project.org/web/packages/forecast/forecast.pdf<https://cran.r-project.org/web/packages/forecast/forecast.pdf>

Since I created this practice data using the structure() function I am unsure why there would be NA’s as there are none apparently in the structure?

No worries though, I am going to reach out to the package author.

Cheers.

WHP

From: MacQueen, Don [mailto:macqueen1 using llnl.gov]
Sent: Friday, June 01, 2018 11:24 AM
To: Bill Poling <Bill.Poling using zelis.com<mailto:Bill.Poling using zelis.com>>; r-help (r-help using r-project.org<mailto:r-help using r-project.org>) <r-help using r-project.org<mailto:r-help using r-project.org>>
Subject: Re: [R] Time-series moving average question

My guess would be that if you inspect the output from
ma(dat3[1:28], order=3)
you will find some NAs in it. And then forecast() doesn't like NAs.

But I can't check, because I can't find the ma() and forecast() functions. I assume they come from some package you installed; it would be helpful to say which package.

-Don

--
Don MacQueen
Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062
Lab cell 925-724-7509


______________________________________________
mailto:R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help>
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html<http://www.R-project.org/posting-guide.html>
and provide commented, minimal, self-contained, reproducible code.



Confidentiality Notice This message is sent from Zelis. This transmission may contain information which is privileged and confidential and is intended for the personal and confidential use of the named recipient only. Such information may be protected by applicable State and Federal laws from this disclosure or unauthorized use. If the reader of this message is not the intended recipient, or the employee or agent responsible for delivering the message to the intended recipient, you are hereby notified that any disclosure, review, discussion, copying, or taking any action in reliance on the contents of this transmission is strictly prohibited. If you have received this transmission in error, please contact the sender immediately. Zelis, 2018.

Confidentiality Notice This message is sent from Zelis. This transmission may contain information which is privileged and confidential and is intended for the personal and confidential use of the named recipient only. Such information may be protected by applicable State and Federal laws from this disclosure or unauthorized use. If the reader of this message is not the intended recipient, or the employee or agent responsible for delivering the message to the intended recipient, you are hereby notified that any disclosure, review, discussion, copying, or taking any action in reliance on the contents of this transmission is strictly prohibited. If you have received this transmission in error, please contact the sender immediately. Zelis, 2018.

	[[alternative HTML version deleted]]



More information about the R-help mailing list