# 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 practical forecasting model techniques 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 and investigate 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.`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`

. To know what type of time series object `theft_ts`

data, subset it which contains the first 10 years using `head()`

and visualize it with `autoplot()`

from `forecast`

package and answer the first question. Remember, when you subset it, please do not store it into an object, just visualize it.

```
# your code here
```

- Which statement below is
**TRUE**based on the time series plot above?- [ ]
`theft_ts`

is additive because the seasonality pattern is rather constant across the observed period - [ ]
`theft_ts`

is multiplicative because as the trend increases, the amplitude of seasonal activity is also increases - [ ] there is no seasonal pattern in
`theft_ts`

- [ ]

# Decompose

After we make the time series object for our `theft`

data, we inspect our time series element of our `theft_ts`

data. We want to look at the trend and seasonality pattern to choose the appropriate model for forecast `theft_ts`

data. We can use `decompose()`

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

.

```
# 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 trends 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 you split the `theft_ts`

into `train`

and `test`

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
```

- If your answer is yes, using Holt-Winters as a model, which is the most appropriate code to model the
`theft_ts`

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 and set the method argument as `arima`

then store it as `model_arima`

object.

```
# your code here
```

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

- Based on the explanation above, which of the 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`

model, try forecasting 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`

.

# Model Evaluation (Erorr)

Now that we have the forecasting results from the Holt-Winters model and ARIMA model. We can now evaluate our model, find the MAPE (mean absolute percentage error) value between our forecast result and our `test_theft`

data. Please evaluate both models with MAPE using `accuracy()`

function and from the `forecast`

package.

```
# your code here
```

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

# Model evaluation (Assumption Checking)

There are some assumptions when we use the time series analysis. These assumptions are used to make our model reliable to predict the real data.

- To make sure that our forecasting model is reliable enough, 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 the following statement is
**TRUE**about the no-autocorrelation assumption of the time series model?- [ ] there is no autocorrelation in error, means each error does not have any relation
- [ ] there is autocorrelation in error, means each error have relation
- [ ] there is autocorrelation of each prediction data, means each predicted data have relation
- [ ] there is no autocorrelation in each prediction data, means 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