# Time Series and Forecasting Quiz

This quiz is part of Algoritma Academy assessment process. Congratulations on completing the Time Series and Forecasting course! We will conduct an assessment quiz to test the practical forecasting model techniques that you have learned on the course. The quiz is expected to be taken in the classroom, please contact our team of instructors if you missed the chance to take it in class.

# Data Exploration

In this quiz, you will use the Chicago Crime dataset. The dataset contains real-time historical data of the various types of crime in the city of Chicago. This dataset was downloaded from Chicago Data Portal and has been filtered for the primary type of crime "THEFT". The data is stored as a `.csv`

file in this repository as `theft-ts.csv`

.

Please load the data given `theft-ts.csv`

and assign it to `theft`

object, then investigate the data using `str()`

or `glimpse()`

function.

```
# your code here
```

The `theft`

data consists of 6,492 observations and 2 variables. The description of each feature is explained below:

`Date`

: Date when the incident occurred (recorded daily).`Amount_Theft`

: The total amount of theft on each date.

As a data scientist, you will develop a forecasting model that will aid security and other concerned parties in the decision-making process. Based on our data, we want to forecast the number of theft incidents (`Amount_Theft`

). The purpose is to anticipate any crime activities on the given date and help security parties to allocate a proper amount of resources in the city of Chicago.

Before we make a forecasting model, let us first inspect our data. Is our data a time series object? If not, please make a time series object using the `theft`

data using `ts()`

function with the frequency of this period is 365 and store it under `theft_ts`

.

- Time series data has several characteristics. Based on your knowledge on time series, which of the following statement is
**TRUE**?- [ ] Additive time series is additive because the amplitude of seasonal activity increases across the observed period.
- [ ] Multiplicative time series is multiplicative because as the trend increases, the amplitude of seasonal activity also increases.
- [ ] Time series data has no trend, seasonality, and error pattern.

To know the characteristics of our time series object we can visualize it using plot. For example, you can subset `theft_ts`

to obtain the first 10 years of data using `head()`

and visualize it with `autoplot()`

from `forecast`

package.

*Note: When you subset the ts object, you don't need to store the result into an object. You can directly visualize it.*

```
# your code here
```

# Decompose

After we make the time series object `theft_ts`

, we can inspect its time series element. Try to look at the trend and seasonality pattern of the data to choose the appropriate model in forecasting `theft_ts`

data. We can use `decompose()`

to inspect the trend, seasonality, and error of our time series data and visualize them using `autoplot()`

. Use the parameter `type = "multiplicative"`

when decomposing the data to assume that the data is a multiplicative time series.

```
# your code here
```

- Based on the decompose plot, how is the trend pattern of
`theft_ts`

?- [ ] there's no trend
- [ ] the trend is increasing
- [ ] the trend is decreasing

# Cross Validation

We have looked at the trend and seasonality of our `theft_ts`

data. The next step is to build our time series model. However, we should split the dataset into training and test data before we make a model. In this section, please split the `theft_ts`

data into `test_theft`

which contains the last 365 days of our data using `tail()`

function, and use the rest as `train_theft`

using `head()`

function.

```
# your code here
```

# Time Series Modeling

After splitting the `theft_ts`

into `train_theft`

and `test_theft`

data, please inspect the trend and seasonality pattern of `train_theft`

data.

```
# your code here
```

- Based on the decomposition plot, is it appropriate to use the Holt-Winters model? Why?
- [ ] Yes, because the plot consists of trends and seasonality
- [ ] No, it's more appropriate to use Holt's Exponential Smoothing
- [ ] No, because we only focus on the trend, therefore, it is more appropriate to use Single Moving Average (SMA)
- [ ] Yes, because the plot only consist of seasonality

After we analyze the decomposition result of `train_theft`

, we are ready to build our model. Let's build our first model using Holt-Winters algorithm. You can use `HoltWinters()`

function and store it under `model_hw`

object.

```
# your code here
```

- Using Holt-Winters as a model, which is the most appropriate code to model the
`train_theft`

data?- [ ] HoltWinters(train, gamma = F)
- [ ] HoltWinters(train)
- [ ] HoltWinters(train, beta = F)
- [ ] HoltWinters(train, beta = F, gamma = F)

Let's explore another method to forecast our `train_theft`

data using the ARIMA algorithm. Let's build an ARIMA model using `stlm()`

function, set the method argument as `method = arima`

and don't forget to set the `s.window`

argument based on your time series frequency then store it as `model_arima`

object.

```
# your code here
```

ARIMA is a statistical model to forecast time series object. It stands for AR(autoregressive) I (integrated) MA (moving average).

- Based on the explanation above which of this following statement is
**TRUE**about ARIMA(p,d,q)?- [ ] the time series object is being differenced q times to make it stationary
- [ ] p is the number of orders you can use to determine the process of making an Autoregressive model
- [ ] d shows the number of time in 1 frequency
- [ ] p shows the amount of data for smoothing error using Moving Average

# Forecasting

On the previous section, we have built a forecasting model using Holt-Winters and ARIMA. Using `model_hw`

and `model_arima`

, try to forecast the theft frequency for the following 365 days using `forecast()`

function. Store the result from `model_hw`

in `hw_forecast`

and `model_arima`

in `arima_forecast`

.

```
# your code here
```

# Model Evaluation (Error)

Now we have the forecast result of the Holt-Winters and ARIMA model. To evaluate our model, find the MAPE (mean absolute percentage error) value between our forecast result and our actual `test_theft`

data. Please find each MAPE value from both model using `accuracy()`

function from `forecast`

package.

```
# your code here
```

## Model Evaluation Quiz

- Based on the result, which of the following statement is
**TRUE**?- [ ] using ARIMA model, the mean absolute percentage error is 11.6%
- [ ] using Holt-Winters model, the mean absolute percentage error is around 11.6 theft event
- [ ] The difference of mean absolute percentage error between ARIMA and Holt-Winters model is 0.53%

# Model Evaluation (Assumtion Checking)

There are several assumptions to check when performing time series analysis. These assumptions are used to make our model reliable to predict the real data.

- What assumption should we check in the time series analysis?
- [ ] Multicollinearity, No-Autocorrelation
- [ ] No-Autocorrelation, Normality
- [ ] Linearity, No-Autocorrelation
- [ ] Heteroscedasticity, No-Autocorrelation

Please check the assumption of no-autocorrelation from your models using Ljung-Box Test.

```
# your code here
```

- Which of this following statement is
**TRUE**about the no-autocorrelation assumption of our time series model?- [ ] there is no autocorrelation in error, meaning that each error have no relation
- [ ] there is autocorrelation in error, meaning that each error have a relation
- [ ] there is autocorrelation in the prediction data, meaning that each predicted data a have relation
- [ ] there is no autocorrelation in the prediction data, meaning that each predicted data have no relation

### Users with passing score on time-series

- ysitta
- NabiilahArdini
- wulanandriyani
- ssendifx
- maswin312
- abraham-sys
- szicoc
- john-81
- fadhilahm
- jonglisasilaban
- smaratusr
- valdywiratama
- fprasetyoyuwono
- auffan
- leonardyhh
- elmoudy
- rafael9rfl
- dhaneswaramandrasa
- dvsezr
- UmiNurambarini
- alfanaminulloh
- redsynwa
- t3981-h
- Meeps50
- tohodss
- brian-santoso
- wuriwd
- raihandwisatria
- fanipristama
- fabuloskoala
- HafniMarfuah
- mqolbun
- awlaksono
- vg2207
- arleneazaria
- lazuardy85
- Serbukcabe
- Lennywibisana
- kaniakenz
- jimmytandri
- sabrinaidavita
- aprzz
- hardiyanto249
- wkaniar
- giovanniabel-abel
- blackmiracle91
- Danamonbisa
- rickysaputra12345
- tiwici
- gulistiani
- christianregensius
- budipriswanto
- dimartana
- blessedivn
- Wild-Great-Hornbill
- ulinnuha27
- andreasliu
- Khacand13
- ryns07
- abdinulinnuha
- christianusangga
- DeepDreamCode
- Argaadya
- HengkyNg
- RPD1204
- deomareza
- blankAD
- katashtrophes
- utomoreza
- isaacedwin
- dniarastuti
- maddew820
- alfandash
- putrantolucky
- septu-kor
- taufik-arfani
- dinnah88
- rogate16
- ropi225
- justedgar
- indraa6
- christyonathan
- princewolf
- vlyoir
- ajiputera
- Wawanp2020
- yufiyufi
- BLN42
- alfadodhusi
- satrioadarmawan
- ezrasote
- leimk
- reksiandari
- denifajarsidiq
- endtrisk
- drafitrandi24
- aguscuk
- rinaldoeri
- enggal21
- meinari
- sinnersia
- ekamuliawan
- gabrielerichson2019
- dikdik7
- koraji
- wiwiekwinarta
- yevonnaelandrew
- dwinandahtm
- tomytjandra
- kulturaco
- promenimus
- farishisyam
- valencialie11
- bitra
- yoannaevelina
- bachtiarj15
- johnramsky2
- onlyyouandme
- muhrisman
- rhidayats
- muslimalfatih
- aerlaut
- taryonb
- wennykezia
- aderahman01
- nhrs
- verawaty77
- riarizki
- damarbrian
- AlfaAbbas
- justarya
- johannaritonang
- Jodialanshari13
- Stefen-Li
- cockaigne
- hamdanalim
- ddtambunan
- ronniegoei
- Nhhhs
- atikadw95
- dpermanads
- novanrz
- marcelladjuhana
- AntoniusAndr3
- orangefly000bf42cec66f1a465f
- orangefly01
- orangefly013310b125fe6b47cd
- a13nma
- Briantino
- rulianto26
- ferry-tan
- okinawarikenata
- ysetiadji
- barsyagallery
- rjputra
- lianamutz
- algoritmalover
- randylawrentius
- cindytanjung
- u051227
- sianadewi
- yulialanita
- apadityo
- glenjosh11
- eligunawan
- staciagun
- rendi27
- hartonomochtar
- sarasdew
- SatriaSyah
- IbnuDessetiadi
- ayuputrivd
- sndypvtra
- RitaLie
- wulaidazuhriana
- HANIASRI
- ahmadhusain
- minichieff
- hermy-santoso-halim
- ignatiuskevinnn
- adamhafid
- franscaharris
- rezalutfi40
- travelogy-project
- Lbthn
- PratamaAgung
- hizom
- rauldatascience
- Bonnie-Alexandra
- fathonirisman27
- wahyuindrasukma
- mhasyim
- teukuaidilfikri
- sabrinapribadi
- nadyapribadi
- davedaveit
- tommy9981
- jansgerald
- Adityawicaks
- paulpanggabean
- armangetter
- imanuel-code
- nurfitryah
- Vraha
- sayaberani
- petrusardi
- ranggata
- aldobritano2812
- hendrasyahputrarahul
- dwisyanto
- EndiWicaksono
- eoktavianus
- achmadanr
- gitgungun
- mituspens
- vtFaded
- Gods-Killer
- 93kryptonian
- tomy-algo9f7a9ca6f5d34cda
- friandhiazaki
- sarahningtyas
- grendy
- Jengkol117
- alfa-dharmawijaya
- mithalearn
- maltesedena
- Gevinferdinand
- fairuzalief
- krisnadw
- graceshela-wirawaty
- fchriselly
- thomaslimanjaya
- 18213020-18213038
- jessicanathania95
- alvianojs
- abadeus
- reyshabigael
- laksmini
- perceus838
- poctaviana
- evelinalarisa
- kurniawanbdiono
- Devanew
- fransiskahuang
- rizkameutia
- geraldbryan
- erikatrisliana
- FinCendikia
- erlywind
- haphapy
- exozkvn
- PetBI
- StellaLie30
- Sellayenti
- Dnx220
- ameliaclara
- Aprilioan
- hadeskun025
- teddynilam
- Cls2kuis
- Titangemez
- maulanaarif8894
- titatata06
- noviarinanti
- metamahyarani
- TB-BankIndonesia
- vsebas7
- Pozwa
- bambangcrot
- AnnisaAuliaRahma
- shadowmirza
- ichlasulamal12
- niamzaki
- trialista
- githubuser273
- marniblewah
- Ichakristy
- dwiuzila
- ianrahardian
- iqbal1201
- sinduttv
- haridinatafelix
- RachelSinondang
- aldien03
- chuun17
- isew25
- ekapranadanian
- gissellanadya
- feruzta
- rickyliejaya
- thekarlharyo
- doddyabe
- FadhlanRahim
- monica-aw
- jimihendrik808
- PatricioKresnatama
- muhammadrmaulana
- RayAdisurya
- jeremiahutagodang
- winlywilliamdy
- alvinwillio
- DavidSamuel295
- bagasmw
- Madeleeine
- MARYANTO1803
- klaudiuswp
- margarethdevina
- maltreba
- fauzanalamsyah
- djogie23
- nisa-basalamah
- codingchanges
- hotsince99
- luthfriandi
- prestasicode
- andrewmlpt
- galtaufiq
- ekonugroho99
- DebrinaSugiharto
- bdpriyambodo
- reyvb24
- jtsimanjuntak
- julius987
- edwinandreash
- anggasbs
- fadtau
- VitoSS10
- cherr1412
- difapratama
- Vae2002
- wildanfirdaus26
- terkoizmy
- harudini
- Astrowests
- adisaksonoo
- Penny1919
- infra-429
- yanawicaksana
- fajardwinugroho
- hsnHdyt
- Pamboedi
- AngginiDina
- lugita
- corgia
- tomythoven
- vyndic
- prima850
- gustavothiodorus
- calvincetus
- stefkim
- sayyidmquthb
- januhajj
- RahmanOhoirenan19
- ikasulistiorini
- eldoranadel
- keenwizard
- stanvgee
- phinewijaya
- iwky77
- brianthadius
- CyndyRomarizka08
- sanisapascaline
- adam1004-gif
- yuyakuchiki
- bayualansyah
- magic-ardy
- chandraharry
- rarizukii
- feliciahaliman
- juanjosua
- samsinar
- baypsil
- rejaaa
- syabaruddin
- bunchofcodes
- VictorNugraha
- defriandwk
- Bataraparimpin
- palver7
- watashiwamaru
- mutiaree
- luthfisoni
- ibnucas
- ekonfy
- Danielown
- kylajsmine11
- bayuraka
- RickyDoesCode
- anasofiia
- EngSun-Oei
- nobohiko-svg
- gashasp
- rifkynovrian
- laurandretha
- dedygs26
- tprasetyo
- zulkarnain17
- bayurespatiyulianto
- strwaskita
- rendiff
- musthofasyarifudin
- ZainulArifin1
- raymond2910
- Wizyth20
- AnggaPramana
- Jatmiko9
- radenredi
- rizuchaa
- sumberpocong
- vlanvlan
- bhagaskara1997
- kvnwhyd
- janetfelita
- Anvil-28
- ariefrachmady
- Triuning
- asep818
- richyrich14
- godointan
- diancharlovalentine
- YeadyTiffano