Tag: R
-
Day 64
Volatile Model (ARCH & GARCH) Technique to address irregular fluctuation that cannot be handle by typical time series model such as ARIMA, Moving Average, Exponential Smoothing & others. R Import data. (download from https://finance.yahoo.com/quote/005930.KS/history) Check order of differencing. Result: Stationary check after differencing. Result: Check stationary and ARIMA hyperparameter. Result: Train an ARIMA model. Check…
-
Day 63
Tutorial 4 Question 1 The table below shows the result after fitting a time series data by an ARIMA model. (a) Write the ARIMA model equation based on the results above. (b) Represent the ARIMA model in ARIMA (p, d, q). (c) Is the ARIMA model adequate? Justify your answers. (d) Are all the AR…
-
Day 62
Box Jenkins Methodology (Recap) Split the below data into training (80%) and testing data (20%). Analyse the training data and formulate the model equation for the ARIMA model you chosen: Then, compute the accuracy of the model in the testing data. Check the residuals and test whether the model you chosen is satisfactory. Sales Import data. Split Train/Test. Check stationary and…
-
Day 61
Box Jenkins Methodology A step by step process to identify and fitting ARIMA model hyperparameter; as the model itself has 3 main component: In R, the model will be wrote as ARIMA (data, order=c(p aka [AR], d aka [I], q aka [MA])). ARIMA rely on stationary data; throw back to Day 56, there are 4…
-
Day 60
Measuring Predictive Accuracy Raw data (only for illustration) X Y Forecast Value 1 0.3324 1 2 2.9232 2 3 1.4348 3 4 4.0073 4 5 3.7612 5 6 5.1456 6 7 8.1008 7 8 8.3195 8 9 8.4495 9 10 10.9755 10 11 12.1784 11 12 13.6671 12 13 14.6767 13 14 17.7715 14 15…
-
Day 59
Recap. Differencing vs smoothing = differencing is about removing trend from time series, by “station” the data back to its mean; smoothing in the other hand focus on removing irregular signal to uncover pattern (trend & seasonality). Tutorial 2 Question 1 (a) Compute a three-quarter moving average forecast for quarters 4 through 13. (b) Compute…
-
Day 58
Smoothing Techniques (Con’t) Regression on seasonality and trend Linear Regression VS Trend Component Multi-Linear Regression VS / to handle Seasonality Component Using dummy encoding to handle season. 3 dummy to handle quarterly, 11 dummy to handle monthly. Excel 1. Raw Data; Predict Year 6. Season Year 1 Year 2 Year 3 Year 4 Year 5…
-
Day 57
Smoothing Techniques Techniques Focus on Moving Average Stationary / Irregular Component Weighted Moving Average Exponential Moving Average Modified Moving Average Exponential Smoothing Holts Method Trend Component Linear / Quadratic / Exponential Trend Decomposition Model Seasonal + Trend Component Holts Winter Smoothing Dummy variable + Regression ps. Most of the time series forecast technique are under…
-
Day 56
Time Series 4 Components that made up time series 1. Irregular fluctuations – Does not follow any available pattern and not predictable; normally short period. Eg. Rise in the steel due the strike in the factory. 2. Cyclical – Large sine wave cycle about 8-10 year. Exhibit 4 phases (Peak → Recession → Depression →…
-
Day 55
Objective of time series Time Series Chart Excel 1. Raw Data Year Quarter 1 Quarter 2 Quarter 3 Quarter 4 1 667 631 675 699 2 739 695 751 779 3 823 795 835 875 4 931 855 939 967 2. Copy & paste again but holding “Ctrl” button3. Click on “Transpose” button 4. Copy…
-
Day 12 (2)
Perks! Add “dplyr” package to enable following function select(variable_name, column_name) → similar like SQL select, can perform column alias, range column name, start/end with column name and exclude column. Result: filter(variable_name, condition) → single or multiple logical condition; similar to subset(). Result: mutate(variable_name, column_name) → create, edit or delete column (fill value with NULL). Result:…
-
Day 10 (2)
Data Structure (con’t) data.frame(data) → two dimension, multiple datatype Result: Add data rbind(variable_name, variable_name) Result: cbind(variable_name, variable_name) Result: Import data read.csv(file_path, header=TRUE/FALSE) Access column Result: Delete column Result: Data frame function nrow(variable_name) Result: 4 ncol(variable_name) Result: 3 dim(variable_name) Result: names(variable_name) Result: head(variable_name, quantity) Result: tail(variable_name, quantity) Result: list(data) → multi dimension, multiple datatype Result:
-
Day 9 (2)
Data Structure the way how to store data in memory. For example, store data in matrix form, 5row x 3column. factor(data,levels,labels) → single dimension, kinda like relational database dim::fact concept Result: so what happen here is that data is “a”, “a”, “b”, 1. But due to levels parameter, “1” is remove to end and all…
-
Day 5 (2)
Condition ==,<,<=,>,>=,!= → boolean operators if/else Result: switch → if not integer/index, must define result. Result: out of condition return NULL Result: for Result: while Result: repeat Result:
-
Day 2 (1)
UI in R Studio Code Code reusability, introduce “package”, which is a public directory from CRAN. also similar to Operation+,-,*,/,%% → Basic Maths operatorsfirst *, / later +, – → Operator Precedence=, ->, <-, assign → variable declarationsrm(<<variable name>>), remove(<<variable name>>) → remove a variableclass → to tell datatypes(numeric,integer,character,logical,date)is.<<datatype>>(<<variable name>>) → checking/testing/validation the data typeas.<<datatype>>(<<variable…
