# Load required libraries
library(readxl)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(stringr)
library(lubridate)
##
## Attaching package: 'lubridate'
## The following objects are masked from 'package:base':
##
## date, intersect, setdiff, union
library(PerformanceAnalytics)
## Loading required package: xts
## Loading required package: zoo
##
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
##
## ######################### Warning from 'xts' package ##########################
## # #
## # The dplyr lag() function breaks how base R's lag() function is supposed to #
## # work, which breaks lag(my_xts). Calls to lag(my_xts) that you type or #
## # source() into this session won't work correctly. #
## # #
## # Use stats::lag() to make sure you're not using dplyr::lag(), or you can add #
## # conflictRules('dplyr', exclude = 'lag') to your .Rprofile to stop #
## # dplyr from breaking base R's lag() function. #
## # #
## # Code in packages is not affected. It's protected by R's namespace mechanism #
## # Set `options(xts.warn_dplyr_breaks_lag = FALSE)` to suppress this warning. #
## # #
## ###############################################################################
##
## Attaching package: 'xts'
## The following objects are masked from 'package:dplyr':
##
## first, last
##
## Attaching package: 'PerformanceAnalytics'
## The following object is masked from 'package:graphics':
##
## legend
library(forecast)
## Registered S3 method overwritten by 'quantmod':
## method from
## as.zoo.data.frame zoo
library(tseries)
library(car)
## Loading required package: carData
##
## Attaching package: 'car'
## The following object is masked from 'package:dplyr':
##
## recode
library(lmtest)
library(PortfolioAnalytics)
## Loading required package: foreach
## Registered S3 method overwritten by 'PortfolioAnalytics':
## method from
## print.constraint ROI
library(DEoptim)
## Loading required package: parallel
##
## DEoptim package
## Differential Evolution algorithm in R
## Authors: D. Ardia, K. Mullen, B. Peterson and J. Ulrich
library(reshape2)
library(ggplot2)
library(quadprog)
library(quantmod)
## Loading required package: TTR
library(rugarch) # Untuk GARCH-X
# Import BI Rate data
birate <- read_excel("Database/bi_rate.xlsx")
colnames(birate) <- c("date","bi_rate")
head(birate); tail(birate)
## # A tibble: 6 × 2
## date bi_rate
## <chr> <chr>
## 1 18 Desember 2024 6.00
## 2 20 November 2024 6.00
## 3 16 Oktober 2024 6.00
## 4 18 September 2024 6.00
## 5 21 Agustus 2024 6.25
## 6 17 Juli 2024 6.25
## # A tibble: 6 × 2
## date bi_rate
## <chr> <chr>
## 1 22 September 2016 5.00
## 2 19 Agustus 2016 5.25
## 3 21 Juli 2016 5.25
## 4 16 Juni 2016 5.25
## 5 19 Mei 2016 5.50
## 6 21 April 2016 5.50
# Replace date with month date from January 2005 - Desember 2025
Sys.setlocale("LC_TIME", "id_ID.UTF-8")
## [1] "id_ID.UTF-8"
birate <- birate %>%
mutate(date = dmy(date))
birate$bi_rate <- as.numeric(birate$bi_rate)
birate <- birate[order(birate$date), ]
head(birate)
## # A tibble: 6 × 2
## date bi_rate
## <date> <dbl>
## 1 2016-04-21 5.5
## 2 2016-05-19 5.5
## 3 2016-06-16 5.25
## 4 2016-07-21 5.25
## 5 2016-08-19 5.25
## 6 2016-09-22 5
# Import 10-year bond data
bond10 <- read.csv("Database/bond10.csv")
# Select only Date and Open.Price
bond10 <- bond10[, c("Tanggal", "Terakhir")]
# Rename columns to Open.Price and bond10
colnames(bond10) <- c("date", "bond10")
# Convert date to Date type and reoder from earliest to latest
bond10 <- bond10 %>%
mutate(date = dmy(date))
bond10 <- bond10[order(bond10$date), ]
bond10 <- bond10 %>%
mutate(bond10 = as.numeric(gsub(",", "", bond10)))
head(bond10)
## date bond10
## 2756 2014-01-02 8462
## 2755 2014-01-03 8550
## 2754 2014-01-06 9103
## 2753 2014-01-07 9124
## 2752 2014-01-08 9036
## 2751 2014-01-09 9017
# Import Bitcoin data
btc_usd <- read.csv("Database/btc_usd.csv")
# Select only Date and Open.Price
btc_usd <- btc_usd[, c("Tanggal", "Terakhir")]
# Rename columns to date
colnames(btc_usd) <- c("date", "btc")
# Convert date to Date type and reoder from earliest to latest
btc_usd <- btc_usd %>%
mutate(date = dmy(date))
btc_usd <- btc_usd[order(btc_usd$date), ]
btc_usd <- btc_usd %>%
mutate(btc = as.numeric(gsub(",", "", btc)))
head(btc_usd)
## date btc
## 4015 2014-01-01 7403
## 4014 2014-01-02 7750
## 4013 2014-01-03 8121
## 4012 2014-01-04 8018
## 4011 2014-01-05 9040
## 4010 2014-01-06 9345
# Import CPI data
cpi <- read_excel("Database/inflation.xlsx")
# Rename columns to date and cpi
colnames(cpi) <- c("date", "cpi")
# Daftar nama bulan Indonesia -> Inggris
bulan_id <- c("Januari","Februari","Maret","April","Mei","Juni",
"Juli","Agustus","September","Oktober","November","Desember")
bulan_en <- c("January","February","March","April","May","June",
"July","August","September","October","November","December")
# Ubah nama bulan ke bahasa Inggris, lalu parse jadi date
cpi <- cpi %>%
mutate(date = str_replace_all(date, setNames(bulan_en, bulan_id)),
date = parse_date_time(date, orders = "my"),
date = as.Date(date))
cpi <- cpi[order(cpi$date), ]
cpi$cpi <- as.numeric(cpi$cpi)
head(cpi)
## # A tibble: 6 × 2
## date cpi
## <date> <dbl>
## 1 2014-01-01 8.22
## 2 2014-02-01 7.75
## 3 2014-03-01 7.32
## 4 2014-04-01 7.25
## 5 2014-05-01 7.32
## 6 2014-06-01 6.7
# Import JKSE data
jkse <- read.csv("Database/jkse.csv")
# Select only Date and Open.Price
jkse <- jkse[, c("Tanggal", "Terakhir")]
# Rename columns to date and jkse
colnames(jkse) <- c("date", "jkse")
# Convert date to Date type and reoder from earliest to latest
jkse <- jkse %>%
mutate(date = dmy(date))
jkse <- jkse[order(jkse$date), ]
jkse <- jkse %>%
mutate(
jkse = str_replace_all(jkse, "\\.", ""), # hapus titik (pemisah ribuan)
jkse = str_replace_all(jkse, ",", "."), # ubah koma jadi titik (desimal)
jkse = as.numeric(jkse) # ubah jadi numeric
)
head(jkse)
## date jkse
## 2681 2014-01-01 4274.18
## 2680 2014-01-02 4327.27
## 2679 2014-01-03 4257.66
## 2678 2014-01-06 4202.81
## 2677 2014-01-07 4175.81
## 2676 2014-01-08 4200.59
# Import IDR exchange rate data
kurs_idr <- read.csv("Database/idr_kurs.csv")
# Select only Date and Open.Price
kurs_idr <- kurs_idr[, c("Tanggal", "Terakhir")]
# Rename columns to date and kurs_idr
colnames(kurs_idr) <- c("date", "kurs_idr")
# Convert date to Date type and reoder from earliest to latest
kurs_idr <- kurs_idr %>%
mutate(date = dmy(date))
kurs_idr <- kurs_idr[order(kurs_idr$date), ]
kurs_idr <- kurs_idr %>%
mutate(
kurs_idr = str_replace_all(kurs_idr, "\\.", ""), # hapus titik (pemisah ribuan)
kurs_idr = str_replace_all(kurs_idr, ",", "."), # ubah koma jadi titik (desimal)
kurs_idr = as.numeric(kurs_idr) # ubah jadi numeric
)
head(kurs_idr)
## date kurs_idr
## 2815 2014-01-01 12170.0
## 2814 2014-01-02 12160.0
## 2813 2014-01-03 12170.0
## 2812 2014-01-06 12180.0
## 2811 2014-01-07 12237.5
## 2810 2014-01-08 12235.0
# Gold data
gold <- read.csv("Database/gold.csv")
# Select only Date and Open.Price
gold <- gold[, c("Tanggal", "Terakhir")]
colnames(gold) <- c("date", "gold_idr")
gold <- gold %>%
mutate(date = dmy(date))
gold <- gold[order(gold$date), ]
gold <- gold %>%
mutate(
gold_idr = str_replace_all(gold_idr, "\\.", ""), # hapus titik (pemisah ribuan)
gold_idr = str_replace_all(gold_idr, ",", "."), # ubah koma jadi titik (desimal)
gold_idr = as.numeric(gold_idr) # ubah jadi numeric
)
head(gold)
## date gold_idr
## 2816 2014-01-02 1225.2
## 2815 2014-01-03 1238.6
## 2814 2014-01-06 1238.0
## 2813 2014-01-07 1229.6
## 2812 2014-01-08 1225.5
## 2811 2014-01-09 1229.4
## Monthly Data Aggregation and Preprocessing
# Load necessary packages
library(dplyr)
library(lubridate)
# Convert data to monthly format (for those that aren't already monthly)
# For bi rate - get monthly average
birate_monthly <- birate %>%
mutate(year_month = floor_date(date, "month")) %>%
group_by(year_month) %>%
summarise(bi_rate = mean(bi_rate, na.rm = TRUE)) %>%
rename(date = year_month)
# For bond10 - get monthly average
bond10_monthly <- bond10 %>%
mutate(year_month = floor_date(date, "month")) %>%
group_by(year_month) %>%
summarise(bond10 = mean(bond10, na.rm = TRUE)) %>%
rename(date = year_month)
# For btc_usd - get monthly average
btc_monthly <- btc_usd %>%
mutate(year_month = floor_date(date, "month")) %>%
group_by(year_month) %>%
summarise(btc = mean(btc, na.rm = TRUE)) %>%
rename(date = year_month)
# For jkse - get monthly average
jkse_monthly <- jkse %>%
mutate(year_month = floor_date(date, "month")) %>%
group_by(year_month) %>%
summarise(jkse = mean(jkse, na.rm = TRUE)) %>%
rename(date = year_month)
# For kurs_idr - get monthly average
kurs_idr_monthly <- kurs_idr %>%
mutate(year_month = floor_date(date, "month")) %>%
group_by(year_month) %>%
summarise(kurs_idr = mean(kurs_idr, na.rm = TRUE)) %>%
rename(date = year_month)
# For gold - get monthly average
gold_monthly <- gold %>%
mutate(year_month = floor_date(date, "month")) %>%
group_by(year_month) %>%
summarise(gold_idr = mean(gold_idr, na.rm = TRUE)) %>%
rename(date = year_month)
# For cpi - ensure it's monthly format
cpi_monthly <- cpi %>%
mutate(year_month = floor_date(date, "month")) %>%
group_by(year_month) %>%
summarise(cpi = mean(cpi, na.rm = TRUE)) %>%
rename(date = year_month)
# Merge all datasets
merged_data <- birate_monthly %>%
full_join(bond10_monthly, by = "date") %>%
full_join(btc_monthly, by = "date") %>%
full_join(cpi_monthly, by = "date") %>%
full_join(jkse_monthly, by = "date") %>%
full_join(kurs_idr_monthly, by = "date") %>%
full_join(gold_monthly, by = "date")
# Sort by date
merged_data <- merged_data %>% arrange(date)
# Check the result
head(merged_data)
## # A tibble: 6 × 8
## date bi_rate bond10 btc cpi jkse kurs_idr gold_idr
## <date> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 2014-01-01 NA 8746. 8194. 8.22 4350. 12158. 1244.
## 2 2014-02-01 NA 8702. 6605. 7.75 4515. 11918. 1301.
## 3 2014-03-01 NA 8061. 5929. 7.32 4720. 11416. 1337.
## 4 2014-04-01 NA 7908. 4620. 7.25 4871. 11431. 1299.
## 5 2014-05-01 NA 8003. 4829. 7.32 4925. 11536. 1288.
## 6 2014-06-01 NA 8088. 6179. 6.7 4898. 11892. 1283.
tail(merged_data)
## # A tibble: 6 × 8
## date bi_rate bond10 btc cpi jkse kurs_idr gold_idr
## <date> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 2024-07-01 6.25 6986. 62.9 2.13 7258. 16238. 2398.
## 2 2024-08-01 6.25 6714. 60.0 2.12 7417. 15735. 2474.
## 3 2024-09-01 6 6544. 60.5 1.84 7740. 15318. 2579.
## 4 2024-10-01 6 6699. 65.7 1.71 7621. 15558. 2695.
## 5 2024-11-01 6 6852. 86.5 1.55 7269. 15813. 2656.
## 6 2024-12-01 6 6994. 98.3 1.57 7216. 16036. 2650.
# Check for missing values
colSums(is.na(merged_data))
## date bi_rate bond10 btc cpi jkse kurs_idr gold_idr
## 0 27 0 0 0 0 0 0
# Data with non NA values
non_na_data <- merged_data %>%
filter(complete.cases(.))
# Check the non NA data
head(non_na_data)
## # A tibble: 6 × 8
## date bi_rate bond10 btc cpi jkse kurs_idr gold_idr
## <date> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 2016-04-01 5.5 7545 4352. 3.6 4853. 13172. 1244.
## 2 2016-05-01 5.5 7784. 4617. 3.33 4770. 13417. 1261.
## 3 2016-06-01 5.25 7660. 6445. 3.45 4871. 13338. 1279.
## 4 2016-07-01 5.25 7106. 6616. 3.21 5166. 13114. 1339.
## 5 2016-08-01 5.25 6913. 5858. 2.79 5401. 13160. 1344.
## 6 2016-09-01 5 6956. 6083. 3.07 5337. 13110. 1330.
tail(non_na_data)
## # A tibble: 6 × 8
## date bi_rate bond10 btc cpi jkse kurs_idr gold_idr
## <date> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 2024-07-01 6.25 6986. 62.9 2.13 7258. 16238. 2398.
## 2 2024-08-01 6.25 6714. 60.0 2.12 7417. 15735. 2474.
## 3 2024-09-01 6 6544. 60.5 1.84 7740. 15318. 2579.
## 4 2024-10-01 6 6699. 65.7 1.71 7621. 15558. 2695.
## 5 2024-11-01 6 6852. 86.5 1.55 7269. 15813. 2656.
## 6 2024-12-01 6 6994. 98.3 1.57 7216. 16036. 2650.
nrow(non_na_data)
## [1] 105
# Convert BTC to IDR
btc_idr <- non_na_data %>%
mutate(btc_idr = btc * kurs_idr) %>%
select(date, btc_idr)
# Add BTC_IDR to the dataset
non_na_data <- non_na_data %>%
left_join(btc_idr, by = "date")
# Select final set of variables
non_na_data <- non_na_data %>%
select(date, bi_rate, bond10, btc_idr, cpi, jkse, kurs_idr, gold_idr)
# Display the final dataset
head(non_na_data); tail(non_na_data)
## # A tibble: 6 × 8
## date bi_rate bond10 btc_idr cpi jkse kurs_idr gold_idr
## <date> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 2016-04-01 5.5 7545 57318032. 3.6 4853. 13172. 1244.
## 2 2016-05-01 5.5 7784. 61939403. 3.33 4770. 13417. 1261.
## 3 2016-06-01 5.25 7660. 85965931. 3.45 4871. 13338. 1279.
## 4 2016-07-01 5.25 7106. 86769238. 3.21 5166. 13114. 1339.
## 5 2016-08-01 5.25 6913. 77097435. 2.79 5401. 13160. 1344.
## 6 2016-09-01 5 6956. 79744103. 3.07 5337. 13110. 1330.
## # A tibble: 6 × 8
## date bi_rate bond10 btc_idr cpi jkse kurs_idr gold_idr
## <date> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 2024-07-01 6.25 6986. 1021903. 2.13 7258. 16238. 2398.
## 2 2024-08-01 6.25 6714. 944448. 2.12 7417. 15735. 2474.
## 3 2024-09-01 6 6544. 926531. 1.84 7740. 15318. 2579.
## 4 2024-10-01 6 6699. 1021507. 1.71 7621. 15558. 2695.
## 5 2024-11-01 6 6852. 1368402. 1.55 7269. 15813. 2656.
## 6 2024-12-01 6 6994. 1576530. 1.57 7216. 16036. 2650.
# Calculate returns and changes for each variable
non_na_data$bi_rate <- as.numeric(non_na_data$bi_rate)
apt_data <- non_na_data %>%
arrange(date) %>%
mutate(
jkse_return = c(NA, diff(log(jkse))),
bond_return = c(NA, diff(log(bond10))),
btc_return = c(NA, diff(log(btc_idr))),
gold_return = c(NA, diff(log(gold_idr))), # Add gold returns calculation
birate_change = c(NA, diff(bi_rate)),
cpi_change = c(NA, diff(cpi) / cpi[-length(cpi)]),
kurs_change = c(NA, diff(kurs_idr) / kurs_idr[-length(kurs_idr)])
) %>%
na.omit()
# Create risk-free rate variable from BI Rate
apt_data$rf_rate <- apt_data$bi_rate / 12 / 100 # Convert annual BI Rate to monthly
# Calculate excess returns
apt_data$excess_jkse <- apt_data$jkse_return - apt_data$rf_rate
apt_data$excess_bond <- apt_data$bond_return - apt_data$rf_rate
apt_data$excess_btc <- apt_data$btc_return - apt_data$rf_rate
apt_data$excess_gold <- apt_data$gold_return - apt_data$rf_rate # Add excess returns for gold
# Check the data
head(apt_data)
## # A tibble: 6 × 20
## date bi_rate bond10 btc_idr cpi jkse kurs_idr gold_idr jkse_return
## <date> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 2016-05-01 5.5 7784. 61939403. 3.33 4770. 13417. 1261. -0.0173
## 2 2016-06-01 5.25 7660. 85965931. 3.45 4871. 13338. 1279. 0.0210
## 3 2016-07-01 5.25 7106. 86769238. 3.21 5166. 13114. 1339. 0.0589
## 4 2016-08-01 5.25 6913. 77097435. 2.79 5401. 13160. 1344. 0.0445
## 5 2016-09-01 5 6956. 79744103. 3.07 5337. 13110. 1330. -0.0120
## 6 2016-10-01 4.75 7088. 83963283. 3.31 5406. 13018. 1266. 0.0128
## # ℹ 11 more variables: bond_return <dbl>, btc_return <dbl>, gold_return <dbl>,
## # birate_change <dbl>, cpi_change <dbl>, kurs_change <dbl>, rf_rate <dbl>,
## # excess_jkse <dbl>, excess_bond <dbl>, excess_btc <dbl>, excess_gold <dbl>
summary(apt_data)
## date bi_rate bond10 btc_idr
## Min. :2016-05-01 Min. :3.500 Min. :6111 Min. : 16779
## 1st Qu.:2018-06-23 1st Qu.:4.188 1st Qu.:6597 1st Qu.: 118135
## Median :2020-08-16 Median :4.750 Median :6916 Median : 342069
## Mean :2020-08-15 Mean :4.886 Mean :6998 Mean : 8297702
## 3rd Qu.:2022-10-08 3rd Qu.:5.750 3rd Qu.:7289 3rd Qu.: 724748
## Max. :2024-12-01 Max. :6.250 Max. :8554 Max. :110728567
## cpi jkse kurs_idr gold_idr
## Min. :1.320 Min. :4599 Min. :13018 Min. :1154
## 1st Qu.:2.167 1st Qu.:5853 1st Qu.:13954 1st Qu.:1298
## Median :3.060 Median :6237 Median :14345 Median :1726
## Mean :2.997 Mean :6248 Mean :14459 Mean :1672
## 3rd Qu.:3.490 3rd Qu.:6843 3rd Qu.:15057 3rd Qu.:1907
## Max. :5.950 Max. :7740 Max. :16335 Max. :2695
## jkse_return bond_return btc_return
## Min. :-0.201493 Min. :-0.0785464 Min. :-6.89749
## 1st Qu.:-0.012833 1st Qu.:-0.0260494 1st Qu.:-0.06265
## Median : 0.008020 Median :-0.0050788 Median : 0.02405
## Mean : 0.003815 Mean :-0.0007297 Mean :-0.03455
## 3rd Qu.: 0.020662 3rd Qu.: 0.0229104 3rd Qu.: 0.14451
## Max. : 0.086305 Max. : 0.1188922 Max. : 0.65514
## gold_return birate_change cpi_change
## Min. :-0.069265 Min. :-0.250000 Min. :-0.302752
## 1st Qu.:-0.011329 1st Qu.: 0.000000 1st Qu.:-0.077589
## Median : 0.001830 Median : 0.000000 Median :-0.013377
## Mean : 0.007274 Mean : 0.004808 Mean :-0.002132
## 3rd Qu.: 0.030706 3rd Qu.: 0.000000 3rd Qu.: 0.068724
## Max. : 0.075923 Max. : 0.625000 Max. : 0.314394
## kurs_change rf_rate excess_jkse
## Min. :-0.054480 Min. :0.002917 Min. :-0.2052429
## 1st Qu.:-0.006061 1st Qu.:0.003490 1st Qu.:-0.0176251
## Median : 0.001096 Median :0.003958 Median : 0.0038237
## Mean : 0.002065 Mean :0.004072 Mean :-0.0002566
## 3rd Qu.: 0.011865 3rd Qu.:0.004792 3rd Qu.: 0.0164970
## Max. : 0.102563 Max. :0.005208 Max. : 0.0831804
## excess_bond excess_btc excess_gold
## Min. :-0.082088 Min. :-6.90145 Min. :-0.073224
## 1st Qu.:-0.030534 1st Qu.:-0.06723 1st Qu.:-0.015524
## Median :-0.010287 Median : 0.01946 Median :-0.001594
## Mean :-0.004801 Mean :-0.03862 Mean : 0.003203
## 3rd Qu.: 0.018067 3rd Qu.: 0.14029 3rd Qu.: 0.025654
## Max. : 0.115142 Max. : 0.65159 Max. : 0.070715
min(apt_data$date)
## [1] "2016-05-01"
max(apt_data$date)
## [1] "2024-12-01"
#Figure 1. Monthly Closing Price of Assets
#Note : is JKSE’s monthly closing price meanwhile is representating the gold’s price. is government bond’s monthly closing price, is the bitcoin’s price.
library(ggplot2)
library(reshape2)
# Prepare data for plotting
price_data <- non_na_data %>%
select(date, jkse, bond10, btc_idr, gold_idr) %>%
mutate(
log_jkse = log(jkse),
log_bond10 = log(bond10),
log_btc_idr = log(btc_idr),
log_gold = log(gold_idr)
) %>%
select(date, log_jkse, log_bond10, log_btc_idr, log_gold)
# Reshape for ggplot
price_long <- melt(price_data, id.vars = "date", variable.name = "Asset", value.name = "LogPrice")
asset_labels <- c(
log_jkse = "JKSE",
log_bond10 = "Bond 10Y",
log_btc_idr = "Bitcoin (IDR)",
log_gold = "Gold"
)
price_long$Asset <- factor(price_long$Asset, levels = names(asset_labels), labels = asset_labels)
# Plot
ggplot(price_long, aes(x = date, y = LogPrice, color = Asset)) +
geom_line(linewidth = 1) +
labs(title = "Monthly Log Closing Price of Assets",
x = "Date", y = "Log Price",
color = "Asset") +
theme_minimal() +
theme(legend.position = "bottom")

## GARCH(1,1)-X Model Implementation
# Calculate macroeconomic surprises using simple exponential smoothing
library(forecast)
# For BI Rate surprise
birate_model <- ses(ts(head(apt_data$bi_rate, -1)), h=1)
birate_forecasts <- c(NA, fitted(birate_model))
birate_surprise <- apt_data$bi_rate - birate_forecasts
# For CPI surprise
cpi_model <- ses(ts(head(apt_data$cpi, -1)), h=1)
cpi_forecasts <- c(NA, fitted(cpi_model))
cpi_surprise <- (apt_data$cpi - cpi_forecasts)/apt_data$cpi
# For exchange rate surprise
kurs_model <- ses(ts(head(apt_data$kurs_idr, -1)), h=1)
kurs_forecasts <- c(NA, fitted(kurs_model))
kurs_surprise <- (apt_data$kurs_idr - kurs_forecasts)/apt_data$kurs_idr
# Add surprises to the dataset
apt_data$birate_surprise <- birate_surprise
apt_data$cpi_surprise <- cpi_surprise
apt_data$kurs_surprise <- kurs_surprise
# Remove rows with NA in surprise variables
apt_data <- apt_data %>% filter(!is.na(birate_surprise) & !is.na(cpi_surprise) & !is.na(kurs_surprise))
# Fungsi untuk fitting GARCH(1,1)-X dengan distribusi berbeda per aset
create_garch_x_model <- function(return_series, exog_data, asset_name) {
# Use surprises instead of changes for external regressors
exog_matrix <- as.matrix(exog_data[, c("birate_surprise", "kurs_surprise", "cpi_surprise")])
# Pilih distribusi: gold & Portfolio_Equal pakai "std", lainnya "norm"
dist_model <- if (asset_name %in% c("Gold", 'Portfolio_MeanVaR',"Portfolio_Equal")) "sstd" else "norm"
# Pilih model variance: Gold & Portfolio_MeanVaR pakai "sGARCH", lainnya "eGARCH"
variance_model <- if (asset_name %in% c("Gold", "Portfolio_MeanVaR")) "sGARCH" else "eGARCH"
spec <- ugarchspec(
variance.model = list(model = variance_model, garchOrder = c(1, 1)),
mean.model = list(armaOrder = c(1, 0), include.mean = TRUE, external.regressors = exog_matrix),
distribution.model = dist_model
)
tryCatch({
fit <- ugarchfit(spec, return_series)
list(spec = spec, fit = fit, valid = TRUE, name = asset_name)
}, error = function(e) {
list(spec = spec, fit = NULL, valid = FALSE, name = asset_name, error = e$message)
})
}
create_egarch_x_model <- function(return_series, exog_data, asset_name) {
# Gunakan "surprises" untuk faktor eksogenus
exog_matrix <- as.matrix(exog_data[, c("birate_surprise", "kurs_surprise", "cpi_surprise")])
# Pilih distribusi
dist_model <- if (asset_name %in% c("Gold", "Portfolio_MeanVaR", "Portfolio_Equal")) "sstd" else "norm"
# Pilih tipe model variance
variance_model <- if (asset_name %in% c("Gold", "Portfolio_MeanVaR")) "sGARCH" else "eGARCH"
# Spesifikasi model
spec <- ugarchspec(
variance.model = list(
model = variance_model,
garchOrder = c(1, 1),
external.regressors = exog_matrix # <--- Tambahkan di sini untuk variance equation
),
mean.model = list(
armaOrder = c(1, 0),
include.mean = TRUE,
external.regressors = exog_matrix # <--- Tetap ada di mean equation
),
distribution.model = dist_model
)
# Estimasi model
tryCatch({
fit <- ugarchfit(spec, return_series)
list(spec = spec, fit = fit, valid = TRUE, name = asset_name)
}, error = function(e) {
list(spec = spec, fit = NULL, valid = FALSE, name = asset_name, error = e$message)
})
}
# Ekstrak statistik model
extract_garch_stats <- function(model) {
if (!model$valid) {
return(data.frame(
Asset = model$name, Convergence = "Failed",
Mean_Intercept = NA, Beta_BIRate = NA, Beta_Exchange = NA, Beta_Inflation = NA,
AR1 = NA, GARCH_Alpha1 = NA, GARCH_Beta1 = NA, Persistence = NA, Log_Likelihood = NA
))
}
coefs <- coef(model$fit)
data.frame(
Asset = model$name, Convergence = "Success",
Mean_Intercept = coefs["mu"],
Beta_BIRate = coefs["mxreg1"], Beta_Exchange = coefs["mxreg2"], Beta_Inflation = coefs["mxreg3"],
AR1 = coefs["ar1"], GARCH_Alpha1 = coefs["alpha1"], GARCH_Beta1 = coefs["beta1"],
Persistence = coefs["alpha1"] + coefs["beta1"],
Log_Likelihood = likelihood(model$fit)
)
}
# Matriks return portofolio (termasuk gold)
return_matrix <- as.matrix(apt_data[, c("jkse_return", "bond_return", "btc_return", "gold_return")])
colnames(return_matrix) <- c("JKSE", "Bond", "BTC", "Gold")
# Fungsi portofolio
calculate_portfolio_return <- function(weights, returns) sum(colMeans(returns) * weights)
calculate_portfolio_var <- function(weights, returns, alpha = 0.05) {
portfolio_returns <- returns %*% weights
-quantile(portfolio_returns, alpha)
}
mean_var_objective <- function(weights, returns, target_return) {
weights <- weights / sum(weights)
port_return <- calculate_portfolio_return(weights, returns)
port_var <- calculate_portfolio_var(weights, returns)
return_penalty <- 100 * abs(port_return - target_return)
port_var + return_penalty
}
# Calculate equal-weighted portfolio return first
num_assets <- ncol(return_matrix)
equal_weights <- rep(1/num_assets, num_assets)
names(equal_weights) <- colnames(return_matrix)
equal_portfolio_return <- calculate_portfolio_return(equal_weights, return_matrix)
# Set target return to be at least equal to the equal-weighted portfolio return
target_return <- equal_portfolio_return
# Optimasi portofolio
set.seed(123)
opt_result <- DEoptim(
mean_var_objective,
lower = rep(0.01, num_assets),
upper = rep(1, num_assets),
returns = return_matrix,
target_return = target_return,
control = DEoptim.control(itermax = 200, NP = 50)
)
## Iteration: 1 bestvalit: 0.062039 bestmemit: 0.273313 0.472111 0.253266 0.160823
## Iteration: 2 bestvalit: 0.062039 bestmemit: 0.273313 0.472111 0.253266 0.160823
## Iteration: 3 bestvalit: 0.062039 bestmemit: 0.273313 0.472111 0.253266 0.160823
## Iteration: 4 bestvalit: 0.062039 bestmemit: 0.273313 0.472111 0.253266 0.160823
## Iteration: 5 bestvalit: 0.062039 bestmemit: 0.273313 0.472111 0.253266 0.160823
## Iteration: 6 bestvalit: 0.062039 bestmemit: 0.273313 0.472111 0.253266 0.160823
## Iteration: 7 bestvalit: 0.062039 bestmemit: 0.273313 0.472111 0.253266 0.160823
## Iteration: 8 bestvalit: 0.062000 bestmemit: 0.016550 0.824927 0.409047 0.550693
## Iteration: 9 bestvalit: 0.057103 bestmemit: 0.204473 0.979034 0.448585 0.434142
## Iteration: 10 bestvalit: 0.057103 bestmemit: 0.204473 0.979034 0.448585 0.434142
## Iteration: 11 bestvalit: 0.057103 bestmemit: 0.204473 0.979034 0.448585 0.434142
## Iteration: 12 bestvalit: 0.052360 bestmemit: 0.531433 0.958499 0.390748 0.060669
## Iteration: 13 bestvalit: 0.052360 bestmemit: 0.531433 0.958499 0.390748 0.060669
## Iteration: 14 bestvalit: 0.052360 bestmemit: 0.531433 0.958499 0.390748 0.060669
## Iteration: 15 bestvalit: 0.052360 bestmemit: 0.531433 0.958499 0.390748 0.060669
## Iteration: 16 bestvalit: 0.052360 bestmemit: 0.531433 0.958499 0.390748 0.060669
## Iteration: 17 bestvalit: 0.051905 bestmemit: 0.100336 0.918013 0.324173 0.259298
## Iteration: 18 bestvalit: 0.051660 bestmemit: 0.088067 0.810439 0.310098 0.282976
## Iteration: 19 bestvalit: 0.051660 bestmemit: 0.088067 0.810439 0.310098 0.282976
## Iteration: 20 bestvalit: 0.051660 bestmemit: 0.088067 0.810439 0.310098 0.282976
## Iteration: 21 bestvalit: 0.051523 bestmemit: 0.279569 0.795103 0.324443 0.178672
## Iteration: 22 bestvalit: 0.051523 bestmemit: 0.279569 0.795103 0.324443 0.178672
## Iteration: 23 bestvalit: 0.051523 bestmemit: 0.279569 0.795103 0.324443 0.178672
## Iteration: 24 bestvalit: 0.051523 bestmemit: 0.279569 0.795103 0.324443 0.178672
## Iteration: 25 bestvalit: 0.051523 bestmemit: 0.279569 0.795103 0.324443 0.178672
## Iteration: 26 bestvalit: 0.051523 bestmemit: 0.279569 0.795103 0.324443 0.178672
## Iteration: 27 bestvalit: 0.051523 bestmemit: 0.279569 0.795103 0.324443 0.178672
## Iteration: 28 bestvalit: 0.051523 bestmemit: 0.279569 0.795103 0.324443 0.178672
## Iteration: 29 bestvalit: 0.051523 bestmemit: 0.279569 0.795103 0.324443 0.178672
## Iteration: 30 bestvalit: 0.051523 bestmemit: 0.279569 0.795103 0.324443 0.178672
## Iteration: 31 bestvalit: 0.051523 bestmemit: 0.279569 0.795103 0.324443 0.178672
## Iteration: 32 bestvalit: 0.051523 bestmemit: 0.279569 0.795103 0.324443 0.178672
## Iteration: 33 bestvalit: 0.051523 bestmemit: 0.279569 0.795103 0.324443 0.178672
## Iteration: 34 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 35 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 36 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 37 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 38 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 39 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 40 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 41 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 42 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 43 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 44 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 45 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 46 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 47 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 48 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 49 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 50 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 51 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 52 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 53 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 54 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 55 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 56 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 57 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 58 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 59 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 60 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 61 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 62 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 63 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 64 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 65 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 66 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 67 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 68 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 69 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 70 bestvalit: 0.047281 bestmemit: 0.219855 0.905710 0.321927 0.169975
## Iteration: 71 bestvalit: 0.047281 bestmemit: 0.219855 0.905710 0.321927 0.169975
## Iteration: 72 bestvalit: 0.047281 bestmemit: 0.219855 0.905710 0.321927 0.169975
## Iteration: 73 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 74 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 75 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 76 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 77 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 78 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 79 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 80 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 81 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 82 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 83 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 84 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 85 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 86 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 87 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 88 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 89 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 90 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 91 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 92 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 93 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 94 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 95 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 96 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 97 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 98 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 99 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 100 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 101 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 102 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 103 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 104 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 105 bestvalit: 0.046212 bestmemit: 0.218916 0.964264 0.338939 0.185751
## Iteration: 106 bestvalit: 0.046212 bestmemit: 0.218916 0.964264 0.338939 0.185751
## Iteration: 107 bestvalit: 0.046212 bestmemit: 0.218916 0.964264 0.338939 0.185751
## Iteration: 108 bestvalit: 0.046212 bestmemit: 0.218916 0.964264 0.338939 0.185751
## Iteration: 109 bestvalit: 0.046212 bestmemit: 0.218916 0.964264 0.338939 0.185751
## Iteration: 110 bestvalit: 0.046212 bestmemit: 0.218916 0.964264 0.338939 0.185751
## Iteration: 111 bestvalit: 0.046212 bestmemit: 0.218916 0.964264 0.338939 0.185751
## Iteration: 112 bestvalit: 0.046212 bestmemit: 0.218916 0.964264 0.338939 0.185751
## Iteration: 113 bestvalit: 0.046212 bestmemit: 0.218916 0.964264 0.338939 0.185751
## Iteration: 114 bestvalit: 0.046212 bestmemit: 0.218916 0.964264 0.338939 0.185751
## Iteration: 115 bestvalit: 0.046212 bestmemit: 0.218916 0.964264 0.338939 0.185751
## Iteration: 116 bestvalit: 0.046212 bestmemit: 0.218916 0.964264 0.338939 0.185751
## Iteration: 117 bestvalit: 0.046212 bestmemit: 0.218916 0.964264 0.338939 0.185751
## Iteration: 118 bestvalit: 0.046212 bestmemit: 0.218916 0.964264 0.338939 0.185751
## Iteration: 119 bestvalit: 0.046212 bestmemit: 0.218916 0.964264 0.338939 0.185751
## Iteration: 120 bestvalit: 0.046212 bestmemit: 0.218916 0.964264 0.338939 0.185751
## Iteration: 121 bestvalit: 0.046212 bestmemit: 0.218916 0.964264 0.338939 0.185751
## Iteration: 122 bestvalit: 0.046212 bestmemit: 0.218916 0.964264 0.338939 0.185751
## Iteration: 123 bestvalit: 0.046212 bestmemit: 0.218916 0.964264 0.338939 0.185751
## Iteration: 124 bestvalit: 0.046212 bestmemit: 0.218916 0.964264 0.338939 0.185751
## Iteration: 125 bestvalit: 0.046212 bestmemit: 0.218916 0.964264 0.338939 0.185751
## Iteration: 126 bestvalit: 0.046212 bestmemit: 0.218916 0.964264 0.338939 0.185751
## Iteration: 127 bestvalit: 0.046212 bestmemit: 0.218916 0.964264 0.338939 0.185751
## Iteration: 128 bestvalit: 0.046212 bestmemit: 0.218916 0.964264 0.338939 0.185751
## Iteration: 129 bestvalit: 0.046212 bestmemit: 0.218916 0.964264 0.338939 0.185751
## Iteration: 130 bestvalit: 0.046212 bestmemit: 0.218916 0.964264 0.338939 0.185751
## Iteration: 131 bestvalit: 0.046212 bestmemit: 0.218916 0.964264 0.338939 0.185751
## Iteration: 132 bestvalit: 0.046212 bestmemit: 0.218916 0.964264 0.338939 0.185751
## Iteration: 133 bestvalit: 0.046212 bestmemit: 0.218916 0.964264 0.338939 0.185751
## Iteration: 134 bestvalit: 0.046208 bestmemit: 0.192594 0.842652 0.294009 0.156534
## Iteration: 135 bestvalit: 0.046208 bestmemit: 0.192594 0.842652 0.294009 0.156534
## Iteration: 136 bestvalit: 0.046208 bestmemit: 0.192594 0.842652 0.294009 0.156534
## Iteration: 137 bestvalit: 0.046208 bestmemit: 0.192594 0.842652 0.294009 0.156534
## Iteration: 138 bestvalit: 0.046208 bestmemit: 0.192594 0.842652 0.294009 0.156534
## Iteration: 139 bestvalit: 0.046208 bestmemit: 0.192594 0.842652 0.294009 0.156534
## Iteration: 140 bestvalit: 0.046208 bestmemit: 0.192594 0.842652 0.294009 0.156534
## Iteration: 141 bestvalit: 0.046208 bestmemit: 0.192594 0.842652 0.294009 0.156534
## Iteration: 142 bestvalit: 0.046208 bestmemit: 0.192594 0.842652 0.294009 0.156534
## Iteration: 143 bestvalit: 0.046208 bestmemit: 0.192594 0.842652 0.294009 0.156534
## Iteration: 144 bestvalit: 0.046208 bestmemit: 0.192594 0.842652 0.294009 0.156534
## Iteration: 145 bestvalit: 0.046208 bestmemit: 0.192594 0.842652 0.294009 0.156534
## Iteration: 146 bestvalit: 0.046208 bestmemit: 0.192594 0.842652 0.294009 0.156534
## Iteration: 147 bestvalit: 0.046208 bestmemit: 0.192594 0.842652 0.294009 0.156534
## Iteration: 148 bestvalit: 0.046208 bestmemit: 0.192594 0.842652 0.294009 0.156534
## Iteration: 149 bestvalit: 0.046153 bestmemit: 0.203803 0.867648 0.305635 0.163131
## Iteration: 150 bestvalit: 0.046153 bestmemit: 0.203803 0.867648 0.305635 0.163131
## Iteration: 151 bestvalit: 0.046153 bestmemit: 0.203803 0.867648 0.305635 0.163131
## Iteration: 152 bestvalit: 0.046153 bestmemit: 0.203803 0.867648 0.305635 0.163131
## Iteration: 153 bestvalit: 0.046153 bestmemit: 0.203803 0.867648 0.305635 0.163131
## Iteration: 154 bestvalit: 0.046153 bestmemit: 0.203803 0.867648 0.305635 0.163131
## Iteration: 155 bestvalit: 0.046153 bestmemit: 0.203803 0.867648 0.305635 0.163131
## Iteration: 156 bestvalit: 0.046127 bestmemit: 0.222692 0.956303 0.336311 0.180250
## Iteration: 157 bestvalit: 0.046127 bestmemit: 0.222692 0.956303 0.336311 0.180250
## Iteration: 158 bestvalit: 0.046127 bestmemit: 0.222692 0.956303 0.336311 0.180250
## Iteration: 159 bestvalit: 0.046127 bestmemit: 0.222692 0.956303 0.336311 0.180250
## Iteration: 160 bestvalit: 0.046096 bestmemit: 0.211256 0.911140 0.321953 0.175644
## Iteration: 161 bestvalit: 0.046096 bestmemit: 0.211256 0.911140 0.321953 0.175644
## Iteration: 162 bestvalit: 0.046096 bestmemit: 0.211256 0.911140 0.321953 0.175644
## Iteration: 163 bestvalit: 0.046096 bestmemit: 0.211256 0.911140 0.321953 0.175644
## Iteration: 164 bestvalit: 0.046096 bestmemit: 0.211256 0.911140 0.321953 0.175644
## Iteration: 165 bestvalit: 0.046096 bestmemit: 0.211256 0.911140 0.321953 0.175644
## Iteration: 166 bestvalit: 0.046096 bestmemit: 0.211256 0.911140 0.321953 0.175644
## Iteration: 167 bestvalit: 0.046096 bestmemit: 0.211256 0.911140 0.321953 0.175644
## Iteration: 168 bestvalit: 0.046070 bestmemit: 0.200474 0.869171 0.305103 0.164034
## Iteration: 169 bestvalit: 0.046070 bestmemit: 0.200474 0.869171 0.305103 0.164034
## Iteration: 170 bestvalit: 0.046070 bestmemit: 0.200474 0.869171 0.305103 0.164034
## Iteration: 171 bestvalit: 0.046070 bestmemit: 0.200474 0.869171 0.305103 0.164034
## Iteration: 172 bestvalit: 0.046059 bestmemit: 0.212116 0.916195 0.323134 0.175547
## Iteration: 173 bestvalit: 0.046059 bestmemit: 0.212116 0.916195 0.323134 0.175547
## Iteration: 174 bestvalit: 0.046059 bestmemit: 0.212116 0.916195 0.323134 0.175547
## Iteration: 175 bestvalit: 0.046059 bestmemit: 0.212116 0.916195 0.323134 0.175547
## Iteration: 176 bestvalit: 0.046059 bestmemit: 0.212116 0.916195 0.323134 0.175547
## Iteration: 177 bestvalit: 0.046059 bestmemit: 0.212116 0.916195 0.323134 0.175547
## Iteration: 178 bestvalit: 0.046059 bestmemit: 0.212116 0.916195 0.323134 0.175547
## Iteration: 179 bestvalit: 0.046059 bestmemit: 0.212116 0.916195 0.323134 0.175547
## Iteration: 180 bestvalit: 0.046056 bestmemit: 0.193300 0.836383 0.294459 0.159410
## Iteration: 181 bestvalit: 0.046056 bestmemit: 0.193300 0.836383 0.294459 0.159410
## Iteration: 182 bestvalit: 0.046056 bestmemit: 0.193300 0.836383 0.294459 0.159410
## Iteration: 183 bestvalit: 0.046056 bestmemit: 0.193300 0.836383 0.294459 0.159410
## Iteration: 184 bestvalit: 0.046056 bestmemit: 0.193300 0.836383 0.294459 0.159410
## Iteration: 185 bestvalit: 0.046056 bestmemit: 0.193300 0.836383 0.294459 0.159410
## Iteration: 186 bestvalit: 0.046056 bestmemit: 0.193300 0.836383 0.294459 0.159410
## Iteration: 187 bestvalit: 0.046056 bestmemit: 0.193300 0.836383 0.294459 0.159410
## Iteration: 188 bestvalit: 0.046056 bestmemit: 0.193300 0.836383 0.294459 0.159410
## Iteration: 189 bestvalit: 0.046041 bestmemit: 0.200474 0.869049 0.305103 0.164034
## Iteration: 190 bestvalit: 0.046041 bestmemit: 0.200474 0.869049 0.305103 0.164034
## Iteration: 191 bestvalit: 0.046041 bestmemit: 0.200474 0.869049 0.305103 0.164034
## Iteration: 192 bestvalit: 0.046041 bestmemit: 0.200474 0.869049 0.305103 0.164034
## Iteration: 193 bestvalit: 0.046041 bestmemit: 0.200474 0.869049 0.305103 0.164034
## Iteration: 194 bestvalit: 0.046041 bestmemit: 0.200474 0.869049 0.305103 0.164034
## Iteration: 195 bestvalit: 0.046041 bestmemit: 0.200474 0.869049 0.305103 0.164034
## Iteration: 196 bestvalit: 0.046041 bestmemit: 0.200474 0.869049 0.305103 0.164034
## Iteration: 197 bestvalit: 0.046037 bestmemit: 0.198717 0.858318 0.302009 0.162900
## Iteration: 198 bestvalit: 0.046037 bestmemit: 0.198717 0.858318 0.302009 0.162900
## Iteration: 199 bestvalit: 0.046037 bestmemit: 0.198717 0.858318 0.302009 0.162900
## Iteration: 200 bestvalit: 0.046037 bestmemit: 0.198717 0.858318 0.302009 0.162900
meanvar_weights <- opt_result$optim$bestmem
meanvar_weights <- meanvar_weights / sum(meanvar_weights)
names(meanvar_weights) <- colnames(return_matrix)
cat("\n==== Mean-VaR Optimal Portfolio Weights ====\n")
##
## ==== Mean-VaR Optimal Portfolio Weights ====
print(round(meanvar_weights * 100, 2))
## JKSE Bond BTC Gold
## 13.06 56.40 19.84 10.70
# Return portofolio
apt_data$portfolio_return_meanvar <- as.numeric(return_matrix %*% meanvar_weights)
apt_data$excess_portfolio_meanvar <- apt_data$portfolio_return_meanvar - apt_data$rf_rate
apt_data$portfolio_return_equal <- as.numeric(return_matrix %*% equal_weights)
apt_data$excess_portfolio_equal <- apt_data$portfolio_return_equal - apt_data$rf_rate
# Fitting eGARCH-X dan GARCH-X untuk semua aset dan portofolio
garch_jkse <- create_garch_x_model(apt_data$excess_jkse, apt_data, "JKSE")
garch_bond <- create_garch_x_model(apt_data$excess_bond, apt_data, "Bond")
garch_btc <- create_garch_x_model(apt_data$excess_btc, apt_data, "BTC")
garch_gold <- create_garch_x_model(apt_data$excess_gold, apt_data, "Gold")
garch_portfolio_meanvar <- create_garch_x_model(apt_data$excess_portfolio_meanvar, apt_data, "Portfolio_MeanVaR")
garch_portfolio_equal <- create_garch_x_model(apt_data$excess_portfolio_equal, apt_data, "Portfolio_Equal")
egarch_jkse <- create_egarch_x_model(apt_data$excess_jkse, apt_data, "JKSE")
egarch_bond <- create_egarch_x_model(apt_data$excess_bond, apt_data, "Bond")
egarch_btc <- create_egarch_x_model(apt_data$excess_btc, apt_data, "BTC")
egarch_gold <- create_egarch_x_model(apt_data$excess_gold, apt_data, "Gold")
egarch_portfolio_meanvar <- create_egarch_x_model(apt_data$excess_portfolio_meanvar, apt_data, "Portfolio_MeanVaR")
egarch_portfolio_equal <- create_egarch_x_model(apt_data$excess_portfolio_equal, apt_data, "Portfolio_Equal")
# Statistik model
stats_jkse <- extract_garch_stats(garch_jkse)
stats_bond <- extract_garch_stats(garch_bond)
stats_btc <- extract_garch_stats(garch_btc)
stats_gold <- extract_garch_stats(garch_gold)
stats_portfolio_meanvar <- extract_garch_stats(garch_portfolio_meanvar)
stats_portfolio_equal <- extract_garch_stats(garch_portfolio_equal)
estats_jkse <- extract_garch_stats(egarch_jkse)
estats_bond <- extract_garch_stats(egarch_bond)
estats_btc <- extract_garch_stats(egarch_btc)
estats_gold <- extract_garch_stats(egarch_gold)
estats_portfolio_meanvar <- extract_garch_stats(egarch_portfolio_meanvar)
estats_portfolio_equal <- extract_garch_stats(egarch_portfolio_equal)
garch_stats <- rbind(
stats_jkse, stats_bond, stats_btc, stats_gold,
stats_portfolio_meanvar, stats_portfolio_equal
)
print(garch_stats)
## Asset Convergence Mean_Intercept Beta_BIRate Beta_Exchange
## mu JKSE Success 0.004664537 0.005322206 -0.7833513
## mu1 Bond Success -0.007232778 -0.004008689 0.8085291
## mu2 BTC Success -0.035729324 -0.074610331 -0.2790316
## mu3 Gold Success 0.002808595 -0.004564162 -0.1189763
## mu4 Portfolio_MeanVaR Success 0.006204778 -0.031959860 0.4279122
## mu5 Portfolio_Equal Success -0.017947264 -0.042700159 0.2153660
## Beta_Inflation AR1 GARCH_Alpha1 GARCH_Beta1 Persistence
## mu -0.0055231881 0.01531685 -3.234912e-01 0.5940208 0.2705295
## mu1 0.0033099545 0.08284225 1.294581e-01 0.4281244 0.5575825
## mu2 -0.0660850704 0.56079104 -5.640867e-01 0.8619609 0.2978741
## mu3 -0.0205650856 0.17909046 4.382287e-10 0.9989995 0.9989995
## mu4 0.0005766877 0.32616769 1.563977e-03 0.9750174 0.9765813
## mu5 -0.0406747992 0.37112468 -1.806870e+00 0.8989769 -0.9078930
## Log_Likelihood
## mu 233.298887
## mu1 225.191523
## mu2 -5.032547
## mu3 219.507112
## mu4 178.405997
## mu5 162.688442
egarch_stats <- rbind(
estats_jkse, estats_bond, estats_btc, estats_gold,
estats_portfolio_meanvar, estats_portfolio_equal
)
print(egarch_stats)
## Asset Convergence Mean_Intercept Beta_BIRate Beta_Exchange
## mu JKSE Success -0.001054353 0.005632771 -0.6721015
## mu1 Bond Success -0.010633775 0.002703505 0.7762693
## mu2 BTC Success 0.002539593 -0.099982004 1.4332071
## mu3 Gold Success 0.002818610 -0.004518633 -0.1201844
## mu4 Portfolio_MeanVaR Success 0.006204241 -0.031958715 0.4279095
## mu5 Portfolio_Equal Success -0.007197691 -0.024945935 0.0770409
## Beta_Inflation AR1 GARCH_Alpha1 GARCH_Beta1 Persistence
## mu 0.005252649 0.1174564 -3.037635e-01 0.9259269 0.62216341
## mu1 -0.022078723 0.1329884 1.146575e-01 0.6979373 0.81259481
## mu2 0.004525471 0.4903829 -5.026460e-01 0.6909849 0.18833883
## mu3 -0.020505399 0.1777259 1.214602e-05 0.9996369 0.99964907
## mu4 0.000575705 0.3261689 1.565930e-03 0.9750087 0.97657461
## mu5 -0.001217856 0.3119912 -8.581519e-01 0.9403223 0.08217039
## Log_Likelihood
## mu 239.191201
## mu1 229.081383
## mu2 9.635011
## mu3 219.455978
## mu4 178.405957
## mu5 162.176083
portfolio_comparison <- data.frame(
Metric = c("Mean Monthly Return", "Monthly Volatility", "Sharpe Ratio", "Monthly VaR (95%)"),
MeanVaR_Portfolio = c(
mean(apt_data$portfolio_return_meanvar),
sd(apt_data$portfolio_return_meanvar),
mean(apt_data$excess_portfolio_meanvar) / sd(apt_data$portfolio_return_meanvar),
calculate_portfolio_var(meanvar_weights, return_matrix)
),
Equal_Portfolio = c(
mean(apt_data$portfolio_return_equal),
sd(apt_data$portfolio_return_equal),
mean(apt_data$excess_portfolio_equal) / sd(apt_data$portfolio_return_equal),
calculate_portfolio_var(equal_weights, return_matrix)
)
)
cat("\n==== Portfolio Performance Comparison ====\n")
##
## ==== Portfolio Performance Comparison ====
print(portfolio_comparison)
## Metric MeanVaR_Portfolio Equal_Portfolio
## 1 Mean Monthly Return -0.006361107 -0.006360949
## 2 Monthly Volatility 0.145151872 0.180433286
## 3 Sharpe Ratio -0.071839597 -0.057791411
## 4 Monthly VaR (95%) 0.046020820 0.072489481
for (model_name in c("JKSE", "Bond", "BTC", "Gold", "Portfolio_MeanVaR", "Portfolio_Equal")) {
model <- get(paste0("garch_", tolower(model_name)))
if (model$valid) {
cat(paste0("\n==== GARCH(1,1)-X MODEL: ", model_name, " ====\n"))
print(model$fit)
} else {
cat(paste0("\n==== GARCH(1,1)-X MODEL: ", model_name, " ====\n"))
cat("Failed to converge. Error:", model$error, "\n")
}
}
##
## ==== GARCH(1,1)-X MODEL: JKSE ====
##
## *---------------------------------*
## * GARCH Model Fit *
## *---------------------------------*
##
## Conditional Variance Dynamics
## -----------------------------------
## GARCH Model : eGARCH(1,1)
## Mean Model : ARFIMA(1,0,0)
## Distribution : norm
##
## Optimal Parameters
## ------------------------------------
## Estimate Std. Error t value Pr(>|t|)
## mu 0.004665 0.002567 1.81742 0.069152
## ar1 0.015317 0.126646 0.12094 0.903737
## mxreg1 0.005322 0.008748 0.60843 0.542905
## mxreg2 -0.783351 0.126415 -6.19669 0.000000
## mxreg3 -0.005523 0.013777 -0.40089 0.688501
## omega -3.007437 1.457437 -2.06351 0.039064
## alpha1 -0.323491 0.126791 -2.55137 0.010730
## beta1 0.594021 0.197467 3.00820 0.002628
## gamma1 0.527070 0.238843 2.20676 0.027331
##
## Robust Standard Errors:
## Estimate Std. Error t value Pr(>|t|)
## mu 0.004665 0.003558 1.31104 0.189844
## ar1 0.015317 0.143855 0.10647 0.915206
## mxreg1 0.005322 0.008913 0.59712 0.550429
## mxreg2 -0.783351 0.184756 -4.23993 0.000022
## mxreg3 -0.005523 0.012403 -0.44529 0.656108
## omega -3.007437 1.898599 -1.58403 0.113187
## alpha1 -0.323491 0.127828 -2.53068 0.011384
## beta1 0.594021 0.262240 2.26518 0.023502
## gamma1 0.527070 0.290971 1.81142 0.070076
##
## LogLikelihood : 233.2989
##
## Information Criteria
## ------------------------------------
##
## Akaike -4.3553
## Bayes -4.1251
## Shibata -4.3690
## Hannan-Quinn -4.2621
##
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.5611 0.4538
## Lag[2*(p+q)+(p+q)-1][2] 1.4860 0.4451
## Lag[4*(p+q)+(p+q)-1][5] 2.3099 0.6212
## d.o.f=1
## H0 : No serial correlation
##
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.3842 0.5354
## Lag[2*(p+q)+(p+q)-1][5] 1.6667 0.6989
## Lag[4*(p+q)+(p+q)-1][9] 3.4612 0.6810
## d.o.f=2
##
## Weighted ARCH LM Tests
## ------------------------------------
## Statistic Shape Scale P-Value
## ARCH Lag[3] 0.01527 0.500 2.000 0.9016
## ARCH Lag[5] 0.12602 1.440 1.667 0.9818
## ARCH Lag[7] 0.17265 2.315 1.543 0.9979
##
## Nyblom stability test
## ------------------------------------
## Joint Statistic: 1.0348
## Individual Statistics:
## mu 0.13231
## ar1 0.07413
## mxreg1 0.05896
## mxreg2 0.07025
## mxreg3 0.17220
## omega 0.13270
## alpha1 0.04512
## beta1 0.13717
## gamma1 0.09821
##
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic: 2.1 2.32 2.82
## Individual Statistic: 0.35 0.47 0.75
##
## Sign Bias Test
## ------------------------------------
## t-value prob sig
## Sign Bias 0.000132 0.9999
## Negative Sign Bias 0.284146 0.7769
## Positive Sign Bias 0.153314 0.8785
## Joint Effect 0.112105 0.9903
##
##
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
## group statistic p-value(g-1)
## 1 20 27.29 0.09805
## 2 30 28.94 0.46810
## 3 40 38.75 0.48127
## 4 50 45.06 0.63364
##
##
## Elapsed time : 0.15256
##
##
## ==== GARCH(1,1)-X MODEL: Bond ====
##
## *---------------------------------*
## * GARCH Model Fit *
## *---------------------------------*
##
## Conditional Variance Dynamics
## -----------------------------------
## GARCH Model : eGARCH(1,1)
## Mean Model : ARFIMA(1,0,0)
## Distribution : norm
##
## Optimal Parameters
## ------------------------------------
## Estimate Std. Error t value Pr(>|t|)
## mu -0.007233 0.001042 -6.9391 0.000000
## ar1 0.082842 0.030744 2.6946 0.007047
## mxreg1 -0.004009 0.000378 -10.5974 0.000000
## mxreg2 0.808529 0.077306 10.4589 0.000000
## mxreg3 0.003310 0.000165 20.0674 0.000000
## omega -4.111165 0.167536 -24.5391 0.000000
## alpha1 0.129458 0.122080 1.0604 0.288945
## beta1 0.428124 0.024111 17.7565 0.000000
## gamma1 -0.442844 0.022034 -20.0986 0.000000
##
## Robust Standard Errors:
## Estimate Std. Error t value Pr(>|t|)
## mu -0.007233 0.000606 -11.9423 0.000000
## ar1 0.082842 0.032192 2.5734 0.010071
## mxreg1 -0.004009 0.001142 -3.5102 0.000448
## mxreg2 0.808529 0.056045 14.4263 0.000000
## mxreg3 0.003310 0.001337 2.4763 0.013277
## omega -4.111165 0.148187 -27.7431 0.000000
## alpha1 0.129458 0.118950 1.0883 0.276444
## beta1 0.428124 0.019627 21.8128 0.000000
## gamma1 -0.442844 0.014194 -31.1986 0.000000
##
## LogLikelihood : 225.1915
##
## Information Criteria
## ------------------------------------
##
## Akaike -4.1979
## Bayes -3.9677
## Shibata -4.2116
## Hannan-Quinn -4.1046
##
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.001801 0.9661
## Lag[2*(p+q)+(p+q)-1][2] 2.402994 0.1082
## Lag[4*(p+q)+(p+q)-1][5] 4.505619 0.1558
## d.o.f=1
## H0 : No serial correlation
##
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.00172 0.9669
## Lag[2*(p+q)+(p+q)-1][5] 0.35924 0.9771
## Lag[4*(p+q)+(p+q)-1][9] 0.86797 0.9911
## d.o.f=2
##
## Weighted ARCH LM Tests
## ------------------------------------
## Statistic Shape Scale P-Value
## ARCH Lag[3] 0.001069 0.500 2.000 0.9739
## ARCH Lag[5] 0.212644 1.440 1.667 0.9625
## ARCH Lag[7] 0.247585 2.315 1.543 0.9952
##
## Nyblom stability test
## ------------------------------------
## Joint Statistic: 1.91
## Individual Statistics:
## mu 0.11430
## ar1 0.07333
## mxreg1 0.17190
## mxreg2 0.10483
## mxreg3 0.08324
## omega 0.50256
## alpha1 0.11019
## beta1 0.48986
## gamma1 0.18020
##
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic: 2.1 2.32 2.82
## Individual Statistic: 0.35 0.47 0.75
##
## Sign Bias Test
## ------------------------------------
## t-value prob sig
## Sign Bias 0.7081 0.4805
## Negative Sign Bias 0.1866 0.8523
## Positive Sign Bias 0.7061 0.4818
## Joint Effect 0.6199 0.8919
##
##
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
## group statistic p-value(g-1)
## 1 20 15.25 0.7064
## 2 30 20.20 0.8865
## 3 40 33.31 0.7264
## 4 50 47.97 0.5148
##
##
## Elapsed time : 0.155009
##
##
## ==== GARCH(1,1)-X MODEL: BTC ====
##
## *---------------------------------*
## * GARCH Model Fit *
## *---------------------------------*
##
## Conditional Variance Dynamics
## -----------------------------------
## GARCH Model : eGARCH(1,1)
## Mean Model : ARFIMA(1,0,0)
## Distribution : norm
##
## Optimal Parameters
## ------------------------------------
## Estimate Std. Error t value Pr(>|t|)
## mu -0.035729 0.047501 -0.75218 0.451944
## ar1 0.560791 0.113552 4.93862 0.000001
## mxreg1 -0.074610 0.140876 -0.52961 0.596379
## mxreg2 -0.279032 0.663335 -0.42065 0.674011
## mxreg3 -0.066085 0.158990 -0.41566 0.677661
## omega -0.334817 0.115879 -2.88935 0.003860
## alpha1 -0.564087 0.134096 -4.20660 0.000026
## beta1 0.861961 0.041115 20.96460 0.000000
## gamma1 0.493343 0.163713 3.01347 0.002583
##
## Robust Standard Errors:
## Estimate Std. Error t value Pr(>|t|)
## mu -0.035729 0.066776 -0.53506 0.592606
## ar1 0.560791 0.161811 3.46572 0.000529
## mxreg1 -0.074610 0.315878 -0.23620 0.813278
## mxreg2 -0.279032 0.978003 -0.28531 0.775408
## mxreg3 -0.066085 0.190531 -0.34685 0.728707
## omega -0.334817 0.191134 -1.75174 0.079819
## alpha1 -0.564087 0.371593 -1.51802 0.129009
## beta1 0.861961 0.054978 15.67819 0.000000
## gamma1 0.493343 0.304742 1.61889 0.105472
##
## LogLikelihood : -5.032547
##
## Information Criteria
## ------------------------------------
##
## Akaike 0.27248
## Bayes 0.50270
## Shibata 0.25878
## Hannan-Quinn 0.36572
##
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.1290 0.7195
## Lag[2*(p+q)+(p+q)-1][2] 0.2582 0.9968
## Lag[4*(p+q)+(p+q)-1][5] 0.9317 0.9565
## d.o.f=1
## H0 : No serial correlation
##
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.1068 0.7438
## Lag[2*(p+q)+(p+q)-1][5] 1.3262 0.7825
## Lag[4*(p+q)+(p+q)-1][9] 1.7975 0.9277
## d.o.f=2
##
## Weighted ARCH LM Tests
## ------------------------------------
## Statistic Shape Scale P-Value
## ARCH Lag[3] 0.1106 0.500 2.000 0.7394
## ARCH Lag[5] 0.3576 1.440 1.667 0.9246
## ARCH Lag[7] 0.6177 2.315 1.543 0.9665
##
## Nyblom stability test
## ------------------------------------
## Joint Statistic: 1.8749
## Individual Statistics:
## mu 0.07632
## ar1 0.05777
## mxreg1 0.38623
## mxreg2 0.05587
## mxreg3 0.06861
## omega 0.10953
## alpha1 0.24137
## beta1 0.13312
## gamma1 0.01641
##
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic: 2.1 2.32 2.82
## Individual Statistic: 0.35 0.47 0.75
##
## Sign Bias Test
## ------------------------------------
## t-value prob sig
## Sign Bias 0.69267 0.4902
## Negative Sign Bias 0.32753 0.7440
## Positive Sign Bias 0.05774 0.9541
## Joint Effect 0.55583 0.9065
##
##
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
## group statistic p-value(g-1)
## 1 20 38.94 0.004494
## 2 30 48.75 0.012279
## 3 40 53.50 0.060875
## 4 50 69.33 0.029474
##
##
## Elapsed time : 0.111685
##
##
## ==== GARCH(1,1)-X MODEL: Gold ====
##
## *---------------------------------*
## * GARCH Model Fit *
## *---------------------------------*
##
## Conditional Variance Dynamics
## -----------------------------------
## GARCH Model : sGARCH(1,1)
## Mean Model : ARFIMA(1,0,0)
## Distribution : sstd
##
## Optimal Parameters
## ------------------------------------
## Estimate Std. Error t value Pr(>|t|)
## mu 0.002809 0.003473 0.80872 0.418678
## ar1 0.179090 0.093593 1.91350 0.055684
## mxreg1 -0.004564 0.011283 -0.40450 0.685844
## mxreg2 -0.118976 0.116683 -1.01966 0.307892
## mxreg3 -0.020565 0.018943 -1.08564 0.277639
## omega 0.000001 0.000005 0.16549 0.868555
## alpha1 0.000000 0.006659 0.00000 1.000000
## beta1 0.998999 0.006538 152.79732 0.000000
## skew 1.231053 0.190840 6.45069 0.000000
## shape 59.999829 96.949078 0.61888 0.535996
##
## Robust Standard Errors:
## Estimate Std. Error t value Pr(>|t|)
## mu 0.002809 0.003291 0.85337 0.393455
## ar1 0.179090 0.070238 2.54976 0.010780
## mxreg1 -0.004564 0.011832 -0.38575 0.699683
## mxreg2 -0.118976 0.148310 -0.80221 0.422429
## mxreg3 -0.020565 0.024116 -0.85275 0.393798
## omega 0.000001 0.000008 0.09994 0.920392
## alpha1 0.000000 0.000881 0.00000 1.000000
## beta1 0.998999 0.000618 1615.45524 0.000000
## skew 1.231053 0.164611 7.47858 0.000000
## shape 59.999829 15.074833 3.98013 0.000069
##
## LogLikelihood : 219.5071
##
## Information Criteria
## ------------------------------------
##
## Akaike -4.0681
## Bayes -3.8123
## Shibata -4.0848
## Hannan-Quinn -3.9645
##
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.1298 0.7187
## Lag[2*(p+q)+(p+q)-1][2] 0.4967 0.9651
## Lag[4*(p+q)+(p+q)-1][5] 1.2362 0.9055
## d.o.f=1
## H0 : No serial correlation
##
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.01507 0.9023
## Lag[2*(p+q)+(p+q)-1][5] 1.03881 0.8508
## Lag[4*(p+q)+(p+q)-1][9] 2.23042 0.8758
## d.o.f=2
##
## Weighted ARCH LM Tests
## ------------------------------------
## Statistic Shape Scale P-Value
## ARCH Lag[3] 0.0258 0.500 2.000 0.8724
## ARCH Lag[5] 0.4723 1.440 1.667 0.8918
## ARCH Lag[7] 1.3377 2.315 1.543 0.8533
##
## Nyblom stability test
## ------------------------------------
## Joint Statistic: 1.0054
## Individual Statistics:
## mu 0.12634
## ar1 0.03419
## mxreg1 0.09063
## mxreg2 0.18719
## mxreg3 0.06484
## omega 0.63223
## alpha1 0.06759
## beta1 0.06944
## skew 0.09877
## shape 0.53866
##
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic: 2.29 2.54 3.05
## Individual Statistic: 0.35 0.47 0.75
##
## Sign Bias Test
## ------------------------------------
## t-value prob sig
## Sign Bias 1.1589 0.2493
## Negative Sign Bias 0.3115 0.7561
## Positive Sign Bias 0.9787 0.3301
## Joint Effect 2.8355 0.4177
##
##
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
## group statistic p-value(g-1)
## 1 20 13.31 0.8223
## 2 30 18.46 0.9344
## 3 40 33.31 0.7264
## 4 50 38.26 0.8659
##
##
## Elapsed time : 0.07762384
##
##
## ==== GARCH(1,1)-X MODEL: Portfolio_MeanVaR ====
##
## *---------------------------------*
## * GARCH Model Fit *
## *---------------------------------*
##
## Conditional Variance Dynamics
## -----------------------------------
## GARCH Model : sGARCH(1,1)
## Mean Model : ARFIMA(1,0,0)
## Distribution : sstd
##
## Optimal Parameters
## ------------------------------------
## Estimate Std. Error t value Pr(>|t|)
## mu 0.006205 0.006354 0.976561 0.328786
## ar1 0.326168 0.079207 4.117890 0.000038
## mxreg1 -0.031960 0.016446 -1.943365 0.051972
## mxreg2 0.427912 0.136876 3.126282 0.001770
## mxreg3 0.000577 0.022254 0.025914 0.979326
## omega 0.000000 0.000048 0.000003 0.999998
## alpha1 0.001564 0.010036 0.155838 0.876161
## beta1 0.975017 0.009323 104.586668 0.000000
## skew 1.085970 0.139892 7.762943 0.000000
## shape 2.211492 0.211551 10.453726 0.000000
##
## Robust Standard Errors:
## Estimate Std. Error t value Pr(>|t|)
## mu 0.006205 0.006922 0.896353 0.370064
## ar1 0.326168 0.095798 3.404748 0.000662
## mxreg1 -0.031960 0.021608 -1.479059 0.139124
## mxreg2 0.427912 0.142606 3.000655 0.002694
## mxreg3 0.000577 0.028813 0.020015 0.984032
## omega 0.000000 0.000029 0.000004 0.999997
## alpha1 0.001564 0.013374 0.116941 0.906907
## beta1 0.975017 0.008733 111.648289 0.000000
## skew 1.085970 0.131112 8.282746 0.000000
## shape 2.211492 0.292923 7.549736 0.000000
##
## LogLikelihood : 178.406
##
## Information Criteria
## ------------------------------------
##
## Akaike -3.2700
## Bayes -3.0142
## Shibata -3.2867
## Hannan-Quinn -3.1664
##
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 7.018 8.070e-03
## Lag[2*(p+q)+(p+q)-1][2] 7.971 2.752e-07
## Lag[4*(p+q)+(p+q)-1][5] 8.957 3.063e-03
## d.o.f=1
## H0 : No serial correlation
##
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 1.336 0.2477
## Lag[2*(p+q)+(p+q)-1][5] 1.414 0.7610
## Lag[4*(p+q)+(p+q)-1][9] 1.463 0.9586
## d.o.f=2
##
## Weighted ARCH LM Tests
## ------------------------------------
## Statistic Shape Scale P-Value
## ARCH Lag[3] 0.01025 0.500 2.000 0.9194
## ARCH Lag[5] 0.03883 1.440 1.667 0.9966
## ARCH Lag[7] 0.06686 2.315 1.543 0.9998
##
## Nyblom stability test
## ------------------------------------
## Joint Statistic: 1.6638
## Individual Statistics:
## mu 0.04376
## ar1 0.52762
## mxreg1 0.06161
## mxreg2 0.09153
## mxreg3 0.07228
## omega 0.03735
## alpha1 0.07918
## beta1 0.05765
## skew 0.04863
## shape 0.08209
##
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic: 2.29 2.54 3.05
## Individual Statistic: 0.35 0.47 0.75
##
## Sign Bias Test
## ------------------------------------
## t-value prob sig
## Sign Bias 1.3668 0.1748
## Negative Sign Bias 1.2327 0.2206
## Positive Sign Bias 0.7615 0.4482
## Joint Effect 2.9981 0.3919
##
##
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
## group statistic p-value(g-1)
## 1 20 19.14 0.4481
## 2 30 19.04 0.9203
## 3 40 43.41 0.2890
## 4 50 49.91 0.4369
##
##
## Elapsed time : 0.09505987
##
##
## ==== GARCH(1,1)-X MODEL: Portfolio_Equal ====
##
## *---------------------------------*
## * GARCH Model Fit *
## *---------------------------------*
##
## Conditional Variance Dynamics
## -----------------------------------
## GARCH Model : eGARCH(1,1)
## Mean Model : ARFIMA(1,0,0)
## Distribution : sstd
##
## Optimal Parameters
## ------------------------------------
## Estimate Std. Error t value Pr(>|t|)
## mu -0.017947 0.000009 -2071.33 0
## ar1 0.371125 0.000051 7342.00 0
## mxreg1 -0.042700 0.000114 -374.67 0
## mxreg2 0.215366 0.000652 330.14 0
## mxreg3 -0.040675 0.000096 -423.36 0
## omega -0.376752 0.000163 -2318.26 0
## alpha1 -1.806870 0.000318 -5683.44 0
## beta1 0.898977 0.000250 3596.85 0
## gamma1 -1.380971 0.000297 -4644.65 0
## skew 0.727878 0.000600 1212.90 0
## shape 2.097399 0.000499 4201.84 0
##
## Robust Standard Errors:
## Estimate Std. Error t value Pr(>|t|)
## mu -0.017947 0.000720 -24.9432 0
## ar1 0.371125 0.000752 493.5768 0
## mxreg1 -0.042700 0.005006 -8.5302 0
## mxreg2 0.215366 0.036516 5.8979 0
## mxreg3 -0.040675 0.004009 -10.1467 0
## omega -0.376752 0.002511 -150.0684 0
## alpha1 -1.806870 0.034435 -52.4711 0
## beta1 0.898977 0.011988 74.9867 0
## gamma1 -1.380971 0.018591 -74.2836 0
## skew 0.727878 0.033298 21.8592 0
## shape 2.097399 0.023164 90.5443 0
##
## LogLikelihood : 162.6884
##
## Information Criteria
## ------------------------------------
##
## Akaike -2.9454
## Bayes -2.6640
## Shibata -2.9654
## Hannan-Quinn -2.8314
##
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.7581 0.3839
## Lag[2*(p+q)+(p+q)-1][2] 2.0949 0.1831
## Lag[4*(p+q)+(p+q)-1][5] 3.1305 0.3992
## d.o.f=1
## H0 : No serial correlation
##
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.0007602 0.9780
## Lag[2*(p+q)+(p+q)-1][5] 0.3843233 0.9740
## Lag[4*(p+q)+(p+q)-1][9] 0.5025007 0.9984
## d.o.f=2
##
## Weighted ARCH LM Tests
## ------------------------------------
## Statistic Shape Scale P-Value
## ARCH Lag[3] 0.03341 0.500 2.000 0.8550
## ARCH Lag[5] 0.07365 1.440 1.667 0.9914
## ARCH Lag[7] 0.10912 2.315 1.543 0.9992
##
## Nyblom stability test
## ------------------------------------
## Joint Statistic: 2.4528
## Individual Statistics:
## mu 0.02717
## ar1 0.02662
## mxreg1 0.02796
## mxreg2 0.02735
## mxreg3 0.02745
## omega 0.02704
## alpha1 0.02712
## beta1 0.02706
## gamma1 0.02716
## skew 0.02711
## shape 0.02635
##
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic: 2.49 2.75 3.27
## Individual Statistic: 0.35 0.47 0.75
##
## Sign Bias Test
## ------------------------------------
## t-value prob sig
## Sign Bias 0.74613 0.4574
## Negative Sign Bias 0.13715 0.8912
## Positive Sign Bias 0.02446 0.9805
## Joint Effect 0.61037 0.8941
##
##
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
## group statistic p-value(g-1)
## 1 20 17.58 0.5505
## 2 30 28.94 0.4681
## 3 40 37.97 0.5167
## 4 50 42.15 0.7452
##
##
## Elapsed time : 0.8072391
for (model_name in c("JKSE", "Bond", "BTC", "Gold", "Portfolio_MeanVaR", "Portfolio_Equal")) {
model <- get(paste0("egarch_", tolower(model_name)))
if (model$valid) {
cat(paste0("\n==== EGARCH(1,1)-X MODEL: ", model_name, " ====\n"))
print(model$fit)
} else {
cat(paste0("\n==== EGARCH(1,1)-X MODEL: ", model_name, " ====\n"))
cat("Failed to converge. Error:", model$error, "\n")
}
}
##
## ==== EGARCH(1,1)-X MODEL: JKSE ====
##
## *---------------------------------*
## * GARCH Model Fit *
## *---------------------------------*
##
## Conditional Variance Dynamics
## -----------------------------------
## GARCH Model : eGARCH(1,1)
## Mean Model : ARFIMA(1,0,0)
## Distribution : norm
##
## Optimal Parameters
## ------------------------------------
## Estimate Std. Error t value Pr(>|t|)
## mu -0.001054 0.000000 -3191.09 0
## ar1 0.117456 0.000004 29938.71 0
## mxreg1 0.005633 0.000004 1448.49 0
## mxreg2 -0.672102 0.000349 -1927.64 0
## mxreg3 0.005253 0.000005 1091.85 0
## omega -0.516788 0.000098 -5274.24 0
## alpha1 -0.303763 0.000108 -2810.64 0
## beta1 0.925927 0.000210 4417.85 0
## gamma1 -0.351802 0.000076 -4602.47 0
## vxreg1 -0.270683 0.000078 -3485.80 0
## vxreg2 1.810344 0.000435 4166.23 0
## vxreg3 0.623981 0.000745 837.82 0
##
## Robust Standard Errors:
## Estimate Std. Error t value Pr(>|t|)
## mu -0.001054 0.000007 -153.294 0
## ar1 0.117456 0.000167 702.832 0
## mxreg1 0.005633 0.000008 679.019 0
## mxreg2 -0.672102 0.017332 -38.778 0
## mxreg3 0.005253 0.000096 54.475 0
## omega -0.516788 0.000883 -585.507 0
## alpha1 -0.303763 0.001165 -260.811 0
## beta1 0.925927 0.005853 158.198 0
## gamma1 -0.351802 0.000167 -2107.989 0
## vxreg1 -0.270683 0.001292 -209.551 0
## vxreg2 1.810344 0.037860 47.817 0
## vxreg3 0.623981 0.008759 71.239 0
##
## LogLikelihood : 239.1912
##
## Information Criteria
## ------------------------------------
##
## Akaike -4.4115
## Bayes -4.1045
## Shibata -4.4350
## Hannan-Quinn -4.2872
##
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.5738 0.4487
## Lag[2*(p+q)+(p+q)-1][2] 1.8549 0.2670
## Lag[4*(p+q)+(p+q)-1][5] 3.3175 0.3558
## d.o.f=1
## H0 : No serial correlation
##
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 1.065 0.3020
## Lag[2*(p+q)+(p+q)-1][5] 2.399 0.5276
## Lag[4*(p+q)+(p+q)-1][9] 4.352 0.5303
## d.o.f=2
##
## Weighted ARCH LM Tests
## ------------------------------------
## Statistic Shape Scale P-Value
## ARCH Lag[3] 0.0006429 0.500 2.000 0.9798
## ARCH Lag[5] 0.4827435 1.440 1.667 0.8887
## ARCH Lag[7] 1.6857605 2.315 1.543 0.7834
##
## Nyblom stability test
## ------------------------------------
## Joint Statistic: 11.2567
## Individual Statistics:
## mu 0.02630
## ar1 0.02622
## mxreg1 0.02632
## mxreg2 0.07996
## mxreg3 0.02562
## omega 0.02631
## alpha1 0.02635
## beta1 0.04832
## gamma1 0.02829
## vxreg1 0.02628
## vxreg2 0.02622
## vxreg3 0.02639
##
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic: 2.69 2.96 3.51
## Individual Statistic: 0.35 0.47 0.75
##
## Sign Bias Test
## ------------------------------------
## t-value prob sig
## Sign Bias 0.6204 0.5365
## Negative Sign Bias 1.4899 0.1395
## Positive Sign Bias 0.2270 0.8209
## Joint Effect 2.4167 0.4905
##
##
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
## group statistic p-value(g-1)
## 1 20 18.36 0.4986
## 2 30 20.79 0.8668
## 3 40 30.98 0.8165
## 4 50 45.06 0.6336
##
##
## Elapsed time : 0.3568261
##
##
## ==== EGARCH(1,1)-X MODEL: Bond ====
##
## *---------------------------------*
## * GARCH Model Fit *
## *---------------------------------*
##
## Conditional Variance Dynamics
## -----------------------------------
## GARCH Model : eGARCH(1,1)
## Mean Model : ARFIMA(1,0,0)
## Distribution : norm
##
## Optimal Parameters
## ------------------------------------
## Estimate Std. Error t value Pr(>|t|)
## mu -0.010634 0.000002 -5362.5 0
## ar1 0.132988 0.000036 3711.1 0
## mxreg1 0.002704 0.000002 1103.4 0
## mxreg2 0.776269 0.000067 11511.8 0
## mxreg3 -0.022079 0.000007 -3227.3 0
## omega -2.139778 0.000290 -7390.8 0
## alpha1 0.114657 0.000072 1598.4 0
## beta1 0.697937 0.000095 7347.7 0
## gamma1 -0.870332 0.000136 -6386.7 0
## vxreg1 -0.381749 0.000046 -8262.1 0
## vxreg2 3.276956 0.001924 1703.2 0
## vxreg3 0.643845 0.000313 2056.9 0
##
## Robust Standard Errors:
## Estimate Std. Error t value Pr(>|t|)
## mu -0.010634 0.000009 -1123.44 0
## ar1 0.132988 0.000291 456.26 0
## mxreg1 0.002704 0.000005 510.11 0
## mxreg2 0.776269 0.001997 388.69 0
## mxreg3 -0.022079 0.000017 -1328.82 0
## omega -2.139778 0.002627 -814.44 0
## alpha1 0.114657 0.000111 1034.37 0
## beta1 0.697937 0.001311 532.35 0
## gamma1 -0.870332 0.001262 -689.52 0
## vxreg1 -0.381749 0.000021 -18341.41 0
## vxreg2 3.276956 0.008675 377.75 0
## vxreg3 0.643845 0.000276 2328.90 0
##
## LogLikelihood : 229.0814
##
## Information Criteria
## ------------------------------------
##
## Akaike -4.2152
## Bayes -3.9082
## Shibata -4.2387
## Hannan-Quinn -4.0908
##
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.3993 0.527459
## Lag[2*(p+q)+(p+q)-1][2] 4.0354 0.003978
## Lag[4*(p+q)+(p+q)-1][5] 6.8130 0.022828
## d.o.f=1
## H0 : No serial correlation
##
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.09026 0.7639
## Lag[2*(p+q)+(p+q)-1][5] 0.92325 0.8768
## Lag[4*(p+q)+(p+q)-1][9] 1.27473 0.9719
## d.o.f=2
##
## Weighted ARCH LM Tests
## ------------------------------------
## Statistic Shape Scale P-Value
## ARCH Lag[3] 0.02318 0.500 2.000 0.8790
## ARCH Lag[5] 0.02806 1.440 1.667 0.9978
## ARCH Lag[7] 0.04009 2.315 1.543 0.9999
##
## Nyblom stability test
## ------------------------------------
## Joint Statistic: 4.9428
## Individual Statistics:
## mu 0.05785
## ar1 0.05797
## mxreg1 0.05870
## mxreg2 0.05885
## mxreg3 0.05946
## omega 0.30326
## alpha1 0.05678
## beta1 0.09717
## gamma1 0.05493
## vxreg1 0.05488
## vxreg2 0.06111
## vxreg3 0.05920
##
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic: 2.69 2.96 3.51
## Individual Statistic: 0.35 0.47 0.75
##
## Sign Bias Test
## ------------------------------------
## t-value prob sig
## Sign Bias 0.02017 0.9840
## Negative Sign Bias 0.65821 0.5119
## Positive Sign Bias 0.18372 0.8546
## Joint Effect 1.16404 0.7616
##
##
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
## group statistic p-value(g-1)
## 1 20 34.28 0.01702
## 2 30 35.93 0.17555
## 3 40 62.05 0.01087
## 4 50 62.53 0.09270
##
##
## Elapsed time : 0.147676
##
##
## ==== EGARCH(1,1)-X MODEL: BTC ====
##
## *---------------------------------*
## * GARCH Model Fit *
## *---------------------------------*
##
## Conditional Variance Dynamics
## -----------------------------------
## GARCH Model : eGARCH(1,1)
## Mean Model : ARFIMA(1,0,0)
## Distribution : norm
##
## Optimal Parameters
## ------------------------------------
## Estimate Std. Error t value Pr(>|t|)
## mu 0.002540 0.004786 0.530578 0.595712
## ar1 0.490383 0.088132 5.564174 0.000000
## mxreg1 -0.099982 0.031978 -3.126636 0.001768
## mxreg2 1.433207 0.191585 7.480795 0.000000
## mxreg3 0.004525 0.010070 0.449397 0.653145
## omega -0.782469 0.234091 -3.342588 0.000830
## alpha1 -0.502646 0.184739 -2.720840 0.006512
## beta1 0.690985 0.067079 10.301109 0.000000
## gamma1 1.762704 0.261497 6.740812 0.000000
## vxreg1 0.034650 0.438329 0.079049 0.936994
## vxreg2 11.953194 5.103819 2.342009 0.019180
## vxreg3 2.549913 0.709806 3.592410 0.000328
##
## Robust Standard Errors:
## Estimate Std. Error t value Pr(>|t|)
## mu 0.002540 0.003731 0.680716 0.496051
## ar1 0.490383 0.096454 5.084126 0.000000
## mxreg1 -0.099982 0.031920 -3.132228 0.001735
## mxreg2 1.433207 0.194721 7.360299 0.000000
## mxreg3 0.004525 0.007606 0.594991 0.551850
## omega -0.782469 0.457855 -1.708989 0.087453
## alpha1 -0.502646 0.198886 -2.527311 0.011494
## beta1 0.690985 0.095345 7.247224 0.000000
## gamma1 1.762704 0.468576 3.761833 0.000169
## vxreg1 0.034650 0.419262 0.082644 0.934135
## vxreg2 11.953194 6.240425 1.915445 0.055436
## vxreg3 2.549913 0.838963 3.039362 0.002371
##
## LogLikelihood : 9.635011
##
## Information Criteria
## ------------------------------------
##
## Akaike 0.045922
## Bayes 0.352881
## Shibata 0.022371
## Hannan-Quinn 0.170251
##
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.2592 0.6106
## Lag[2*(p+q)+(p+q)-1][2] 0.3811 0.9861
## Lag[4*(p+q)+(p+q)-1][5] 2.6362 0.5280
## d.o.f=1
## H0 : No serial correlation
##
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.3693 0.5434
## Lag[2*(p+q)+(p+q)-1][5] 1.7259 0.6844
## Lag[4*(p+q)+(p+q)-1][9] 2.3184 0.8638
## d.o.f=2
##
## Weighted ARCH LM Tests
## ------------------------------------
## Statistic Shape Scale P-Value
## ARCH Lag[3] 0.3315 0.500 2.000 0.5648
## ARCH Lag[5] 0.7671 1.440 1.667 0.8031
## ARCH Lag[7] 1.0332 2.315 1.543 0.9081
##
## Nyblom stability test
## ------------------------------------
## Joint Statistic: 2.4579
## Individual Statistics:
## mu 0.01918
## ar1 0.02076
## mxreg1 0.07137
## mxreg2 0.02219
## mxreg3 0.07373
## omega 0.03186
## alpha1 0.08188
## beta1 0.26664
## gamma1 0.23160
## vxreg1 0.04269
## vxreg2 0.07414
## vxreg3 0.10439
##
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic: 2.69 2.96 3.51
## Individual Statistic: 0.35 0.47 0.75
##
## Sign Bias Test
## ------------------------------------
## t-value prob sig
## Sign Bias 0.1915 0.8486
## Negative Sign Bias 0.5682 0.5712
## Positive Sign Bias 0.5572 0.5787
## Joint Effect 0.6668 0.8810
##
##
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
## group statistic p-value(g-1)
## 1 20 25.35 0.14936
## 2 30 29.52 0.43803
## 3 40 51.95 0.08024
## 4 50 50.88 0.39933
##
##
## Elapsed time : 0.2549028
##
##
## ==== EGARCH(1,1)-X MODEL: Gold ====
##
## *---------------------------------*
## * GARCH Model Fit *
## *---------------------------------*
##
## Conditional Variance Dynamics
## -----------------------------------
## GARCH Model : sGARCH(1,1)
## Mean Model : ARFIMA(1,0,0)
## Distribution : sstd
##
## Optimal Parameters
## ------------------------------------
## Estimate Std. Error t value Pr(>|t|)
## mu 0.002819 0.003727 0.756359 0.449434
## ar1 0.177726 0.094622 1.878274 0.060344
## mxreg1 -0.004519 0.011366 -0.397540 0.690970
## mxreg2 -0.120184 0.118869 -1.011066 0.311985
## mxreg3 -0.020505 0.019176 -1.069335 0.284919
## omega 0.000000 0.000005 0.061943 0.950608
## alpha1 0.000012 0.010167 0.001195 0.999047
## beta1 0.999637 0.000319 3136.271820 0.000000
## vxreg1 0.000000 0.000018 0.000000 1.000000
## vxreg2 0.000000 0.002731 0.000004 0.999997
## vxreg3 0.000000 0.000150 0.000095 0.999924
## skew 1.233050 0.226819 5.436281 0.000000
## shape 47.365961 67.379995 0.702968 0.482076
##
## Robust Standard Errors:
## Estimate Std. Error t value Pr(>|t|)
## mu 0.002819 0.003652 0.771864 0.440195
## ar1 0.177726 0.072896 2.438069 0.014766
## mxreg1 -0.004519 0.012105 -0.373300 0.708925
## mxreg2 -0.120184 0.145987 -0.823252 0.410365
## mxreg3 -0.020505 0.024390 -0.840717 0.400507
## omega 0.000000 0.000008 0.036268 0.971069
## alpha1 0.000012 0.009563 0.001270 0.998987
## beta1 0.999637 0.000435 2298.241567 0.000000
## vxreg1 0.000000 0.000018 0.000000 1.000000
## vxreg2 0.000000 0.002869 0.000003 0.999997
## vxreg3 0.000000 0.000115 0.000124 0.999901
## skew 1.233050 0.237216 5.198006 0.000000
## shape 47.365961 14.459757 3.275709 0.001054
##
## LogLikelihood : 219.456
##
## Information Criteria
## ------------------------------------
##
## Akaike -4.0089
## Bayes -3.6763
## Shibata -4.0362
## Hannan-Quinn -3.8742
##
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.1373 0.7110
## Lag[2*(p+q)+(p+q)-1][2] 0.5014 0.9640
## Lag[4*(p+q)+(p+q)-1][5] 1.2369 0.9053
## d.o.f=1
## H0 : No serial correlation
##
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.01683 0.8968
## Lag[2*(p+q)+(p+q)-1][5] 1.04479 0.8495
## Lag[4*(p+q)+(p+q)-1][9] 2.23901 0.8746
## d.o.f=2
##
## Weighted ARCH LM Tests
## ------------------------------------
## Statistic Shape Scale P-Value
## ARCH Lag[3] 0.02519 0.500 2.000 0.8739
## ARCH Lag[5] 0.47097 1.440 1.667 0.8922
## ARCH Lag[7] 1.33938 2.315 1.543 0.8529
##
## Nyblom stability test
## ------------------------------------
## Joint Statistic: 15.717
## Individual Statistics:
## mu 0.12592
## ar1 0.03459
## mxreg1 0.09160
## mxreg2 0.18803
## mxreg3 0.06433
## omega 0.76568
## alpha1 0.06735
## beta1 0.06963
## vxreg1 0.40069
## vxreg2 0.10209
## vxreg3 0.05210
## skew 0.09799
## shape 0.54789
##
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic: 2.89 3.15 3.69
## Individual Statistic: 0.35 0.47 0.75
##
## Sign Bias Test
## ------------------------------------
## t-value prob sig
## Sign Bias 1.1591 0.2492
## Negative Sign Bias 0.3099 0.7573
## Positive Sign Bias 0.9794 0.3298
## Joint Effect 2.8323 0.4182
##
##
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
## group statistic p-value(g-1)
## 1 20 14.86 0.7312
## 2 30 19.62 0.9043
## 3 40 35.64 0.6239
## 4 50 38.26 0.8659
##
##
## Elapsed time : 0.1009791
##
##
## ==== EGARCH(1,1)-X MODEL: Portfolio_MeanVaR ====
##
## *---------------------------------*
## * GARCH Model Fit *
## *---------------------------------*
##
## Conditional Variance Dynamics
## -----------------------------------
## GARCH Model : sGARCH(1,1)
## Mean Model : ARFIMA(1,0,0)
## Distribution : sstd
##
## Optimal Parameters
## ------------------------------------
## Estimate Std. Error t value Pr(>|t|)
## mu 0.006204 0.006663 0.931122 0.351791
## ar1 0.326169 0.078783 4.140067 0.000035
## mxreg1 -0.031959 0.017048 -1.874633 0.060843
## mxreg2 0.427909 0.140016 3.056144 0.002242
## mxreg3 0.000576 0.022847 0.025199 0.979897
## omega 0.000000 0.000048 0.001043 0.999168
## alpha1 0.001566 0.012257 0.127760 0.898339
## beta1 0.975009 0.002974 327.835215 0.000000
## vxreg1 0.000000 0.000055 0.000000 1.000000
## vxreg2 0.000000 0.002821 0.000003 0.999997
## vxreg3 0.000000 0.001153 0.000009 0.999993
## skew 1.085959 0.148915 7.292458 0.000000
## shape 2.211484 0.271067 8.158429 0.000000
##
## Robust Standard Errors:
## Estimate Std. Error t value Pr(>|t|)
## mu 0.006204 0.007955 0.779966 0.435411
## ar1 0.326169 0.095492 3.415661 0.000636
## mxreg1 -0.031959 0.022793 -1.402124 0.160878
## mxreg2 0.427909 0.156950 2.726408 0.006403
## mxreg3 0.000576 0.028066 0.020512 0.983635
## omega 0.000000 0.000040 0.001255 0.998999
## alpha1 0.001566 0.022048 0.071023 0.943379
## beta1 0.975009 0.008490 114.846221 0.000000
## vxreg1 0.000000 0.000427 0.000000 1.000000
## vxreg2 0.000000 0.016588 0.000001 1.000000
## vxreg3 0.000000 0.000905 0.000011 0.999991
## skew 1.085959 0.150524 7.214522 0.000000
## shape 2.211484 0.504135 4.386686 0.000012
##
## LogLikelihood : 178.406
##
## Information Criteria
## ------------------------------------
##
## Akaike -3.2118
## Bayes -2.8792
## Shibata -3.2391
## Hannan-Quinn -3.0771
##
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 7.017 8.074e-03
## Lag[2*(p+q)+(p+q)-1][2] 7.970 2.757e-07
## Lag[4*(p+q)+(p+q)-1][5] 8.957 3.065e-03
## d.o.f=1
## H0 : No serial correlation
##
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 1.335 0.2478
## Lag[2*(p+q)+(p+q)-1][5] 1.414 0.7611
## Lag[4*(p+q)+(p+q)-1][9] 1.462 0.9586
## d.o.f=2
##
## Weighted ARCH LM Tests
## ------------------------------------
## Statistic Shape Scale P-Value
## ARCH Lag[3] 0.01025 0.500 2.000 0.9194
## ARCH Lag[5] 0.03883 1.440 1.667 0.9966
## ARCH Lag[7] 0.06686 2.315 1.543 0.9998
##
## Nyblom stability test
## ------------------------------------
## Joint Statistic: 2.7377
## Individual Statistics:
## mu 0.04376
## ar1 0.52763
## mxreg1 0.06161
## mxreg2 0.09153
## mxreg3 0.07227
## omega 0.03735
## alpha1 0.07921
## beta1 0.05767
## vxreg1 0.39357
## vxreg2 0.03845
## vxreg3 0.03473
## skew 0.04863
## shape 0.08210
##
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic: 2.89 3.15 3.69
## Individual Statistic: 0.35 0.47 0.75
##
## Sign Bias Test
## ------------------------------------
## t-value prob sig
## Sign Bias 1.3668 0.1748
## Negative Sign Bias 1.2325 0.2207
## Positive Sign Bias 0.7615 0.4482
## Joint Effect 2.9975 0.3920
##
##
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
## group statistic p-value(g-1)
## 1 20 19.14 0.4481
## 2 30 19.04 0.9203
## 3 40 43.41 0.2890
## 4 50 49.91 0.4369
##
##
## Elapsed time : 0.105469
##
##
## ==== EGARCH(1,1)-X MODEL: Portfolio_Equal ====
##
## *---------------------------------*
## * GARCH Model Fit *
## *---------------------------------*
##
## Conditional Variance Dynamics
## -----------------------------------
## GARCH Model : eGARCH(1,1)
## Mean Model : ARFIMA(1,0,0)
## Distribution : sstd
##
## Optimal Parameters
## ------------------------------------
## Estimate Std. Error t value Pr(>|t|)
## mu -0.007198 0.000004 -1898.1144 0.00000
## ar1 0.311991 0.000118 2634.6729 0.00000
## mxreg1 -0.024946 0.000026 -970.7738 0.00000
## mxreg2 0.077041 0.001634 47.1463 0.00000
## mxreg3 -0.001218 0.000762 -1.5987 0.10989
## omega -0.346215 0.000091 -3809.2900 0.00000
## alpha1 -0.858152 0.000240 -3574.0457 0.00000
## beta1 0.940322 0.000249 3773.2538 0.00000
## gamma1 -0.693724 0.000157 -4422.0317 0.00000
## vxreg1 -0.052507 0.000113 -465.8167 0.00000
## vxreg2 -1.088692 0.012301 -88.5040 0.00000
## vxreg3 -0.508416 0.018264 -27.8376 0.00000
## skew 0.681881 0.000321 2124.0870 0.00000
## shape 2.414738 0.000729 3311.4749 0.00000
##
## Robust Standard Errors:
## Estimate Std. Error t value Pr(>|t|)
## mu -0.007198 0.000020 -353.14088 0.000000
## ar1 0.311991 0.001306 238.80496 0.000000
## mxreg1 -0.024946 0.000103 -243.29429 0.000000
## mxreg2 0.077041 0.018253 4.22076 0.000024
## mxreg3 -0.001218 0.004692 -0.25956 0.795199
## omega -0.346215 0.003150 -109.90642 0.000000
## alpha1 -0.858152 0.006397 -134.14403 0.000000
## beta1 0.940322 0.014159 66.41283 0.000000
## gamma1 -0.693724 0.004455 -155.71075 0.000000
## vxreg1 -0.052507 0.000863 -60.80788 0.000000
## vxreg2 -1.088692 0.169037 -6.44054 0.000000
## vxreg3 -0.508416 0.086170 -5.90018 0.000000
## skew 0.681881 0.001835 371.53785 0.000000
## shape 2.414738 0.014046 171.91495 0.000000
##
## LogLikelihood : 162.1761
##
## Information Criteria
## ------------------------------------
##
## Akaike -2.8772
## Bayes -2.5191
## Shibata -2.9086
## Hannan-Quinn -2.7322
##
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.5335 0.4651
## Lag[2*(p+q)+(p+q)-1][2] 0.8821 0.8081
## Lag[4*(p+q)+(p+q)-1][5] 1.5380 0.8373
## d.o.f=1
## H0 : No serial correlation
##
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.0914 0.7624
## Lag[2*(p+q)+(p+q)-1][5] 0.2863 0.9851
## Lag[4*(p+q)+(p+q)-1][9] 0.4719 0.9987
## d.o.f=2
##
## Weighted ARCH LM Tests
## ------------------------------------
## Statistic Shape Scale P-Value
## ARCH Lag[3] 0.06755 0.500 2.000 0.7949
## ARCH Lag[5] 0.13757 1.440 1.667 0.9794
## ARCH Lag[7] 0.19682 2.315 1.543 0.9971
##
## Nyblom stability test
## ------------------------------------
## Joint Statistic: 9.1122
## Individual Statistics:
## mu 0.03529
## ar1 0.03527
## mxreg1 0.03546
## mxreg2 0.03539
## mxreg3 0.03485
## omega 0.03519
## alpha1 0.03532
## beta1 0.02049
## gamma1 0.03539
## vxreg1 0.03519
## vxreg2 0.03541
## vxreg3 0.03354
## skew 0.03502
## shape 0.03524
##
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic: 3.08 3.34 3.9
## Individual Statistic: 0.35 0.47 0.75
##
## Sign Bias Test
## ------------------------------------
## t-value prob sig
## Sign Bias 0.9840 0.3276
## Negative Sign Bias 0.4237 0.6727
## Positive Sign Bias 0.3381 0.7360
## Joint Effect 1.0160 0.7974
##
##
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
## group statistic p-value(g-1)
## 1 20 28.84 0.06847
## 2 30 37.68 0.12963
## 3 40 56.61 0.03381
## 4 50 61.56 0.10740
##
##
## Elapsed time : 0.4869609
# Ekstrak hasil uji ARCH-LM dan Ljung-Box dari residual model GARCH-X
extract_arch_ljungbox <- function(garch_model) {
if (!garch_model$valid) return(data.frame(
Asset = garch_model$name,
ARCH_LM_pvalue = NA,
LjungBox_pvalue = NA
))
res <- residuals(garch_model$fit, standardize = TRUE)
# ARCH-LM test pada squared residuals, lag=5
arch_test <- tryCatch(lmtest::ArchTest(res, lags = 5), error = function(e) NULL)
arch_lm_pvalue <- if (!is.null(arch_test)) arch_test$p.value else NA
# Ljung-Box test pada squared residuals, lag=5
lb_test <- tryCatch(Box.test(res^2, lag = 5, type = "Ljung-Box"), error = function(e) NULL)
ljungbox_pvalue <- if (!is.null(lb_test)) lb_test$p.value else NA
data.frame(
Asset = garch_model$name,
ARCH_LM_pvalue = arch_lm_pvalue,
LjungBox_pvalue = ljungbox_pvalue
)
}
arch_ljungbox_table_garch <- do.call(rbind, lapply(
list(garch_jkse, garch_bond, garch_btc, garch_gold, garch_portfolio_meanvar, garch_portfolio_equal),
extract_arch_ljungbox
))
print(arch_ljungbox_table_garch)
## Asset ARCH_LM_pvalue LjungBox_pvalue
## 1 JKSE NA 0.8352112
## 2 Bond NA 0.9858232
## 3 BTC NA 0.8624085
## 4 Gold NA 0.8899282
## 5 Portfolio_MeanVaR NA 0.9172916
## 6 Portfolio_Equal NA 0.9910696
arch_ljungbox_table_egarch <- do.call(rbind, lapply(
list(egarch_jkse, egarch_bond, egarch_btc, egarch_gold, egarch_portfolio_meanvar, egarch_portfolio_equal),
extract_arch_ljungbox
))
print(arch_ljungbox_table_egarch)
## Asset ARCH_LM_pvalue LjungBox_pvalue
## 1 JKSE NA 0.6593049
## 2 Bond NA 0.9504252
## 3 BTC NA 0.7485473
## 4 Gold NA 0.8890743
## 5 Portfolio_MeanVaR NA 0.9173475
## 6 Portfolio_Equal NA 0.9946003
# Ekstrak hasil uji ARCH-LM dan Weighted Ljung-Box dari model GARCH-X
extract_arch_ljungbox <- function(garch_model) {
if (!garch_model$valid) return(data.frame(
Asset = garch_model$name,
ARCH_LM_pvalue = NA,
LjungBox_pvalue = NA
))
# ARCH-LM: gunakan lag 5 (umum dipakai)
arch_lm <- garch_model$fit@fit$robust.archlm
arch_lm_pvalue <- if (!is.null(arch_lm)) arch_lm[2, "P-Value"] else NA
# Ljung-Box: gunakan lag 5 pada squared residuals
ljungbox <- garch_model$fit@fit$robust.lbq2
ljungbox_pvalue <- if (!is.null(ljungbox)) ljungbox[2, "p-value"] else NA
data.frame(
Asset = garch_model$name,
ARCH_LM_pvalue = arch_lm_pvalue,
LjungBox_pvalue = ljungbox_pvalue
)
}
arch_ljungbox_table_garch <- do.call(rbind, lapply(
list(garch_jkse, garch_bond, garch_btc, garch_gold, garch_portfolio_meanvar, garch_portfolio_equal),
extract_arch_ljungbox
))
print(arch_ljungbox_table_garch)
## Asset ARCH_LM_pvalue LjungBox_pvalue
## 1 JKSE NA NA
## 2 Bond NA NA
## 3 BTC NA NA
## 4 Gold NA NA
## 5 Portfolio_MeanVaR NA NA
## 6 Portfolio_Equal NA NA
arch_ljungbox_table_egarch <- do.call(rbind, lapply(
list(egarch_jkse, egarch_bond, egarch_btc, egarch_gold, egarch_portfolio_meanvar, egarch_portfolio_equal),
extract_arch_ljungbox
))
print(arch_ljungbox_table_egarch)
## Asset ARCH_LM_pvalue LjungBox_pvalue
## 1 JKSE NA NA
## 2 Bond NA NA
## 3 BTC NA NA
## 4 Gold NA NA
## 5 Portfolio_MeanVaR NA NA
## 6 Portfolio_Equal NA NA
library(ggplot2)
library(gridExtra)
##
## Attaching package: 'gridExtra'
## The following object is masked from 'package:dplyr':
##
## combine
# Your existing code - Fixed length issue
birate_model <- ses(ts(head(apt_data$bi_rate, -1)), h=1)
birate_forecasts <- c(NA, fitted(birate_model)[1:(nrow(apt_data)-1)]) # Fix length
birate_surprise <- apt_data$bi_rate - birate_forecasts
cpi_model <- ses(ts(head(apt_data$cpi, -1)), h=1)
cpi_forecasts <- c(NA, fitted(cpi_model)[1:(nrow(apt_data)-1)]) # Fix length
cpi_surprise <- (apt_data$cpi - cpi_forecasts)/apt_data$cpi
kurs_model <- ses(ts(head(apt_data$kurs_idr, -1)), h=1)
kurs_forecasts <- c(NA, fitted(kurs_model)[1:(nrow(apt_data)-1)]) # Fix length
kurs_surprise <- (apt_data$kurs_idr - kurs_forecasts)/apt_data$kurs_idr
# Add to dataset (now same length)
apt_data$birate_surprise <- birate_surprise
apt_data$cpi_surprise <- cpi_surprise
apt_data$kurs_surprise <- kurs_surprise
apt_data$birate_forecasts <- birate_forecasts
apt_data$cpi_forecasts <- cpi_forecasts
apt_data$kurs_forecasts <- kurs_forecasts
# BI Rate plot
p1 <- ggplot(apt_data, aes(x = 1:nrow(apt_data))) +
geom_line(aes(y = bi_rate, color = "Actual"), linewidth = 1) +
geom_line(aes(y = birate_forecasts, color = "Forecast"), size = 1) +
labs(title = "BI Rate: Actual vs Forecast", x = "Time", y = "Rate") +
scale_color_manual(values = c("blue", "red")) +
theme_minimal()
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
# CPI plot
p2 <- ggplot(apt_data, aes(x = 1:nrow(apt_data))) +
geom_line(aes(y = cpi, color = "Actual"), size = 1) +
geom_line(aes(y = cpi_forecasts, color = "Forecast"), size = 1) +
labs(title = "CPI: Actual vs Forecast", x = "Time", y = "Rate") +
scale_color_manual(values = c("blue", "red")) +
theme_minimal()
# Exchange Rate plot
p3 <- ggplot(apt_data, aes(x = 1:nrow(apt_data))) +
geom_line(aes(y = kurs_idr, color = "Actual"), size = 1) +
geom_line(aes(y = kurs_forecasts, color = "Forecast"), size = 1) +
labs(title = "Exchange Rate: Actual vs Forecast", x = "Time", y = "IDR/USD") +
scale_color_manual(values = c("blue", "red")) +
theme_minimal()
# Show plots
grid.arrange(p1, p2, p3, ncol = 1)
## Warning: Removed 1 row containing missing values or values outside the scale range
## (`geom_line()`).
## Warning: Removed 1 row containing missing values or values outside the scale range
## (`geom_line()`).
## Removed 1 row containing missing values or values outside the scale range
## (`geom_line()`).

# desctiptive table exxess for macroeconomic variables
library(psych)
##
## Attaching package: 'psych'
## The following objects are masked from 'package:ggplot2':
##
## %+%, alpha
## The following object is masked from 'package:car':
##
## logit
macro_vars <- apt_data %>%
select(birate_surprise, cpi_surprise, kurs_surprise)
describe(macro_vars)
## vars n mean sd median trimmed mad min max range skew
## birate_surprise 1 102 0.01 0.29 0.00 -0.01 0.00 -0.50 1.00 1.50 1.22
## cpi_surprise 2 102 -0.03 0.17 -0.03 -0.02 0.16 -0.48 0.41 0.89 -0.22
## kurs_surprise 3 102 0.00 0.03 0.00 0.00 0.02 -0.11 0.12 0.24 0.20
## kurtosis se
## birate_surprise 2.91 0.03
## cpi_surprise -0.11 0.02
## kurs_surprise 5.29 0.00
summary(macro_vars)
## birate_surprise cpi_surprise kurs_surprise
## Min. :-5.000e-01 Min. :-0.48487 Min. :-0.113800
## 1st Qu.:-2.503e-05 1st Qu.:-0.12932 1st Qu.:-0.010813
## Median : 0.000e+00 Median :-0.02579 Median : 0.002625
## Mean : 1.445e-02 Mean :-0.02908 Mean : 0.003135
## 3rd Qu.: 0.000e+00 3rd Qu.: 0.08686 3rd Qu.: 0.016062
## Max. : 1.000e+00 Max. : 0.40634 Max. : 0.123705
## NA's :1 NA's :1 NA's :1
# Uji Stasioneritas
# Daftar variabel yang akan diuji stasioneritasnya
variables_to_test <- c(
"excess_jkse", "excess_bond", "excess_btc", "excess_gold",
"excess_portfolio_meanvar", "excess_portfolio_equal",
"birate_surprise", "cpi_surprise", "kurs_surprise"
)
# Lakukan PP test untuk setiap variabel
stationarity_results <- lapply(variables_to_test, function(var_name) {
if (var_name %in% colnames(apt_data)) {
x <- apt_data[[var_name]]
# Pastikan numeric dan buang NA
x <- as.numeric(x)
x <- na.omit(x)
# Jalankan pp.test dengan tryCatch untuk hindari error
test_result <- tryCatch(
pp.test(x, alternative = "stationary"),
error = function(e) NULL
)
if (!is.null(test_result)) {
data.frame(
Variable = var_name,
PP_Statistic = test_result$statistic,
P_Value = test_result$p.value,
Stationary = ifelse(test_result$p.value < 0.05, "Yes", "No")
)
} else {
data.frame(
Variable = var_name,
PP_Statistic = NA,
P_Value = NA,
Stationary = "Error or non-numeric data"
)
}
} else {
data.frame(
Variable = var_name,
PP_Statistic = NA,
P_Value = NA,
Stationary = "Variable not found"
)
}
})
## Warning in pp.test(x, alternative = "stationary"): p-value smaller than printed
## p-value
## Warning in pp.test(x, alternative = "stationary"): p-value smaller than printed
## p-value
## Warning in pp.test(x, alternative = "stationary"): p-value smaller than printed
## p-value
## Warning in pp.test(x, alternative = "stationary"): p-value smaller than printed
## p-value
## Warning in pp.test(x, alternative = "stationary"): p-value smaller than printed
## p-value
## Warning in pp.test(x, alternative = "stationary"): p-value smaller than printed
## p-value
## Warning in pp.test(x, alternative = "stationary"): p-value smaller than printed
## p-value
## Warning in pp.test(x, alternative = "stationary"): p-value smaller than printed
## p-value
# Gabungkan hasil
stationarity_summary <- do.call(rbind, stationarity_results)
print(stationarity_summary)
## Variable PP_Statistic P_Value
## Dickey-Fuller Z(alpha) excess_jkse -63.71615 0.01000000
## Dickey-Fuller Z(alpha)1 excess_bond -67.10386 0.01000000
## Dickey-Fuller Z(alpha)2 excess_btc -105.63195 0.01000000
## Dickey-Fuller Z(alpha)3 excess_gold -72.38109 0.01000000
## Dickey-Fuller Z(alpha)4 excess_portfolio_meanvar -103.60496 0.01000000
## Dickey-Fuller Z(alpha)5 excess_portfolio_equal -104.84247 0.01000000
## Dickey-Fuller Z(alpha)6 birate_surprise -23.03102 0.02994868
## Dickey-Fuller Z(alpha)7 cpi_surprise -37.77057 0.01000000
## Dickey-Fuller Z(alpha)8 kurs_surprise -40.46130 0.01000000
## Stationary
## Dickey-Fuller Z(alpha) Yes
## Dickey-Fuller Z(alpha)1 Yes
## Dickey-Fuller Z(alpha)2 Yes
## Dickey-Fuller Z(alpha)3 Yes
## Dickey-Fuller Z(alpha)4 Yes
## Dickey-Fuller Z(alpha)5 Yes
## Dickey-Fuller Z(alpha)6 Yes
## Dickey-Fuller Z(alpha)7 Yes
## Dickey-Fuller Z(alpha)8 Yes
# Interpretasi:
# P-value < 0.05 menunjukkan bahwa kita menolak hipotesis nol (data tidak stasioner)
# dan menyimpulkan bahwa data stasioner.
# Visualize the portfolio weights
par(mfrow=c(1,2))
# Plot Mean-VaR weights
bp <- barplot(meanvar_weights,
main="Mean-VaR Portfolio Weights",
col=rainbow(length(meanvar_weights)),
ylab="Weight",
ylim=c(0, max(meanvar_weights) * 1.2))
text(x = bp,
y = meanvar_weights + 0.02,
labels = paste0(round(meanvar_weights * 100, 1), "%"),
cex = 0.9,
pos = 3, # pos = 3 → di atas batang
adj = 0.5)
# Plot Equal-weighted for comparison
equal_weights <- rep(1/length(meanvar_weights), length(meanvar_weights))
names(equal_weights) <- names(meanvar_weights)
bp2 <- barplot(equal_weights,
main="Equal-Weighted Portfolio",
col=rainbow(length(equal_weights)),
ylab="Weight",
ylim=c(0, max(meanvar_weights) * 1.2))
text(x = bp2,
y = equal_weights + 0.02,
labels = paste0(round(equal_weights * 100, 1), "%"),
cex = 0.9,
pos = 3, # pos = 3 → di atas batang
adj = 0.5)

# Create pie charts for the portfolio weights
par(mfrow=c(1,2))
# Mean-VaR portfolio
pie(meanvar_weights,
labels=paste0(names(meanvar_weights), " (", round(meanvar_weights * 100, 1), "%)"),
col=rainbow(length(meanvar_weights)),
main="Mean-VaR Portfolio Allocation")
# Equal-weighted portfolio
pie(equal_weights,
labels=paste0(names(equal_weights), " (", round(equal_weights * 100, 1), "%)"),
col=rainbow(length(equal_weights)),
main="Equal-Weighted Portfolio Allocation")

par(mfrow=c(1,1))
# Plot efficient frontier
n_portfolios <- 500
weights_matrix <- matrix(0, nrow=n_portfolios, ncol=num_assets)
returns_vector <- numeric(n_portfolios)
risk_vector <- numeric(n_portfolios)
# Generate random portfolios
for (i in 1:n_portfolios) {
weights <- runif(num_assets)
weights <- weights / sum(weights)
weights_matrix[i,] <- weights
# Calculate portfolio return and risk
returns_vector[i] <- calculate_portfolio_return(weights, return_matrix)
risk_vector[i] <- calculate_portfolio_var(weights, return_matrix)
}
# Plot the efficient frontier
plot(risk_vector, returns_vector * 100,
pch=19, cex=0.5, col="gray",
xlab="Value at Risk (VaR)",
ylab="Expected Monthly Return (%)",
main="Portfolio Efficiency: Return vs. VaR")
# Add individual assets
asset_returns <- colMeans(return_matrix) * 100
asset_vars <- apply(return_matrix, 2, function(x) calculate_portfolio_var(1, matrix(x)))
points(asset_vars, asset_returns, col="blue", pch=17, cex=1.5)
text(asset_vars, asset_returns, labels=colnames(return_matrix), pos=4)
# Add the optimized and equal-weight portfolios
points(calculate_portfolio_var(meanvar_weights, return_matrix),
calculate_portfolio_return(meanvar_weights, return_matrix) * 100,
col="red", pch=18, cex=2)
text(calculate_portfolio_var(meanvar_weights, return_matrix),
calculate_portfolio_return(meanvar_weights, return_matrix) * 100,
"Mean-VaR", pos=2, col="red")
points(calculate_portfolio_var(equal_weights, return_matrix),
calculate_portfolio_return(equal_weights, return_matrix) * 100,
col="darkgreen", pch=18, cex=2)
text(calculate_portfolio_var(equal_weights, return_matrix),
calculate_portfolio_return(equal_weights, return_matrix) * 100,
"Equal-Weight", pos=4, col="darkgreen")
legend("topright",
legend=c("Random Portfolios", "Individual Assets", "Mean-VaR Portfolio", "Equal-Weight Portfolio"),
col=c("gray", "blue", "red", "darkgreen"),
pch=c(19, 17, 18, 18),
cex=0.8)

# Visualisasi beta GARCH-X
beta_data <- data.frame(
Asset = garch_stats$Asset,
Factor = rep(c("BI Rate", "Exchange Rate", "Inflation"), each = nrow(garch_stats)),
Beta = c(garch_stats$Beta_BIRate, garch_stats$Beta_Exchange, garch_stats$Beta_Inflation)
)
ggplot(beta_data, aes(x = Asset, y = Beta, fill = Factor)) +
geom_bar(stat = "identity", position = position_dodge()) +
theme_minimal() +
labs(title = "Factor Sensitivities (Betas) by Asset",
subtitle = "GARCH(1,1)-X Model with Macroeconomic Factors",
x = "Asset",
y = "Beta Coefficient") +
theme(axis.text.x = element_text(angle = 45, hjust = 1))

garch_params <- garch_stats[, c("Asset", "GARCH_Alpha1", "GARCH_Beta1", "Persistence")]
garch_params_wide <- reshape2::dcast(
reshape2::melt(garch_params, id.vars = "Asset"),
Asset ~ variable
)
rownames(garch_params_wide) <- garch_params_wide$Asset
garch_params_wide$Asset <- NULL
heatmap(as.matrix(garch_params_wide),
Rowv = NA, Colv = NA,
col = colorRampPalette(c("blue", "white", "red"))(100),
scale = "none",
margins = c(5, 10),
main = "GARCH Model Parameters")

persistence_data <- data.frame(
Asset = garch_stats$Asset,
Persistence = garch_stats$Persistence
)
# Urutkan data berdasarkan nilai Persistence (descending)
persistence_data <- persistence_data[order(-persistence_data$Persistence), ]
# Buat barplot dan simpan posisi tengah tiap batang
bar_centers <- barplot(persistence_data$Persistence,
names.arg = persistence_data$Asset,
main = "GARCH Volatility Persistence by Asset",
col = rainbow(nrow(persistence_data)),
las = 2,
ylim = c(0, 1.1),
cex.names = 0.8)
# Garis referensi di nilai 1
abline(h = 1, lty = 2, col = "red")
# Tambahkan label di atas tengah setiap batang
text(x = bar_centers,
y = persistence_data$Persistence + 0.05,
labels = paste0(round(persistence_data$Persistence * 100, 1), "%"),
cex = 0.7,
pos = 3)

# Visualisasi beta EGARCH-X
beta_data_egarch <- data.frame(
Asset = egarch_stats$Asset,
Factor = rep(c("BI Rate", "Exchange Rate", "Inflation"), each = nrow(egarch_stats)),
Beta = c(egarch_stats$Beta_BIRate, egarch_stats$Beta_Exchange, egarch_stats$Beta_Inflation)
)
ggplot(beta_data_egarch, aes(x = Asset, y = Beta, fill = Factor)) +
geom_bar(stat = "identity", position = position_dodge()) +
theme_minimal() +
labs(title = "Factor Sensitivities (Betas) by Asset",
subtitle = "EGARCH(1,1)-X Model with Macroeconomic Factors",
x = "Asset",
y = "Beta Coefficient") +
theme(axis.text.x = element_text(angle = 45, hjust = 1))

egarch_params <- egarch_stats[, c("Asset", "GARCH_Alpha1", "GARCH_Beta1", "Persistence")]
egarch_params_wide <- reshape2::dcast(
reshape2::melt(egarch_params, id.vars = "Asset"),
Asset ~ variable
)
rownames(egarch_params_wide) <- egarch_params_wide$Asset
egarch_params_wide$Asset <- NULL
heatmap(as.matrix(egarch_params_wide),
Rowv = NA, Colv = NA,
col = colorRampPalette(c("blue", "white", "red"))(100),
scale = "none",
margins = c(5, 10),
main = "EGARCH Model Parameters")

persistence_data_egarch <- data.frame(
Asset = egarch_stats$Asset,
Persistence = egarch_stats$Persistence
)
# Urutkan data berdasarkan nilai Persistence (descending)
persistence_data_egarch <- persistence_data_egarch[order(-persistence_data_egarch$Persistence), ]
# Buat barplot dan simpan posisi tengah tiap batang
bar_centers_egarch <- barplot(persistence_data_egarch$Persistence,
names.arg = persistence_data_egarch$Asset,
main = "EGARCH Volatility Persistence by Asset",
col = rainbow(nrow(persistence_data_egarch)),
las = 2,
ylim = c(0, 1.1),
cex.names = 0.8)
# Garis referensi di nilai 1
abline(h = 1, lty = 2, col = "red")
# Tambahkan label di atas tengah setiap batang
text(x = bar_centers_egarch,
y = persistence_data_egarch$Persistence + 0.05,
labels = paste0(round(persistence_data_egarch$Persistence * 100, 1), "%"),
cex = 0.7,
pos = 3)

## Value-at-Risk (VaR) Calculation with GARCH and Backtesting
# Helper functions for GARCH models
extract_conditional_mean <- function(garch_model) {
if (!garch_model$valid) return(NULL)
fitted(garch_model$fit)
}
extract_conditional_volatility <- function(garch_model) {
if (!garch_model$valid) return(NULL)
sigma(garch_model$fit)
}
# Fungsi VaR GARCH-X
calculate_garch_var <- function(garch_model, confidence_level = 0.95) {
if (!garch_model$valid) return(NULL)
cond_mean <- extract_conditional_mean(garch_model)
cond_vol <- extract_conditional_volatility(garch_model)
df <- tail(coef(garch_model$fit), 1)
if (is.na(df) || df <= 2) df <- 5
t_critical <- qt(1 - confidence_level, df = df)
-(cond_mean + t_critical * cond_vol)
}
perform_garch_var_backtesting <- function(returns, garch_model, confidence_level = 0.95) {
if (!garch_model$valid) return(list(exceedances = NA, dates = NA, var_estimates = NA, n = NA))
var_estimates <- calculate_garch_var(garch_model, confidence_level)
exceedances <- ifelse(-returns > var_estimates, 1, 0)
list(var_estimates = var_estimates, exceedances = exceedances, dates = seq_along(var_estimates), n = length(var_estimates))
}
kupiec_test <- function(exceedances, total_obs, confidence_level) {
alpha <- 1 - confidence_level
x <- sum(exceedances, na.rm=TRUE)
p_hat <- x / total_obs
if (x == 0) {
lr_stat <- -2 * log((1-alpha)^total_obs)
} else if (x == total_obs) {
lr_stat <- -2 * log(alpha^total_obs)
} else {
lr_stat <- -2 * log((1-alpha)^(total_obs - x) * alpha^x) +
2 * log((1-p_hat)^(total_obs - x) * p_hat^x)
}
p_value <- 1 - pchisq(lr_stat, df = 1)
list(
exceptions = x, total_obs = total_obs, expected_rate = alpha, actual_rate = p_hat,
lr_stat = lr_stat, p_value = p_value, result = ifelse(p_value > 0.05, "Accept", "Reject")
)
}
# Update to use excess returns for backtesting
returns <- list(
JKSE = apt_data$excess_jkse,
Bond = apt_data$excess_bond,
BTC = apt_data$excess_btc,
Gold = apt_data$excess_gold,
Portfolio_MeanVaR = apt_data$excess_portfolio_meanvar,
Portfolio_Equal = apt_data$excess_portfolio_equal
)
garch_models <- list(
JKSE = garch_jkse,
Bond = garch_bond,
BTC = garch_btc,
Gold = garch_gold,
Portfolio_MeanVaR = garch_portfolio_meanvar,
Portfolio_Equal = garch_portfolio_equal
)
egarch_models <- list(
JKSE = egarch_jkse,
Bond = egarch_bond,
BTC = egarch_btc,
Gold = egarch_gold,
Portfolio_MeanVaR = egarch_portfolio_meanvar,
Portfolio_Equal = egarch_portfolio_equal
)
confidence_level <- 0.95
garch_backtest_results <- list()
garch_kupiec_results <- list()
egarch_backtest_results <- list()
egarch_kupiec_results <- list()
for (asset_name in names(returns)) {
backtest <- perform_garch_var_backtesting(returns[[asset_name]], garch_models[[asset_name]], confidence_level)
garch_backtest_results[[asset_name]] <- backtest
if (!is.na(backtest$n)) {
kupiec <- kupiec_test(backtest$exceedances, backtest$n, confidence_level)
garch_kupiec_results[[asset_name]] <- kupiec
}
}
for (asset_name in names(returns)) {
backtest <- perform_garch_var_backtesting(returns[[asset_name]], egarch_models[[asset_name]], confidence_level)
egarch_backtest_results[[asset_name]] <- backtest
if (!is.na(backtest$n)) {
kupiec <- kupiec_test(backtest$exceedances, backtest$n, confidence_level)
egarch_kupiec_results[[asset_name]] <- kupiec
}
}
garch_kupiec_summary <- do.call(rbind, lapply(names(garch_kupiec_results), function(asset) {
result <- garch_kupiec_results[[asset]]
if (is.null(result)) return(NULL)
data.frame(
Asset = asset,
Observations = result$total_obs,
Exceptions = result$exceptions,
Expected_Rate = result$expected_rate,
Actual_Rate = result$actual_rate,
LR_Statistic = result$lr_stat,
P_Value = result$p_value,
Result = result$result
)
}))
egarch_kupiec_summary <- do.call(rbind, lapply(names(egarch_kupiec_results), function(asset) {
result <- egarch_kupiec_results[[asset]]
if (is.null(result)) return(NULL)
data.frame(
Asset = asset,
Observations = result$total_obs,
Exceptions = result$exceptions,
Expected_Rate = result$expected_rate,
Actual_Rate = result$actual_rate,
LR_Statistic = result$lr_stat,
P_Value = result$p_value,
Result = result$result
)
}))
print(garch_kupiec_summary)
## Asset Observations Exceptions Expected_Rate Actual_Rate
## 1 JKSE 103 3 0.05 0.029126214
## 2 Bond 103 2 0.05 0.019417476
## 3 BTC 103 2 0.05 0.019417476
## 4 Gold 103 4 0.05 0.038834951
## 5 Portfolio_MeanVaR 103 1 0.05 0.009708738
## 6 Portfolio_Equal 103 1 0.05 0.009708738
## LR_Statistic P_Value Result
## 1 1.1045919 0.29326058 Accept
## 2 2.6169361 0.10572841 Accept
## 3 2.6169361 0.10572841 Accept
## 4 0.2918441 0.58904119 Accept
## 5 5.1955789 0.02264441 Reject
## 6 5.1955789 0.02264441 Reject
print(egarch_kupiec_summary)
## Asset Observations Exceptions Expected_Rate Actual_Rate
## 1 JKSE 103 3 0.05 0.029126214
## 2 Bond 103 3 0.05 0.029126214
## 3 BTC 103 1 0.05 0.009708738
## 4 Gold 103 4 0.05 0.038834951
## 5 Portfolio_MeanVaR 103 1 0.05 0.009708738
## 6 Portfolio_Equal 103 1 0.05 0.009708738
## LR_Statistic P_Value Result
## 1 1.1045919 0.29326058 Accept
## 2 1.1045919 0.29326058 Accept
## 3 5.1955789 0.02264441 Reject
## 4 0.2918441 0.58904119 Accept
## 5 5.1955789 0.02264441 Reject
## 6 5.1955789 0.02264441 Reject
# Compare Mean-VaR and Equal-weighted portfolio performance over time
# Calculate cumulative returns
dates <- apt_data$date
meanvar_cumulative <- cumprod(1 + apt_data$portfolio_return_meanvar)
equal_cumulative <- cumprod(1 + apt_data$portfolio_return_equal)
jkse_cumulative <- cumprod(1 + apt_data$jkse_return)
bond_cumulative <- cumprod(1 + apt_data$bond_return)
btc_cumulative <- cumprod(1 + apt_data$btc_return)
gold_cumulative <- cumprod(1 + apt_data$gold_return)
# Plot cumulative returns
plot(dates, meanvar_cumulative, type="l", col="red", lwd=2,
xlab="Date", ylab="Cumulative Return (Starting with 1)",
main="Cumulative Performance Comparison",
ylim=c(min(0.5, min(meanvar_cumulative, equal_cumulative) * 0.9),
max(meanvar_cumulative, equal_cumulative, btc_cumulative) * 1.1))
lines(dates, equal_cumulative, col="blue", lwd=2)
lines(dates, jkse_cumulative, col="darkgreen", lwd=1)
lines(dates, bond_cumulative, col="purple", lwd=1)
lines(dates, btc_cumulative, col="black", lwd=1)
lines(dates, gold_cumulative, col="goldenrod1", lwd=1)
legend("topleft",
legend=c("Mean-VaR Portfolio", "Equal-Weight Portfolio",
"JKSE", "Bond", "BTC", "Gold"),
col=c("red", "blue", "darkgreen", "purple", "orange", "black", "goldenrod1"),
lwd=c(2, 2, 1, 1, 1, 1, 1),
cex=0.7)

# Rolling metrics
window <- 24 # 24-month rolling window
rolling_returns <- matrix(NA, nrow=length(dates) - window, ncol=6)
rolling_volatility <- matrix(NA, nrow=length(dates) - window, ncol=6)
rolling_sharpe <- matrix(NA, nrow=length(dates) - window, ncol=6)
rolling_var <- matrix(NA, nrow=length(dates) - window, ncol=6)
for(i in 1:(length(dates) - window)) {
window_returns <- cbind(
apt_data$portfolio_return_meanvar[i:(i+window-1)],
apt_data$portfolio_return_equal[i:(i+window-1)],
apt_data$jkse_return[i:(i+window-1)],
apt_data$bond_return[i:(i+window-1)],
apt_data$btc_return[i:(i+window-1)],
apt_data$gold_return[i:(i+window-1)]
)
rolling_returns[i,] <- colMeans(window_returns)
rolling_volatility[i,] <- apply(window_returns, 2, sd)
rolling_sharpe[i,] <- rolling_returns[i,] / rolling_volatility[i,]
rolling_var[i,] <- apply(window_returns, 2, function(x) -quantile(x, 0.05))
}
# Plot rolling Sharpe ratio
par(mfrow=c(2,1))
plot(dates[(window+1):length(dates)], rolling_sharpe[,1], type="l", col="red", lwd=2,
xlab="Date", ylab="Sharpe Ratio",
main="Rolling 24-Month Sharpe Ratio",
ylim=c(min(rolling_sharpe[,1:2]) * 1.1, max(rolling_sharpe[,1:2]) * 1.1))
lines(dates[(window+1):length(dates)], rolling_sharpe[,2], col="blue", lwd=2)
abline(h=0, lty=2, col="gray")
legend("bottomright",
legend=c("Mean-VaR Portfolio", "Equal-Weight Portfolio"),
col=c("red", "blue"),
lwd=2,
cex=0.8)
# Plot rolling VaR
plot(dates[(window+1):length(dates)], rolling_var[,1], type="l", col="red", lwd=2,
xlab="Date", ylab="Value-at-Risk (95%)",
main="Rolling 24-Month VaR (95%)",
ylim=c(min(rolling_var[,1:2]) * 0.9, max(rolling_var[,1:2]) * 1.1))
lines(dates[(window+1):length(dates)], rolling_var[,2], col="blue", lwd=2)
legend("topright",
legend=c("Mean-VaR Portfolio", "Equal-Weight Portfolio"),
col=c("red", "blue"),
lwd=2,
cex=0.8)

par(mfrow=c(1,1))
# Calculate summary statistics
return_stats <- data.frame(
Asset = c("JKSE", "Bond", "BTC", "Gold", "Portfolio_MeanVaR", "Portfolio_Equal"),
Mean_Return = c(
mean(apt_data$jkse_return, na.rm=TRUE),
mean(apt_data$bond_return, na.rm=TRUE),
mean(apt_data$btc_return, na.rm=TRUE),
mean(apt_data$gold_return, na.rm=TRUE),
mean(apt_data$portfolio_return_meanvar, na.rm=TRUE),
mean(apt_data$portfolio_return_equal, na.rm=TRUE)
) * 100,
Volatility = c(
sd(apt_data$jkse_return, na.rm=TRUE),
sd(apt_data$bond_return, na.rm=TRUE),
sd(apt_data$btc_return, na.rm=TRUE),
sd(apt_data$gold_return, na.rm=TRUE),
sd(apt_data$portfolio_return_meanvar, na.rm=TRUE),
sd(apt_data$portfolio_return_equal, na.rm=TRUE)
) * 100,
Sharpe = c(
mean(apt_data$excess_jkse, na.rm=TRUE) / sd(apt_data$jkse_return, na.rm=TRUE),
mean(apt_data$excess_bond, na.rm=TRUE) / sd(apt_data$bond_return, na.rm=TRUE),
mean(apt_data$excess_btc, na.rm=TRUE) / sd(apt_data$btc_return, na.rm=TRUE),
mean(apt_data$excess_gold, na.rm=TRUE) / sd(apt_data$gold_return, na.rm=TRUE),
mean(apt_data$excess_portfolio_meanvar, na.rm=TRUE) / sd(apt_data$portfolio_return_meanvar, na.rm=TRUE),
mean(apt_data$excess_portfolio_equal, na.rm=TRUE) / sd(apt_data$portfolio_return_equal, na.rm=TRUE)
),
VaR_95 = sapply(returns, function(x) -quantile(x, 0.05, na.rm=TRUE)) * 100,
GARCH_VaR_95 = sapply(names(garch_models), function(a) {
var_vals <- calculate_garch_var(garch_models[[a]])
if (is.null(var_vals)) return(NA)
mean(var_vals, na.rm=TRUE)
}) * 100,
EGARCH_VaR_95 = sapply(names(egarch_models), function(a) {
var_vals <- calculate_garch_var(egarch_models[[a]])
if (is.null(var_vals)) return(NA)
mean(var_vals, na.rm=TRUE)
}) * 100,
Max_Drawdown = sapply(returns, function(x) {
cumu <- cumprod(1 + x)
maxDD <- 0
peak <- cumu[1]
for(i in 2:length(cumu)) {
if(cumu[i] > peak) peak <- cumu[i]
DD <- (peak - cumu[i]) / peak
if(DD > maxDD) maxDD <- DD
}
return(maxDD * 100)
})
)
return_stats <- return_stats[order(-return_stats$Sharpe),]
print(return_stats)
## Asset Mean_Return Volatility Sharpe
## Gold.5% Gold 0.7215469 3.026203 0.10405524
## JKSE.5% JKSE 0.4019900 3.525595 -0.00132305
## BTC.5% BTC -3.5640100 72.298532 -0.05492040
## Portfolio_Equal.5% Portfolio_Equal -0.6360949 18.043329 -0.05779141
## Portfolio_MeanVaR.5% Portfolio_MeanVaR -0.6361107 14.515187 -0.07183960
## Bond.5% Bond -0.1039063 3.529937 -0.14463740
## VaR_95 GARCH_VaR_95 EGARCH_VaR_95 Max_Drawdown
## Gold.5% 4.834474 4.517751 4.544245 22.56251
## JKSE.5% 5.136946 5.107161 5.476672 40.18008
## BTC.5% 26.100493 89.811051 152.033916 145.20110
## Portfolio_Equal.5% 7.546865 53.900799 29.094118 199.89648
## Portfolio_MeanVaR.5% 4.946454 24.853187 24.853688 141.77021
## Bond.5% 5.909587 6.010028 6.046596 46.28102
# Visualisasi VaR backtesting GARCH-X untuk semua aset (termasuk gold)
par(mfrow=c(3,3), mar=c(4,4,3,1))
for (asset_name in names(garch_backtest_results)) {
backtest <- garch_backtest_results[[asset_name]]
asset_returns <- returns[[asset_name]]
if (is.na(backtest$n)) next
plot_data <- data.frame(
Index = 1:length(asset_returns),
Return = asset_returns,
VaR = backtest$var_estimates,
Exceed = backtest$exceedances
)
plot_data$NegReturn <- -plot_data$Return
plot(plot_data$Index, plot_data$NegReturn, type = "l",
col = "black", xlab = "Observation", ylab = "Return/VaR",
main = paste0(asset_name, " GARCH-VaR (", confidence_level*100, "%)"),
ylim = c(min(c(plot_data$NegReturn, plot_data$VaR), na.rm=TRUE),
max(c(plot_data$NegReturn, plot_data$VaR), na.rm=TRUE) * 1.2))
lines(plot_data$Index, plot_data$VaR, col = "blue", lty = 2)
exceed_idx <- which(plot_data$Exceed == 1)
points(exceed_idx, plot_data$NegReturn[exceed_idx],
col = "red", pch = 19, cex = 0.8)
if (asset_name %in% names(garch_kupiec_results)) {
result <- garch_kupiec_results[[asset_name]]
legend_text <- paste0(
"Exceptions: ", result$exceptions, "/", result$total_obs, " (",
round(result$actual_rate * 100, 2), "%)\n",
"Expected: ", round(result$expected_rate * 100, 2), "%\n",
"p-value: ", round(result$p_value, 4), "\n",
"Result: ", result$result
)
} else {
legend_text <- "No Kupiec test results"
}
legend("topright", legend = legend_text, bty = "n", cex = 0.7)
}
for (asset_name in names(egarch_backtest_results)) {
backtest <- egarch_backtest_results[[asset_name]]
asset_returns <- returns[[asset_name]]
if (is.na(backtest$n)) next
plot_data <- data.frame(
Index = 1:length(asset_returns),
Return = asset_returns,
VaR = backtest$var_estimates,
Exceed = backtest$exceedances
)
plot_data$NegReturn <- -plot_data$Return
plot(plot_data$Index, plot_data$NegReturn, type = "l",
col = "black", xlab = "Observation", ylab = "Return/VaR",
main = paste0(asset_name, " EGARCH-VaR (", confidence_level*100, "%)"),
ylim = c(min(c(plot_data$NegReturn, plot_data$VaR), na.rm=TRUE),
max(c(plot_data$NegReturn, plot_data$VaR), na.rm=TRUE) * 1.2))
lines(plot_data$Index, plot_data$VaR, col = "blue", lty = 2)
exceed_idx <- which(plot_data$Exceed == 1)
points(exceed_idx, plot_data$NegReturn[exceed_idx],
col = "red", pch = 19, cex = 0.8)
if (asset_name %in% names(egarch_kupiec_results)) {
result <- egarch_kupiec_results[[asset_name]]
legend_text <- paste0(
"Exceptions: ", result$exceptions, "/", result$total_obs, " (",
round(result$actual_rate * 100, 2), "%)\n",
"Expected: ", round(result$expected_rate * 100, 2), "%\n",
"p-value: ", round(result$p_value, 4), "\n",
"Result: ", result$result
)
} else {
legend_text <- "No Kupiec test results"
}
legend("topright", legend = legend_text, bty = "n", cex = 0.7)
}

# Basel traffic light test
basel_traffic_light <- function(exceptions, observations, confidence_level) {
if (confidence_level == 0.99) {
if (exceptions <= 4) return("Green Zone")
else if (exceptions <= 9) return("Yellow Zone")
else return("Red Zone")
} else if (confidence_level == 0.95) {
expected_exceptions <- observations * 0.05
if (exceptions <= expected_exceptions * 1.2) return("Green Zone")
else if (exceptions <= expected_exceptions * 1.6) return("Yellow Zone")
else return("Red Zone")
}
}
basel_results <- lapply(garch_kupiec_results, function(result) {
if (is.null(result)) return(NULL)
zone <- basel_traffic_light(result$exceptions, result$total_obs, confidence_level)
data.frame(
Exceptions = result$exceptions,
Observations = result$total_obs,
Expected_Rate = result$expected_rate,
Actual_Rate = result$actual_rate,
Zone = zone
)
})
basel_results_egarch <- lapply(egarch_kupiec_results, function(result) {
if (is.null(result)) return(NULL)
zone <- basel_traffic_light(result$exceptions, result$total_obs, confidence_level)
data.frame(
Exceptions = result$exceptions,
Observations = result$total_obs,
Expected_Rate = result$expected_rate,
Actual_Rate = result$actual_rate,
Zone = zone
)
})
basel_summary <- do.call(rbind, lapply(names(basel_results), function(asset) {
result <- basel_results[[asset]]
if (is.null(result)) return(NULL)
result$Asset <- asset
return(result)
}))
basel_egarch_summary <- do.call(rbind, lapply(names(basel_results_egarch), function(asset) {
result <- basel_results_egarch[[asset]]
if (is.null(result)) return(NULL)
result$Asset <- asset
return(result)
}))
if (!is.null(basel_summary) && nrow(basel_summary) > 0) {
basel_summary <- basel_summary[, c("Asset", "Exceptions", "Observations",
"Expected_Rate", "Actual_Rate", "Zone")]
print(basel_summary)
ggplot(basel_summary, aes(x = Asset, y = Actual_Rate * 100, fill = Zone)) +
geom_bar(stat = "identity") +
geom_hline(yintercept = 5, linetype = "dashed", color = "black") +
scale_fill_manual(values = c("Green Zone" = "darkgreen",
"Yellow Zone" = "gold",
"Red Zone" = "darkred")) +
theme_minimal() +
labs(title = "GARCH-VaR Exceedance Rates by Asset with Basel Zones",
subtitle = paste0(confidence_level * 100, "% VaR"),
y = "Exceedance Rate (%)",
x = "Asset") +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
}
## Asset Exceptions Observations Expected_Rate Actual_Rate
## 1 JKSE 3 103 0.05 0.029126214
## 2 Bond 2 103 0.05 0.019417476
## 3 BTC 2 103 0.05 0.019417476
## 4 Gold 4 103 0.05 0.038834951
## 5 Portfolio_MeanVaR 1 103 0.05 0.009708738
## 6 Portfolio_Equal 1 103 0.05 0.009708738
## Zone
## 1 Green Zone
## 2 Green Zone
## 3 Green Zone
## 4 Green Zone
## 5 Green Zone
## 6 Green Zone
if (!is.null(basel_egarch_summary) && nrow(basel_egarch_summary) > 0) {
basel_egarch_summary <- basel_egarch_summary[, c("Asset", "Exceptions", "Observations",
"Expected_Rate", "Actual_Rate", "Zone")]
print(basel_egarch_summary)
ggplot(basel_egarch_summary, aes(x = Asset, y = Actual_Rate * 100, fill = Zone)) +
geom_bar(stat = "identity") +
geom_hline(yintercept = 5, linetype = "dashed", color = "black") +
scale_fill_manual(values = c("Green Zone" = "darkgreen",
"Yellow Zone" = "gold",
"Red Zone" = "darkred")) +
theme_minimal() +
labs(title = "EGARCH-VaR Exceedance Rates by Asset with Basel Zones",
subtitle = paste0(confidence_level * 100, "% VaR"),
y = "Exceedance Rate (%)",
x = "Asset") +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
}
## Asset Exceptions Observations Expected_Rate Actual_Rate
## 1 JKSE 3 103 0.05 0.029126214
## 2 Bond 3 103 0.05 0.029126214
## 3 BTC 1 103 0.05 0.009708738
## 4 Gold 4 103 0.05 0.038834951
## 5 Portfolio_MeanVaR 1 103 0.05 0.009708738
## 6 Portfolio_Equal 1 103 0.05 0.009708738
## Zone
## 1 Green Zone
## 2 Green Zone
## 3 Green Zone
## 4 Green Zone
## 5 Green Zone
## 6 Green Zone
# Exercise
# ===== Fungsi portofolio =====
calculate_portfolio_risk <- function(weights, returns) {
sqrt(t(weights) %*% cov(returns) %*% weights)
}
# ===== Fungsi objektif dengan batas risiko =====
mean_var_objective <- function(weights, returns, target_return, max_risk = NULL) {
weights <- weights / sum(weights)
port_return <- calculate_portfolio_return(weights, returns)
port_var <- calculate_portfolio_var(weights, returns)
port_risk <- calculate_portfolio_risk(weights, returns)
# Hanya terapkan constraint jika max_risk ada nilainya (bukan NA atau NULL)
if (!is.null(max_risk) && !is.na(max_risk) && port_risk > max_risk) {
return(Inf)
}
return_penalty <- 100 * abs(port_return - target_return)
objective_value <- port_var + return_penalty
return(objective_value)
}
# ===== Hitung portofolio rata-rata =====
num_assets <- ncol(return_matrix)
equal_weights <- rep(1 / num_assets, num_assets)
names(equal_weights) <- colnames(return_matrix)
equal_portfolio_return <- calculate_portfolio_return(equal_weights, return_matrix)
target_return <- equal_portfolio_return
# ===== Fungsi untuk menjalankan DEoptim =====
optimize_portfolio <- function(max_risk = NULL) {
set.seed(123)
opt <- DEoptim(
mean_var_objective,
lower = rep(0.01, num_assets),
upper = rep(1, num_assets),
returns = return_matrix,
target_return = target_return,
max_risk = max_risk,
control = DEoptim.control(itermax = 200, NP = 50)
)
w <- opt$optim$bestmem
w <- w / sum(w)
names(w) <- colnames(return_matrix)
return(w)
}
# ===== Jalankan optimisasi untuk beberapa max_risk =====
risk_levels <- c(NA, 0.02, 0.04, 0.06, 0.08)
results <- list()
for (r in risk_levels) {
label <- ifelse(is.na(r), "No Risk Limit", paste0("≤ ", r))
cat("\n==== Optimizing for Risk ", label, " ====\n")
results[[label]] <- optimize_portfolio(r)
}
##
## ==== Optimizing for Risk No Risk Limit ====
## Iteration: 1 bestvalit: 0.062039 bestmemit: 0.273313 0.472111 0.253266 0.160823
## Iteration: 2 bestvalit: 0.062039 bestmemit: 0.273313 0.472111 0.253266 0.160823
## Iteration: 3 bestvalit: 0.062039 bestmemit: 0.273313 0.472111 0.253266 0.160823
## Iteration: 4 bestvalit: 0.062039 bestmemit: 0.273313 0.472111 0.253266 0.160823
## Iteration: 5 bestvalit: 0.062039 bestmemit: 0.273313 0.472111 0.253266 0.160823
## Iteration: 6 bestvalit: 0.062039 bestmemit: 0.273313 0.472111 0.253266 0.160823
## Iteration: 7 bestvalit: 0.062039 bestmemit: 0.273313 0.472111 0.253266 0.160823
## Iteration: 8 bestvalit: 0.062000 bestmemit: 0.016550 0.824927 0.409047 0.550693
## Iteration: 9 bestvalit: 0.057103 bestmemit: 0.204473 0.979034 0.448585 0.434142
## Iteration: 10 bestvalit: 0.057103 bestmemit: 0.204473 0.979034 0.448585 0.434142
## Iteration: 11 bestvalit: 0.057103 bestmemit: 0.204473 0.979034 0.448585 0.434142
## Iteration: 12 bestvalit: 0.052360 bestmemit: 0.531433 0.958499 0.390748 0.060669
## Iteration: 13 bestvalit: 0.052360 bestmemit: 0.531433 0.958499 0.390748 0.060669
## Iteration: 14 bestvalit: 0.052360 bestmemit: 0.531433 0.958499 0.390748 0.060669
## Iteration: 15 bestvalit: 0.052360 bestmemit: 0.531433 0.958499 0.390748 0.060669
## Iteration: 16 bestvalit: 0.052360 bestmemit: 0.531433 0.958499 0.390748 0.060669
## Iteration: 17 bestvalit: 0.051905 bestmemit: 0.100336 0.918013 0.324173 0.259298
## Iteration: 18 bestvalit: 0.051660 bestmemit: 0.088067 0.810439 0.310098 0.282976
## Iteration: 19 bestvalit: 0.051660 bestmemit: 0.088067 0.810439 0.310098 0.282976
## Iteration: 20 bestvalit: 0.051660 bestmemit: 0.088067 0.810439 0.310098 0.282976
## Iteration: 21 bestvalit: 0.051523 bestmemit: 0.279569 0.795103 0.324443 0.178672
## Iteration: 22 bestvalit: 0.051523 bestmemit: 0.279569 0.795103 0.324443 0.178672
## Iteration: 23 bestvalit: 0.051523 bestmemit: 0.279569 0.795103 0.324443 0.178672
## Iteration: 24 bestvalit: 0.051523 bestmemit: 0.279569 0.795103 0.324443 0.178672
## Iteration: 25 bestvalit: 0.051523 bestmemit: 0.279569 0.795103 0.324443 0.178672
## Iteration: 26 bestvalit: 0.051523 bestmemit: 0.279569 0.795103 0.324443 0.178672
## Iteration: 27 bestvalit: 0.051523 bestmemit: 0.279569 0.795103 0.324443 0.178672
## Iteration: 28 bestvalit: 0.051523 bestmemit: 0.279569 0.795103 0.324443 0.178672
## Iteration: 29 bestvalit: 0.051523 bestmemit: 0.279569 0.795103 0.324443 0.178672
## Iteration: 30 bestvalit: 0.051523 bestmemit: 0.279569 0.795103 0.324443 0.178672
## Iteration: 31 bestvalit: 0.051523 bestmemit: 0.279569 0.795103 0.324443 0.178672
## Iteration: 32 bestvalit: 0.051523 bestmemit: 0.279569 0.795103 0.324443 0.178672
## Iteration: 33 bestvalit: 0.051523 bestmemit: 0.279569 0.795103 0.324443 0.178672
## Iteration: 34 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 35 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 36 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 37 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 38 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 39 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 40 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 41 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 42 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 43 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 44 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 45 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 46 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 47 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 48 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 49 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 50 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 51 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 52 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 53 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 54 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 55 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 56 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 57 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 58 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 59 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 60 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 61 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 62 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 63 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 64 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 65 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 66 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 67 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 68 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 69 bestvalit: 0.047585 bestmemit: 0.280908 0.943401 0.357548 0.187027
## Iteration: 70 bestvalit: 0.047281 bestmemit: 0.219855 0.905710 0.321927 0.169975
## Iteration: 71 bestvalit: 0.047281 bestmemit: 0.219855 0.905710 0.321927 0.169975
## Iteration: 72 bestvalit: 0.047281 bestmemit: 0.219855 0.905710 0.321927 0.169975
## Iteration: 73 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 74 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 75 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 76 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 77 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 78 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 79 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 80 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 81 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 82 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 83 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 84 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 85 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 86 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 87 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 88 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 89 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 90 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 91 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 92 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 93 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 94 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 95 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 96 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 97 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 98 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 99 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 100 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 101 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 102 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 103 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 104 bestvalit: 0.046220 bestmemit: 0.218965 0.950012 0.332571 0.177580
## Iteration: 105 bestvalit: 0.046212 bestmemit: 0.218916 0.964264 0.338939 0.185751
## Iteration: 106 bestvalit: 0.046212 bestmemit: 0.218916 0.964264 0.338939 0.185751
## Iteration: 107 bestvalit: 0.046212 bestmemit: 0.218916 0.964264 0.338939 0.185751
## Iteration: 108 bestvalit: 0.046212 bestmemit: 0.218916 0.964264 0.338939 0.185751
## Iteration: 109 bestvalit: 0.046212 bestmemit: 0.218916 0.964264 0.338939 0.185751
## Iteration: 110 bestvalit: 0.046212 bestmemit: 0.218916 0.964264 0.338939 0.185751
## Iteration: 111 bestvalit: 0.046212 bestmemit: 0.218916 0.964264 0.338939 0.185751
## Iteration: 112 bestvalit: 0.046212 bestmemit: 0.218916 0.964264 0.338939 0.185751
## Iteration: 113 bestvalit: 0.046212 bestmemit: 0.218916 0.964264 0.338939 0.185751
## Iteration: 114 bestvalit: 0.046212 bestmemit: 0.218916 0.964264 0.338939 0.185751
## Iteration: 115 bestvalit: 0.046212 bestmemit: 0.218916 0.964264 0.338939 0.185751
## Iteration: 116 bestvalit: 0.046212 bestmemit: 0.218916 0.964264 0.338939 0.185751
## Iteration: 117 bestvalit: 0.046212 bestmemit: 0.218916 0.964264 0.338939 0.185751
## Iteration: 118 bestvalit: 0.046212 bestmemit: 0.218916 0.964264 0.338939 0.185751
## Iteration: 119 bestvalit: 0.046212 bestmemit: 0.218916 0.964264 0.338939 0.185751
## Iteration: 120 bestvalit: 0.046212 bestmemit: 0.218916 0.964264 0.338939 0.185751
## Iteration: 121 bestvalit: 0.046212 bestmemit: 0.218916 0.964264 0.338939 0.185751
## Iteration: 122 bestvalit: 0.046212 bestmemit: 0.218916 0.964264 0.338939 0.185751
## Iteration: 123 bestvalit: 0.046212 bestmemit: 0.218916 0.964264 0.338939 0.185751
## Iteration: 124 bestvalit: 0.046212 bestmemit: 0.218916 0.964264 0.338939 0.185751
## Iteration: 125 bestvalit: 0.046212 bestmemit: 0.218916 0.964264 0.338939 0.185751
## Iteration: 126 bestvalit: 0.046212 bestmemit: 0.218916 0.964264 0.338939 0.185751
## Iteration: 127 bestvalit: 0.046212 bestmemit: 0.218916 0.964264 0.338939 0.185751
## Iteration: 128 bestvalit: 0.046212 bestmemit: 0.218916 0.964264 0.338939 0.185751
## Iteration: 129 bestvalit: 0.046212 bestmemit: 0.218916 0.964264 0.338939 0.185751
## Iteration: 130 bestvalit: 0.046212 bestmemit: 0.218916 0.964264 0.338939 0.185751
## Iteration: 131 bestvalit: 0.046212 bestmemit: 0.218916 0.964264 0.338939 0.185751
## Iteration: 132 bestvalit: 0.046212 bestmemit: 0.218916 0.964264 0.338939 0.185751
## Iteration: 133 bestvalit: 0.046212 bestmemit: 0.218916 0.964264 0.338939 0.185751
## Iteration: 134 bestvalit: 0.046208 bestmemit: 0.192594 0.842652 0.294009 0.156534
## Iteration: 135 bestvalit: 0.046208 bestmemit: 0.192594 0.842652 0.294009 0.156534
## Iteration: 136 bestvalit: 0.046208 bestmemit: 0.192594 0.842652 0.294009 0.156534
## Iteration: 137 bestvalit: 0.046208 bestmemit: 0.192594 0.842652 0.294009 0.156534
## Iteration: 138 bestvalit: 0.046208 bestmemit: 0.192594 0.842652 0.294009 0.156534
## Iteration: 139 bestvalit: 0.046208 bestmemit: 0.192594 0.842652 0.294009 0.156534
## Iteration: 140 bestvalit: 0.046208 bestmemit: 0.192594 0.842652 0.294009 0.156534
## Iteration: 141 bestvalit: 0.046208 bestmemit: 0.192594 0.842652 0.294009 0.156534
## Iteration: 142 bestvalit: 0.046208 bestmemit: 0.192594 0.842652 0.294009 0.156534
## Iteration: 143 bestvalit: 0.046208 bestmemit: 0.192594 0.842652 0.294009 0.156534
## Iteration: 144 bestvalit: 0.046208 bestmemit: 0.192594 0.842652 0.294009 0.156534
## Iteration: 145 bestvalit: 0.046208 bestmemit: 0.192594 0.842652 0.294009 0.156534
## Iteration: 146 bestvalit: 0.046208 bestmemit: 0.192594 0.842652 0.294009 0.156534
## Iteration: 147 bestvalit: 0.046208 bestmemit: 0.192594 0.842652 0.294009 0.156534
## Iteration: 148 bestvalit: 0.046208 bestmemit: 0.192594 0.842652 0.294009 0.156534
## Iteration: 149 bestvalit: 0.046153 bestmemit: 0.203803 0.867648 0.305635 0.163131
## Iteration: 150 bestvalit: 0.046153 bestmemit: 0.203803 0.867648 0.305635 0.163131
## Iteration: 151 bestvalit: 0.046153 bestmemit: 0.203803 0.867648 0.305635 0.163131
## Iteration: 152 bestvalit: 0.046153 bestmemit: 0.203803 0.867648 0.305635 0.163131
## Iteration: 153 bestvalit: 0.046153 bestmemit: 0.203803 0.867648 0.305635 0.163131
## Iteration: 154 bestvalit: 0.046153 bestmemit: 0.203803 0.867648 0.305635 0.163131
## Iteration: 155 bestvalit: 0.046153 bestmemit: 0.203803 0.867648 0.305635 0.163131
## Iteration: 156 bestvalit: 0.046127 bestmemit: 0.222692 0.956303 0.336311 0.180250
## Iteration: 157 bestvalit: 0.046127 bestmemit: 0.222692 0.956303 0.336311 0.180250
## Iteration: 158 bestvalit: 0.046127 bestmemit: 0.222692 0.956303 0.336311 0.180250
## Iteration: 159 bestvalit: 0.046127 bestmemit: 0.222692 0.956303 0.336311 0.180250
## Iteration: 160 bestvalit: 0.046096 bestmemit: 0.211256 0.911140 0.321953 0.175644
## Iteration: 161 bestvalit: 0.046096 bestmemit: 0.211256 0.911140 0.321953 0.175644
## Iteration: 162 bestvalit: 0.046096 bestmemit: 0.211256 0.911140 0.321953 0.175644
## Iteration: 163 bestvalit: 0.046096 bestmemit: 0.211256 0.911140 0.321953 0.175644
## Iteration: 164 bestvalit: 0.046096 bestmemit: 0.211256 0.911140 0.321953 0.175644
## Iteration: 165 bestvalit: 0.046096 bestmemit: 0.211256 0.911140 0.321953 0.175644
## Iteration: 166 bestvalit: 0.046096 bestmemit: 0.211256 0.911140 0.321953 0.175644
## Iteration: 167 bestvalit: 0.046096 bestmemit: 0.211256 0.911140 0.321953 0.175644
## Iteration: 168 bestvalit: 0.046070 bestmemit: 0.200474 0.869171 0.305103 0.164034
## Iteration: 169 bestvalit: 0.046070 bestmemit: 0.200474 0.869171 0.305103 0.164034
## Iteration: 170 bestvalit: 0.046070 bestmemit: 0.200474 0.869171 0.305103 0.164034
## Iteration: 171 bestvalit: 0.046070 bestmemit: 0.200474 0.869171 0.305103 0.164034
## Iteration: 172 bestvalit: 0.046059 bestmemit: 0.212116 0.916195 0.323134 0.175547
## Iteration: 173 bestvalit: 0.046059 bestmemit: 0.212116 0.916195 0.323134 0.175547
## Iteration: 174 bestvalit: 0.046059 bestmemit: 0.212116 0.916195 0.323134 0.175547
## Iteration: 175 bestvalit: 0.046059 bestmemit: 0.212116 0.916195 0.323134 0.175547
## Iteration: 176 bestvalit: 0.046059 bestmemit: 0.212116 0.916195 0.323134 0.175547
## Iteration: 177 bestvalit: 0.046059 bestmemit: 0.212116 0.916195 0.323134 0.175547
## Iteration: 178 bestvalit: 0.046059 bestmemit: 0.212116 0.916195 0.323134 0.175547
## Iteration: 179 bestvalit: 0.046059 bestmemit: 0.212116 0.916195 0.323134 0.175547
## Iteration: 180 bestvalit: 0.046056 bestmemit: 0.193300 0.836383 0.294459 0.159410
## Iteration: 181 bestvalit: 0.046056 bestmemit: 0.193300 0.836383 0.294459 0.159410
## Iteration: 182 bestvalit: 0.046056 bestmemit: 0.193300 0.836383 0.294459 0.159410
## Iteration: 183 bestvalit: 0.046056 bestmemit: 0.193300 0.836383 0.294459 0.159410
## Iteration: 184 bestvalit: 0.046056 bestmemit: 0.193300 0.836383 0.294459 0.159410
## Iteration: 185 bestvalit: 0.046056 bestmemit: 0.193300 0.836383 0.294459 0.159410
## Iteration: 186 bestvalit: 0.046056 bestmemit: 0.193300 0.836383 0.294459 0.159410
## Iteration: 187 bestvalit: 0.046056 bestmemit: 0.193300 0.836383 0.294459 0.159410
## Iteration: 188 bestvalit: 0.046056 bestmemit: 0.193300 0.836383 0.294459 0.159410
## Iteration: 189 bestvalit: 0.046041 bestmemit: 0.200474 0.869049 0.305103 0.164034
## Iteration: 190 bestvalit: 0.046041 bestmemit: 0.200474 0.869049 0.305103 0.164034
## Iteration: 191 bestvalit: 0.046041 bestmemit: 0.200474 0.869049 0.305103 0.164034
## Iteration: 192 bestvalit: 0.046041 bestmemit: 0.200474 0.869049 0.305103 0.164034
## Iteration: 193 bestvalit: 0.046041 bestmemit: 0.200474 0.869049 0.305103 0.164034
## Iteration: 194 bestvalit: 0.046041 bestmemit: 0.200474 0.869049 0.305103 0.164034
## Iteration: 195 bestvalit: 0.046041 bestmemit: 0.200474 0.869049 0.305103 0.164034
## Iteration: 196 bestvalit: 0.046041 bestmemit: 0.200474 0.869049 0.305103 0.164034
## Iteration: 197 bestvalit: 0.046037 bestmemit: 0.198717 0.858318 0.302009 0.162900
## Iteration: 198 bestvalit: 0.046037 bestmemit: 0.198717 0.858318 0.302009 0.162900
## Iteration: 199 bestvalit: 0.046037 bestmemit: 0.198717 0.858318 0.302009 0.162900
## Iteration: 200 bestvalit: 0.046037 bestmemit: 0.198717 0.858318 0.302009 0.162900
##
## ==== Optimizing for Risk ≤ 0.02 ====
## Iteration: 1 bestvalit: 1.092102 bestmemit: 0.419587 0.350081 0.020362 0.985784
## Iteration: 2 bestvalit: 1.092102 bestmemit: 0.419587 0.350081 0.020362 0.985784
## Iteration: 3 bestvalit: 1.092102 bestmemit: 0.419587 0.350081 0.020362 0.985784
## Iteration: 4 bestvalit: 1.092102 bestmemit: 0.419587 0.350081 0.020362 0.985784
## Iteration: 5 bestvalit: 0.999671 bestmemit: 0.523635 0.233121 0.016238 0.364952
## Iteration: 6 bestvalit: 0.938997 bestmemit: 0.430623 0.350081 0.020362 0.376719
## Iteration: 7 bestvalit: 0.892533 bestmemit: 0.430623 0.350081 0.020362 0.259534
## Iteration: 8 bestvalit: 0.892533 bestmemit: 0.430623 0.350081 0.020362 0.259534
## Iteration: 9 bestvalit: 0.860237 bestmemit: 0.429186 0.678965 0.033000 0.484549
## Iteration: 10 bestvalit: 0.860237 bestmemit: 0.429186 0.678965 0.033000 0.484549
## Iteration: 11 bestvalit: 0.860237 bestmemit: 0.429186 0.678965 0.033000 0.484549
## Iteration: 12 bestvalit: 0.860237 bestmemit: 0.429186 0.678965 0.033000 0.484549
## Iteration: 13 bestvalit: 0.807153 bestmemit: 0.223848 0.516262 0.016238 0.234000
## Iteration: 14 bestvalit: 0.807153 bestmemit: 0.223848 0.516262 0.016238 0.234000
## Iteration: 15 bestvalit: 0.807153 bestmemit: 0.223848 0.516262 0.016238 0.234000
## Iteration: 16 bestvalit: 0.789114 bestmemit: 0.204908 0.582096 0.011513 0.202209
## Iteration: 17 bestvalit: 0.789114 bestmemit: 0.204908 0.582096 0.011513 0.202209
## Iteration: 18 bestvalit: 0.789114 bestmemit: 0.204908 0.582096 0.011513 0.202209
## Iteration: 19 bestvalit: 0.789114 bestmemit: 0.204908 0.582096 0.011513 0.202209
## Iteration: 20 bestvalit: 0.787422 bestmemit: 0.186294 0.569559 0.011513 0.202209
## Iteration: 21 bestvalit: 0.787422 bestmemit: 0.186294 0.569559 0.011513 0.202209
## Iteration: 22 bestvalit: 0.787422 bestmemit: 0.186294 0.569559 0.011513 0.202209
## Iteration: 23 bestvalit: 0.774513 bestmemit: 0.223848 0.689449 0.016238 0.234000
## Iteration: 24 bestvalit: 0.774513 bestmemit: 0.223848 0.689449 0.016238 0.234000
## Iteration: 25 bestvalit: 0.747093 bestmemit: 0.430623 0.614606 0.020362 0.086338
## Iteration: 26 bestvalit: 0.747093 bestmemit: 0.430623 0.614606 0.020362 0.086338
## Iteration: 27 bestvalit: 0.747093 bestmemit: 0.430623 0.614606 0.020362 0.086338
## Iteration: 28 bestvalit: 0.747093 bestmemit: 0.430623 0.614606 0.020362 0.086338
## Iteration: 29 bestvalit: 0.747093 bestmemit: 0.430623 0.614606 0.020362 0.086338
## Iteration: 30 bestvalit: 0.747093 bestmemit: 0.430623 0.614606 0.020362 0.086338
## Iteration: 31 bestvalit: 0.747093 bestmemit: 0.430623 0.614606 0.020362 0.086338
## Iteration: 32 bestvalit: 0.747093 bestmemit: 0.430623 0.614606 0.020362 0.086338
## Iteration: 33 bestvalit: 0.747093 bestmemit: 0.430623 0.614606 0.020362 0.086338
## Iteration: 34 bestvalit: 0.747093 bestmemit: 0.430623 0.614606 0.020362 0.086338
## Iteration: 35 bestvalit: 0.747093 bestmemit: 0.430623 0.614606 0.020362 0.086338
## Iteration: 36 bestvalit: 0.743437 bestmemit: 0.429186 0.897279 0.011350 0.105016
## Iteration: 37 bestvalit: 0.743437 bestmemit: 0.429186 0.897279 0.011350 0.105016
## Iteration: 38 bestvalit: 0.743437 bestmemit: 0.429186 0.897279 0.011350 0.105016
## Iteration: 39 bestvalit: 0.743437 bestmemit: 0.429186 0.897279 0.011350 0.105016
## Iteration: 40 bestvalit: 0.743437 bestmemit: 0.429186 0.897279 0.011350 0.105016
## Iteration: 41 bestvalit: 0.743437 bestmemit: 0.429186 0.897279 0.011350 0.105016
## Iteration: 42 bestvalit: 0.743437 bestmemit: 0.429186 0.897279 0.011350 0.105016
## Iteration: 43 bestvalit: 0.743437 bestmemit: 0.429186 0.897279 0.011350 0.105016
## Iteration: 44 bestvalit: 0.743437 bestmemit: 0.429186 0.897279 0.011350 0.105016
## Iteration: 45 bestvalit: 0.743437 bestmemit: 0.429186 0.897279 0.011350 0.105016
## Iteration: 46 bestvalit: 0.743437 bestmemit: 0.429186 0.897279 0.011350 0.105016
## Iteration: 47 bestvalit: 0.743437 bestmemit: 0.429186 0.897279 0.011350 0.105016
## Iteration: 48 bestvalit: 0.743437 bestmemit: 0.429186 0.897279 0.011350 0.105016
## Iteration: 49 bestvalit: 0.743437 bestmemit: 0.429186 0.897279 0.011350 0.105016
## Iteration: 50 bestvalit: 0.743437 bestmemit: 0.429186 0.897279 0.011350 0.105016
## Iteration: 51 bestvalit: 0.743437 bestmemit: 0.429186 0.897279 0.011350 0.105016
## Iteration: 52 bestvalit: 0.743437 bestmemit: 0.429186 0.897279 0.011350 0.105016
## Iteration: 53 bestvalit: 0.740497 bestmemit: 0.394562 0.902748 0.016181 0.145586
## Iteration: 54 bestvalit: 0.714238 bestmemit: 0.418773 0.665242 0.014149 0.010841
## Iteration: 55 bestvalit: 0.714238 bestmemit: 0.418773 0.665242 0.014149 0.010841
## Iteration: 56 bestvalit: 0.714238 bestmemit: 0.418773 0.665242 0.014149 0.010841
## Iteration: 57 bestvalit: 0.714238 bestmemit: 0.418773 0.665242 0.014149 0.010841
## Iteration: 58 bestvalit: 0.714238 bestmemit: 0.418773 0.665242 0.014149 0.010841
## Iteration: 59 bestvalit: 0.714238 bestmemit: 0.418773 0.665242 0.014149 0.010841
## Iteration: 60 bestvalit: 0.714238 bestmemit: 0.418773 0.665242 0.014149 0.010841
## Iteration: 61 bestvalit: 0.714238 bestmemit: 0.418773 0.665242 0.014149 0.010841
## Iteration: 62 bestvalit: 0.714238 bestmemit: 0.418773 0.665242 0.014149 0.010841
## Iteration: 63 bestvalit: 0.714238 bestmemit: 0.418773 0.665242 0.014149 0.010841
## Iteration: 64 bestvalit: 0.714238 bestmemit: 0.418773 0.665242 0.014149 0.010841
## Iteration: 65 bestvalit: 0.714238 bestmemit: 0.418773 0.665242 0.014149 0.010841
## Iteration: 66 bestvalit: 0.709801 bestmemit: 0.521332 0.940687 0.016238 0.020780
## Iteration: 67 bestvalit: 0.709801 bestmemit: 0.521332 0.940687 0.016238 0.020780
## Iteration: 68 bestvalit: 0.709801 bestmemit: 0.521332 0.940687 0.016238 0.020780
## Iteration: 69 bestvalit: 0.709801 bestmemit: 0.521332 0.940687 0.016238 0.020780
## Iteration: 70 bestvalit: 0.709801 bestmemit: 0.521332 0.940687 0.016238 0.020780
## Iteration: 71 bestvalit: 0.709801 bestmemit: 0.521332 0.940687 0.016238 0.020780
## Iteration: 72 bestvalit: 0.709801 bestmemit: 0.521332 0.940687 0.016238 0.020780
## Iteration: 73 bestvalit: 0.709801 bestmemit: 0.521332 0.940687 0.016238 0.020780
## Iteration: 74 bestvalit: 0.709801 bestmemit: 0.521332 0.940687 0.016238 0.020780
## Iteration: 75 bestvalit: 0.709801 bestmemit: 0.521332 0.940687 0.016238 0.020780
## Iteration: 76 bestvalit: 0.709644 bestmemit: 0.454015 0.861385 0.012057 0.014914
## Iteration: 77 bestvalit: 0.709644 bestmemit: 0.454015 0.861385 0.012057 0.014914
## Iteration: 78 bestvalit: 0.709644 bestmemit: 0.454015 0.861385 0.012057 0.014914
## Iteration: 79 bestvalit: 0.709644 bestmemit: 0.454015 0.861385 0.012057 0.014914
## Iteration: 80 bestvalit: 0.709644 bestmemit: 0.454015 0.861385 0.012057 0.014914
## Iteration: 81 bestvalit: 0.709644 bestmemit: 0.454015 0.861385 0.012057 0.014914
## Iteration: 82 bestvalit: 0.709644 bestmemit: 0.454015 0.861385 0.012057 0.014914
## Iteration: 83 bestvalit: 0.709049 bestmemit: 0.425956 0.786764 0.013499 0.020393
## Iteration: 84 bestvalit: 0.708823 bestmemit: 0.520692 0.975541 0.013852 0.012901
## Iteration: 85 bestvalit: 0.708823 bestmemit: 0.520692 0.975541 0.013852 0.012901
## Iteration: 86 bestvalit: 0.708823 bestmemit: 0.520692 0.975541 0.013852 0.012901
## Iteration: 87 bestvalit: 0.708823 bestmemit: 0.520692 0.975541 0.013852 0.012901
## Iteration: 88 bestvalit: 0.708823 bestmemit: 0.520692 0.975541 0.013852 0.012901
## Iteration: 89 bestvalit: 0.708823 bestmemit: 0.520692 0.975541 0.013852 0.012901
## Iteration: 90 bestvalit: 0.707379 bestmemit: 0.520692 0.993529 0.013852 0.012901
## Iteration: 91 bestvalit: 0.707379 bestmemit: 0.520692 0.993529 0.013852 0.012901
## Iteration: 92 bestvalit: 0.707379 bestmemit: 0.520692 0.993529 0.013852 0.012901
## Iteration: 93 bestvalit: 0.707379 bestmemit: 0.520692 0.993529 0.013852 0.012901
## Iteration: 94 bestvalit: 0.707379 bestmemit: 0.520692 0.993529 0.013852 0.012901
## Iteration: 95 bestvalit: 0.707379 bestmemit: 0.520692 0.993529 0.013852 0.012901
## Iteration: 96 bestvalit: 0.707379 bestmemit: 0.520692 0.993529 0.013852 0.012901
## Iteration: 97 bestvalit: 0.707379 bestmemit: 0.520692 0.993529 0.013852 0.012901
## Iteration: 98 bestvalit: 0.707379 bestmemit: 0.520692 0.993529 0.013852 0.012901
## Iteration: 99 bestvalit: 0.707379 bestmemit: 0.520692 0.993529 0.013852 0.012901
## Iteration: 100 bestvalit: 0.707379 bestmemit: 0.520692 0.993529 0.013852 0.012901
## Iteration: 101 bestvalit: 0.707379 bestmemit: 0.520692 0.993529 0.013852 0.012901
## Iteration: 102 bestvalit: 0.707379 bestmemit: 0.520692 0.993529 0.013852 0.012901
## Iteration: 103 bestvalit: 0.707379 bestmemit: 0.520692 0.993529 0.013852 0.012901
## Iteration: 104 bestvalit: 0.707379 bestmemit: 0.520692 0.993529 0.013852 0.012901
## Iteration: 105 bestvalit: 0.707379 bestmemit: 0.520692 0.993529 0.013852 0.012901
## Iteration: 106 bestvalit: 0.707379 bestmemit: 0.520692 0.993529 0.013852 0.012901
## Iteration: 107 bestvalit: 0.707379 bestmemit: 0.520692 0.993529 0.013852 0.012901
## Iteration: 108 bestvalit: 0.707379 bestmemit: 0.520692 0.993529 0.013852 0.012901
## Iteration: 109 bestvalit: 0.707379 bestmemit: 0.520692 0.993529 0.013852 0.012901
## Iteration: 110 bestvalit: 0.707379 bestmemit: 0.520692 0.993529 0.013852 0.012901
## Iteration: 111 bestvalit: 0.707379 bestmemit: 0.520692 0.993529 0.013852 0.012901
## Iteration: 112 bestvalit: 0.706990 bestmemit: 0.520692 0.993529 0.013852 0.011975
## Iteration: 113 bestvalit: 0.706990 bestmemit: 0.520692 0.993529 0.013852 0.011975
## Iteration: 114 bestvalit: 0.706990 bestmemit: 0.520692 0.993529 0.013852 0.011975
## Iteration: 115 bestvalit: 0.706990 bestmemit: 0.520692 0.993529 0.013852 0.011975
## Iteration: 116 bestvalit: 0.706990 bestmemit: 0.520692 0.993529 0.013852 0.011975
## Iteration: 117 bestvalit: 0.706990 bestmemit: 0.520692 0.993529 0.013852 0.011975
## Iteration: 118 bestvalit: 0.706990 bestmemit: 0.520692 0.993529 0.013852 0.011975
## Iteration: 119 bestvalit: 0.706990 bestmemit: 0.520692 0.993529 0.013852 0.011975
## Iteration: 120 bestvalit: 0.706990 bestmemit: 0.520692 0.993529 0.013852 0.011975
## Iteration: 121 bestvalit: 0.706990 bestmemit: 0.520692 0.993529 0.013852 0.011975
## Iteration: 122 bestvalit: 0.706990 bestmemit: 0.520692 0.993529 0.013852 0.011975
## Iteration: 123 bestvalit: 0.706990 bestmemit: 0.520692 0.993529 0.013852 0.011975
## Iteration: 124 bestvalit: 0.706990 bestmemit: 0.520692 0.993529 0.013852 0.011975
## Iteration: 125 bestvalit: 0.706990 bestmemit: 0.520692 0.993529 0.013852 0.011975
## Iteration: 126 bestvalit: 0.706641 bestmemit: 0.507612 0.973645 0.013659 0.012627
## Iteration: 127 bestvalit: 0.706641 bestmemit: 0.507612 0.973645 0.013659 0.012627
## Iteration: 128 bestvalit: 0.706641 bestmemit: 0.507612 0.973645 0.013659 0.012627
## Iteration: 129 bestvalit: 0.706641 bestmemit: 0.507612 0.973645 0.013659 0.012627
## Iteration: 130 bestvalit: 0.706641 bestmemit: 0.507612 0.973645 0.013659 0.012627
## Iteration: 131 bestvalit: 0.706641 bestmemit: 0.507612 0.973645 0.013659 0.012627
## Iteration: 132 bestvalit: 0.706641 bestmemit: 0.507612 0.973645 0.013659 0.012627
## Iteration: 133 bestvalit: 0.706641 bestmemit: 0.507612 0.973645 0.013659 0.012627
## Iteration: 134 bestvalit: 0.706552 bestmemit: 0.466946 0.897640 0.012645 0.012216
## Iteration: 135 bestvalit: 0.706552 bestmemit: 0.466946 0.897640 0.012645 0.012216
## Iteration: 136 bestvalit: 0.706551 bestmemit: 0.472849 0.910563 0.012825 0.012764
## Iteration: 137 bestvalit: 0.706551 bestmemit: 0.472849 0.910563 0.012825 0.012764
## Iteration: 138 bestvalit: 0.706551 bestmemit: 0.472849 0.910563 0.012825 0.012764
## Iteration: 139 bestvalit: 0.706513 bestmemit: 0.518272 0.993529 0.013852 0.011975
## Iteration: 140 bestvalit: 0.706513 bestmemit: 0.518272 0.993529 0.013852 0.011975
## Iteration: 141 bestvalit: 0.706513 bestmemit: 0.518272 0.993529 0.013852 0.011975
## Iteration: 142 bestvalit: 0.706114 bestmemit: 0.508204 0.979980 0.013379 0.010764
## Iteration: 143 bestvalit: 0.706114 bestmemit: 0.508204 0.979980 0.013379 0.010764
## Iteration: 144 bestvalit: 0.706114 bestmemit: 0.508204 0.979980 0.013379 0.010764
## Iteration: 145 bestvalit: 0.706114 bestmemit: 0.508204 0.979980 0.013379 0.010764
## Iteration: 146 bestvalit: 0.706114 bestmemit: 0.508204 0.979980 0.013379 0.010764
## Iteration: 147 bestvalit: 0.706114 bestmemit: 0.508204 0.979980 0.013379 0.010764
## Iteration: 148 bestvalit: 0.706114 bestmemit: 0.508204 0.979980 0.013379 0.010764
## Iteration: 149 bestvalit: 0.706114 bestmemit: 0.508204 0.979980 0.013379 0.010764
## Iteration: 150 bestvalit: 0.706114 bestmemit: 0.508204 0.979980 0.013379 0.010764
## Iteration: 151 bestvalit: 0.706114 bestmemit: 0.508204 0.979980 0.013379 0.010764
## Iteration: 152 bestvalit: 0.706114 bestmemit: 0.508204 0.979980 0.013379 0.010764
## Iteration: 153 bestvalit: 0.706114 bestmemit: 0.508204 0.979980 0.013379 0.010764
## Iteration: 154 bestvalit: 0.706114 bestmemit: 0.508204 0.979980 0.013379 0.010764
## Iteration: 155 bestvalit: 0.706114 bestmemit: 0.508204 0.979980 0.013379 0.010764
## Iteration: 156 bestvalit: 0.706114 bestmemit: 0.508204 0.979980 0.013379 0.010764
## Iteration: 157 bestvalit: 0.706114 bestmemit: 0.508204 0.979980 0.013379 0.010764
## Iteration: 158 bestvalit: 0.706114 bestmemit: 0.508204 0.979980 0.013379 0.010764
## Iteration: 159 bestvalit: 0.706114 bestmemit: 0.508204 0.979980 0.013379 0.010764
## Iteration: 160 bestvalit: 0.706114 bestmemit: 0.508204 0.979980 0.013379 0.010764
## Iteration: 161 bestvalit: 0.706114 bestmemit: 0.508204 0.979980 0.013379 0.010764
## Iteration: 162 bestvalit: 0.706114 bestmemit: 0.508204 0.979980 0.013379 0.010764
## Iteration: 163 bestvalit: 0.706114 bestmemit: 0.508204 0.979980 0.013379 0.010764
## Iteration: 164 bestvalit: 0.706114 bestmemit: 0.508204 0.979980 0.013379 0.010764
## Iteration: 165 bestvalit: 0.706114 bestmemit: 0.508204 0.979980 0.013379 0.010764
## Iteration: 166 bestvalit: 0.706114 bestmemit: 0.508204 0.979980 0.013379 0.010764
## Iteration: 167 bestvalit: 0.706114 bestmemit: 0.508204 0.979980 0.013379 0.010764
## Iteration: 168 bestvalit: 0.706114 bestmemit: 0.508204 0.979980 0.013379 0.010764
## Iteration: 169 bestvalit: 0.706114 bestmemit: 0.508204 0.979980 0.013379 0.010764
## Iteration: 170 bestvalit: 0.706114 bestmemit: 0.508204 0.979980 0.013379 0.010764
## Iteration: 171 bestvalit: 0.706114 bestmemit: 0.508204 0.979980 0.013379 0.010764
## Iteration: 172 bestvalit: 0.706114 bestmemit: 0.508204 0.979980 0.013379 0.010764
## Iteration: 173 bestvalit: 0.706114 bestmemit: 0.508204 0.979980 0.013379 0.010764
## Iteration: 174 bestvalit: 0.706114 bestmemit: 0.508204 0.979980 0.013379 0.010764
## Iteration: 175 bestvalit: 0.706114 bestmemit: 0.508204 0.979980 0.013379 0.010764
## Iteration: 176 bestvalit: 0.706114 bestmemit: 0.508204 0.979980 0.013379 0.010764
## Iteration: 177 bestvalit: 0.706114 bestmemit: 0.508204 0.979980 0.013379 0.010764
## Iteration: 178 bestvalit: 0.706114 bestmemit: 0.508204 0.979980 0.013379 0.010764
## Iteration: 179 bestvalit: 0.706114 bestmemit: 0.508204 0.979980 0.013379 0.010764
## Iteration: 180 bestvalit: 0.706114 bestmemit: 0.508204 0.979980 0.013379 0.010764
## Iteration: 181 bestvalit: 0.706114 bestmemit: 0.508204 0.979980 0.013379 0.010764
## Iteration: 182 bestvalit: 0.706114 bestmemit: 0.508204 0.979980 0.013379 0.010764
## Iteration: 183 bestvalit: 0.706114 bestmemit: 0.508204 0.979980 0.013379 0.010764
## Iteration: 184 bestvalit: 0.706114 bestmemit: 0.508204 0.979980 0.013379 0.010764
## Iteration: 185 bestvalit: 0.706114 bestmemit: 0.508204 0.979980 0.013379 0.010764
## Iteration: 186 bestvalit: 0.706114 bestmemit: 0.508204 0.979980 0.013379 0.010764
## Iteration: 187 bestvalit: 0.706114 bestmemit: 0.508204 0.979980 0.013379 0.010764
## Iteration: 188 bestvalit: 0.706042 bestmemit: 0.514215 0.976993 0.013984 0.010433
## Iteration: 189 bestvalit: 0.706042 bestmemit: 0.514215 0.976993 0.013984 0.010433
## Iteration: 190 bestvalit: 0.706042 bestmemit: 0.514215 0.976993 0.013984 0.010433
## Iteration: 191 bestvalit: 0.706042 bestmemit: 0.514215 0.976993 0.013984 0.010433
## Iteration: 192 bestvalit: 0.706042 bestmemit: 0.514215 0.976993 0.013984 0.010433
## Iteration: 193 bestvalit: 0.705994 bestmemit: 0.513797 0.981294 0.013807 0.010374
## Iteration: 194 bestvalit: 0.705994 bestmemit: 0.513797 0.981294 0.013807 0.010374
## Iteration: 195 bestvalit: 0.705994 bestmemit: 0.513797 0.981294 0.013807 0.010374
## Iteration: 196 bestvalit: 0.705994 bestmemit: 0.513797 0.981294 0.013807 0.010374
## Iteration: 197 bestvalit: 0.705994 bestmemit: 0.513797 0.981294 0.013807 0.010374
## Iteration: 198 bestvalit: 0.705994 bestmemit: 0.513797 0.981294 0.013807 0.010374
## Iteration: 199 bestvalit: 0.705994 bestmemit: 0.513797 0.981294 0.013807 0.010374
## Iteration: 200 bestvalit: 0.705994 bestmemit: 0.513797 0.981294 0.013807 0.010374
##
## ==== Optimizing for Risk ≤ 0.04 ====
## Iteration: 1 bestvalit: 0.723163 bestmemit: 0.566223 0.716574 0.088733 0.379818
## Iteration: 2 bestvalit: 0.723163 bestmemit: 0.566223 0.716574 0.088733 0.379818
## Iteration: 3 bestvalit: 0.723163 bestmemit: 0.566223 0.716574 0.088733 0.379818
## Iteration: 4 bestvalit: 0.723163 bestmemit: 0.566223 0.716574 0.088733 0.379818
## Iteration: 5 bestvalit: 0.640644 bestmemit: 0.425943 0.991184 0.052056 0.104819
## Iteration: 6 bestvalit: 0.640644 bestmemit: 0.425943 0.991184 0.052056 0.104819
## Iteration: 7 bestvalit: 0.640644 bestmemit: 0.425943 0.991184 0.052056 0.104819
## Iteration: 8 bestvalit: 0.618824 bestmemit: 0.407669 0.899821 0.076306 0.182522
## Iteration: 9 bestvalit: 0.618824 bestmemit: 0.407669 0.899821 0.076306 0.182522
## Iteration: 10 bestvalit: 0.618824 bestmemit: 0.407669 0.899821 0.076306 0.182522
## Iteration: 11 bestvalit: 0.618824 bestmemit: 0.407669 0.899821 0.076306 0.182522
## Iteration: 12 bestvalit: 0.618824 bestmemit: 0.407669 0.899821 0.076306 0.182522
## Iteration: 13 bestvalit: 0.618824 bestmemit: 0.407669 0.899821 0.076306 0.182522
## Iteration: 14 bestvalit: 0.583462 bestmemit: 0.328237 0.991184 0.052056 0.042823
## Iteration: 15 bestvalit: 0.583462 bestmemit: 0.328237 0.991184 0.052056 0.042823
## Iteration: 16 bestvalit: 0.570233 bestmemit: 0.017076 0.880911 0.040304 0.145346
## Iteration: 17 bestvalit: 0.570233 bestmemit: 0.017076 0.880911 0.040304 0.145346
## Iteration: 18 bestvalit: 0.570233 bestmemit: 0.017076 0.880911 0.040304 0.145346
## Iteration: 19 bestvalit: 0.559757 bestmemit: 0.345706 0.946338 0.063085 0.040766
## Iteration: 20 bestvalit: 0.559757 bestmemit: 0.345706 0.946338 0.063085 0.040766
## Iteration: 21 bestvalit: 0.559757 bestmemit: 0.345706 0.946338 0.063085 0.040766
## Iteration: 22 bestvalit: 0.559757 bestmemit: 0.345706 0.946338 0.063085 0.040766
## Iteration: 23 bestvalit: 0.559757 bestmemit: 0.345706 0.946338 0.063085 0.040766
## Iteration: 24 bestvalit: 0.534870 bestmemit: 0.108162 0.980931 0.036297 0.025865
## Iteration: 25 bestvalit: 0.534870 bestmemit: 0.108162 0.980931 0.036297 0.025865
## Iteration: 26 bestvalit: 0.534870 bestmemit: 0.108162 0.980931 0.036297 0.025865
## Iteration: 27 bestvalit: 0.534870 bestmemit: 0.108162 0.980931 0.036297 0.025865
## Iteration: 28 bestvalit: 0.534870 bestmemit: 0.108162 0.980931 0.036297 0.025865
## Iteration: 29 bestvalit: 0.534870 bestmemit: 0.108162 0.980931 0.036297 0.025865
## Iteration: 30 bestvalit: 0.534870 bestmemit: 0.108162 0.980931 0.036297 0.025865
## Iteration: 31 bestvalit: 0.512782 bestmemit: 0.051390 0.949924 0.035664 0.027793
## Iteration: 32 bestvalit: 0.512782 bestmemit: 0.051390 0.949924 0.035664 0.027793
## Iteration: 33 bestvalit: 0.512782 bestmemit: 0.051390 0.949924 0.035664 0.027793
## Iteration: 34 bestvalit: 0.512782 bestmemit: 0.051390 0.949924 0.035664 0.027793
## Iteration: 35 bestvalit: 0.512782 bestmemit: 0.051390 0.949924 0.035664 0.027793
## Iteration: 36 bestvalit: 0.512782 bestmemit: 0.051390 0.949924 0.035664 0.027793
## Iteration: 37 bestvalit: 0.512782 bestmemit: 0.051390 0.949924 0.035664 0.027793
## Iteration: 38 bestvalit: 0.512782 bestmemit: 0.051390 0.949924 0.035664 0.027793
## Iteration: 39 bestvalit: 0.512782 bestmemit: 0.051390 0.949924 0.035664 0.027793
## Iteration: 40 bestvalit: 0.512782 bestmemit: 0.051390 0.949924 0.035664 0.027793
## Iteration: 41 bestvalit: 0.512782 bestmemit: 0.051390 0.949924 0.035664 0.027793
## Iteration: 42 bestvalit: 0.512782 bestmemit: 0.051390 0.949924 0.035664 0.027793
## Iteration: 43 bestvalit: 0.512782 bestmemit: 0.051390 0.949924 0.035664 0.027793
## Iteration: 44 bestvalit: 0.512782 bestmemit: 0.051390 0.949924 0.035664 0.027793
## Iteration: 45 bestvalit: 0.512782 bestmemit: 0.051390 0.949924 0.035664 0.027793
## Iteration: 46 bestvalit: 0.512782 bestmemit: 0.051390 0.949924 0.035664 0.027793
## Iteration: 47 bestvalit: 0.512782 bestmemit: 0.051390 0.949924 0.035664 0.027793
## Iteration: 48 bestvalit: 0.512782 bestmemit: 0.051390 0.949924 0.035664 0.027793
## Iteration: 49 bestvalit: 0.512782 bestmemit: 0.051390 0.949924 0.035664 0.027793
## Iteration: 50 bestvalit: 0.512782 bestmemit: 0.051390 0.949924 0.035664 0.027793
## Iteration: 51 bestvalit: 0.512478 bestmemit: 0.031028 0.930671 0.029475 0.019254
## Iteration: 52 bestvalit: 0.512478 bestmemit: 0.031028 0.930671 0.029475 0.019254
## Iteration: 53 bestvalit: 0.512478 bestmemit: 0.031028 0.930671 0.029475 0.019254
## Iteration: 54 bestvalit: 0.511230 bestmemit: 0.031028 0.930671 0.029853 0.019254
## Iteration: 55 bestvalit: 0.511230 bestmemit: 0.031028 0.930671 0.029853 0.019254
## Iteration: 56 bestvalit: 0.509828 bestmemit: 0.031028 0.911508 0.029853 0.019254
## Iteration: 57 bestvalit: 0.508561 bestmemit: 0.061342 0.934388 0.035222 0.017112
## Iteration: 58 bestvalit: 0.507664 bestmemit: 0.051778 0.958522 0.034194 0.014050
## Iteration: 59 bestvalit: 0.507664 bestmemit: 0.051778 0.958522 0.034194 0.014050
## Iteration: 60 bestvalit: 0.507664 bestmemit: 0.051778 0.958522 0.034194 0.014050
## Iteration: 61 bestvalit: 0.507664 bestmemit: 0.051778 0.958522 0.034194 0.014050
## Iteration: 62 bestvalit: 0.507664 bestmemit: 0.051778 0.958522 0.034194 0.014050
## Iteration: 63 bestvalit: 0.507664 bestmemit: 0.051778 0.958522 0.034194 0.014050
## Iteration: 64 bestvalit: 0.507664 bestmemit: 0.051778 0.958522 0.034194 0.014050
## Iteration: 65 bestvalit: 0.506079 bestmemit: 0.072312 0.980756 0.037744 0.013911
## Iteration: 66 bestvalit: 0.505080 bestmemit: 0.025442 0.939742 0.030108 0.015478
## Iteration: 67 bestvalit: 0.505080 bestmemit: 0.025442 0.939742 0.030108 0.015478
## Iteration: 68 bestvalit: 0.505080 bestmemit: 0.025442 0.939742 0.030108 0.015478
## Iteration: 69 bestvalit: 0.505080 bestmemit: 0.025442 0.939742 0.030108 0.015478
## Iteration: 70 bestvalit: 0.505080 bestmemit: 0.025442 0.939742 0.030108 0.015478
## Iteration: 71 bestvalit: 0.504703 bestmemit: 0.022202 0.972767 0.029168 0.010048
## Iteration: 72 bestvalit: 0.504703 bestmemit: 0.022202 0.972767 0.029168 0.010048
## Iteration: 73 bestvalit: 0.503559 bestmemit: 0.034829 0.941859 0.031032 0.010848
## Iteration: 74 bestvalit: 0.503559 bestmemit: 0.034829 0.941859 0.031032 0.010848
## Iteration: 75 bestvalit: 0.503559 bestmemit: 0.034829 0.941859 0.031032 0.010848
## Iteration: 76 bestvalit: 0.501386 bestmemit: 0.022202 0.972767 0.030172 0.010048
## Iteration: 77 bestvalit: 0.501386 bestmemit: 0.022202 0.972767 0.030172 0.010048
## Iteration: 78 bestvalit: 0.501386 bestmemit: 0.022202 0.972767 0.030172 0.010048
## Iteration: 79 bestvalit: 0.501386 bestmemit: 0.022202 0.972767 0.030172 0.010048
## Iteration: 80 bestvalit: 0.501386 bestmemit: 0.022202 0.972767 0.030172 0.010048
## Iteration: 81 bestvalit: 0.501386 bestmemit: 0.022202 0.972767 0.030172 0.010048
## Iteration: 82 bestvalit: 0.501386 bestmemit: 0.022202 0.972767 0.030172 0.010048
## Iteration: 83 bestvalit: 0.501386 bestmemit: 0.022202 0.972767 0.030172 0.010048
## Iteration: 84 bestvalit: 0.501386 bestmemit: 0.022202 0.972767 0.030172 0.010048
## Iteration: 85 bestvalit: 0.501386 bestmemit: 0.022202 0.972767 0.030172 0.010048
## Iteration: 86 bestvalit: 0.501386 bestmemit: 0.022202 0.972767 0.030172 0.010048
## Iteration: 87 bestvalit: 0.501386 bestmemit: 0.022202 0.972767 0.030172 0.010048
## Iteration: 88 bestvalit: 0.501386 bestmemit: 0.022202 0.972767 0.030172 0.010048
## Iteration: 89 bestvalit: 0.501386 bestmemit: 0.022202 0.972767 0.030172 0.010048
## Iteration: 90 bestvalit: 0.501386 bestmemit: 0.022202 0.972767 0.030172 0.010048
## Iteration: 91 bestvalit: 0.501386 bestmemit: 0.022202 0.972767 0.030172 0.010048
## Iteration: 92 bestvalit: 0.501386 bestmemit: 0.022202 0.972767 0.030172 0.010048
## Iteration: 93 bestvalit: 0.501386 bestmemit: 0.022202 0.972767 0.030172 0.010048
## Iteration: 94 bestvalit: 0.501386 bestmemit: 0.022202 0.972767 0.030172 0.010048
## Iteration: 95 bestvalit: 0.501386 bestmemit: 0.022202 0.972767 0.030172 0.010048
## Iteration: 96 bestvalit: 0.501386 bestmemit: 0.022202 0.972767 0.030172 0.010048
## Iteration: 97 bestvalit: 0.501382 bestmemit: 0.017543 0.927853 0.028359 0.010188
## Iteration: 98 bestvalit: 0.501382 bestmemit: 0.017543 0.927853 0.028359 0.010188
## Iteration: 99 bestvalit: 0.501382 bestmemit: 0.017543 0.927853 0.028359 0.010188
## Iteration: 100 bestvalit: 0.501382 bestmemit: 0.017543 0.927853 0.028359 0.010188
## Iteration: 101 bestvalit: 0.501382 bestmemit: 0.017543 0.927853 0.028359 0.010188
## Iteration: 102 bestvalit: 0.501382 bestmemit: 0.017543 0.927853 0.028359 0.010188
## Iteration: 103 bestvalit: 0.501382 bestmemit: 0.017543 0.927853 0.028359 0.010188
## Iteration: 104 bestvalit: 0.501382 bestmemit: 0.017543 0.927853 0.028359 0.010188
## Iteration: 105 bestvalit: 0.501382 bestmemit: 0.017543 0.927853 0.028359 0.010188
## Iteration: 106 bestvalit: 0.501382 bestmemit: 0.017543 0.927853 0.028359 0.010188
## Iteration: 107 bestvalit: 0.501382 bestmemit: 0.017543 0.927853 0.028359 0.010188
## Iteration: 108 bestvalit: 0.501253 bestmemit: 0.022389 0.944186 0.029546 0.010097
## Iteration: 109 bestvalit: 0.501253 bestmemit: 0.022389 0.944186 0.029546 0.010097
## Iteration: 110 bestvalit: 0.501253 bestmemit: 0.022389 0.944186 0.029546 0.010097
## Iteration: 111 bestvalit: 0.501253 bestmemit: 0.022389 0.944186 0.029546 0.010097
## Iteration: 112 bestvalit: 0.501253 bestmemit: 0.022389 0.944186 0.029546 0.010097
## Iteration: 113 bestvalit: 0.501253 bestmemit: 0.022389 0.944186 0.029546 0.010097
## Iteration: 114 bestvalit: 0.500896 bestmemit: 0.015892 0.908172 0.027728 0.010097
## Iteration: 115 bestvalit: 0.500896 bestmemit: 0.015892 0.908172 0.027728 0.010097
## Iteration: 116 bestvalit: 0.500896 bestmemit: 0.015892 0.908172 0.027728 0.010097
## Iteration: 117 bestvalit: 0.500896 bestmemit: 0.015892 0.908172 0.027728 0.010097
## Iteration: 118 bestvalit: 0.500896 bestmemit: 0.015892 0.908172 0.027728 0.010097
## Iteration: 119 bestvalit: 0.500896 bestmemit: 0.015892 0.908172 0.027728 0.010097
## Iteration: 120 bestvalit: 0.500896 bestmemit: 0.015892 0.908172 0.027728 0.010097
## Iteration: 121 bestvalit: 0.500896 bestmemit: 0.015892 0.908172 0.027728 0.010097
## Iteration: 122 bestvalit: 0.500896 bestmemit: 0.015892 0.908172 0.027728 0.010097
## Iteration: 123 bestvalit: 0.500896 bestmemit: 0.015892 0.908172 0.027728 0.010097
## Iteration: 124 bestvalit: 0.500896 bestmemit: 0.015892 0.908172 0.027728 0.010097
## Iteration: 125 bestvalit: 0.500896 bestmemit: 0.015892 0.908172 0.027728 0.010097
## Iteration: 126 bestvalit: 0.500896 bestmemit: 0.015892 0.908172 0.027728 0.010097
## Iteration: 127 bestvalit: 0.500896 bestmemit: 0.015892 0.908172 0.027728 0.010097
## Iteration: 128 bestvalit: 0.500896 bestmemit: 0.015892 0.908172 0.027728 0.010097
## Iteration: 129 bestvalit: 0.500896 bestmemit: 0.015892 0.908172 0.027728 0.010097
## Iteration: 130 bestvalit: 0.500896 bestmemit: 0.015892 0.908172 0.027728 0.010097
## Iteration: 131 bestvalit: 0.500896 bestmemit: 0.015892 0.908172 0.027728 0.010097
## Iteration: 132 bestvalit: 0.500896 bestmemit: 0.015892 0.908172 0.027728 0.010097
## Iteration: 133 bestvalit: 0.500896 bestmemit: 0.015892 0.908172 0.027728 0.010097
## Iteration: 134 bestvalit: 0.500896 bestmemit: 0.015892 0.908172 0.027728 0.010097
## Iteration: 135 bestvalit: 0.500896 bestmemit: 0.015892 0.908172 0.027728 0.010097
## Iteration: 136 bestvalit: 0.500896 bestmemit: 0.015892 0.908172 0.027728 0.010097
## Iteration: 137 bestvalit: 0.500869 bestmemit: 0.016497 0.948253 0.028821 0.010029
## Iteration: 138 bestvalit: 0.500869 bestmemit: 0.016497 0.948253 0.028821 0.010029
## Iteration: 139 bestvalit: 0.500869 bestmemit: 0.016497 0.948253 0.028821 0.010029
## Iteration: 140 bestvalit: 0.500789 bestmemit: 0.016827 0.962618 0.029254 0.010017
## Iteration: 141 bestvalit: 0.500628 bestmemit: 0.019393 0.989298 0.030373 0.010040
## Iteration: 142 bestvalit: 0.500628 bestmemit: 0.019393 0.989298 0.030373 0.010040
## Iteration: 143 bestvalit: 0.500628 bestmemit: 0.019393 0.989298 0.030373 0.010040
## Iteration: 144 bestvalit: 0.500628 bestmemit: 0.019393 0.989298 0.030373 0.010040
## Iteration: 145 bestvalit: 0.500628 bestmemit: 0.019393 0.989298 0.030373 0.010040
## Iteration: 146 bestvalit: 0.500628 bestmemit: 0.019393 0.989298 0.030373 0.010040
## Iteration: 147 bestvalit: 0.500628 bestmemit: 0.019393 0.989298 0.030373 0.010040
## Iteration: 148 bestvalit: 0.500628 bestmemit: 0.019393 0.989298 0.030373 0.010040
## Iteration: 149 bestvalit: 0.500628 bestmemit: 0.019393 0.989298 0.030373 0.010040
## Iteration: 150 bestvalit: 0.500586 bestmemit: 0.013382 0.993526 0.029598 0.010139
## Iteration: 151 bestvalit: 0.500586 bestmemit: 0.013382 0.993526 0.029598 0.010139
## Iteration: 152 bestvalit: 0.500586 bestmemit: 0.013382 0.993526 0.029598 0.010139
## Iteration: 153 bestvalit: 0.500586 bestmemit: 0.013382 0.993526 0.029598 0.010139
## Iteration: 154 bestvalit: 0.500586 bestmemit: 0.013382 0.993526 0.029598 0.010139
## Iteration: 155 bestvalit: 0.500586 bestmemit: 0.013382 0.993526 0.029598 0.010139
## Iteration: 156 bestvalit: 0.500586 bestmemit: 0.013382 0.993526 0.029598 0.010139
## Iteration: 157 bestvalit: 0.500586 bestmemit: 0.013382 0.993526 0.029598 0.010139
## Iteration: 158 bestvalit: 0.500586 bestmemit: 0.013382 0.993526 0.029598 0.010139
## Iteration: 159 bestvalit: 0.500586 bestmemit: 0.013382 0.993526 0.029598 0.010139
## Iteration: 160 bestvalit: 0.500586 bestmemit: 0.013382 0.993526 0.029598 0.010139
## Iteration: 161 bestvalit: 0.500586 bestmemit: 0.013382 0.993526 0.029598 0.010139
## Iteration: 162 bestvalit: 0.500586 bestmemit: 0.013382 0.993526 0.029598 0.010139
## Iteration: 163 bestvalit: 0.500586 bestmemit: 0.013382 0.993526 0.029598 0.010139
## Iteration: 164 bestvalit: 0.500586 bestmemit: 0.013382 0.993526 0.029598 0.010139
## Iteration: 165 bestvalit: 0.500586 bestmemit: 0.013382 0.993526 0.029598 0.010139
## Iteration: 166 bestvalit: 0.500586 bestmemit: 0.013382 0.993526 0.029598 0.010139
## Iteration: 167 bestvalit: 0.500586 bestmemit: 0.013382 0.993526 0.029598 0.010139
## Iteration: 168 bestvalit: 0.500586 bestmemit: 0.013382 0.993526 0.029598 0.010139
## Iteration: 169 bestvalit: 0.500586 bestmemit: 0.013382 0.993526 0.029598 0.010139
## Iteration: 170 bestvalit: 0.500586 bestmemit: 0.013382 0.993526 0.029598 0.010139
## Iteration: 171 bestvalit: 0.500586 bestmemit: 0.013382 0.993526 0.029598 0.010139
## Iteration: 172 bestvalit: 0.500586 bestmemit: 0.013382 0.993526 0.029598 0.010139
## Iteration: 173 bestvalit: 0.500586 bestmemit: 0.013382 0.993526 0.029598 0.010139
## Iteration: 174 bestvalit: 0.500586 bestmemit: 0.013382 0.993526 0.029598 0.010139
## Iteration: 175 bestvalit: 0.500586 bestmemit: 0.013382 0.993526 0.029598 0.010139
## Iteration: 176 bestvalit: 0.500586 bestmemit: 0.013382 0.993526 0.029598 0.010139
## Iteration: 177 bestvalit: 0.500586 bestmemit: 0.013382 0.993526 0.029598 0.010139
## Iteration: 178 bestvalit: 0.500586 bestmemit: 0.013382 0.993526 0.029598 0.010139
## Iteration: 179 bestvalit: 0.500586 bestmemit: 0.013382 0.993526 0.029598 0.010139
## Iteration: 180 bestvalit: 0.500586 bestmemit: 0.013382 0.993526 0.029598 0.010139
## Iteration: 181 bestvalit: 0.500586 bestmemit: 0.013382 0.993526 0.029598 0.010139
## Iteration: 182 bestvalit: 0.500562 bestmemit: 0.018920 0.988474 0.030302 0.010046
## Iteration: 183 bestvalit: 0.500562 bestmemit: 0.018920 0.988474 0.030302 0.010046
## Iteration: 184 bestvalit: 0.500562 bestmemit: 0.018920 0.988474 0.030302 0.010046
## Iteration: 185 bestvalit: 0.500562 bestmemit: 0.018920 0.988474 0.030302 0.010046
## Iteration: 186 bestvalit: 0.500562 bestmemit: 0.018920 0.988474 0.030302 0.010046
## Iteration: 187 bestvalit: 0.500562 bestmemit: 0.018920 0.988474 0.030302 0.010046
## Iteration: 188 bestvalit: 0.500562 bestmemit: 0.018920 0.988474 0.030302 0.010046
## Iteration: 189 bestvalit: 0.500562 bestmemit: 0.018920 0.988474 0.030302 0.010046
## Iteration: 190 bestvalit: 0.500562 bestmemit: 0.018920 0.988474 0.030302 0.010046
## Iteration: 191 bestvalit: 0.500562 bestmemit: 0.018920 0.988474 0.030302 0.010046
## Iteration: 192 bestvalit: 0.500561 bestmemit: 0.017923 0.986249 0.030103 0.010086
## Iteration: 193 bestvalit: 0.500561 bestmemit: 0.017923 0.986249 0.030103 0.010086
## Iteration: 194 bestvalit: 0.500561 bestmemit: 0.017923 0.986249 0.030103 0.010086
## Iteration: 195 bestvalit: 0.500528 bestmemit: 0.017255 0.989129 0.030064 0.010005
## Iteration: 196 bestvalit: 0.500528 bestmemit: 0.017255 0.989129 0.030064 0.010005
## Iteration: 197 bestvalit: 0.500528 bestmemit: 0.017255 0.989129 0.030064 0.010005
## Iteration: 198 bestvalit: 0.500528 bestmemit: 0.017255 0.989129 0.030064 0.010005
## Iteration: 199 bestvalit: 0.500528 bestmemit: 0.017255 0.989129 0.030064 0.010005
## Iteration: 200 bestvalit: 0.500528 bestmemit: 0.017255 0.989129 0.030064 0.010005
##
## ==== Optimizing for Risk ≤ 0.06 ====
## Iteration: 1 bestvalit: 0.601959 bestmemit: 0.742248 0.767695 0.153339 0.287710
## Iteration: 2 bestvalit: 0.565862 bestmemit: 0.503873 0.860483 0.136553 0.281594
## Iteration: 3 bestvalit: 0.565862 bestmemit: 0.503873 0.860483 0.136553 0.281594
## Iteration: 4 bestvalit: 0.565148 bestmemit: 0.501273 0.860483 0.136553 0.281594
## Iteration: 5 bestvalit: 0.565148 bestmemit: 0.501273 0.860483 0.136553 0.281594
## Iteration: 6 bestvalit: 0.565148 bestmemit: 0.501273 0.860483 0.136553 0.281594
## Iteration: 7 bestvalit: 0.559202 bestmemit: 0.459901 0.528419 0.082016 0.057188
## Iteration: 8 bestvalit: 0.552033 bestmemit: 0.448491 0.966767 0.111505 0.177107
## Iteration: 9 bestvalit: 0.524984 bestmemit: 0.458954 0.732459 0.101481 0.083713
## Iteration: 10 bestvalit: 0.519049 bestmemit: 0.095748 0.463407 0.054270 0.129690
## Iteration: 11 bestvalit: 0.519049 bestmemit: 0.095748 0.463407 0.054270 0.129690
## Iteration: 12 bestvalit: 0.483295 bestmemit: 0.418182 0.732459 0.101481 0.045717
## Iteration: 13 bestvalit: 0.483295 bestmemit: 0.418182 0.732459 0.101481 0.045717
## Iteration: 14 bestvalit: 0.455986 bestmemit: 0.023803 0.742803 0.069969 0.132548
## Iteration: 15 bestvalit: 0.455986 bestmemit: 0.023803 0.742803 0.069969 0.132548
## Iteration: 16 bestvalit: 0.455986 bestmemit: 0.023803 0.742803 0.069969 0.132548
## Iteration: 17 bestvalit: 0.446238 bestmemit: 0.266523 0.763897 0.086615 0.032453
## Iteration: 18 bestvalit: 0.446238 bestmemit: 0.266523 0.763897 0.086615 0.032453
## Iteration: 19 bestvalit: 0.446238 bestmemit: 0.266523 0.763897 0.086615 0.032453
## Iteration: 20 bestvalit: 0.421974 bestmemit: 0.155637 0.597137 0.062183 0.013474
## Iteration: 21 bestvalit: 0.421974 bestmemit: 0.155637 0.597137 0.062183 0.013474
## Iteration: 22 bestvalit: 0.421974 bestmemit: 0.155637 0.597137 0.062183 0.013474
## Iteration: 23 bestvalit: 0.421974 bestmemit: 0.155637 0.597137 0.062183 0.013474
## Iteration: 24 bestvalit: 0.421974 bestmemit: 0.155637 0.597137 0.062183 0.013474
## Iteration: 25 bestvalit: 0.421974 bestmemit: 0.155637 0.597137 0.062183 0.013474
## Iteration: 26 bestvalit: 0.421974 bestmemit: 0.155637 0.597137 0.062183 0.013474
## Iteration: 27 bestvalit: 0.421974 bestmemit: 0.155637 0.597137 0.062183 0.013474
## Iteration: 28 bestvalit: 0.421029 bestmemit: 0.150573 0.803832 0.072745 0.012808
## Iteration: 29 bestvalit: 0.421029 bestmemit: 0.150573 0.803832 0.072745 0.012808
## Iteration: 30 bestvalit: 0.421029 bestmemit: 0.150573 0.803832 0.072745 0.012808
## Iteration: 31 bestvalit: 0.416937 bestmemit: 0.112114 0.746895 0.065638 0.018721
## Iteration: 32 bestvalit: 0.416937 bestmemit: 0.112114 0.746895 0.065638 0.018721
## Iteration: 33 bestvalit: 0.416937 bestmemit: 0.112114 0.746895 0.065638 0.018721
## Iteration: 34 bestvalit: 0.406757 bestmemit: 0.063881 0.662999 0.058663 0.031714
## Iteration: 35 bestvalit: 0.406757 bestmemit: 0.063881 0.662999 0.058663 0.031714
## Iteration: 36 bestvalit: 0.406757 bestmemit: 0.063881 0.662999 0.058663 0.031714
## Iteration: 37 bestvalit: 0.406757 bestmemit: 0.063881 0.662999 0.058663 0.031714
## Iteration: 38 bestvalit: 0.406757 bestmemit: 0.063881 0.662999 0.058663 0.031714
## Iteration: 39 bestvalit: 0.398922 bestmemit: 0.012594 0.526514 0.039983 0.023742
## Iteration: 40 bestvalit: 0.398922 bestmemit: 0.012594 0.526514 0.039983 0.023742
## Iteration: 41 bestvalit: 0.398922 bestmemit: 0.012594 0.526514 0.039983 0.023742
## Iteration: 42 bestvalit: 0.398922 bestmemit: 0.012594 0.526514 0.039983 0.023742
## Iteration: 43 bestvalit: 0.398922 bestmemit: 0.012594 0.526514 0.039983 0.023742
## Iteration: 44 bestvalit: 0.398922 bestmemit: 0.012594 0.526514 0.039983 0.023742
## Iteration: 45 bestvalit: 0.398922 bestmemit: 0.012594 0.526514 0.039983 0.023742
## Iteration: 46 bestvalit: 0.391929 bestmemit: 0.058368 0.730177 0.059627 0.013398
## Iteration: 47 bestvalit: 0.391929 bestmemit: 0.058368 0.730177 0.059627 0.013398
## Iteration: 48 bestvalit: 0.391929 bestmemit: 0.058368 0.730177 0.059627 0.013398
## Iteration: 49 bestvalit: 0.391929 bestmemit: 0.058368 0.730177 0.059627 0.013398
## Iteration: 50 bestvalit: 0.391929 bestmemit: 0.058368 0.730177 0.059627 0.013398
## Iteration: 51 bestvalit: 0.391929 bestmemit: 0.058368 0.730177 0.059627 0.013398
## Iteration: 52 bestvalit: 0.391929 bestmemit: 0.058368 0.730177 0.059627 0.013398
## Iteration: 53 bestvalit: 0.391929 bestmemit: 0.058368 0.730177 0.059627 0.013398
## Iteration: 54 bestvalit: 0.391929 bestmemit: 0.058368 0.730177 0.059627 0.013398
## Iteration: 55 bestvalit: 0.391929 bestmemit: 0.058368 0.730177 0.059627 0.013398
## Iteration: 56 bestvalit: 0.391929 bestmemit: 0.058368 0.730177 0.059627 0.013398
## Iteration: 57 bestvalit: 0.390742 bestmemit: 0.101963 0.983836 0.084388 0.014077
## Iteration: 58 bestvalit: 0.390742 bestmemit: 0.101963 0.983836 0.084388 0.014077
## Iteration: 59 bestvalit: 0.390742 bestmemit: 0.101963 0.983836 0.084388 0.014077
## Iteration: 60 bestvalit: 0.390742 bestmemit: 0.101963 0.983836 0.084388 0.014077
## Iteration: 61 bestvalit: 0.390742 bestmemit: 0.101963 0.983836 0.084388 0.014077
## Iteration: 62 bestvalit: 0.390742 bestmemit: 0.101963 0.983836 0.084388 0.014077
## Iteration: 63 bestvalit: 0.390742 bestmemit: 0.101963 0.983836 0.084388 0.014077
## Iteration: 64 bestvalit: 0.378423 bestmemit: 0.040712 0.966151 0.074294 0.011738
## Iteration: 65 bestvalit: 0.378423 bestmemit: 0.040712 0.966151 0.074294 0.011738
## Iteration: 66 bestvalit: 0.378423 bestmemit: 0.040712 0.966151 0.074294 0.011738
## Iteration: 67 bestvalit: 0.378423 bestmemit: 0.040712 0.966151 0.074294 0.011738
## Iteration: 68 bestvalit: 0.378423 bestmemit: 0.040712 0.966151 0.074294 0.011738
## Iteration: 69 bestvalit: 0.377437 bestmemit: 0.019179 0.655157 0.049894 0.011226
## Iteration: 70 bestvalit: 0.377437 bestmemit: 0.019179 0.655157 0.049894 0.011226
## Iteration: 71 bestvalit: 0.377437 bestmemit: 0.019179 0.655157 0.049894 0.011226
## Iteration: 72 bestvalit: 0.377437 bestmemit: 0.019179 0.655157 0.049894 0.011226
## Iteration: 73 bestvalit: 0.375130 bestmemit: 0.019179 0.655157 0.050465 0.011226
## Iteration: 74 bestvalit: 0.375130 bestmemit: 0.019179 0.655157 0.050465 0.011226
## Iteration: 75 bestvalit: 0.375130 bestmemit: 0.019179 0.655157 0.050465 0.011226
## Iteration: 76 bestvalit: 0.375130 bestmemit: 0.019179 0.655157 0.050465 0.011226
## Iteration: 77 bestvalit: 0.375130 bestmemit: 0.019179 0.655157 0.050465 0.011226
## Iteration: 78 bestvalit: 0.375130 bestmemit: 0.019179 0.655157 0.050465 0.011226
## Iteration: 79 bestvalit: 0.375130 bestmemit: 0.019179 0.655157 0.050465 0.011226
## Iteration: 80 bestvalit: 0.375130 bestmemit: 0.019179 0.655157 0.050465 0.011226
## Iteration: 81 bestvalit: 0.375130 bestmemit: 0.019179 0.655157 0.050465 0.011226
## Iteration: 82 bestvalit: 0.374782 bestmemit: 0.016443 0.921349 0.069050 0.016474
## Iteration: 83 bestvalit: 0.370448 bestmemit: 0.012976 0.914179 0.068130 0.012914
## Iteration: 84 bestvalit: 0.370448 bestmemit: 0.012976 0.914179 0.068130 0.012914
## Iteration: 85 bestvalit: 0.369776 bestmemit: 0.016443 0.921349 0.069050 0.011282
## Iteration: 86 bestvalit: 0.369776 bestmemit: 0.016443 0.921349 0.069050 0.011282
## Iteration: 87 bestvalit: 0.369776 bestmemit: 0.016443 0.921349 0.069050 0.011282
## Iteration: 88 bestvalit: 0.369776 bestmemit: 0.016443 0.921349 0.069050 0.011282
## Iteration: 89 bestvalit: 0.369776 bestmemit: 0.016443 0.921349 0.069050 0.011282
## Iteration: 90 bestvalit: 0.369776 bestmemit: 0.016443 0.921349 0.069050 0.011282
## Iteration: 91 bestvalit: 0.369776 bestmemit: 0.016443 0.921349 0.069050 0.011282
## Iteration: 92 bestvalit: 0.369776 bestmemit: 0.016443 0.921349 0.069050 0.011282
## Iteration: 93 bestvalit: 0.369776 bestmemit: 0.016443 0.921349 0.069050 0.011282
## Iteration: 94 bestvalit: 0.369776 bestmemit: 0.016443 0.921349 0.069050 0.011282
## Iteration: 95 bestvalit: 0.369776 bestmemit: 0.016443 0.921349 0.069050 0.011282
## Iteration: 96 bestvalit: 0.369776 bestmemit: 0.016443 0.921349 0.069050 0.011282
## Iteration: 97 bestvalit: 0.368716 bestmemit: 0.016443 0.921349 0.069050 0.010189
## Iteration: 98 bestvalit: 0.368716 bestmemit: 0.016443 0.921349 0.069050 0.010189
## Iteration: 99 bestvalit: 0.368716 bestmemit: 0.016443 0.921349 0.069050 0.010189
## Iteration: 100 bestvalit: 0.368716 bestmemit: 0.016443 0.921349 0.069050 0.010189
## Iteration: 101 bestvalit: 0.368716 bestmemit: 0.016443 0.921349 0.069050 0.010189
## Iteration: 102 bestvalit: 0.368716 bestmemit: 0.016443 0.921349 0.069050 0.010189
## Iteration: 103 bestvalit: 0.368716 bestmemit: 0.016443 0.921349 0.069050 0.010189
## Iteration: 104 bestvalit: 0.368716 bestmemit: 0.016443 0.921349 0.069050 0.010189
## Iteration: 105 bestvalit: 0.368716 bestmemit: 0.016443 0.921349 0.069050 0.010189
## Iteration: 106 bestvalit: 0.368716 bestmemit: 0.016443 0.921349 0.069050 0.010189
## Iteration: 107 bestvalit: 0.368716 bestmemit: 0.016443 0.921349 0.069050 0.010189
## Iteration: 108 bestvalit: 0.368716 bestmemit: 0.016443 0.921349 0.069050 0.010189
## Iteration: 109 bestvalit: 0.368282 bestmemit: 0.013721 0.890516 0.066467 0.010020
## Iteration: 110 bestvalit: 0.368282 bestmemit: 0.013721 0.890516 0.066467 0.010020
## Iteration: 111 bestvalit: 0.368282 bestmemit: 0.013721 0.890516 0.066467 0.010020
## Iteration: 112 bestvalit: 0.368282 bestmemit: 0.013721 0.890516 0.066467 0.010020
## Iteration: 113 bestvalit: 0.368282 bestmemit: 0.013721 0.890516 0.066467 0.010020
## Iteration: 114 bestvalit: 0.368282 bestmemit: 0.013721 0.890516 0.066467 0.010020
## Iteration: 115 bestvalit: 0.368282 bestmemit: 0.013721 0.890516 0.066467 0.010020
## Iteration: 116 bestvalit: 0.368282 bestmemit: 0.013721 0.890516 0.066467 0.010020
## Iteration: 117 bestvalit: 0.368282 bestmemit: 0.013721 0.890516 0.066467 0.010020
## Iteration: 118 bestvalit: 0.368282 bestmemit: 0.013721 0.890516 0.066467 0.010020
## Iteration: 119 bestvalit: 0.368143 bestmemit: 0.013794 0.920230 0.068700 0.010509
## Iteration: 120 bestvalit: 0.368143 bestmemit: 0.013794 0.920230 0.068700 0.010509
## Iteration: 121 bestvalit: 0.368143 bestmemit: 0.013794 0.920230 0.068700 0.010509
## Iteration: 122 bestvalit: 0.368143 bestmemit: 0.013794 0.920230 0.068700 0.010509
## Iteration: 123 bestvalit: 0.368143 bestmemit: 0.013794 0.920230 0.068700 0.010509
## Iteration: 124 bestvalit: 0.368143 bestmemit: 0.013794 0.920230 0.068700 0.010509
## Iteration: 125 bestvalit: 0.368143 bestmemit: 0.013794 0.920230 0.068700 0.010509
## Iteration: 126 bestvalit: 0.368143 bestmemit: 0.013794 0.920230 0.068700 0.010509
## Iteration: 127 bestvalit: 0.367074 bestmemit: 0.013081 0.983546 0.073099 0.010169
## Iteration: 128 bestvalit: 0.367074 bestmemit: 0.013081 0.983546 0.073099 0.010169
## Iteration: 129 bestvalit: 0.367074 bestmemit: 0.013081 0.983546 0.073099 0.010169
## Iteration: 130 bestvalit: 0.367074 bestmemit: 0.013081 0.983546 0.073099 0.010169
## Iteration: 131 bestvalit: 0.367074 bestmemit: 0.013081 0.983546 0.073099 0.010169
## Iteration: 132 bestvalit: 0.367074 bestmemit: 0.013081 0.983546 0.073099 0.010169
## Iteration: 133 bestvalit: 0.367074 bestmemit: 0.013081 0.983546 0.073099 0.010169
## Iteration: 134 bestvalit: 0.367074 bestmemit: 0.013081 0.983546 0.073099 0.010169
## Iteration: 135 bestvalit: 0.367074 bestmemit: 0.013081 0.983546 0.073099 0.010169
## Iteration: 136 bestvalit: 0.367074 bestmemit: 0.013081 0.983546 0.073099 0.010169
## Iteration: 137 bestvalit: 0.366636 bestmemit: 0.010757 0.966048 0.071532 0.010088
## Iteration: 138 bestvalit: 0.366636 bestmemit: 0.010757 0.966048 0.071532 0.010088
## Iteration: 139 bestvalit: 0.366636 bestmemit: 0.010757 0.966048 0.071532 0.010088
## Iteration: 140 bestvalit: 0.366636 bestmemit: 0.010757 0.966048 0.071532 0.010088
## Iteration: 141 bestvalit: 0.366636 bestmemit: 0.010757 0.966048 0.071532 0.010088
## Iteration: 142 bestvalit: 0.366636 bestmemit: 0.010757 0.966048 0.071532 0.010088
## Iteration: 143 bestvalit: 0.366636 bestmemit: 0.010757 0.966048 0.071532 0.010088
## Iteration: 144 bestvalit: 0.366636 bestmemit: 0.010757 0.966048 0.071532 0.010088
## Iteration: 145 bestvalit: 0.366636 bestmemit: 0.010757 0.966048 0.071532 0.010088
## Iteration: 146 bestvalit: 0.366636 bestmemit: 0.010757 0.966048 0.071532 0.010088
## Iteration: 147 bestvalit: 0.366636 bestmemit: 0.010757 0.966048 0.071532 0.010088
## Iteration: 148 bestvalit: 0.366636 bestmemit: 0.010757 0.966048 0.071532 0.010088
## Iteration: 149 bestvalit: 0.366636 bestmemit: 0.010757 0.966048 0.071532 0.010088
## Iteration: 150 bestvalit: 0.366636 bestmemit: 0.010757 0.966048 0.071532 0.010088
## Iteration: 151 bestvalit: 0.366636 bestmemit: 0.010757 0.966048 0.071532 0.010088
## Iteration: 152 bestvalit: 0.366636 bestmemit: 0.010757 0.966048 0.071532 0.010088
## Iteration: 153 bestvalit: 0.366636 bestmemit: 0.010757 0.966048 0.071532 0.010088
## Iteration: 154 bestvalit: 0.366636 bestmemit: 0.010757 0.966048 0.071532 0.010088
## Iteration: 155 bestvalit: 0.366636 bestmemit: 0.010757 0.966048 0.071532 0.010088
## Iteration: 156 bestvalit: 0.366636 bestmemit: 0.010757 0.966048 0.071532 0.010088
## Iteration: 157 bestvalit: 0.366636 bestmemit: 0.010757 0.966048 0.071532 0.010088
## Iteration: 158 bestvalit: 0.366636 bestmemit: 0.010757 0.966048 0.071532 0.010088
## Iteration: 159 bestvalit: 0.366636 bestmemit: 0.010757 0.966048 0.071532 0.010088
## Iteration: 160 bestvalit: 0.366636 bestmemit: 0.010757 0.966048 0.071532 0.010088
## Iteration: 161 bestvalit: 0.366636 bestmemit: 0.010757 0.966048 0.071532 0.010088
## Iteration: 162 bestvalit: 0.366636 bestmemit: 0.010757 0.966048 0.071532 0.010088
## Iteration: 163 bestvalit: 0.366636 bestmemit: 0.010757 0.966048 0.071532 0.010088
## Iteration: 164 bestvalit: 0.366636 bestmemit: 0.010757 0.966048 0.071532 0.010088
## Iteration: 165 bestvalit: 0.366636 bestmemit: 0.010757 0.966048 0.071532 0.010088
## Iteration: 166 bestvalit: 0.366547 bestmemit: 0.010024 0.993553 0.073280 0.010094
## Iteration: 167 bestvalit: 0.366547 bestmemit: 0.010024 0.993553 0.073280 0.010094
## Iteration: 168 bestvalit: 0.366547 bestmemit: 0.010024 0.993553 0.073280 0.010094
## Iteration: 169 bestvalit: 0.366547 bestmemit: 0.010024 0.993553 0.073280 0.010094
## Iteration: 170 bestvalit: 0.366547 bestmemit: 0.010024 0.993553 0.073280 0.010094
## Iteration: 171 bestvalit: 0.366547 bestmemit: 0.010024 0.993553 0.073280 0.010094
## Iteration: 172 bestvalit: 0.366547 bestmemit: 0.010024 0.993553 0.073280 0.010094
## Iteration: 173 bestvalit: 0.366547 bestmemit: 0.010024 0.993553 0.073280 0.010094
## Iteration: 174 bestvalit: 0.366547 bestmemit: 0.010024 0.993553 0.073280 0.010094
## Iteration: 175 bestvalit: 0.366522 bestmemit: 0.010739 0.970843 0.071888 0.010065
## Iteration: 176 bestvalit: 0.366522 bestmemit: 0.010739 0.970843 0.071888 0.010065
## Iteration: 177 bestvalit: 0.366522 bestmemit: 0.010739 0.970843 0.071888 0.010065
## Iteration: 178 bestvalit: 0.366522 bestmemit: 0.010739 0.970843 0.071888 0.010065
## Iteration: 179 bestvalit: 0.366522 bestmemit: 0.010739 0.970843 0.071888 0.010065
## Iteration: 180 bestvalit: 0.366522 bestmemit: 0.010739 0.970843 0.071888 0.010065
## Iteration: 181 bestvalit: 0.366522 bestmemit: 0.010739 0.970843 0.071888 0.010065
## Iteration: 182 bestvalit: 0.366522 bestmemit: 0.010739 0.970843 0.071888 0.010065
## Iteration: 183 bestvalit: 0.366522 bestmemit: 0.010739 0.970843 0.071888 0.010065
## Iteration: 184 bestvalit: 0.366522 bestmemit: 0.010739 0.970843 0.071888 0.010065
## Iteration: 185 bestvalit: 0.366461 bestmemit: 0.010618 0.999648 0.073893 0.010203
## Iteration: 186 bestvalit: 0.366461 bestmemit: 0.010618 0.999648 0.073893 0.010203
## Iteration: 187 bestvalit: 0.366425 bestmemit: 0.010786 0.991820 0.073383 0.010124
## Iteration: 188 bestvalit: 0.366425 bestmemit: 0.010786 0.991820 0.073383 0.010124
## Iteration: 189 bestvalit: 0.366293 bestmemit: 0.010618 0.999648 0.073955 0.010203
## Iteration: 190 bestvalit: 0.366293 bestmemit: 0.010618 0.999648 0.073955 0.010203
## Iteration: 191 bestvalit: 0.366293 bestmemit: 0.010618 0.999648 0.073955 0.010203
## Iteration: 192 bestvalit: 0.366293 bestmemit: 0.010618 0.999648 0.073955 0.010203
## Iteration: 193 bestvalit: 0.366293 bestmemit: 0.010618 0.999648 0.073955 0.010203
## Iteration: 194 bestvalit: 0.366293 bestmemit: 0.010618 0.999648 0.073955 0.010203
## Iteration: 195 bestvalit: 0.366293 bestmemit: 0.010618 0.999648 0.073955 0.010203
## Iteration: 196 bestvalit: 0.366293 bestmemit: 0.010618 0.999648 0.073955 0.010203
## Iteration: 197 bestvalit: 0.366293 bestmemit: 0.010618 0.999648 0.073955 0.010203
## Iteration: 198 bestvalit: 0.366293 bestmemit: 0.010618 0.999648 0.073955 0.010203
## Iteration: 199 bestvalit: 0.366293 bestmemit: 0.010618 0.999648 0.073955 0.010203
## Iteration: 200 bestvalit: 0.366293 bestmemit: 0.010618 0.999648 0.073955 0.010203
##
## ==== Optimizing for Risk ≤ 0.08 ====
## Iteration: 1 bestvalit: 0.456915 bestmemit: 0.321713 0.932622 0.186251 0.356064
## Iteration: 2 bestvalit: 0.456915 bestmemit: 0.321713 0.932622 0.186251 0.356064
## Iteration: 3 bestvalit: 0.456915 bestmemit: 0.321713 0.932622 0.186251 0.356064
## Iteration: 4 bestvalit: 0.456915 bestmemit: 0.321713 0.932622 0.186251 0.356064
## Iteration: 5 bestvalit: 0.451730 bestmemit: 0.485783 0.955806 0.204399 0.300506
## Iteration: 6 bestvalit: 0.450589 bestmemit: 0.800110 0.977808 0.186234 0.013361
## Iteration: 7 bestvalit: 0.340412 bestmemit: 0.341916 0.992726 0.157297 0.028306
## Iteration: 8 bestvalit: 0.340412 bestmemit: 0.341916 0.992726 0.157297 0.028306
## Iteration: 9 bestvalit: 0.340412 bestmemit: 0.341916 0.992726 0.157297 0.028306
## Iteration: 10 bestvalit: 0.340412 bestmemit: 0.341916 0.992726 0.157297 0.028306
## Iteration: 11 bestvalit: 0.340412 bestmemit: 0.341916 0.992726 0.157297 0.028306
## Iteration: 12 bestvalit: 0.340412 bestmemit: 0.341916 0.992726 0.157297 0.028306
## Iteration: 13 bestvalit: 0.340412 bestmemit: 0.341916 0.992726 0.157297 0.028306
## Iteration: 14 bestvalit: 0.340412 bestmemit: 0.341916 0.992726 0.157297 0.028306
## Iteration: 15 bestvalit: 0.340412 bestmemit: 0.341916 0.992726 0.157297 0.028306
## Iteration: 16 bestvalit: 0.340412 bestmemit: 0.341916 0.992726 0.157297 0.028306
## Iteration: 17 bestvalit: 0.340412 bestmemit: 0.341916 0.992726 0.157297 0.028306
## Iteration: 18 bestvalit: 0.340412 bestmemit: 0.341916 0.992726 0.157297 0.028306
## Iteration: 19 bestvalit: 0.340412 bestmemit: 0.341916 0.992726 0.157297 0.028306
## Iteration: 20 bestvalit: 0.340412 bestmemit: 0.341916 0.992726 0.157297 0.028306
## Iteration: 21 bestvalit: 0.340412 bestmemit: 0.341916 0.992726 0.157297 0.028306
## Iteration: 22 bestvalit: 0.340412 bestmemit: 0.341916 0.992726 0.157297 0.028306
## Iteration: 23 bestvalit: 0.340412 bestmemit: 0.341916 0.992726 0.157297 0.028306
## Iteration: 24 bestvalit: 0.340412 bestmemit: 0.341916 0.992726 0.157297 0.028306
## Iteration: 25 bestvalit: 0.340412 bestmemit: 0.341916 0.992726 0.157297 0.028306
## Iteration: 26 bestvalit: 0.318875 bestmemit: 0.281977 0.970879 0.146840 0.011574
## Iteration: 27 bestvalit: 0.318875 bestmemit: 0.281977 0.970879 0.146840 0.011574
## Iteration: 28 bestvalit: 0.318875 bestmemit: 0.281977 0.970879 0.146840 0.011574
## Iteration: 29 bestvalit: 0.317151 bestmemit: 0.045717 0.807576 0.086949 0.019188
## Iteration: 30 bestvalit: 0.314807 bestmemit: 0.056739 0.774536 0.086949 0.019188
## Iteration: 31 bestvalit: 0.314807 bestmemit: 0.056739 0.774536 0.086949 0.019188
## Iteration: 32 bestvalit: 0.314807 bestmemit: 0.056739 0.774536 0.086949 0.019188
## Iteration: 33 bestvalit: 0.286786 bestmemit: 0.013572 0.920276 0.108063 0.043624
## Iteration: 34 bestvalit: 0.286786 bestmemit: 0.013572 0.920276 0.108063 0.043624
## Iteration: 35 bestvalit: 0.286786 bestmemit: 0.013572 0.920276 0.108063 0.043624
## Iteration: 36 bestvalit: 0.286786 bestmemit: 0.013572 0.920276 0.108063 0.043624
## Iteration: 37 bestvalit: 0.286786 bestmemit: 0.013572 0.920276 0.108063 0.043624
## Iteration: 38 bestvalit: 0.286786 bestmemit: 0.013572 0.920276 0.108063 0.043624
## Iteration: 39 bestvalit: 0.286786 bestmemit: 0.013572 0.920276 0.108063 0.043624
## Iteration: 40 bestvalit: 0.286786 bestmemit: 0.013572 0.920276 0.108063 0.043624
## Iteration: 41 bestvalit: 0.286786 bestmemit: 0.013572 0.920276 0.108063 0.043624
## Iteration: 42 bestvalit: 0.286786 bestmemit: 0.013572 0.920276 0.108063 0.043624
## Iteration: 43 bestvalit: 0.286786 bestmemit: 0.013572 0.920276 0.108063 0.043624
## Iteration: 44 bestvalit: 0.286786 bestmemit: 0.013572 0.920276 0.108063 0.043624
## Iteration: 45 bestvalit: 0.286786 bestmemit: 0.013572 0.920276 0.108063 0.043624
## Iteration: 46 bestvalit: 0.286164 bestmemit: 0.013572 0.920276 0.108273 0.043624
## Iteration: 47 bestvalit: 0.286164 bestmemit: 0.013572 0.920276 0.108273 0.043624
## Iteration: 48 bestvalit: 0.286164 bestmemit: 0.013572 0.920276 0.108273 0.043624
## Iteration: 49 bestvalit: 0.286164 bestmemit: 0.013572 0.920276 0.108273 0.043624
## Iteration: 50 bestvalit: 0.282308 bestmemit: 0.031223 0.966741 0.114174 0.031410
## Iteration: 51 bestvalit: 0.282308 bestmemit: 0.031223 0.966741 0.114174 0.031410
## Iteration: 52 bestvalit: 0.282308 bestmemit: 0.031223 0.966741 0.114174 0.031410
## Iteration: 53 bestvalit: 0.282308 bestmemit: 0.031223 0.966741 0.114174 0.031410
## Iteration: 54 bestvalit: 0.282308 bestmemit: 0.031223 0.966741 0.114174 0.031410
## Iteration: 55 bestvalit: 0.282308 bestmemit: 0.031223 0.966741 0.114174 0.031410
## Iteration: 56 bestvalit: 0.282308 bestmemit: 0.031223 0.966741 0.114174 0.031410
## Iteration: 57 bestvalit: 0.282308 bestmemit: 0.031223 0.966741 0.114174 0.031410
## Iteration: 58 bestvalit: 0.282308 bestmemit: 0.031223 0.966741 0.114174 0.031410
## Iteration: 59 bestvalit: 0.278019 bestmemit: 0.051839 0.949244 0.113773 0.016957
## Iteration: 60 bestvalit: 0.278019 bestmemit: 0.051839 0.949244 0.113773 0.016957
## Iteration: 61 bestvalit: 0.274475 bestmemit: 0.031474 0.945617 0.107937 0.010107
## Iteration: 62 bestvalit: 0.274475 bestmemit: 0.031474 0.945617 0.107937 0.010107
## Iteration: 63 bestvalit: 0.274475 bestmemit: 0.031474 0.945617 0.107937 0.010107
## Iteration: 64 bestvalit: 0.274475 bestmemit: 0.031474 0.945617 0.107937 0.010107
## Iteration: 65 bestvalit: 0.274475 bestmemit: 0.031474 0.945617 0.107937 0.010107
## Iteration: 66 bestvalit: 0.274475 bestmemit: 0.031474 0.945617 0.107937 0.010107
## Iteration: 67 bestvalit: 0.274475 bestmemit: 0.031474 0.945617 0.107937 0.010107
## Iteration: 68 bestvalit: 0.274475 bestmemit: 0.031474 0.945617 0.107937 0.010107
## Iteration: 69 bestvalit: 0.274475 bestmemit: 0.031474 0.945617 0.107937 0.010107
## Iteration: 70 bestvalit: 0.274475 bestmemit: 0.031474 0.945617 0.107937 0.010107
## Iteration: 71 bestvalit: 0.274475 bestmemit: 0.031474 0.945617 0.107937 0.010107
## Iteration: 72 bestvalit: 0.274475 bestmemit: 0.031474 0.945617 0.107937 0.010107
## Iteration: 73 bestvalit: 0.274475 bestmemit: 0.031474 0.945617 0.107937 0.010107
## Iteration: 74 bestvalit: 0.274475 bestmemit: 0.031474 0.945617 0.107937 0.010107
## Iteration: 75 bestvalit: 0.274475 bestmemit: 0.031474 0.945617 0.107937 0.010107
## Iteration: 76 bestvalit: 0.274475 bestmemit: 0.031474 0.945617 0.107937 0.010107
## Iteration: 77 bestvalit: 0.273007 bestmemit: 0.020937 0.941457 0.106803 0.013570
## Iteration: 78 bestvalit: 0.272159 bestmemit: 0.029690 0.836639 0.097521 0.011745
## Iteration: 79 bestvalit: 0.272159 bestmemit: 0.029690 0.836639 0.097521 0.011745
## Iteration: 80 bestvalit: 0.272159 bestmemit: 0.029690 0.836639 0.097521 0.011745
## Iteration: 81 bestvalit: 0.272159 bestmemit: 0.029690 0.836639 0.097521 0.011745
## Iteration: 82 bestvalit: 0.272159 bestmemit: 0.029690 0.836639 0.097521 0.011745
## Iteration: 83 bestvalit: 0.272159 bestmemit: 0.029690 0.836639 0.097521 0.011745
## Iteration: 84 bestvalit: 0.272159 bestmemit: 0.029690 0.836639 0.097521 0.011745
## Iteration: 85 bestvalit: 0.270216 bestmemit: 0.020937 0.941457 0.106803 0.010668
## Iteration: 86 bestvalit: 0.270216 bestmemit: 0.020937 0.941457 0.106803 0.010668
## Iteration: 87 bestvalit: 0.270216 bestmemit: 0.020937 0.941457 0.106803 0.010668
## Iteration: 88 bestvalit: 0.270216 bestmemit: 0.020937 0.941457 0.106803 0.010668
## Iteration: 89 bestvalit: 0.270216 bestmemit: 0.020937 0.941457 0.106803 0.010668
## Iteration: 90 bestvalit: 0.267569 bestmemit: 0.011536 0.957997 0.107731 0.011837
## Iteration: 91 bestvalit: 0.267569 bestmemit: 0.011536 0.957997 0.107731 0.011837
## Iteration: 92 bestvalit: 0.267569 bestmemit: 0.011536 0.957997 0.107731 0.011837
## Iteration: 93 bestvalit: 0.267569 bestmemit: 0.011536 0.957997 0.107731 0.011837
## Iteration: 94 bestvalit: 0.267569 bestmemit: 0.011536 0.957997 0.107731 0.011837
## Iteration: 95 bestvalit: 0.267569 bestmemit: 0.011536 0.957997 0.107731 0.011837
## Iteration: 96 bestvalit: 0.266611 bestmemit: 0.016108 0.925239 0.105521 0.011574
## Iteration: 97 bestvalit: 0.266440 bestmemit: 0.010794 0.911961 0.103601 0.013469
## Iteration: 98 bestvalit: 0.266440 bestmemit: 0.010794 0.911961 0.103601 0.013469
## Iteration: 99 bestvalit: 0.266440 bestmemit: 0.010794 0.911961 0.103601 0.013469
## Iteration: 100 bestvalit: 0.266440 bestmemit: 0.010794 0.911961 0.103601 0.013469
## Iteration: 101 bestvalit: 0.265976 bestmemit: 0.011536 0.952873 0.107731 0.011837
## Iteration: 102 bestvalit: 0.264776 bestmemit: 0.011536 0.952873 0.107731 0.010594
## Iteration: 103 bestvalit: 0.264776 bestmemit: 0.011536 0.952873 0.107731 0.010594
## Iteration: 104 bestvalit: 0.264776 bestmemit: 0.011536 0.952873 0.107731 0.010594
## Iteration: 105 bestvalit: 0.264776 bestmemit: 0.011536 0.952873 0.107731 0.010594
## Iteration: 106 bestvalit: 0.264776 bestmemit: 0.011536 0.952873 0.107731 0.010594
## Iteration: 107 bestvalit: 0.264776 bestmemit: 0.011536 0.952873 0.107731 0.010594
## Iteration: 108 bestvalit: 0.264776 bestmemit: 0.011536 0.952873 0.107731 0.010594
## Iteration: 109 bestvalit: 0.264776 bestmemit: 0.011536 0.952873 0.107731 0.010594
## Iteration: 110 bestvalit: 0.264776 bestmemit: 0.011536 0.952873 0.107731 0.010594
## Iteration: 111 bestvalit: 0.264776 bestmemit: 0.011536 0.952873 0.107731 0.010594
## Iteration: 112 bestvalit: 0.264776 bestmemit: 0.011536 0.952873 0.107731 0.010594
## Iteration: 113 bestvalit: 0.264776 bestmemit: 0.011536 0.952873 0.107731 0.010594
## Iteration: 114 bestvalit: 0.264776 bestmemit: 0.011536 0.952873 0.107731 0.010594
## Iteration: 115 bestvalit: 0.264776 bestmemit: 0.011536 0.952873 0.107731 0.010594
## Iteration: 116 bestvalit: 0.264776 bestmemit: 0.011536 0.952873 0.107731 0.010594
## Iteration: 117 bestvalit: 0.264776 bestmemit: 0.011536 0.952873 0.107731 0.010594
## Iteration: 118 bestvalit: 0.264776 bestmemit: 0.011536 0.952873 0.107731 0.010594
## Iteration: 119 bestvalit: 0.264776 bestmemit: 0.011536 0.952873 0.107731 0.010594
## Iteration: 120 bestvalit: 0.264776 bestmemit: 0.011536 0.952873 0.107731 0.010594
## Iteration: 121 bestvalit: 0.264776 bestmemit: 0.011536 0.952873 0.107731 0.010594
## Iteration: 122 bestvalit: 0.264776 bestmemit: 0.011536 0.952873 0.107731 0.010594
## Iteration: 123 bestvalit: 0.264776 bestmemit: 0.011536 0.952873 0.107731 0.010594
## Iteration: 124 bestvalit: 0.264776 bestmemit: 0.011536 0.952873 0.107731 0.010594
## Iteration: 125 bestvalit: 0.264776 bestmemit: 0.011536 0.952873 0.107731 0.010594
## Iteration: 126 bestvalit: 0.264776 bestmemit: 0.011536 0.952873 0.107731 0.010594
## Iteration: 127 bestvalit: 0.264776 bestmemit: 0.011536 0.952873 0.107731 0.010594
## Iteration: 128 bestvalit: 0.264776 bestmemit: 0.011536 0.952873 0.107731 0.010594
## Iteration: 129 bestvalit: 0.264776 bestmemit: 0.011536 0.952873 0.107731 0.010594
## Iteration: 130 bestvalit: 0.264776 bestmemit: 0.011536 0.952873 0.107731 0.010594
## Iteration: 131 bestvalit: 0.264776 bestmemit: 0.011536 0.952873 0.107731 0.010594
## Iteration: 132 bestvalit: 0.264776 bestmemit: 0.011536 0.952873 0.107731 0.010594
## Iteration: 133 bestvalit: 0.264776 bestmemit: 0.011536 0.952873 0.107731 0.010594
## Iteration: 134 bestvalit: 0.264776 bestmemit: 0.011536 0.952873 0.107731 0.010594
## Iteration: 135 bestvalit: 0.264776 bestmemit: 0.011536 0.952873 0.107731 0.010594
## Iteration: 136 bestvalit: 0.264776 bestmemit: 0.011536 0.952873 0.107731 0.010594
## Iteration: 137 bestvalit: 0.264776 bestmemit: 0.011536 0.952873 0.107731 0.010594
## Iteration: 138 bestvalit: 0.264776 bestmemit: 0.011536 0.952873 0.107731 0.010594
## Iteration: 139 bestvalit: 0.264776 bestmemit: 0.011536 0.952873 0.107731 0.010594
## Iteration: 140 bestvalit: 0.264776 bestmemit: 0.011536 0.952873 0.107731 0.010594
## Iteration: 141 bestvalit: 0.264776 bestmemit: 0.011536 0.952873 0.107731 0.010594
## Iteration: 142 bestvalit: 0.264776 bestmemit: 0.011536 0.952873 0.107731 0.010594
## Iteration: 143 bestvalit: 0.264449 bestmemit: 0.011342 0.967701 0.109432 0.010744
## Iteration: 144 bestvalit: 0.264449 bestmemit: 0.011342 0.967701 0.109432 0.010744
## Iteration: 145 bestvalit: 0.264449 bestmemit: 0.011342 0.967701 0.109432 0.010744
## Iteration: 146 bestvalit: 0.264427 bestmemit: 0.011215 0.953994 0.107877 0.010532
## Iteration: 147 bestvalit: 0.264427 bestmemit: 0.011215 0.953994 0.107877 0.010532
## Iteration: 148 bestvalit: 0.264427 bestmemit: 0.011215 0.953994 0.107877 0.010532
## Iteration: 149 bestvalit: 0.264427 bestmemit: 0.011215 0.953994 0.107877 0.010532
## Iteration: 150 bestvalit: 0.264226 bestmemit: 0.011536 0.952873 0.107731 0.010025
## Iteration: 151 bestvalit: 0.264226 bestmemit: 0.011536 0.952873 0.107731 0.010025
## Iteration: 152 bestvalit: 0.264217 bestmemit: 0.011523 0.952873 0.107731 0.010025
## Iteration: 153 bestvalit: 0.264217 bestmemit: 0.011523 0.952873 0.107731 0.010025
## Iteration: 154 bestvalit: 0.264217 bestmemit: 0.011523 0.952873 0.107731 0.010025
## Iteration: 155 bestvalit: 0.264217 bestmemit: 0.011523 0.952873 0.107731 0.010025
## Iteration: 156 bestvalit: 0.264217 bestmemit: 0.011523 0.952873 0.107731 0.010025
## Iteration: 157 bestvalit: 0.264217 bestmemit: 0.011523 0.952873 0.107731 0.010025
## Iteration: 158 bestvalit: 0.264217 bestmemit: 0.011523 0.952873 0.107731 0.010025
## Iteration: 159 bestvalit: 0.264217 bestmemit: 0.011523 0.952873 0.107731 0.010025
## Iteration: 160 bestvalit: 0.264217 bestmemit: 0.011523 0.952873 0.107731 0.010025
## Iteration: 161 bestvalit: 0.264217 bestmemit: 0.011523 0.952873 0.107731 0.010025
## Iteration: 162 bestvalit: 0.264217 bestmemit: 0.011523 0.952873 0.107731 0.010025
## Iteration: 163 bestvalit: 0.264217 bestmemit: 0.011523 0.952873 0.107731 0.010025
## Iteration: 164 bestvalit: 0.264217 bestmemit: 0.011523 0.952873 0.107731 0.010025
## Iteration: 165 bestvalit: 0.264217 bestmemit: 0.011523 0.952873 0.107731 0.010025
## Iteration: 166 bestvalit: 0.263997 bestmemit: 0.010691 0.984266 0.111141 0.010524
## Iteration: 167 bestvalit: 0.263997 bestmemit: 0.010691 0.984266 0.111141 0.010524
## Iteration: 168 bestvalit: 0.263997 bestmemit: 0.010691 0.984266 0.111141 0.010524
## Iteration: 169 bestvalit: 0.263997 bestmemit: 0.010691 0.984266 0.111141 0.010524
## Iteration: 170 bestvalit: 0.263997 bestmemit: 0.010691 0.984266 0.111141 0.010524
## Iteration: 171 bestvalit: 0.263997 bestmemit: 0.010691 0.984266 0.111141 0.010524
## Iteration: 172 bestvalit: 0.263997 bestmemit: 0.010691 0.984266 0.111141 0.010524
## Iteration: 173 bestvalit: 0.263997 bestmemit: 0.010691 0.984266 0.111141 0.010524
## Iteration: 174 bestvalit: 0.263997 bestmemit: 0.010691 0.984266 0.111141 0.010524
## Iteration: 175 bestvalit: 0.263997 bestmemit: 0.010691 0.984266 0.111141 0.010524
## Iteration: 176 bestvalit: 0.263997 bestmemit: 0.010691 0.984266 0.111141 0.010524
## Iteration: 177 bestvalit: 0.263997 bestmemit: 0.010691 0.984266 0.111141 0.010524
## Iteration: 178 bestvalit: 0.263987 bestmemit: 0.010324 0.992163 0.111957 0.010677
## Iteration: 179 bestvalit: 0.263987 bestmemit: 0.010324 0.992163 0.111957 0.010677
## Iteration: 180 bestvalit: 0.263987 bestmemit: 0.010324 0.992163 0.111957 0.010677
## Iteration: 181 bestvalit: 0.263987 bestmemit: 0.010324 0.992163 0.111957 0.010677
## Iteration: 182 bestvalit: 0.263987 bestmemit: 0.010324 0.992163 0.111957 0.010677
## Iteration: 183 bestvalit: 0.263987 bestmemit: 0.010324 0.992163 0.111957 0.010677
## Iteration: 184 bestvalit: 0.263987 bestmemit: 0.010324 0.992163 0.111957 0.010677
## Iteration: 185 bestvalit: 0.263898 bestmemit: 0.010135 0.999754 0.112749 0.010650
## Iteration: 186 bestvalit: 0.263836 bestmemit: 0.010135 0.999754 0.112749 0.010583
## Iteration: 187 bestvalit: 0.263836 bestmemit: 0.010135 0.999754 0.112749 0.010583
## Iteration: 188 bestvalit: 0.263836 bestmemit: 0.010135 0.999754 0.112749 0.010583
## Iteration: 189 bestvalit: 0.263836 bestmemit: 0.010135 0.999754 0.112749 0.010583
## Iteration: 190 bestvalit: 0.263832 bestmemit: 0.010515 0.995915 0.112350 0.010353
## Iteration: 191 bestvalit: 0.263832 bestmemit: 0.010515 0.995915 0.112350 0.010353
## Iteration: 192 bestvalit: 0.263761 bestmemit: 0.010515 0.995915 0.112350 0.010276
## Iteration: 193 bestvalit: 0.263761 bestmemit: 0.010515 0.995915 0.112350 0.010276
## Iteration: 194 bestvalit: 0.263761 bestmemit: 0.010515 0.995915 0.112350 0.010276
## Iteration: 195 bestvalit: 0.263761 bestmemit: 0.010515 0.995915 0.112350 0.010276
## Iteration: 196 bestvalit: 0.263761 bestmemit: 0.010515 0.995915 0.112350 0.010276
## Iteration: 197 bestvalit: 0.263761 bestmemit: 0.010515 0.995915 0.112350 0.010276
## Iteration: 198 bestvalit: 0.263761 bestmemit: 0.010515 0.995915 0.112350 0.010276
## Iteration: 199 bestvalit: 0.263761 bestmemit: 0.010515 0.995915 0.112350 0.010276
## Iteration: 200 bestvalit: 0.263761 bestmemit: 0.010515 0.995915 0.112350 0.010276
# ===== Buat tabel perbandingan hasil =====
comparison_df <- do.call(rbind, lapply(names(results), function(x) {
data.frame(
Portfolio = x,
Asset = names(results[[x]]),
Weight = round(results[[x]] * 100, 2)
)
}))
# Tampilkan tabel ringkas
cat("\n==== Comparison of Mean-VaR Optimal Portfolio Weights (%) ====\n")
##
## ==== Comparison of Mean-VaR Optimal Portfolio Weights (%) ====
print(comparison_df)
## Portfolio Asset Weight
## JKSE No Risk Limit JKSE 13.06
## Bond No Risk Limit Bond 56.40
## BTC No Risk Limit BTC 19.84
## Gold No Risk Limit Gold 10.70
## JKSE1 ≤ 0.02 JKSE 33.82
## Bond1 ≤ 0.02 Bond 64.59
## BTC1 ≤ 0.02 BTC 0.91
## Gold1 ≤ 0.02 Gold 0.68
## JKSE2 ≤ 0.04 JKSE 1.65
## Bond2 ≤ 0.04 Bond 94.52
## BTC2 ≤ 0.04 BTC 2.87
## Gold2 ≤ 0.04 Gold 0.96
## JKSE3 ≤ 0.06 JKSE 0.97
## Bond3 ≤ 0.06 Bond 91.34
## BTC3 ≤ 0.06 BTC 6.76
## Gold3 ≤ 0.06 Gold 0.93
## JKSE4 ≤ 0.08 JKSE 0.93
## Bond4 ≤ 0.08 Bond 88.21
## BTC4 ≤ 0.08 BTC 9.95
## Gold4 ≤ 0.08 Gold 0.91
# ===== Plot pie chart untuk tiap hasil =====
plots <- list()
for (name in names(results)) {
df <- data.frame(
Asset = names(results[[name]]),
Weight = results[[name]] * 100
)
p <- ggplot(df, aes(x = "", y = Weight, fill = Asset)) +
geom_col(width = 1, color = "white") +
coord_polar(theta = "y") +
geom_text(aes(label = paste0(round(Weight, 1), "%")),
position = position_stack(vjust = 0.5), size = 3) +
theme_void() +
ggtitle(paste("Mean–VaR Portfolio\n", name))
plots[[name]] <- p
}
# ===== Gabungkan semua pie chart dalam satu frame =====
grid.arrange(grobs = plots, ncol = 3)
writexl::write_xlsx(comparison_df,"Comparison Data Frame.xlsx")
# === Exercise Portfolio: Perbandingan Mean-Var vs Empiris ===
# Fungsi objektif: optimasi Mean–Var dengan penalti terhadap target return
# === Bobot Empiris (rata-rata historis) ===
empirical_weights <- rep(1 / ncol(return_matrix), ncol(return_matrix))
# === Buat tabel perbandingan bobot ===
comparison_df <- data.frame(
Asset = colnames(return_matrix),
MeanVar_Weight = round(meanvar_weights, 4),
Empirical_Weight = round(empirical_weights, 4),
Difference = round(meanvar_weights - empirical_weights, 4)
)
print(comparison_df)
## Asset MeanVar_Weight Empirical_Weight Difference
## JKSE JKSE 0.1306 0.25 -0.1194
## Bond Bond 0.5640 0.25 0.3140
## BTC BTC 0.1984 0.25 -0.0516
## Gold Gold 0.1070 0.25 -0.1430
# === Visualisasi Perbandingan Bobot ===
melted_weights <- melt(
comparison_df[, c("Asset", "MeanVar_Weight", "Empirical_Weight")],
id.vars = "Asset"
)
ggplot(melted_weights, aes(x = Asset, y = value, fill = variable)) +
geom_bar(stat = "identity", position = position_dodge(width = 0.9)) +
geom_text(
aes(label = round(value, 4)), # menampilkan nilai bobot
position = position_dodge(width = 0.9), # sejajar dengan batang
vjust = -0.3, # posisi sedikit di atas batang
size = 3.5 # ukuran teks
) +
labs(
title = "Perbandingan Bobot Portofolio: Mean–Var vs Empiris",
x = "Aset",
y = "Bobot",
fill = "Tipe Bobot"
) +
theme_minimal() +
theme(
axis.text.x = element_text(angle = 30, hjust = 1),
plot.title = element_text(hjust = 0.5)
) +
ylim(0, max(melted_weights$value) * 1.15) # beri ruang atas agar label tidak terpotong
