# Datos
# ------------------------------
Portafolio <- c("TSLA", "MSFT", "V", "AAPL", "WMT", "AMX")
library(quantmod)
## Loading required package: xts
## Loading required package: zoo
##
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
## Loading required package: TTR
## Registered S3 method overwritten by 'quantmod':
## method from
## as.zoo.data.frame zoo
quantmod::getSymbols(Portafolio, from = "2015-01-01", src='yahoo')
## [1] "TSLA" "MSFT" "V" "AAPL" "WMT" "AMX"
Portfolio <- cbind(AAPL$AAPL.Close,V$V.Close,TSLA$TSLA.Close,MSFT$MSFT.Close,WMT$WMT.Close,AMX$AMX.Close)
Portafolio
## [1] "TSLA" "MSFT" "V" "AAPL" "WMT" "AMX"
Portafolio <- cbind(AAPL$AAPL.Close,V$V.Close,TSLA$TSLA.Close,MSFT$MSFT.Close,WMT$WMT.Close,AMX$AMX.Close)
# 2.1 Renombramos columnas
colnames(Portafolio)<- c("Apple","Visa","Tesla","Microsoft","Walmart","AM")
View(Portafolio)
# 2.2 Calculamos rendimientos
Portafolio_R <- Portafolio
for(i in 1:6){
Portafolio_R[,i] <- dailyReturn(Portafolio[,i])
}
Portafolio_R <- Portafolio_R[-1,]
#APPLE
#-----------------------------------
library(plotly)
## Warning: package 'plotly' was built under R version 4.3.3
## Loading required package: ggplot2
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
par(mfrow = c(2,2))
Portafolio_plot <- ggplot(Portafolio, aes(x = Index, y = Apple))+
ggtitle("Cotizaciones")+
geom_line(color = "blue") +
xlab("Fecha") + ylab("cotización")
ggplotly(Portafolio_plot)
Portafolio_Plot_R <- ggplot(Portafolio_R, aes(x = Index, y = Apple))+
ggtitle("Rendimientos")+
geom_line(color = "blue") +
xlab("Fecha") + ylab("Rendimientos")
ggplotly(Portafolio_Plot_R)
# America móvil
#--------------------------
Portafolio_plot <- ggplot(Portafolio, aes(x = Index, y = AM))+
ggtitle("Cotizaciones")+
geom_line(color = "blue") +
xlab("Fecha") + ylab("cotización")
ggplotly(Portafolio_plot)
# Rentabilidad AM
#-----------------------------
par(mfrow = c(2,2))
Portafolio_Plot_R <- ggplot(Portafolio_R, aes(x = Index, y = AM))+
ggtitle("Rendimientos")+
geom_line(color = "blue") +
xlab("Fecha") + ylab("Rendimientos")
ggplotly(Portafolio_Plot_R)
# VISA
#--------------------------
Portafolio_plot <- ggplot(Portafolio, aes(x = Index, y = Visa))+
ggtitle("Cotizaciones")+
geom_line(color = "blue") +
xlab("Fecha") + ylab("cotización")
ggplotly(Portafolio_plot)
# Rentabilidad VISA
#-----------------------------
par(mfrow = c(2,2))
Portafolio_Plot_R <- ggplot(Portafolio_R, aes(x = Index, y = Visa))+
ggtitle("Rendimientos")+
geom_line(color = "blue") +
xlab("Fecha") + ylab("Rendimientos")
ggplotly(Portafolio_Plot_R)
# Microsoft
#--------------------------
Portafolio_plot <- ggplot(Portafolio, aes(x = Index, y = Microsoft))+
ggtitle("Cotizaciones")+
geom_line(color = "blue") +
xlab("Fecha") + ylab("cotización")
ggplotly(Portafolio_plot)
# Rentabilidad Microsoft
#-----------------------------
par(mfrow = c(2,2))
Portafolio_Plot_R <- ggplot(Portafolio_R, aes(x = Index, y = Microsoft))+
ggtitle("Rendimientos")+
geom_line(color = "blue") +
xlab("Fecha") + ylab("Rendimientos")
ggplotly(Portafolio_Plot_R)
# Tesla
#--------------------------
Portafolio_plot <- ggplot(Portafolio, aes(x = Index, y = Tesla))+
ggtitle("Cotizaciones")+
geom_line(color = "blue") +
xlab("Fecha") + ylab("cotización")
ggplotly(Portafolio_plot)
# Rentabilidad Tesla
#-----------------------------
par(mfrow = c(2,2))
Portafolio_Plot_R <- ggplot(Portafolio_R, aes(x = Index, y = Tesla))+
ggtitle("Rendimientos")+
geom_line(color = "blue") +
xlab("Fecha") + ylab("Rendimientos")
ggplotly(Portafolio_Plot_R)
# Walmart
#--------------------------
Portafolio_plot <- ggplot(Portafolio, aes(x = Index, y = Walmart))+
ggtitle("Cotizaciones")+
geom_line(color = "blue") +
xlab("Fecha") + ylab("cotización")
ggplotly(Portafolio_plot)
# Rentabilidad Walmart
#-----------------------------
par(mfrow = c(2,2))
Portafolio_Plot_R <- ggplot(Portafolio_R, aes(x = Index, y = Walmart))+
ggtitle("Rendimientos")+
geom_line(color = "blue") +
xlab("Fecha") + ylab("Rendimientos")
ggplotly(Portafolio_Plot_R)
Modelos ARCH y GARCH
#Apple
#-------------------
par(mfrow= c(2,1))
acf((Portafolio_R$Apple))
pacf((Portafolio_R$Apple))
#Apple
#-------------------
par(mfrow= c(2,1))
acf((Portafolio_R$Apple)^2)
pacf((Portafolio_R$Apple)^2)
Tenemos decrecimientos en el FAS y PACF, indicando efectos ARCH.
library(tseries)
library(rugarch)
## Warning: package 'rugarch' was built under R version 4.3.3
## Loading required package: parallel
##
## Attaching package: 'rugarch'
## The following object is masked from 'package:stats':
##
## sigma
library(fGarch)
## NOTE: Packages 'fBasics', 'timeDate', and 'timeSeries' are no longer
## attached to the search() path when 'fGarch' is attached.
##
## If needed attach them yourself in your R script by e.g.,
## require("timeSeries")
##
## Attaching package: 'fGarch'
## The following object is masked from 'package:TTR':
##
## volatility
ARCH1_AAPL = ugarchspec(variance.model = list(garchOrder=c(1,1)),
mean.model = list(armaOrder=c(2,2),include.mean=F,archm=F))
arch1_fit_AAPL = ugarchfit(spec = ARCH1_AAPL, data = Portafolio_R$Apple)
arch1_fit_AAPL
##
## *---------------------------------*
## * GARCH Model Fit *
## *---------------------------------*
##
## Conditional Variance Dynamics
## -----------------------------------
## GARCH Model : sGARCH(1,1)
## Mean Model : ARFIMA(2,0,2)
## Distribution : norm
##
## Optimal Parameters
## ------------------------------------
## Estimate Std. Error t value Pr(>|t|)
## ar1 0.385443 0.004361 88.392 0
## ar2 -0.984816 0.003517 -280.032 0
## ma1 -0.377124 0.000737 -512.048 0
## ma2 0.975859 0.000242 4029.334 0
## omega 0.000014 0.000001 10.989 0
## alpha1 0.099589 0.006657 14.960 0
## beta1 0.855494 0.009929 86.159 0
##
## Robust Standard Errors:
## Estimate Std. Error t value Pr(>|t|)
## ar1 0.385443 0.005044 76.4209 0e+00
## ar2 -0.984816 0.003214 -306.3906 0e+00
## ma1 -0.377124 0.002160 -174.5544 0e+00
## ma2 0.975859 0.000206 4747.7427 0e+00
## omega 0.000014 0.000003 4.7603 2e-06
## alpha1 0.099589 0.012564 7.9263 0e+00
## beta1 0.855494 0.018685 45.7860 0e+00
##
## LogLikelihood : 6223.171
##
## Information Criteria
## ------------------------------------
##
## Akaike -5.3703
## Bayes -5.3530
## Shibata -5.3704
## Hannan-Quinn -5.3640
##
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.02222 0.88151
## Lag[2*(p+q)+(p+q)-1][11] 6.87479 0.07799
## Lag[4*(p+q)+(p+q)-1][19] 12.93437 0.11403
## d.o.f=4
## H0 : No serial correlation
##
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.1322 0.7162
## Lag[2*(p+q)+(p+q)-1][5] 0.6376 0.9345
## Lag[4*(p+q)+(p+q)-1][9] 1.3605 0.9662
## d.o.f=2
##
## Weighted ARCH LM Tests
## ------------------------------------
## Statistic Shape Scale P-Value
## ARCH Lag[3] 0.3488 0.500 2.000 0.5548
## ARCH Lag[5] 0.6984 1.440 1.667 0.8239
## ARCH Lag[7] 1.1925 2.315 1.543 0.8804
##
## Nyblom stability test
## ------------------------------------
## Joint Statistic: 23.0202
## Individual Statistics:
## ar1 0.14585
## ar2 0.07124
## ma1 0.13035
## ma2 0.07767
## omega 2.58009
## alpha1 0.27056
## beta1 0.23483
##
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic: 1.69 1.9 2.35
## Individual Statistic: 0.35 0.47 0.75
##
## Sign Bias Test
## ------------------------------------
## t-value prob sig
## Sign Bias 1.4585 0.14485
## Negative Sign Bias 0.5100 0.61010
## Positive Sign Bias 0.3233 0.74649
## Joint Effect 7.1794 0.06639 *
##
##
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
## group statistic p-value(g-1)
## 1 20 103.2 1.423e-13
## 2 30 123.9 1.062e-13
## 3 40 128.7 1.631e-11
## 4 50 156.4 3.827e-13
##
##
## Elapsed time : 0.375134
par(mfrow = c(3,4))
plot(arch1_fit_AAPL, which = 1)
plot(arch1_fit_AAPL, which = 2)
##
## please wait...calculating quantiles...
plot(arch1_fit_AAPL, which = 3)
plot(arch1_fit_AAPL, which = 4)
plot(arch1_fit_AAPL, which = 5)
plot(arch1_fit_AAPL, which = 6)
plot(arch1_fit_AAPL, which = 7)
plot(arch1_fit_AAPL, which = 8)
plot(arch1_fit_AAPL, which = 9)
plot(arch1_fit_AAPL, which = 10)
plot(arch1_fit_AAPL, which = 11)
plot(arch1_fit_AAPL, which = 12)
# Backtesting
par(mfrow=c(1,2))
roll=ugarchroll(ARCH1_AAPL, Portafolio_R$Apple, n.start = 200, refit.every = 20,
refit.window = "moving", solver = "hybrid", calculate.VaR = TRUE,
VaR.alpha = c(.01,.05), keep.coef = T)
## Warning in arima(data, order = c(modelinc[2], 0, modelinc[3]), include.mean =
## modelinc[1], : possible convergence problem: optim gave code = 1
## Warning in arima(data, order = c(modelinc[2], 0, modelinc[3]), include.mean =
## modelinc[1], : possible convergence problem: optim gave code = 1
## Warning in arima(data, order = c(modelinc[2], 0, modelinc[3]), include.mean =
## modelinc[1], : possible convergence problem: optim gave code = 1
## Warning in arima(data, order = c(modelinc[2], 0, modelinc[3]), include.mean =
## modelinc[1], : possible convergence problem: optim gave code = 1
## Warning in arima(data, order = c(modelinc[2], 0, modelinc[3]), include.mean =
## modelinc[1], : possible convergence problem: optim gave code = 1
## Warning in arima(data, order = c(modelinc[2], 0, modelinc[3]), include.mean =
## modelinc[1], : possible convergence problem: optim gave code = 1
par(mfrow=c(1,3))
plot(roll, which = 2)
plot(roll, which = 3)
plot(roll, which = 4)
report(roll, type = "VaR", VaR.alpha = 0.01, conf.level =0.99)
## VaR Backtest Report
## ===========================================
## Model: sGARCH-norm
## Backtest Length: 2115
## Data:
##
## ==========================================
## alpha: 1%
## Expected Exceed: 21.2
## Actual VaR Exceed: 44
## Actual %: 2.1%
##
## Unconditional Coverage (Kupiec)
## Null-Hypothesis: Correct Exceedances
## LR.uc Statistic: 19.015
## LR.uc Critical: 6.635
## LR.uc p-value: 0
## Reject Null: YES
##
## Conditional Coverage (Christoffersen)
## Null-Hypothesis: Correct Exceedances and
## Independence of Failures
## LR.cc Statistic: 19.022
## LR.cc Critical: 9.21
## LR.cc p-value: 0
## Reject Null: YES
# Forecast
# -----------------------------------------
set.seed(123)
bootp_AAPL = ugarchboot(arch1_fit_AAPL, method = "Partial", n.ahead = 200, n.bootpred = 200)
par(mfrow=c(1,2))
plot(bootp_AAPL, which = 2)
plot(bootp_AAPL, which = 3)
VISA
par(mfrow = c(2,1))
acf((Portafolio_R$Visa))
pacf((Portafolio_R$Visa))
par(mfrow = c(2,1))
acf((Portafolio_R$Visa)^2)
pacf((Portafolio_R$Visa)^2)
ARCH1_V = ugarchspec(variance.model = list(garchOrder=c(1,1)),
mean.model = list(armaOrder=c(2,1),include.mean=F,archm=F))
arch1_fit_V = ugarchfit(spec = ARCH1_V, data = Portafolio_R$Visa)
arch1_fit_V
##
## *---------------------------------*
## * GARCH Model Fit *
## *---------------------------------*
##
## Conditional Variance Dynamics
## -----------------------------------
## GARCH Model : sGARCH(1,1)
## Mean Model : ARFIMA(2,0,1)
## Distribution : norm
##
## Optimal Parameters
## ------------------------------------
## Estimate Std. Error t value Pr(>|t|)
## ar1 0.614493 0.157662 3.89753 0.000097
## ar2 0.007653 0.029116 0.26282 0.792685
## ma1 -0.682132 0.153566 -4.44194 0.000009
## omega 0.000005 0.000017 0.29983 0.764306
## alpha1 0.102111 0.012362 8.26000 0.000000
## beta1 0.878663 0.065050 13.50745 0.000000
##
## Robust Standard Errors:
## Estimate Std. Error t value Pr(>|t|)
## ar1 0.614493 1.448618 0.424192 0.67143
## ar2 0.007653 0.031811 0.240566 0.80989
## ma1 -0.682132 1.619973 -0.421076 0.67370
## omega 0.000005 0.000439 0.011583 0.99076
## alpha1 0.102111 0.444416 0.229765 0.81827
## beta1 0.878663 1.710666 0.513638 0.60750
##
## LogLikelihood : 6693.335
##
## Information Criteria
## ------------------------------------
##
## Akaike -5.7774
## Bayes -5.7625
## Shibata -5.7774
## Hannan-Quinn -5.7720
##
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.4561 0.4994
## Lag[2*(p+q)+(p+q)-1][8] 3.4654 0.9635
## Lag[4*(p+q)+(p+q)-1][14] 5.5288 0.8283
## d.o.f=3
## H0 : No serial correlation
##
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.0113 0.9154
## Lag[2*(p+q)+(p+q)-1][5] 1.0080 0.8579
## Lag[4*(p+q)+(p+q)-1][9] 2.6803 0.8104
## d.o.f=2
##
## Weighted ARCH LM Tests
## ------------------------------------
## Statistic Shape Scale P-Value
## ARCH Lag[3] 0.05429 0.500 2.000 0.8158
## ARCH Lag[5] 1.58133 1.440 1.667 0.5712
## ARCH Lag[7] 2.81275 2.315 1.543 0.5496
##
## Nyblom stability test
## ------------------------------------
## Joint Statistic: 1.7924
## Individual Statistics:
## ar1 0.29098
## ar2 0.09942
## ma1 0.25902
## omega 0.18222
## alpha1 0.12928
## beta1 0.16725
##
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic: 1.49 1.68 2.12
## Individual Statistic: 0.35 0.47 0.75
##
## Sign Bias Test
## ------------------------------------
## t-value prob sig
## Sign Bias 0.03914 0.96878
## Negative Sign Bias 1.88054 0.06016 *
## Positive Sign Bias 1.48528 0.13761
## Joint Effect 10.86947 0.01245 **
##
##
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
## group statistic p-value(g-1)
## 1 20 108.8 1.335e-14
## 2 30 135.3 1.139e-15
## 3 40 154.0 1.346e-15
## 4 50 155.0 6.318e-13
##
##
## Elapsed time : 0.25791
par(mfrow = c(3,4))
plot(arch1_fit_V, which = 1)
plot(arch1_fit_V, which = 2)
##
## please wait...calculating quantiles...
plot(arch1_fit_V, which = 3)
plot(arch1_fit_V, which = 4)
plot(arch1_fit_V, which = 5)
plot(arch1_fit_V, which = 6)
plot(arch1_fit_V, which = 7)
plot(arch1_fit_V, which = 8)
plot(arch1_fit_V, which = 9)
plot(arch1_fit_V, which = 10)
plot(arch1_fit_V, which = 11)
plot(arch1_fit_V, which = 12)
# Backtesting
roll=ugarchroll(ARCH1_V, Portafolio_R$Visa, n.start = 200, refit.every = 20, refit.window = "moving", solver = "hybrid", calculate.VaR = TRUE,
VaR.alpha = c(.01,.05), keep.coef = T)
par(mfrow=c(1,3))
plot(roll, which = 2)
plot(roll, which = 3)
plot(roll, which = 4)
report(roll, type = "vaR", VaR.alpha = 0.01, conf.level = 0.99)
#Forecast
set.seed(123)
bootp_V = ugarchboot(arch1_fit_V, method = "Partial", n.ahead = 200, n.bootpred = 200)
par(mfrow=c(1,2))
plot(bootp_V, which=2)
plot(bootp_V, which=3)
TESLA
#Correlogramas
#-----------
par(mfrow= c(2,1))
acf(Portafolio_R$Tesla)
pacf(Portafolio_R$Tesla)
#Correlogramas
#-----------
par(mfrow= c(2,1))
acf((Portafolio_R$Tesla)^2)
pacf((Portafolio_R$Tesla)^2)
Vemos que hay decaimiento hasta 5.
#Modelo para Tesla
#---------------------
ARCH1_TSLA = ugarchspec(variance.model = list(garchOrder=c(2,1)),
mean.model = list(armaOrder=c(1,1),include.mean=F,archm=F))
arch1_fit_TSLA = ugarchfit(spec = ARCH1_TSLA, data = Portafolio_R$Tesla)
arch1_fit_TSLA
##
## *---------------------------------*
## * GARCH Model Fit *
## *---------------------------------*
##
## Conditional Variance Dynamics
## -----------------------------------
## GARCH Model : sGARCH(2,1)
## Mean Model : ARFIMA(1,0,1)
## Distribution : norm
##
## Optimal Parameters
## ------------------------------------
## Estimate Std. Error t value Pr(>|t|)
## ar1 0.870654 0.115864 7.514430 0.000000
## ma1 -0.855892 0.121506 -7.044030 0.000000
## omega 0.000012 0.000002 6.277438 0.000000
## alpha1 0.038686 0.014219 2.720796 0.006512
## alpha2 0.000000 0.014891 0.000001 0.999999
## beta1 0.951581 0.004318 220.382168 0.000000
##
## Robust Standard Errors:
## Estimate Std. Error t value Pr(>|t|)
## ar1 0.870654 0.065889 13.213916 0.000000
## ma1 -0.855892 0.066347 -12.900263 0.000000
## omega 0.000012 0.000005 2.720340 0.006521
## alpha1 0.038686 0.019758 1.957968 0.050234
## alpha2 0.000000 0.021162 0.000001 0.999999
## beta1 0.951581 0.006366 149.485435 0.000000
##
## LogLikelihood : 4621.824
##
## Information Criteria
## ------------------------------------
##
## Akaike -3.9878
## Bayes -3.9729
## Shibata -3.9878
## Hannan-Quinn -3.9823
##
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.008337 0.9272
## Lag[2*(p+q)+(p+q)-1][5] 0.731389 1.0000
## Lag[4*(p+q)+(p+q)-1][9] 3.289968 0.8419
## d.o.f=2
## H0 : No serial correlation
##
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.852 0.3560
## Lag[2*(p+q)+(p+q)-1][8] 3.290 0.6323
## Lag[4*(p+q)+(p+q)-1][14] 6.182 0.6143
## d.o.f=3
##
## Weighted ARCH LM Tests
## ------------------------------------
## Statistic Shape Scale P-Value
## ARCH Lag[4] 0.02029 0.500 2.000 0.8867
## ARCH Lag[6] 0.52534 1.461 1.711 0.8849
## ARCH Lag[8] 1.15146 2.368 1.583 0.9009
##
## Nyblom stability test
## ------------------------------------
## Joint Statistic: 11.3077
## Individual Statistics:
## ar1 0.09277
## ma1 0.08902
## omega 0.73187
## alpha1 0.32196
## alpha2 0.33837
## beta1 0.34109
##
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic: 1.49 1.68 2.12
## Individual Statistic: 0.35 0.47 0.75
##
## Sign Bias Test
## ------------------------------------
## t-value prob sig
## Sign Bias 0.6463 0.5181
## Negative Sign Bias 1.0603 0.2891
## Positive Sign Bias 0.6968 0.4860
## Joint Effect 1.7047 0.6359
##
##
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
## group statistic p-value(g-1)
## 1 20 138.1 4.168e-20
## 2 30 137.6 4.544e-16
## 3 40 165.5 1.606e-17
## 4 50 183.6 1.960e-17
##
##
## Elapsed time : 0.2016151
par(mfrow = c(3,4))
plot(arch1_fit_TSLA, which = 1)
plot(arch1_fit_TSLA, which = 2)
##
## please wait...calculating quantiles...
plot(arch1_fit_TSLA, which = 3)
plot(arch1_fit_TSLA, which = 4)
plot(arch1_fit_TSLA, which = 5)
plot(arch1_fit_TSLA, which = 6)
plot(arch1_fit_TSLA, which = 7)
plot(arch1_fit_TSLA, which = 8)
plot(arch1_fit_TSLA, which = 9)
plot(arch1_fit_TSLA, which = 10)
plot(arch1_fit_TSLA, which = 11)
plot(arch1_fit_TSLA, which = 12)
# Backtesting
roll=ugarchroll(ARCH1_TSLA, Portafolio_R$Tesla, n.start = 200, refit.every = 20, refit.window = "moving", solver = "hybrid", calculate.VaR = TRUE,
VaR.alpha = c(.01,.05), keep.coef = T)
par(mfrow=c(1,3))
plot(roll, which = 2)
plot(roll, which = 3)
plot(roll, which = 4)
1) Varianza Condicional
La Predicción
La pérdida esperada ( valor en riesgo o var). Los puntos rojos son las pérdidas extremas o anómalas.
report(roll, type = "VaR", VaR.alpha =0.01, conf.level = 0.99)
## VaR Backtest Report
## ===========================================
## Model: sGARCH-norm
## Backtest Length: 2115
## Data:
##
## ==========================================
## alpha: 1%
## Expected Exceed: 21.2
## Actual VaR Exceed: 48
## Actual %: 2.3%
##
## Unconditional Coverage (Kupiec)
## Null-Hypothesis: Correct Exceedances
## LR.uc Statistic: 25.324
## LR.uc Critical: 6.635
## LR.uc p-value: 0
## Reject Null: YES
##
## Conditional Coverage (Christoffersen)
## Null-Hypothesis: Correct Exceedances and
## Independence of Failures
## LR.cc Statistic: 27.825
## LR.cc Critical: 9.21
## LR.cc p-value: 0
## Reject Null: YES
La mayor pérdida esperada ocurre en el 2,3% de las ocasiones.
Los excesos de pérdida son significativos, es decir, por encima de lo normal. Pérdidas muy significativas.
Además, vemos que son pérdidas independientes, conforme al informe, al ser p valor 0.
#Forecast
set.seed(123)
bootp_TSLA = ugarchboot(arch1_fit_TSLA, method = "Partial", n.ahead = 200, n.bootpred = 200)
par(mfrow=c(1,2))
plot(bootp_TSLA, which=2)
plot(bootp_TSLA, which=3)
Vemos que la varianza es creciente a medida que aumentan los horizontes
de predicción.
MICROSOFT
#Correlogramas
#-----------------------
par(mfrow = c(2,1))
acf((Portafolio_R$Microsoft))
pacf((Portafolio_R$Microsoft))
Puede ser un ARMA 1 o 2.
#Correlogramas
#-----------------------
par(mfrow = c(2,1))
acf((Portafolio_R$Microsoft)^2)
pacf((Portafolio_R$Microsoft)^2)
Vemos decaimiento en ambos gráficos. Esto quiere decir que tenemos
efectos Garch.
ARCH1_MSFT = ugarchspec(variance.model = list(garchOrder=c(1,1)),
mean.model = list(armaOrder=c(1,2),include.mean=F,archm=F))
arch1_fit_MSFT = ugarchfit(spec = ARCH1_MSFT, data = Portafolio_R$Microsoft)
arch1_fit_MSFT
##
## *---------------------------------*
## * GARCH Model Fit *
## *---------------------------------*
##
## Conditional Variance Dynamics
## -----------------------------------
## GARCH Model : sGARCH(1,1)
## Mean Model : ARFIMA(1,0,2)
## Distribution : norm
##
## Optimal Parameters
## ------------------------------------
## Estimate Std. Error t value Pr(>|t|)
## ar1 0.253931 0.622265 0.40808 0.683218
## ma1 -0.329593 0.622161 -0.52975 0.596282
## ma2 -0.010978 0.058275 -0.18838 0.850582
## omega 0.000021 0.000005 4.38345 0.000012
## alpha1 0.152705 0.028002 5.45339 0.000000
## beta1 0.782443 0.037049 21.11893 0.000000
##
## Robust Standard Errors:
## Estimate Std. Error t value Pr(>|t|)
## ar1 0.253931 0.614602 0.41316 0.679487
## ma1 -0.329593 0.613007 -0.53766 0.590808
## ma2 -0.010978 0.058681 -0.18707 0.851602
## omega 0.000021 0.000011 1.81318 0.069805
## alpha1 0.152705 0.059207 2.57916 0.009904
## beta1 0.782443 0.083402 9.38156 0.000000
##
## LogLikelihood : 6335.658
##
## Information Criteria
## ------------------------------------
##
## Akaike -5.4684
## Bayes -5.4535
## Shibata -5.4684
## Hannan-Quinn -5.4630
##
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.007872 0.9293
## Lag[2*(p+q)+(p+q)-1][8] 2.449740 1.0000
## Lag[4*(p+q)+(p+q)-1][14] 6.647108 0.6298
## d.o.f=3
## H0 : No serial correlation
##
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.02314 0.8791
## Lag[2*(p+q)+(p+q)-1][5] 0.65945 0.9305
## Lag[4*(p+q)+(p+q)-1][9] 1.90166 0.9164
## d.o.f=2
##
## Weighted ARCH LM Tests
## ------------------------------------
## Statistic Shape Scale P-Value
## ARCH Lag[3] 0.3531 0.500 2.000 0.5524
## ARCH Lag[5] 0.6001 1.440 1.667 0.8537
## ARCH Lag[7] 1.3991 2.315 1.543 0.8414
##
## Nyblom stability test
## ------------------------------------
## Joint Statistic: 1.5972
## Individual Statistics:
## ar1 0.1765
## ma1 0.1654
## ma2 0.1037
## omega 0.1994
## alpha1 0.1246
## beta1 0.2125
##
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic: 1.49 1.68 2.12
## Individual Statistic: 0.35 0.47 0.75
##
## Sign Bias Test
## ------------------------------------
## t-value prob sig
## Sign Bias 0.2098 0.8338
## Negative Sign Bias 1.5890 0.1122
## Positive Sign Bias 0.7800 0.4355
## Joint Effect 4.8202 0.1854
##
##
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
## group statistic p-value(g-1)
## 1 20 148.2 4.805e-22
## 2 30 155.9 2.510e-19
## 3 40 169.5 3.348e-18
## 4 50 183.2 2.266e-17
##
##
## Elapsed time : 0.224896
par(mfrow=c(3,4))
plot(arch1_fit_MSFT, which = 1)
plot(arch1_fit_MSFT, which = 2)
##
## please wait...calculating quantiles...
plot(arch1_fit_MSFT, which = 3)
plot(arch1_fit_MSFT, which = 4)
plot(arch1_fit_MSFT, which = 5)
plot(arch1_fit_MSFT, which = 6)
plot(arch1_fit_MSFT, which = 7)
plot(arch1_fit_MSFT, which = 8)
plot(arch1_fit_MSFT, which = 9)
plot(arch1_fit_MSFT, which = 10)
plot(arch1_fit_MSFT, which = 11)
plot(arch1_fit_MSFT, which = 12)
ARCH1_TSLA = ugarchspec(variance.model = list(garchOrder=c(1,1)),
mean.model = list(armaOrder=c(1,2),include.mean=F,archm=F))
arch1_fit_TSLA = ugarchfit(spec = ARCH1_TSLA, data = Portafolio_R$Tesla)
arch1_fit_TSLA
##
## *---------------------------------*
## * GARCH Model Fit *
## *---------------------------------*
##
## Conditional Variance Dynamics
## -----------------------------------
## GARCH Model : sGARCH(1,1)
## Mean Model : ARFIMA(1,0,2)
## Distribution : norm
##
## Optimal Parameters
## ------------------------------------
## Estimate Std. Error t value Pr(>|t|)
## ar1 0.858989 0.125929 6.82123 0.00000
## ma1 -0.849932 0.127795 -6.65076 0.00000
## ma2 0.007251 0.022492 0.32237 0.74717
## omega 0.000012 0.000002 6.27843 0.00000
## alpha1 0.038740 0.002295 16.88265 0.00000
## beta1 0.951477 0.004131 230.35172 0.00000
##
## Robust Standard Errors:
## Estimate Std. Error t value Pr(>|t|)
## ar1 0.858989 0.073623 11.66743 0.000000
## ma1 -0.849932 0.072464 -11.72908 0.000000
## ma2 0.007251 0.019039 0.38084 0.703322
## omega 0.000012 0.000005 2.72807 0.006371
## alpha1 0.038740 0.005217 7.42505 0.000000
## beta1 0.951477 0.006153 154.63268 0.000000
##
## LogLikelihood : 4621.875
##
## Information Criteria
## ------------------------------------
##
## Akaike -3.9878
## Bayes -3.9729
## Shibata -3.9878
## Hannan-Quinn -3.9824
##
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.1187 0.7305
## Lag[2*(p+q)+(p+q)-1][8] 2.6288 0.9998
## Lag[4*(p+q)+(p+q)-1][14] 6.1775 0.7193
## d.o.f=3
## H0 : No serial correlation
##
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.8901 0.3454
## Lag[2*(p+q)+(p+q)-1][5] 2.6055 0.4838
## Lag[4*(p+q)+(p+q)-1][9] 3.5088 0.6729
## d.o.f=2
##
## Weighted ARCH LM Tests
## ------------------------------------
## Statistic Shape Scale P-Value
## ARCH Lag[3] 0.2514 0.500 2.000 0.6161
## ARCH Lag[5] 0.2696 1.440 1.667 0.9482
## ARCH Lag[7] 1.0667 2.315 1.543 0.9025
##
## Nyblom stability test
## ------------------------------------
## Joint Statistic: 11.6694
## Individual Statistics:
## ar1 0.08828
## ma1 0.08301
## ma2 0.18330
## omega 0.74106
## alpha1 0.32436
## beta1 0.34433
##
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic: 1.49 1.68 2.12
## Individual Statistic: 0.35 0.47 0.75
##
## Sign Bias Test
## ------------------------------------
## t-value prob sig
## Sign Bias 0.5631 0.5734
## Negative Sign Bias 1.0202 0.3077
## Positive Sign Bias 0.6307 0.5283
## Joint Effect 1.5624 0.6679
##
##
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
## group statistic p-value(g-1)
## 1 20 137.7 5.001e-20
## 2 30 142.6 6.048e-17
## 3 40 161.6 7.228e-17
## 4 50 180.2 6.878e-17
##
##
## Elapsed time : 0.2056851
par(mfrow = c(3,4))
plot(arch1_fit_TSLA, which = 1)
plot(arch1_fit_TSLA, which = 2)
##
## please wait...calculating quantiles...
plot(arch1_fit_TSLA, which = 3)
plot(arch1_fit_TSLA, which = 4)
plot(arch1_fit_TSLA, which = 5)
plot(arch1_fit_TSLA, which = 6)
plot(arch1_fit_TSLA, which = 7)
plot(arch1_fit_TSLA, which = 8)
plot(arch1_fit_TSLA, which = 9)
plot(arch1_fit_TSLA, which = 10)
plot(arch1_fit_TSLA, which = 11)
plot(arch1_fit_TSLA, which = 12)
par(mfrow = c(3,4))
plot(arch1_fit_V, which = 1)
plot(arch1_fit_V, which = 2)
##
## please wait...calculating quantiles...
plot(arch1_fit_V, which = 3)
plot(arch1_fit_V, which = 4)
plot(arch1_fit_V, which = 5)
plot(arch1_fit_V, which = 6)
plot(arch1_fit_V, which = 7)
plot(arch1_fit_V, which = 8)
plot(arch1_fit_V, which = 9)
plot(arch1_fit_V, which = 10)
plot(arch1_fit_V, which = 11)
plot(arch1_fit_V, which = 12)
par(mfrow = c(3,4))
plot(arch1_fit_AAPL, which = 1)
plot(arch1_fit_AAPL, which = 2)
##
## please wait...calculating quantiles...
plot(arch1_fit_AAPL, which = 3)
plot(arch1_fit_AAPL, which = 4)
plot(arch1_fit_AAPL, which = 5)
plot(arch1_fit_AAPL, which = 6)
plot(arch1_fit_AAPL, which = 7)
plot(arch1_fit_AAPL, which = 8)
plot(arch1_fit_AAPL, which = 9)
plot(arch1_fit_AAPL, which = 10)
plot(arch1_fit_AAPL, which = 11)
plot(arch1_fit_AAPL, which = 12)
WALMART
par(mfrow = c(2,1))
acf((Portafolio_R$Walmart))
pacf((Portafolio_R$Walmart))
Vemos que hay ruido blanco.
par(mfrow = c(2,1))
acf((Portafolio_R$Walmart)^2)
pacf((Portafolio_R$Walmart)^2)
Hay decaimiento, por lo que hay estructura Garch.
ARCH1_WMT = ugarchspec(variance.model = list(garchOrder=c(1,1)),
mean.model = list(armaOrder=c(1,1),include.mean=F,archm=F))
arch1_fit_WMT = ugarchfit(spec = ARCH1_WMT, data = Portafolio_R$Walmart)
arch1_fit_WMT
##
## *---------------------------------*
## * GARCH Model Fit *
## *---------------------------------*
##
## Conditional Variance Dynamics
## -----------------------------------
## GARCH Model : sGARCH(1,1)
## Mean Model : ARFIMA(1,0,1)
## Distribution : norm
##
## Optimal Parameters
## ------------------------------------
## Estimate Std. Error t value Pr(>|t|)
## ar1 0.527890 0.157558 3.3505 0.000807
## ma1 -0.592473 0.147885 -4.0063 0.000062
## omega 0.000033 0.000008 4.3370 0.000014
## alpha1 0.148876 0.028052 5.3071 0.000000
## beta1 0.670324 0.062135 10.7882 0.000000
##
## Robust Standard Errors:
## Estimate Std. Error t value Pr(>|t|)
## ar1 0.527890 0.159065 3.3187 0.000904
## ma1 -0.592473 0.145139 -4.0821 0.000045
## omega 0.000033 0.000026 1.3062 0.191482
## alpha1 0.148876 0.085808 1.7350 0.082742
## beta1 0.670324 0.203728 3.2903 0.001001
##
## LogLikelihood : 6847.689
##
## Information Criteria
## ------------------------------------
##
## Akaike -5.9116
## Bayes -5.8992
## Shibata -5.9116
## Hannan-Quinn -5.9071
##
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.2813 0.5959
## Lag[2*(p+q)+(p+q)-1][5] 0.6334 1.0000
## Lag[4*(p+q)+(p+q)-1][9] 1.9535 0.9864
## d.o.f=2
## H0 : No serial correlation
##
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.0004941 0.9823
## Lag[2*(p+q)+(p+q)-1][5] 0.5175096 0.9549
## Lag[4*(p+q)+(p+q)-1][9] 0.8878461 0.9904
## d.o.f=2
##
## Weighted ARCH LM Tests
## ------------------------------------
## Statistic Shape Scale P-Value
## ARCH Lag[3] 0.1102 0.500 2.000 0.7399
## ARCH Lag[5] 0.4495 1.440 1.667 0.8984
## ARCH Lag[7] 0.6211 2.315 1.543 0.9661
##
## Nyblom stability test
## ------------------------------------
## Joint Statistic: 0.8903
## Individual Statistics:
## ar1 0.15217
## ma1 0.15557
## omega 0.04900
## alpha1 0.05953
## beta1 0.04674
##
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic: 1.28 1.47 1.88
## Individual Statistic: 0.35 0.47 0.75
##
## Sign Bias Test
## ------------------------------------
## t-value prob sig
## Sign Bias 0.5905 0.5549
## Negative Sign Bias 0.7975 0.4252
## Positive Sign Bias 0.1975 0.8435
## Joint Effect 2.6063 0.4564
##
##
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
## group statistic p-value(g-1)
## 1 20 204.9 3.651e-33
## 2 30 221.5 1.544e-31
## 3 40 229.5 7.991e-29
## 4 50 255.6 9.531e-30
##
##
## Elapsed time : 0.1887529
par(mfrow = c(3,4))
plot(arch1_fit_WMT, which = 1)
plot(arch1_fit_WMT, which = 2)
##
## please wait...calculating quantiles...
plot(arch1_fit_WMT, which = 3)
plot(arch1_fit_WMT, which = 4)
plot(arch1_fit_WMT, which = 5)
plot(arch1_fit_WMT, which = 6)
plot(arch1_fit_WMT, which = 7)
plot(arch1_fit_WMT, which = 8)
plot(arch1_fit_WMT, which = 9)
plot(arch1_fit_WMT, which = 10)
plot(arch1_fit_WMT, which = 11)
plot(arch1_fit_WMT, which = 12)
# Backtesting
par(mfrow=c(1,2))
roll=ugarchroll(ARCH1_WMT, Portafolio_R$Walmart, n.start = 200, refit.every = 20, refit.window = "moving", solver = "hybrid", calculate.VaR = TRUE,VaR.alpha = c(.01,.05), keep.coef = T)
## Warning in arima(data, order = c(modelinc[2], 0, modelinc[3]), include.mean =
## modelinc[1], : possible convergence problem: optim gave code = 1
## Warning in arima(data, order = c(modelinc[2], 0, modelinc[3]), include.mean =
## modelinc[1], : possible convergence problem: optim gave code = 1
## Warning in arima(data, order = c(modelinc[2], 0, modelinc[3]), include.mean =
## modelinc[1], : possible convergence problem: optim gave code = 1
par(mfrow=c(1,3))
plot(roll, which = 2)
plot(roll, which = 3)
plot(roll, which = 4)
report(roll, type = "VaR", VaR.alpha = 0.01, conf.level = 0.99)
## VaR Backtest Report
## ===========================================
## Model: sGARCH-norm
## Backtest Length: 2115
## Data:
##
## ==========================================
## alpha: 1%
## Expected Exceed: 21.2
## Actual VaR Exceed: 29
## Actual %: 1.4%
##
## Unconditional Coverage (Kupiec)
## Null-Hypothesis: Correct Exceedances
## LR.uc Statistic: 2.638
## LR.uc Critical: 6.635
## LR.uc p-value: 0.104
## Reject Null: NO
##
## Conditional Coverage (Christoffersen)
## Null-Hypothesis: Correct Exceedances and
## Independence of Failures
## LR.cc Statistic: 3.444
## LR.cc Critical: 9.21
## LR.cc p-value: 0.179
## Reject Null: NO
#Forecast
set.seed(123)
bootp_WMT = ugarchboot(arch1_fit_WMT, method = "Partial", n.ahead = 200, n.bootpred = 200)
par(mfrow=c(1,2))
plot(bootp_WMT, which=2)
plot(bootp_WMT, which=3)
Al principio crece un poco la varianza, pero luego permanece
constante.
AMERICA MOVIL
# Correlogramas
# -------------------
par(mfrow=c(2,1))
acf((Portafolio_R$AM))
pacf((Portafolio_R$AM))
# Correlogramas
# -------------------
par(mfrow=c(2,1))
acf((Portafolio_R$AM)^2)
pacf((Portafolio_R$AM)^2)
ARCH1_AMX = ugarchspec(variance.model = list(garchOrder=c(1,1)),
mean.model = list(armaOrder=c(1,1),include.mean=F,archm=F))
arch1_fit_AMX = ugarchfit(spec = ARCH1_AMX, data = Portafolio_R$AM)
arch1_fit_AMX
##
## *---------------------------------*
## * GARCH Model Fit *
## *---------------------------------*
##
## Conditional Variance Dynamics
## -----------------------------------
## GARCH Model : sGARCH(1,1)
## Mean Model : ARFIMA(1,0,1)
## Distribution : norm
##
## Optimal Parameters
## ------------------------------------
## Estimate Std. Error t value Pr(>|t|)
## ar1 -0.144765 0.449732 -0.32189 0.74753
## ma1 0.183082 0.446847 0.40972 0.68201
## omega 0.000010 0.000000 20.36530 0.00000
## alpha1 0.050474 0.003641 13.86307 0.00000
## beta1 0.921226 0.005784 159.25898 0.00000
##
## Robust Standard Errors:
## Estimate Std. Error t value Pr(>|t|)
## ar1 -0.144765 0.386328 -0.37472 0.70787
## ma1 0.183082 0.386019 0.47428 0.63530
## omega 0.000010 0.000001 9.52632 0.00000
## alpha1 0.050474 0.004477 11.27519 0.00000
## beta1 0.921226 0.008536 107.91967 0.00000
##
## LogLikelihood : 6035.493
##
## Information Criteria
## ------------------------------------
##
## Akaike -5.2099
## Bayes -5.1975
## Shibata -5.2099
## Hannan-Quinn -5.2054
##
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.05212 0.8194
## Lag[2*(p+q)+(p+q)-1][5] 2.65793 0.6886
## Lag[4*(p+q)+(p+q)-1][9] 5.29504 0.3890
## d.o.f=2
## H0 : No serial correlation
##
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.3034 0.5817
## Lag[2*(p+q)+(p+q)-1][5] 0.4452 0.9658
## Lag[4*(p+q)+(p+q)-1][9] 2.2574 0.8721
## d.o.f=2
##
## Weighted ARCH LM Tests
## ------------------------------------
## Statistic Shape Scale P-Value
## ARCH Lag[3] 0.01577 0.500 2.000 0.9001
## ARCH Lag[5] 0.27833 1.440 1.667 0.9460
## ARCH Lag[7] 0.72474 2.315 1.543 0.9538
##
## Nyblom stability test
## ------------------------------------
## Joint Statistic: 34.6348
## Individual Statistics:
## ar1 0.1409
## ma1 0.1436
## omega 4.1999
## alpha1 0.2040
## beta1 0.1999
##
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic: 1.28 1.47 1.88
## Individual Statistic: 0.35 0.47 0.75
##
## Sign Bias Test
## ------------------------------------
## t-value prob sig
## Sign Bias 0.02139 0.9829
## Negative Sign Bias 1.59119 0.1117
## Positive Sign Bias 0.01293 0.9897
## Joint Effect 3.78581 0.2855
##
##
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
## group statistic p-value(g-1)
## 1 20 52.04 6.523e-05
## 2 30 54.35 2.947e-03
## 3 40 63.07 8.661e-03
## 4 50 72.49 1.621e-02
##
##
## Elapsed time : 0.1222382
par(mfrow = c(3,4))
plot(arch1_fit_AMX, which = 1)
plot(arch1_fit_AMX, which = 2)
##
## please wait...calculating quantiles...
plot(arch1_fit_AMX, which = 3)
plot(arch1_fit_AMX, which = 4)
plot(arch1_fit_AMX, which = 5)
plot(arch1_fit_AMX, which = 6)
plot(arch1_fit_AMX, which = 7)
plot(arch1_fit_AMX, which = 8)
plot(arch1_fit_AMX, which = 9)
plot(arch1_fit_AMX, which = 10)
plot(arch1_fit_AMX, which = 11)
plot(arch1_fit_AMX, which = 12)
# Backtesting
par(mfrow=c(1,2))
roll=ugarchroll(ARCH1_AMX, Portafolio_R$AM, n.start = 200, refit.every = 20,
refit.window = "moving", solver = "hybrid", calculate.VaR = TRUE,
VaR.alpha = c(.01,.05), keep.coef = T)
par(mfrow=c(1,3))
plot(roll, which = 2)
plot(roll, which = 3)
plot(roll, which = 4)
report(roll, type = "VaR", VaR.alpha = 0.01, conf.level = 0.99)
## VaR Backtest Report
## ===========================================
## Model: sGARCH-norm
## Backtest Length: 2115
## Data:
##
## ==========================================
## alpha: 1%
## Expected Exceed: 21.2
## Actual VaR Exceed: 37
## Actual %: 1.7%
##
## Unconditional Coverage (Kupiec)
## Null-Hypothesis: Correct Exceedances
## LR.uc Statistic: 9.807
## LR.uc Critical: 6.635
## LR.uc p-value: 0.002
## Reject Null: YES
##
## Conditional Coverage (Christoffersen)
## Null-Hypothesis: Correct Exceedances and
## Independence of Failures
## LR.cc Statistic: 11.715
## LR.cc Critical: 9.21
## LR.cc p-value: 0.003
## Reject Null: YES
#Predecimos
set.seed(123)
bootp_AMX = ugarchboot(arch1_fit_AMX, method = "Partial", n.ahead = 200, n.bootpred = 200)
par(mfrow=c(1,2))
plot(bootp_AMX, which=2)
plot(bootp_AMX, which=3)
Vemos que la varianza condicionada es creciente, a medida que aumentan los horizontes de predicción.
Conclusiones
Los modelos ARCH y GARCH nos ayudan a modelar la volatilidad de una serie histórica con el fin de pronosticar a corto y mediano plazo esta misma volatilidad para poder tener un criterio de análisis de riesgo sobre el precio de un activo.Esto es de gran utilidad debido a que si queremos invertir en un activo podemos intentar analizar la volatilidad del mismo con el fin de ver a cuánto riesgo nos estaríamos exponiendo en caso de invertir en dicho activo.