Easy web publishing from R
Write
R Markdown
documents in RStudio.
Share them here on RPubs.
(It’s free, and couldn’t be simpler!)
Get Started
Recently Published
Daily Facebook Political Ad Spending
As of May 19, 2026
Trực quan hoá dữ liệu với gói cơ bản và ggplot2
File được sử dụng trong Khóa bồi dưỡng giảng viên khu vực miền Nam và Nam Trung Bộ năm 2026 Chủ đề “Thống kê hiện đại với phần mềm thống kê R”
Risk Analysis of Stock Portfolios Using Value at Risk (VaR) with the Extreme Value Theory Approach (Case Study: Banking Sub-sector Stocks Period May 1, 2019 - May 31, 2025)
This document contains the R code syntax and computational workflow for an undergraduate thesis focusing on the risk analysis of a stock portfolio within the Indonesian banking sub-sector (BBCA, BBNI, BBRI, BMRI, and BRIS). This analysis specifically estimates market risk—rather than seeking an optimal portfolio—using the Extreme Value Theory (EVT) approach to capture fat-tail phenomena and extreme events in the capital market.
A crucial step in this computation is data transformation, where the log returns are multiplied by -1. This transformation is mandatory to invert the distribution direction so that the loss metric can be accurately modeled using extreme value theory.
Broadly, the workflow in this document encompasses:
Data Acquisition & Preparation: Retrieval of daily stock price data via Yahoo Finance (2019–2025) and calculation of log returns.
Loss Transformation & Weighting: Determination of individual asset weights and the transformation of portfolio returns into losses.
Extreme Value Identification: Data extraction using two EVT methods: Block Maxima and Peak Over Threshold (POT).
GEV & GPD Distributions: Fitting extreme data into the Generalized Extreme Value (GEV) and Generalized Pareto Distribution (GPD) models, followed by Anderson-Darling goodness-of-fit tests.
Value at Risk (VaR) Estimation: Calculation of VaR at a 95% confidence level for both models.
Backtesting: Validation of the VaR models' accuracy using the Likelihood Ratio test (Kupiec Test) to ensure the actual violation rate aligns with the expected target.
This document serves as a computational reference for students and quantitative practitioners looking to implement EVT-based VaR measurements using R packages such as quantmod, extRemes, evmix, and eva.
Fundamentos en R
Fundamentos en R Clase