CC

Row

CONSUMER CONFIDENCE

ARIMA

EXCHANGE

Row

Exchange

ARIMA

SAHAM

Row

Saham

ARIMA

GDP

Inflasi

Interest

Unemployement

---
title: "EKONOMETRIKA"
author: "DHELA AGATHA"
output: 
  flexdashboard::flex_dashboard:
    orientation: rows
    social: menu
    source_code: embed
---


```{r}
# Print the current working directory
# Read an Excel file located in the current working directory
library(readxl)
library(forecast)
library(dplyr)

consumerconfidence <- read_excel("C:/data ekonom/CONSUMER_CONFIDENCE_FIX.xlsx")
exchange <- read_excel("C:/data ekonom/EXCHANGE_RATE_FIX.xlsx")
gdp <- read_excel("C:/data ekonom/GDP_FIX.xlsx")
saham <- read_excel("C:/data ekonom/INDEX_SAHAM_FIX.xlsx")
inflasi <- read_excel("C:/data ekonom/INFLATION_FIX.xlsx")
interest <- read_excel("C:/data ekonom/INTEREST_FIX.xlsx")
unemployement <- read_excel("C:/data ekonom/UNEMPLOYEMENT_FIX.xlsx")

soal2 <- tibble::tibble(consumerconfidence,
                        exchange = as.numeric(exchange$exchange_rate),
                        gdp = as.numeric(gdp$GDP),
                        saham = as.numeric(saham$index_saham),
                        inflasi = as.numeric(inflasi$Inflation_Rate),
                        interest = as.numeric(interest$Interest_Rate),
                        unemployement = as.numeric(unemployement$Unemployement_Rate))

sample_data <- tibble::tibble(
  Date =   seq.Date(from = as.Date("2010-01-01"), to = as.Date("2021-12-01"), by = "1 month"),
  Value =  as.numeric(exchange$exchange_rate)
)


CC.ts <- ts(soal2$consumer_confidence, start = c(2010, 1), frequency = 12)
CC.ts1 <- data.frame(Date = time(CC.ts), Value = as.numeric(CC.ts))


EX.ts <- ts(soal2$exchange, start = c(2010, 1), frequency = 12)
EX.ts1 <- data.frame(Date = time(EX.ts), Value = as.numeric(EX.ts))


saham.ts <- ts(soal2$saham, start = c(2010, 1), frequency = 12)
saham.ts1 <- data.frame(Date = time(saham.ts), Value = as.numeric(saham.ts))


gdp.ts <- ts(soal2$gdp, start = c(2010, 1), frequency = 12)
gdp.ts1 <- data.frame(Date = time(gdp.ts), Value = as.numeric(gdp.ts))


inflasi.ts <- ts(soal2$inflasi, start = c(2010, 1), frequency = 12)
inflasi.ts1 <- data.frame(Date = time(inflasi.ts), Value = as.numeric(inflasi.ts))


interest.ts <- ts(soal2$interest, start = c(2010, 1), frequency = 12)
interest.ts1 <- data.frame(Date = time(interest.ts), Value = as.numeric(interest.ts))


unemp.ts <- ts(soal2$unemployement, start = c(2010, 1), frequency = 12)
unemp.ts1 <- data.frame(Date = time(unemp.ts), Value = as.numeric(unemp.ts))

```

CC
=======================================================================

Row
-----------------------------------------------------------------------

### CONSUMER CONFIDENCE

```{r}
library(ggplot2)
library(plotly)
library(plyr)
library(flexdashboard)



a<-   plot_ly(CC.ts1, x = ~Date, y = ~Value, type = 'scatter', mode = 'lines') %>%
      layout(title = "Time Series Consumer Confidence",
             xaxis = list(title = "Date"),
             yaxis = list(title = "consumer confidence"))

b<-   plot_ly(EX.ts1, x = ~Date, y = ~Value, type = 'scatter', mode = 'lines') %>%
      layout(title = "Time Series Exchange Rate",
             xaxis = list(title = "Date"),
             yaxis = list(title = "Exchange Rate"))

c<-  plot_ly(saham.ts1, x = ~Date, y = ~Value, type = 'scatter', mode = 'lines') %>%
      layout(title = "Time Series Indeks Saham",
             xaxis = list(title = "Date"),
             yaxis = list(title = "Indeks Saham"))

d<-   plot_ly(gdp.ts1, x = ~Date, y = ~Value, type = 'scatter', mode = 'lines') %>%
      layout(title = "Time Series GDP Growth",
             xaxis = list(title = "Date"),
             yaxis = list(title = " GDP"))

e <-    plot_ly(inflasi.ts1, x = ~Date, y = ~Value, type = 'scatter', mode = 'lines') %>%
      layout(title = "Time Series Plot",
             xaxis = list(title = "Date"),
             yaxis = list(title = "Inflation Rate"))

f <-   plot_ly(interest.ts1, x = ~Date, y = ~Value, type = 'scatter', mode = 'lines') %>%
      layout(title = "Time Series Interest Rate",
             xaxis = list(title = "Date"),
             yaxis = list(title = "Interest Rate"))

g <-   plot_ly(unemp.ts1, x = ~Date, y = ~Value, type = 'scatter', mode = 'lines') %>%
      layout(title = "Time Series Unemployement Rate",
             xaxis = list(title = "Date"),
             yaxis = list(title = "Unemployement Rate"))



ggplotly(a)
```


### ARIMA

```{r}

library(forecast)
library(xts)
fit <- auto.arima(EX.ts)

fcast <- forecast(fit, h = 12) 

library(plotly)
plot_ly() %>%
  add_lines(x = time(EX.ts), y = EX.ts, name = 'Original') %>%
  add_lines(x = time(fcast$mean), y = fcast$mean, name = 'Forecast') %>%
  add_ribbons(x = time(fcast$mean), ymin = fcast$lower[, 2], ymax = fcast$upper[, 2], name = '95% Confidence Interval', fill = 'tonexty', opacity = 0.2)


```


EXCHANGE
=======================================================================

Row
-----------------------------------------------------------------------

### Exchange

```{r}
ggplotly(b)
```

### ARIMA

```{r}

library(forecast)
library(xts)
fit <- auto.arima(CC.ts)

fcast <- forecast(fit, h = 12) 

library(plotly)
plot_ly() %>%
  add_lines(x = time(CC.ts), y = CC.ts, name = 'Original') %>%
  add_lines(x = time(fcast$mean), y = fcast$mean, name = 'Forecast') %>%
  add_ribbons(x = time(fcast$mean), ymin = fcast$lower[, 2], ymax = fcast$upper[, 2], name = '95% Confidence Interval', fill = 'tonexty', opacity = 0.2)


```

SAHAM
=======================================================================

Row
-----------------------------------------------------------------------

### Saham

```{r}
ggplotly(c)
```

### ARIMA

```{r}

library(forecast)
library(xts)
fit <- auto.arima(saham.ts)

fcast <- forecast(fit, h = 12) 

library(plotly)
plot_ly() %>%
  add_lines(x = time(saham.ts), y = saham.ts, name = 'Original') %>%
  add_lines(x = time(fcast$mean), y = fcast$mean, name = 'Forecast') %>%
  add_ribbons(x = time(fcast$mean), ymin = fcast$lower[, 2], ymax = fcast$upper[, 2], name = '95% Confidence Interval', fill = 'tonexty', opacity = 0.2)


```


# GDP
```{r}
ggplotly(d)
```

# Inflasi
```{r}
ggplotly(e)
```

# Interest
```{r}
ggplotly(f)
```

# Unemployement

```{r}
ggplotly(g)
```