File Exchange

image thumbnail

Time Series Analysis and Forecast

version 1.3 (160 KB) by Iman
TSAF enables you to quickly analyze time series and forecast the future.

110 Downloads

Updated 12 Aug 2018

View License

How to open the GUI:
Step 1) download and unzip the package.
Step 2) copy all the files & folders included in the unzipped package into the current working directory of Matlab*.
* To find out the current working directory, please type "pwd" in the Matlab command line.
Step 3) Type "TSAF" in the command line.
Step 4) Enjoy it!
--------------------------------------------------------
Please watch the following short tutorials to quickly learn the topic and master the GUI:
Tutorial 1 - Concept:
https://www.youtube.com/watch?v=7eb141ajT7c&index=1&list=PLJ-OcUCIty7eFl4rjnMf3UgcHp-nWCoCB


Tutorial 2 - Trend and Seasonality:
https://www.youtube.com/watch?v=roujnW4XbS0&list=PLJ-OcUCIty7eFl4rjnMf3UgcHp-nWCoCB&index=2


Tutorial 3 - ARMA:
https://www.youtube.com/watch?v=bs9fKzuUXtY&list=PLJ-OcUCIty7eFl4rjnMf3UgcHp-nWCoCB&index=3


Tutorial 4 - TSAF (Example 1) :
https://www.youtube.com/watch?v=VuCftYyKMnM&index=4&list=PLJ-OcUCIty7eFl4rjnMf3UgcHp-nWCoCB


Tutorial 5 - TSAF (Example 2) :
https://www.youtube.com/watch?v=nJRRHIllGdg&list=PLJ-OcUCIty7eFl4rjnMf3UgcHp-nWCoCB&index=5


Tutorial 6 - TSAF (Example 3)
https://www.youtube.com/watch?v=NNZFotVWFtQ&list=PLJ-OcUCIty7eFl4rjnMf3UgcHp-nWCoCB&index=6


Tutorial 7 - TSAF (New Feature)
https://www.youtube.com/watch?v=jhuXjNaxrVo&index=7&list=PLJ-OcUCIty7eFl4rjnMf3UgcHp-nWCoCB


-----------------------------------------------------------
Please subscribe to my signal processing channel to see more tutorials:
https://www.youtube.com/channel/UCVkatNMgkEdpWLhH0kBqqLw

Acknowledgements:
This GUI is developed for 2060 Project at the Institute for Integrated Energy Systems at the University of Victoria, Canada. The project has been funded by Pacific Institute for Climate Solutions, Natural Resources Canada and Natural Sciences and Engineering Research Council of Canada. This funding is gratefully acknowledged.
-----------------------------------------------------------

References:
[1] Peter J. Brockwell, Richard A. Davis, "Introduction to Time Series and Forecasting", Second Edition, Springer, 2002.
[2] Chris Chatfield, "Time-Series Forecasting", Chapman &C Hall/CRC, 2000.

----------------------------------------------------------

"Photos courtesy of and copyright Free Range Stock, www.freerangestock.com"

Cite As

Iman (2019). Time Series Analysis and Forecast (https://www.mathworks.com/matlabcentral/fileexchange/54276-time-series-analysis-and-forecast), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (76)

Iman

Hi all. Thanks a lot for your feedback and messages and I apologize for some error messages that some of you are getting. I believe that's a consistency issue which is very common in different versions of MATLAB and also between different operating systems. I suggest to use the error message to find out which line goes wrong. Then, find the equivalent command for your MATLAB version/OS. For example, I know "xlsread" command is supported only on Windows computers with Excel software. Of course I didn't know this back then when developing software otherwise I would come up with something more general such as "readtable". I wish I had time to work on TEMS to build something more robust but currently my life has been very hectic. If you are interested to help me building a better "TEMS", please send an email to imanmoaz@uvic.ca

Hi Iman, Such a great work! But can you help me with the error box I'm getting. My Forecast.xls is not opening and giving me error box. My email Id is ndjpshri@gmail.com.
Thank you.

darki

Thank you for the tutorials, I really enjoyed them, but I cannot import my data, I'm using RMatlab17a. Is there any solution for that?

mena hamoum

Hi Iman
thanks for such a great TSAF, easy to use
i hope that you can help me : i'm using this package to estimate the solar radiation using historic data ranges since, 2010 till 2017 of six stations. my probleme is when i import my data i have nothing in frequency window... is this normal??
thank you in advance

Great work:)
I found one flaw.
The "q" in the result of Batch fit can't be seen in the pop-up, please change the pop-up menu size.

Could anybody tell where the excel sheet containing forecasting samples are stored after Forecasting by the GUI
.

helpfull

Iman

Hi Bushra, thanks a lot for your positive feedback. You need econometric toolbox to work with TSAF. I suggest to download the trial version as it is free for one month.

bushra raza

Hi,
i enjoyed learning through your tutorials. thanx a lot.
i tried your TSAF but when i run this on Matlab Command window, i got the error dialog " TSAF recquired econometric toolbox. i am using Matlab R2017b.

i have univariate time series data of Water levels of different stations. historic data ranges since,1985 till 2017.
please guide me would this TSAF work for my data sets. and should i download econometric toolbox . is it free ?

Mrs. Aamir

Iman

Hi Fred. Could your please email your data file to me? I will resolve the issue asap. My email is imanmoaz@uvic.ca

Fred

Hi Iman,
I'm wandering if you have solved data importing issue with RMatlab17a or not?
I cannot import any data other than your example data.

Iman

Sorry for the trouble! Please describe the issue or "print screen" the error and email it to imanmoaz@uvic.ca

I am also facing the same problem. It is not possible to Import data in Matlab 2017a.

Hi Iman, using MATLAB R2017b the "import data" section is not visible, maybe some compatibily issue. Can U help me? Thank a lot

Iman

Hi Gaby, Thank you for the feedback and sorry to hear that you are not happy with my code. Please keep in mind that my toolbox is not doing any magic. It basically uses some simple concepts to see if there is any trend or periodic behavior in data and fit data to an ARIMA(p,q) model based on (partial) autocorrelation. I don't know why you get such a large error. One possible reason might be that you didn't choose a good model or your data is basically so non-stationary. Please note that it is NECESSARY to have a stationary process. That's why we need to remove trend and seasonality first and hopefully what remains has some stationary characteristics. Hope this makes sense and sorry again for the trouble.

Three stars for the hard work and tutorial, however, the forecasting accuracy is very terrible. The produced error is ridiculously high.

Hello Imaan, I cannot display the full window of TSAF.fig using MATLAB 2017a. The import data section is gone due to the over size of the figure and I can't minimize or adjust the size of the window. Can you help me out? Thank you.

Matthias Ho

Good job Iman!
I have watched tutorial 5 and need some explanation on the graph of amplitude response vs freq.

How did you generate amp/freq based on the data/signal chart? Seems like the amplitude response is in the order of 7x10^5.
The concept of harmonic is not explained prior
The rest of acf/pacf explanation is very clear.
Thanks!

I cant download the econometrics toolbox. please help. thanks

Iman

@Vijay: what is your MATLAB version? I guess you have compatibility issue.
@Durgesh: can you please take a screenshot and email it to me? I need to see the settings that you use in other boxes.
@Will: thank you ;)

Will Huang

very good introduction and tools, thanks a lot!

Hi Iman, Thanks for the script and excellent demo. I am getting an error while I am clicking the estimate button. The error message is "Lags and Coefficients vectors must have the same length! ".

Hi Iman, Thanks for wonderful GUI. Could you please help me with below error for importing the file.

matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)TSAF('pushbutton1_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback.

Iman

@Jan, please watch my tutorials on TSAF to learn how I remove trend and seasonality.

Jan

Iman, which method is behind detrending and removing seasonality in data? Are some tests implemented here, like stationarity, normality or can I get advice where is the best to do these tests? I am predicting time series.

Iman

@Teena, please email the excel file to imanmoaz@uvic.ca

hi Iman ,
as I am trying to import the excel file , TSAF is giving the message " the specified column contains no data " . I have downloaded the TSAF version that is mentioned here . KINDLY HELP

HI Iman
im anew beginner in matlab and i concernd with TSAF GUI to solve my research problem can you make a tutorial to learn me how ican download TSAF GUI please
with my great respect

bechir

Thanks Iman for sharing, great tool . Quick question, is there a way to deploy this tool ( using the Matlab deploy App for example of any other methods) to Excel for instance or as a stand alone application such as .exe ?

Iman

Hi Areeha. Thank you for your feedback. You can go through the code (m file) and copy all the parts you need in your script. cheers!

Hello Iman. Thanks for great tutorials. Just wanted to ask if I can use it in my code (Script) like other tools of matlab?

A great work! I really appreciate you. Thanks.

Iman

@xinquan which options are missing? could you please take a screenshot and email it to me? Thanks!

Can not display the full window.MATLAB 2015a

when i click estimate button, it shows "system is not either stable or casual".what does it mean?
Thank you

Saif Mian

Great work!

Iman

Hi iqrar. Please watch my tutorials on this page.

hello sir
i want to forecast electrical prices.so what can i do? and which technique should i have used?

amin s

can

Perfect!!! thanx a lot!

can

Iman

Hi Zakar, Did you copy the files into the current directory of MATLAB? You can find this folder by typing "pwd" in the command line.
Thanks.

Hi Imran, i am using MATLAB_R2015 and MATLAB_R2016b, on both versions the TSAF is giving me error: Undefined function or variable 'TSAF'.
Can you help me please.

Iman

Hi Na Ja,

Thanks for reporting this issue. Could you please take a screenshot from the TSAF window and email it to me (imanmoaz@uvic.ca)? I want to see your settings. Thank you.

Iman

na ja

The code works excellent till the estimate part, but, when forecast is pressed; min and max values are entered; the following error appears.

Error using TSAF>forecast_Callback (line 930)
Argument 'NumPaths' did not match any valid parameter of the parser.

Error in gui_mainfcn (line 96)
feval(varargin{:});

Error in TSAF (line 42)
gui_mainfcn(gui_State, varargin{:});

Error in @(hObject,eventdata)TSAF('forecast_Callback',hObject,eventdata,guidata(hObject))


Error while evaluating uicontrol Callback

What could be the problem?

excellent work

Iman

Thanks a lot Yacine.

Very helpful and complete GUI as a student it helped me a lot, keep the good work,

Iman

Hi Mustapha. I am sorry to hear about the problem with TSAF. I changed something in the initialization part of the code which I think might be problematic. The new version is uploaded here. Could you please delete the old version of TSAF and download the new one? Please run it again, and let me know if you still get the same error message.

Thank you for your valuable time and helping me find the bugs in TSAF.

Thanks for the GUI. When I import my twelve points data from excel into TSAF I get the follwing error message "selected column contains no data!". When I input "arima(1,1,1)" at the Matlab prompt it ran quite well.

Iman

Hi Christian, thank you for using TSAF. You cannot directly use a variable in TSAF, but it is super easy to save the variable as an excel file. Here is an example:

a=[1 2 3 4 5 6].'; % the variable
delete('test.xlsx')
xlswrite('test.xlsx',a)

The variable is now saved in an excel file named test. You can find this file in the current directory of MATLAB. If you don't know where the directory is, just execute "pwd" in the command line. Please let me know if you need more help.

Christian

Can I use a matlab variable instead of importing an excel file???

Iman

@Nima, Thank you for using TSAF.

Nima

TSAF is awesome :) Thanks a million Iman for your great tutorials and effort ! Good Luck

Nima

Iman

Awesome. Thanks for using TSAF.

Hi Iman, Thank you so much for the help. The problem is solved. I get in touch in case of a new problem!
Thanks again and good luck.

Iman

Hi Mahsa. No wirries. Did you follow the instructions that I provided at the top of this page (Description section)? I can help you on the phone/skype. Please send me an emai to imanmoaz@uvic.ca and we can set up a time.

Hi Iman,
Thank you so much again. I am using matlab2015 and I have installed Econometrics Toolbox but when I write TSAF it says that it is undefined!
what should I do?
I really appreciate your answer.

Iman

Hi Mahsa. My pleasure to help. Actually missed data sometimes can be problematic.If you are missing a few observations, that wouldn't be a big deal but make sure that you remove empty cells from the excel file before using TSAF. If it is time-consuming to find and remove empty cells you can easily do it with a few lines of code. If you need more help please let me know.

Thank you so much Iman, very helpful!
Just one other question, what if there are some missed data? Can we just simply put an empty cell in the column?
I mean the periods between all data should be the same, like one year (because there is just 1 column which is for example the number of accidents for each year) but how should I bring into the analysis a data that is missed in one year?
Thank you so much for your answer.

Iman

Hi Mahsa, You can import excel files (csv, xls, xlsx) in TSAF. Data must be stored columnwise, i.e. each column is corresponding to the observations of one random variable.

If you download the package, you can see three examples in the "test folder". When there is just one column of data, TSAF automatically import that column (like the examples in the test folder). But if there are more than one columns, TSAF will ask you which column you want to work with.

Please let me know if my explanation is not clear. Thank you for using TSAF.

Hello,

Would you please let me know how is the Data file you imported to TSAF? What did it include?

Thanks

Iman

Thanks for using my GUI. Don't forget to rate BTW :)

Amir Feyzi

You're right. This solved the error. Thanks.
Good job, BTW.

Iman

Amir, Sorry for the trouble. I guess you don't have "Econometrics Toolbox" or your license for this toolbox has been expired.

Please run "arima(1,1,1)" in the command line and let me know if you get an error. If so, you have the aforementioned issue. In this case, you can download, the free trial version of "Econometrics Toolbox" and use the GUI.

Amir Feyzi

Mentioned problem exists on MATLAB 2015 not on the previous versions.

Amir Feyzi

Running test data produces an error, "Selected column containts no data!,"
and the functions do not work.
The error in command line:
Error while evaluating UIControl Callback

Reference to non-existent field 'data'.

Error in TSAF>pushbutton11_Callback (line 1354)
x=handles.metricdata.data;

Error in gui_mainfcn (line 95)
feval(varargin{:});

Error in TSAF (line 42)
gui_mainfcn(gui_State, varargin{:});

Error in
@(hObject,eventdata)TSAF('pushbutton11_Callback',hObject,eventdata,guidata(hObject))


Error while evaluating UIControl Callback

Updates

1.3

resolving the size issue

1.2.0.0

file update

1.2.0.0

description update

1.2.0.0

Summary update

1.2.0.0

File update.

1.2.0.0

description update.

1.2.0.0

description update.

1.2.0.0

description update.

1.2.0.0

description update.

1.2.0.0

adding youtube channel

1.2.0.0

description update.

1.2.0.0

description update.

1.2.0.0

Description update.

1.2.0.0

description update.

1.2.0.0

Description Update.

1.2.0.0

Description update.

1.2.0.0

Description update.

1.2.0.0

Replacing "imshow" with "image" command

1.2.0.0

Description Update.

1.2.0.0

bug fixed.

1.1.0.0

Description Update.

1.1.0.0

Bug fixed.

1.1.0.0

Description Update.

1.1.0.0

Description Update.

1.1.0.0

File Update.

1.1.0.0

Description Update.

1.1.0.0

In the new version, minimum and maximum values for the forecast can be set.

1.0.0.0

Description Update.

1.0.0.0

Description Update.

1.0.0.0

Description Update.

1.0.0.0

Description Update.

1.0.0.0

Checking availability of the required product (Econometrics Toolbox).

1.0.0.0

Description Update.

1.0.0.0

Description Update.

1.0.0.0

Update Description.

1.0.0.0

Description Update.

1.0.0.0

Test folder is added.

MATLAB Release Compatibility
Created with R2013b
Compatible with any release
Platform Compatibility
Windows macOS Linux