# Limpiar memoria
remove(list = objects())
rm(list = ls())
options(scipen = 999)
Dado la necesidad que se tiene de manejar stocks (indices de acciones), este ejemplo contiene el uso de librerrías bajo este contexto, siguiendo las metodologías de la clase
Este es un ejemplo de como pueden realizar la actividad, no requiere ser completamente igual
Este ejemplo está basado en la extracción de información de (Yahoo Finance)[https://finance.yahoo.com/]
Suponiendo que se extrae información de la PFE PFEe Inc. BIMBOA Amazon.com Inc. TSLA Tesla Inc.
library("tseries")
## Registered S3 method overwritten by 'quantmod':
## method from
## as.zoo.data.frame zoo
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
library("xts")
library("forecast")
library("rugarch")
## Loading required package: parallel
##
## Attaching package: 'rugarch'
## The following object is masked from 'package:stats':
##
## sigma
library("PerformanceAnalytics")
##
## Attaching package: 'PerformanceAnalytics'
## The following object is masked from 'package:graphics':
##
## legend
library(vars)
## Loading required package: MASS
## Loading required package: strucchange
## Loading required package: sandwich
## Loading required package: urca
## Loading required package: lmtest
Ir a datos históricos “Historical Data”, según la fuente seleccionada, en la pantalla que contiene la tabla; seleccionar un periodo, aplicar el filtro y descargar la información en formato CSV
NOTA: tener cuidado del formato que tenga la fecha en el archivo que se extraiga
# <--- Importar la información
PFE <- read.csv("PFE.csv")
BIMBOA <- read.csv("BIMBOA.MX.csv")
TSLA <- read.csv("TSLA.csv")
NVDA <- read.csv("NVDA.csv")
#<---- Convertir la columna fecha
PFE$Date <- as.Date(PFE$Date)
BIMBOA$Date <- as.Date(BIMBOA$Date) # , format = "%d-%m-%y"
TSLA$Date <- as.Date(TSLA$Date) # , format = "%d-%m-%y"
NVDA$Date <- as.Date(NVDA$Date) # , format = "%d-%m-%y"
# Crear un objeto de serie de tiempo.
PFEclose <- ts(PFE$Close, start = c(2019, 02) , frequency = 12)
PFEclose
## Jan Feb Mar Apr May Jun Jul Aug
## 2019 40.27514 41.12903 40.29412 38.52941 39.39279 41.10057 36.85009
## 2020 37.17268 35.33207 31.70778 30.96774 36.39469 36.23340 31.02467 36.50854
## 2021 36.81000 35.90000 33.49000 36.23000 38.65000 38.73000 39.16000 42.81000
## 2022 59.05000 52.69000 46.94000 51.77000 49.07000 53.04000 52.43000 50.51000
## 2023 51.24000 44.16000 40.57000 40.80000 38.89000 38.02000 36.68000 36.06000
## 2024 28.79000
## Sep Oct Nov Dec
## 2019 33.72865 34.08918 36.40418 36.54649
## 2020 35.85389 34.81973 33.66224 38.31000
## 2021 46.07000 43.01000 43.74000 53.73000
## 2022 45.23000 43.76000 46.55000 50.13000
## 2023 35.38000 33.17000 30.56000 30.47000
## 2024
BIMBOAclose <- ts(BIMBOA$Close, start = c(2019, 02) , frequency = 12)
BIMBOAclose
## Jan Feb Mar Apr May Jun Jul Aug Sep Oct
## 2019 40.580 42.220 39.550 40.030 36.500 35.070 35.990 35.740 33.800
## 2020 29.690 34.480 35.590 34.670 38.470 40.090 40.420 41.370 40.990 42.760
## 2021 39.300 42.900 40.540 43.850 43.890 45.880 50.820 58.040 60.940 56.220
## 2022 63.070 60.060 62.900 64.720 65.370 72.040 66.220 70.770 76.810 81.870
## 2023 87.230 90.580 96.500 94.840 91.940 87.030 83.890 83.780 73.180 87.280
## 2024 72.680
## Nov Dec
## 2019 34.880 33.805
## 2020 43.240 38.520
## 2021 62.970 64.590
## 2022 82.300 93.490
## 2023 85.860 78.260
## 2024
TSLAclose <- ts(TSLA$Close, start = c(2019, 02) , frequency = 12)
TSLAclose
## Jan Feb Mar Apr May Jun Jul Aug Sep Oct
## 2019 18.66 15.91 12.34 14.90 16.11 15.04 16.06 20.99 22.00
## 2020 44.53 34.93 52.13 55.67 71.99 95.38 166.11 143.00 129.35 189.20
## 2021 225.17 222.64 236.48 208.41 226.57 229.07 245.24 258.49 371.33 381.59
## 2022 290.14 359.20 290.25 252.75 224.47 297.15 275.61 265.25 227.54 194.70
## 2023 205.71 207.46 164.31 203.93 261.77 267.43 258.08 250.22 200.84 240.08
## 2024 191.97
## Nov Dec
## 2019 27.89 43.37
## 2020 235.22 264.51
## 2021 352.26 312.24
## 2022 123.18 173.22
## 2023 248.48 187.29
## 2024
NVDAclose <- ts(NVDA$Close, start = c(2019, 02) , frequency = 12)
TSLAclose
## Jan Feb Mar Apr May Jun Jul Aug Sep Oct
## 2019 18.66 15.91 12.34 14.90 16.11 15.04 16.06 20.99 22.00
## 2020 44.53 34.93 52.13 55.67 71.99 95.38 166.11 143.00 129.35 189.20
## 2021 225.17 222.64 236.48 208.41 226.57 229.07 245.24 258.49 371.33 381.59
## 2022 290.14 359.20 290.25 252.75 224.47 297.15 275.61 265.25 227.54 194.70
## 2023 205.71 207.46 164.31 203.93 261.77 267.43 258.08 250.22 200.84 240.08
## 2024 191.97
## Nov Dec
## 2019 27.89 43.37
## 2020 235.22 264.51
## 2021 352.26 312.24
## 2022 123.18 173.22
## 2023 248.48 187.29
## 2024
# Graficar la información
plot(PFEclose, main = "Historical Closing Prices\n Pfizer Inc.", ylab = "Price")
plot(BIMBOAclose, main = "Historical Closing Prices\n Bimbo Inc.", ylab = "Price")
plot(TSLAclose, main = "Historical Closing Prices\n TSLA Inc.", ylab = "Price")
plot(NVDAclose, main = "Historical Closing Prices\n Nvidia Inc.", ylab = "Price")
# Estadísticas
mean(PFEclose)
## [1] 40.17695
var(PFEclose)
## [1] 47.59815
sd(PFEclose)
## [1] 6.899141
mean(BIMBOAclose)
## [1] 57.51775
var(BIMBOAclose)
## [1] 426.6625
sd(BIMBOAclose)
## [1] 20.65581
mean(TSLAclose)
## [1] 180.5968
var(TSLAclose)
## [1] 11340.16
sd(TSLAclose)
## [1] 106.4902
mean(NVDAclose)
## [1] 203.8297
var(NVDAclose)
## [1] 24877.03
sd(NVDAclose)
## [1] 157.7245
# ?mean
# ?var
# ?sd
ndiffs(PFEclose)
## [1] 1
ndiffs(BIMBOAclose)
## [1] 1
ndiffs(TSLAclose)
## [1] 1
ndiffs(NVDAclose)
## [1] 2
# <-- Como se descompone esta serie de tiempo
plot(stl(PFEclose, s.window = "periodic"))
# ?stl
PFE_ts <- ts(PFEclose, start=c(2019,02), frequency=12)
# PFE_ts
plot(stl(PFE_ts, s.window = "periodic"))
plot(stl(BIMBOAclose, s.window = "periodic"))
BIMBOA_ts <- ts(BIMBOAclose, start=c(2019,02), frequency=12)
# BIMBOA_ts
plot(stl(BIMBOA_ts, s.window = "periodic"))
plot(stl(TSLAclose, s.window = "periodic"))
TSLA_ts <- ts(TSLAclose, start=c(2019,02), frequency=12)
# TSLA_ts
plot(stl(TSLA_ts, s.window = "periodic"))
plot(stl(NVDAclose, s.window = "periodic"))
NVDA_ts <- ts(NVDAclose, start=c(2019,02), frequency=12)
# TSLA_ts
plot(stl(NVDA_ts, s.window = "periodic"))
# # <-- alternativa de como descomponer una serie de tiempo
# PFE.decomp = decompose(PFEclose, type = "additive")
# # ?decompose
#
# tend <- PFE.decomp$trend #m_t
# estac <- PFE.decomp$seasonal #s_t
# error <- PFE.decomp$random #z_t
#
# plot(PFE.decomp)
# # <-- alternativa
# Limpiar información para evitar errores
PFEclose <- na.omit(PFEclose)
BIMBOAclose <- na.omit(BIMBOAclose)
TSLAclose <- na.omit(TSLAclose)
NVDAose <- na.omit(NVDAclose)
# Hacer la diferenciación para los comparativos
PFEclose_diff <- diff(PFEclose)
BIMBOAclose_diff <- diff(BIMBOAclose)
TSLAclose_diff <- diff(TSLAclose)
NVDAclose_diff <- diff(NVDAclose)
adf_test <- adf.test(ts_data)
p_value <- adf_test$p.value
if (p_value < 0.05) {
print("La serie es estacionaria")
} else {
print("La serie no es estacionaria")
}
adf_test_diff <- adf.test(diff(ts_data))
p_value <- adf_test$p.value
if (p_value < 0.05) {
print("La primera diferencia es estacionaria")
} else {
print("La primera diferencia no es estacionaria")
}
# Explicación de los diagramas, es estacionario o no....
# Prueba aumentada de Dickey Fuller / sin diferenciar
PFE_adf_sin_d <- adf.test(PFEclose)
## Warning in adf.test(PFEclose): p-value greater than printed p-value
BIMBOA_adf_sin_d <- adf.test(BIMBOAclose)
TSLA_adf_sin_d <- adf.test(TSLAclose)
NVDA_adf_sin_d <- adf.test(NVDAclose)
## Warning in adf.test(NVDAclose): p-value greater than printed p-value
# Explica lo encontardo, cada resultado, revisa el p-value
PFE_adf_sin_d
##
## Augmented Dickey-Fuller Test
##
## data: PFEclose
## Dickey-Fuller = -0.13745, Lag order = 3, p-value = 0.99
## alternative hypothesis: stationary
PFE_adf_sin_d$p.value
## [1] 0.99
BIMBOA_adf_sin_d
##
## Augmented Dickey-Fuller Test
##
## data: BIMBOAclose
## Dickey-Fuller = -1.8453, Lag order = 3, p-value = 0.6373
## alternative hypothesis: stationary
BIMBOA_adf_sin_d$p.value
## [1] 0.6372899
TSLA_adf_sin_d
##
## Augmented Dickey-Fuller Test
##
## data: TSLAclose
## Dickey-Fuller = -0.95975, Lag order = 3, p-value = 0.9368
## alternative hypothesis: stationary
TSLA_adf_sin_d$p.value
## [1] 0.9368207
NVDA_adf_sin_d
##
## Augmented Dickey-Fuller Test
##
## data: NVDAclose
## Dickey-Fuller = 0.19565, Lag order = 3, p-value = 0.99
## alternative hypothesis: stationary
NVDA_adf_sin_d$p.value
## [1] 0.99
# ....
# Prueba aumentada de Dickey Fuller / con diferenciar
PFE_adf_con_d <- adf.test(PFEclose_diff)
BIMBOA_adf_con_d <- adf.test(BIMBOAclose_diff)
TSLA_adf_con_d <- adf.test(TSLAclose_diff)
NVDA_adf_con_d <- adf.test(NVDAclose_diff)
# Explica lo encontardo, cada resultado, revisa el p-value
PFE_adf_con_d
##
## Augmented Dickey-Fuller Test
##
## data: PFEclose_diff
## Dickey-Fuller = -3.7895, Lag order = 3, p-value = 0.02497
## alternative hypothesis: stationary
PFE_adf_con_d$p.value
## [1] 0.02497132
BIMBOA_adf_con_d
##
## Augmented Dickey-Fuller Test
##
## data: BIMBOAclose_diff
## Dickey-Fuller = -2.4823, Lag order = 3, p-value = 0.3799
## alternative hypothesis: stationary
BIMBOA_adf_con_d$p.value
## [1] 0.3799175
TSLA_adf_con_d
##
## Augmented Dickey-Fuller Test
##
## data: TSLAclose_diff
## Dickey-Fuller = -3.7026, Lag order = 3, p-value = 0.03226
## alternative hypothesis: stationary
TSLA_adf_con_d$p.value
## [1] 0.03226196
NVDA_adf_con_d
##
## Augmented Dickey-Fuller Test
##
## data: NVDAclose_diff
## Dickey-Fuller = -1.8697, Lag order = 3, p-value = 0.6274
## alternative hypothesis: stationary
NVDA_adf_con_d$p.value
## [1] 0.627366
# ....
pp_test <- pp.test(ts_data)
p_value <- pp_test$p.value
if (p_value < 0.05) {
print("La serie es estacionaria")
} else {
print("La serie no es estacionaria")
}
# Prueba de Phillips - Perron / sin diferenciar
PFE_pp <- pp.test(PFEclose)
BIMBOA_pp <- pp.test(BIMBOAclose)
TSLA_pp <- pp.test(TSLAclose)
NVDA_pp <- pp.test(NVDAclose)
## Warning in pp.test(NVDAclose): p-value greater than printed p-value
# Explica lo encontardo, cada resultado
PFE_pp
##
## Phillips-Perron Unit Root Test
##
## data: PFEclose
## Dickey-Fuller Z(alpha) = -3.2597, Truncation lag parameter = 3, p-value
## = 0.9205
## alternative hypothesis: stationary
PFE_pp$p.value
## [1] 0.9204921
# Prueba de Phillips - Perron / con diferenciar
PFE_pp_con_d <- pp.test(PFEclose_diff)
## Warning in pp.test(PFEclose_diff): p-value smaller than printed p-value
# Explica lo encontardo, cada resultado
PFE_pp_con_d
##
## Phillips-Perron Unit Root Test
##
## data: PFEclose_diff
## Dickey-Fuller Z(alpha) = -42.564, Truncation lag parameter = 3, p-value
## = 0.01
## alternative hypothesis: stationary
PFE_pp_con_d$p.value
## [1] 0.01
library(aTSA)
##
## Attaching package: 'aTSA'
## The following object is masked from 'package:vars':
##
## arch.test
## The following object is masked from 'package:forecast':
##
## forecast
## The following objects are masked from 'package:tseries':
##
## adf.test, kpss.test, pp.test
## The following object is masked from 'package:graphics':
##
## identify
library(vars)
# ?coint.test
# ?coredata
# ?po.test
## <- Ejemplo de como hacerlo con ca.jo
# z <- ts(cbind(PFEclose, BIMBOAclose))
# eg_test <- ca.jo(z, type = "eigen", K = 2)
# eg_test_s <- summary(eg_test)
# if (eg_test_s@cval[, "10pct"] < 0.05) {
# print("Las series son cointegradas")
# } else {
# print("Las series no son cointegradas")
# }
# El siguiente ejemplo, imprime todas las combinaciones, según las acciones que
# fueron ingresadas
series <- list(PFEclose, BIMBOAclose, TSLAclose, NVDAclose) # Coloca las variables que contienen la información
series_names <- c('PFEclose', 'BIMBOAclose', 'TSLAclose', 'NVDAclose') # Coloca como texto el nombre de las Acciones
n <- length(series)
for (i in 1:(n-1)) {
for (j in (i+1):n) {
cat("\nPrueba de cointegración entre", series_names[i], "y", series_names[j], "\n")
coint_test <- coint.test(series[[i]], series[[j]])
print(coint_test)
}
cat('----------- Fin de análisis:',i, "\n\n")
}
##
## Prueba de cointegración entre PFEclose y BIMBOAclose
## Response: series[[i]]
## Input: series[[j]]
## Number of inputs: 1
## Model: y ~ X + 1
## -------------------------------
## Engle-Granger Cointegration Test
## alternative: cointegrated
##
## Type 1: no trend
## lag EG p.value
## 3.000 -0.614 0.100
## -----
## Type 2: linear trend
## lag EG p.value
## 3.00 -1.28 0.10
## -----
## Type 3: quadratic trend
## lag EG p.value
## 3.00 1.57 0.10
## -----------
## Note: p.value = 0.01 means p.value <= 0.01
## : p.value = 0.10 means p.value >= 0.10
## lag EG p.value
## type 1 3 -0.614283 0.1
## type 2 3 -1.280203 0.1
## type 3 3 1.573596 0.1
##
## Prueba de cointegración entre PFEclose y TSLAclose
## Response: series[[i]]
## Input: series[[j]]
## Number of inputs: 1
## Model: y ~ X + 1
## -------------------------------
## Engle-Granger Cointegration Test
## alternative: cointegrated
##
## Type 1: no trend
## lag EG p.value
## 3.000 -0.844 0.100
## -----
## Type 2: linear trend
## lag EG p.value
## 3.00 -1.17 0.10
## -----
## Type 3: quadratic trend
## lag EG p.value
## 3.00 1.27 0.10
## -----------
## Note: p.value = 0.01 means p.value <= 0.01
## : p.value = 0.10 means p.value >= 0.10
## lag EG p.value
## type 1 3 -0.8435394 0.1
## type 2 3 -1.1690402 0.1
## type 3 3 1.2727838 0.1
##
## Prueba de cointegración entre PFEclose y NVDAclose
## Response: series[[i]]
## Input: series[[j]]
## Number of inputs: 1
## Model: y ~ X + 1
## -------------------------------
## Engle-Granger Cointegration Test
## alternative: cointegrated
##
## Type 1: no trend
## lag EG p.value
## 3.00 -1.02 0.10
## -----
## Type 2: linear trend
## lag EG p.value
## 3.000 -0.562 0.100
## -----
## Type 3: quadratic trend
## lag EG p.value
## 3.00 1.57 0.10
## -----------
## Note: p.value = 0.01 means p.value <= 0.01
## : p.value = 0.10 means p.value >= 0.10
## lag EG p.value
## type 1 3 -1.0243367 0.1
## type 2 3 -0.5617273 0.1
## type 3 3 1.5718589 0.1
## ----------- Fin de análisis: 1
##
##
## Prueba de cointegración entre BIMBOAclose y TSLAclose
## Response: series[[i]]
## Input: series[[j]]
## Number of inputs: 1
## Model: y ~ X + 1
## -------------------------------
## Engle-Granger Cointegration Test
## alternative: cointegrated
##
## Type 1: no trend
## lag EG p.value
## 3.000 -0.847 0.100
## -----
## Type 2: linear trend
## lag EG p.value
## 3.000 0.994 0.100
## -----
## Type 3: quadratic trend
## lag EG p.value
## 3.000 -0.463 0.100
## -----------
## Note: p.value = 0.01 means p.value <= 0.01
## : p.value = 0.10 means p.value >= 0.10
## lag EG p.value
## type 1 3 -0.8466010 0.1
## type 2 3 0.9943272 0.1
## type 3 3 -0.4627020 0.1
##
## Prueba de cointegración entre BIMBOAclose y NVDAclose
## Response: series[[i]]
## Input: series[[j]]
## Number of inputs: 1
## Model: y ~ X + 1
## -------------------------------
## Engle-Granger Cointegration Test
## alternative: cointegrated
##
## Type 1: no trend
## lag EG p.value
## 3.000 -0.746 0.100
## -----
## Type 2: linear trend
## lag EG p.value
## 3.00 -1.09 0.10
## -----
## Type 3: quadratic trend
## lag EG p.value
## 3.00 2.93 0.10
## -----------
## Note: p.value = 0.01 means p.value <= 0.01
## : p.value = 0.10 means p.value >= 0.10
## lag EG p.value
## type 1 3 -0.7457287 0.1
## type 2 3 -1.0908245 0.1
## type 3 3 2.9259354 0.1
## ----------- Fin de análisis: 2
##
##
## Prueba de cointegración entre TSLAclose y NVDAclose
## Response: series[[i]]
## Input: series[[j]]
## Number of inputs: 1
## Model: y ~ X + 1
## -------------------------------
## Engle-Granger Cointegration Test
## alternative: cointegrated
##
## Type 1: no trend
## lag EG p.value
## 3.000 -0.859 0.100
## -----
## Type 2: linear trend
## lag EG p.value
## 3.00 -1.11 0.10
## -----
## Type 3: quadratic trend
## lag EG p.value
## 3.00 2.49 0.10
## -----------
## Note: p.value = 0.01 means p.value <= 0.01
## : p.value = 0.10 means p.value >= 0.10
## lag EG p.value
## type 1 3 -0.8588867 0.1
## type 2 3 -1.1083866 0.1
## type 3 3 2.4899826 0.1
## ----------- Fin de análisis: 3
# Revisa la información que se imprimió en la consola
# ols - Ordinary least squares (Mínimos cuadrados ordinarios)
reg_longrun <- lm(PFEclose ~ BIMBOAclose + TSLAclose + NVDAclose)
summary(reg_longrun)
##
## Call:
## lm(formula = PFEclose ~ BIMBOAclose + TSLAclose + NVDAclose)
##
## Residuals:
## Min 1Q Median 3Q Max
## -8.1140 -3.4367 -0.2399 2.1231 15.2388
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 28.532231 1.844615 15.468 < 0.0000000000000002 ***
## BIMBOAclose 0.230494 0.041547 5.548 0.00000081663 ***
## TSLAclose 0.036055 0.006827 5.282 0.00000216644 ***
## NVDAclose -0.039858 0.005451 -7.311 0.00000000106 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 4.51 on 56 degrees of freedom
## Multiple R-squared: 0.5944, Adjusted R-squared: 0.5727
## F-statistic: 27.36 on 3 and 56 DF, p-value: 0.00000000005019
# Guardar los residuales
resid <- reg_longrun$residuals
# Augmented Dickey-Fuller (ADF)
adf <- adf.test(resid)
## Augmented Dickey-Fuller Test
## alternative: stationary
##
## Type 1: no drift no trend
## lag ADF p.value
## [1,] 0 -3.36 0.0100
## [2,] 1 -3.79 0.0100
## [3,] 2 -2.42 0.0181
## [4,] 3 -2.24 0.0259
## Type 2: with drift no trend
## lag ADF p.value
## [1,] 0 -3.33 0.0203
## [2,] 1 -3.75 0.0100
## [3,] 2 -2.40 0.1762
## [4,] 3 -2.22 0.2444
## Type 3: with drift and trend
## lag ADF p.value
## [1,] 0 -3.24 0.0894
## [2,] 1 -3.65 0.0366
## [3,] 2 -2.33 0.4353
## [4,] 3 -2.17 0.4978
## ----
## Note: in fact, p.value = 0.01 means p.value <= 0.01
adf$p.value
## NULL
# Calcular los residuos rezagados 1 período
residl1 <- na.omit(lag(resid, 1))
ecm <- lm(PFEclose_diff ~ BIMBOAclose_diff + TSLAclose_diff + NVDAclose_diff + residl1[2:length(residl1)])
summary(ecm)
##
## Call:
## lm(formula = PFEclose_diff ~ BIMBOAclose_diff + TSLAclose_diff +
## NVDAclose_diff + residl1[2:length(residl1)])
##
## Residuals:
## Min 1Q Median 3Q Max
## -8.6903 -1.8132 0.2058 1.4246 7.0028
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.127270 0.422572 -0.301 0.76443
## BIMBOAclose_diff 0.091642 0.095170 0.963 0.33988
## TSLAclose_diff 0.006161 0.012172 0.506 0.61481
## NVDAclose_diff -0.009269 0.010918 -0.849 0.39966
## residl1[2:length(residl1)] 0.312768 0.093743 3.336 0.00154 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 3.046 on 54 degrees of freedom
## Multiple R-squared: 0.1822, Adjusted R-squared: 0.1216
## F-statistic: 3.008 on 4 and 54 DF, p-value: 0.02592
ecm_coef3 <- abs(ecm$coefficients [3])
ecm_coef3_result <- (1 / ecm_coef3)
print(ecm_coef3_result)
## TSLAclose_diff
## 162.3184
acf(PFEclose)
acf(BIMBOAclose)
acf(TSLAclose)
acf(NVDAclose)
# ejemplo con lags de 10
acf(PFEclose, lag.max = 10, plot = FALSE)
##
## Autocorrelations of series 'PFEclose', by lag
##
## 0.0000 0.0833 0.1667 0.2500 0.3333 0.4167 0.5000 0.5833 0.6667 0.7500 0.8333
## 1.000 0.867 0.728 0.672 0.652 0.583 0.506 0.414 0.285 0.160 0.080
acf(BIMBOAclose, lag.max = 10, plot = FALSE)
##
## Autocorrelations of series 'BIMBOAclose', by lag
##
## 0.0000 0.0833 0.1667 0.2500 0.3333 0.4167 0.5000 0.5833 0.6667 0.7500 0.8333
## 1.000 0.967 0.938 0.903 0.858 0.817 0.769 0.716 0.659 0.599 0.543
acf(TSLAclose, lag.max = 10, plot = FALSE)
##
## Autocorrelations of series 'TSLAclose', by lag
##
## 0.0000 0.0833 0.1667 0.2500 0.3333 0.4167 0.5000 0.5833 0.6667 0.7500 0.8333
## 1.000 0.923 0.843 0.784 0.741 0.674 0.597 0.524 0.463 0.418 0.373
acf(NVDAclose, lag.max = 10, plot = FALSE)
##
## Autocorrelations of series 'NVDAclose', by lag
##
## 0.0000 0.0833 0.1667 0.2500 0.3333 0.4167 0.5000 0.5833 0.6667 0.7500 0.8333
## 1.000 0.840 0.727 0.650 0.576 0.522 0.462 0.368 0.279 0.195 0.120
# PFE
ar1modelPFEclose <- arima(PFEclose, order = c(1, 0, 0))
ar1modelPFEclose
##
## Call:
## arima(x = PFEclose, order = c(1, 0, 0))
##
## Coefficients:
## ar1 intercept
## 0.8931 38.9491
## s.e. 0.0561 3.4039
##
## sigma^2 estimated as 9.873: log likelihood = -154.63, aic = 315.26
ar1modelPFEclose_pred2 <- forecast::forecast(ar1modelPFEclose, h=30)
plot(ar1modelPFEclose_pred2)
# NVDA
ar1modelNVDAclose <- arima(NVDAclose, order = c(1, 1, 0))
ar1modelNVDAclose
##
## Call:
## arima(x = NVDAclose, order = c(1, 1, 0))
##
## Coefficients:
## ar1
## 0.4210
## s.e. 0.1412
##
## sigma^2 estimated as 1522: log likelihood = -299.99, aic = 603.98
ar1modelNVDAclose_pred2 <- forecast::forecast(ar1modelNVDAclose, h=30)
plot(ar1modelNVDAclose_pred2)
# BIMBOA
ar1modelBIMBOAclose <- arima(BIMBOAclose, order = c(1, 0, 0))
ar1modelBIMBOAclose
##
## Call:
## arima(x = BIMBOAclose, order = c(1, 0, 0))
##
## Coefficients:
## ar1 intercept
## 0.9730 57.0541
## s.e. 0.0226 14.1009
##
## sigma^2 estimated as 19.17: log likelihood = -175.2, aic = 356.4
ar1modelBIMBOAclose_pred2 <- forecast::forecast(ar1modelBIMBOAclose, h=30)
plot(ar1modelBIMBOAclose_pred2)
# TSLA
ar1modelTSLAclose <- arima(TSLAclose, order = c(1, 0, 0))
ar1modelTSLAclose
##
## Call:
## arima(x = TSLAclose, order = c(1, 0, 0))
##
## Coefficients:
## ar1 intercept
## 0.9436 153.8138
## s.e. 0.0383 66.1465
##
## sigma^2 estimated as 1258: log likelihood = -300.35, aic = 606.7
ar1modelTSLAclose_pred2 <- forecast::forecast(ar1modelTSLAclose, h=30)
plot(ar1modelTSLAclose_pred2)
# PFE
ma1modelPFEclose <- arima(PFEclose, order = c(0, 0, 1))
ma1modelPFEclose
##
## Call:
## arima(x = PFEclose, order = c(0, 0, 1))
##
## Coefficients:
## ma1 intercept
## 0.7738 40.0741
## s.e. 0.0592 1.0055
##
## sigma^2 estimated as 19.56: log likelihood = -174.8, aic = 355.6
ma1modelPFEclose_pred2 <- forecast::forecast(ma1modelPFEclose, h=30)
plot(ma1modelPFEclose_pred2)
# NVDA
ma1modelNVDAclose <- arima(NVDAclose, order = c(0, 0, 1))
ma1modelNVDAclose
##
## Call:
## arima(x = NVDAclose, order = c(0, 0, 1))
##
## Coefficients:
## ma1 intercept
## 0.8616 207.0948
## s.e. 0.0534 22.7700
##
## sigma^2 estimated as 9114: log likelihood = -359.34, aic = 724.69
ma1modelNVDAclose_pred2 <- forecast::forecast(ma1modelNVDAclose, h=30)
plot(ma1modelNVDAclose_pred2)
# BIMBOA
ma1modelBIMBOAclose <- arima(BIMBOAclose, order = c(0, 0, 1))
ma1modelBIMBOAclose
##
## Call:
## arima(x = BIMBOAclose, order = c(0, 0, 1))
##
## Coefficients:
## ma1 intercept
## 0.8601 57.3560
## s.e. 0.0533 2.8364
##
## sigma^2 estimated as 141.6: log likelihood = -234.4, aic = 474.8
ma1modelBIMBOAclose_pred2 <- forecast::forecast(ma1modelBIMBOAclose, h=30)
plot(ma1modelBIMBOAclose_pred2)
# TSLA
ma1modelTSLAclose <- arima(TSLAclose, order = c(0, 0, 1))
ma1modelTSLAclose
##
## Call:
## arima(x = TSLAclose, order = c(0, 0, 1))
##
## Coefficients:
## ma1 intercept
## 0.7820 179.5833
## s.e. 0.0589 15.0979
##
## sigma^2 estimated as 4370: log likelihood = -337.08, aic = 680.16
ma1modelTSLAclose_pred2 <- forecast::forecast(ma1modelTSLAclose, h=30)
plot(ma1modelTSLAclose_pred2)
# PFE
armamodelPFEclose <- arima(PFEclose, order = c(1, 0, 1))
armamodelPFEclose
##
## Call:
## arima(x = PFEclose, order = c(1, 0, 1))
##
## Coefficients:
## ar1 ma1 intercept
## 0.8308 0.2974 39.2887
## s.e. 0.0808 0.1546 2.8423
##
## sigma^2 estimated as 9.473: log likelihood = -153.44, aic = 314.88
predict(armamodelPFEclose, n.ahead = 30)$pred
## Jan Feb Mar Apr May Jun Jul Aug
## 2024 29.68618 31.31127 32.66133 33.78292 34.71469 35.48877 36.13185
## 2025 38.03946 38.25087 38.42650 38.57241 38.69363 38.79433 38.87799 38.94750
## 2026 39.15366 39.17651 39.19550 39.21126 39.22437 39.23525 39.24429
## Sep Oct Nov Dec
## 2024 36.66610 37.10994 37.47866 37.78498
## 2025 39.00524 39.05320 39.09306 39.12616
## 2026
# NVDA
armamodelNVDAclose <- arima(NVDAclose, order = c(1, 1, 1))
armamodelNVDAclose
##
## Call:
## arima(x = NVDAclose, order = c(1, 1, 1))
##
## Coefficients:
## ar1 ma1
## 0.8114 -0.4400
## s.e. 0.2234 0.2941
##
## sigma^2 estimated as 1477: log likelihood = -299.19, aic = 604.39
predict(armamodelNVDAclose, n.ahead = 30)$pred
## Jan Feb Mar Apr May Jun Jul
## 2024 875.3167 946.0300 1003.4090 1049.9679 1087.7472 1118.4025
## 2025 1212.6620 1219.7620 1225.5232 1230.1980 1233.9913 1237.0692 1239.5668
## 2026 1247.2463 1247.8248 1248.2942 1248.6750 1248.9841 1249.2349 1249.4383
## Aug Sep Oct Nov Dec
## 2024 1143.2771 1163.4611 1179.8389 1193.1284 1203.9119
## 2025 1241.5934 1243.2378 1244.5722 1245.6549 1246.5335
## 2026
# BIMBOA
armamodelBIMBOAclose <- arima(BIMBOAclose, order = c(1, 0, 1))
armamodelBIMBOAclose
##
## Call:
## arima(x = BIMBOAclose, order = c(1, 0, 1))
##
## Coefficients:
## ar1 ma1 intercept
## 0.9792 -0.1240 57.3040
## s.e. 0.0196 0.1239 14.7607
##
## sigma^2 estimated as 18.87: log likelihood = -174.73, aic = 357.47
predict(armamodelBIMBOAclose, n.ahead = 30)$pred
## Jan Feb Mar Apr May Jun Jul Aug
## 2024 73.10430 72.77597 72.45447 72.13964 71.83136 71.52948 71.23387
## 2025 69.84547 69.58486 69.32967 69.07977 68.83507 68.59546 68.36082 68.13106
## 2026 67.05192 66.84936 66.65101 66.45678 66.26659 66.08034 65.89797
## Sep Oct Nov Dec
## 2024 70.94441 70.66096 70.38341 70.11162
## 2025 67.90608 67.68577 67.47003 67.25878
## 2026
# TSLA
armamodelTSLAclose <- arima(TSLAclose, order = c(1, 0, 1))
armamodelTSLAclose
##
## Call:
## arima(x = TSLAclose, order = c(1, 0, 1))
##
## Coefficients:
## ar1 ma1 intercept
## 0.9348 0.0774 156.3211
## s.e. 0.0459 0.1596 63.2541
##
## sigma^2 estimated as 1253: log likelihood = -300.24, aic = 608.48
predict(armamodelTSLAclose, n.ahead = 30)$pred
## Jan Feb Mar Apr May Jun Jul Aug
## 2024 190.4978 188.2678 186.1833 184.2348 182.4134 180.7109 179.1195
## 2025 172.5909 171.5293 170.5370 169.6094 168.7423 167.9318 167.1742 166.4661
## 2026 163.5609 163.0885 162.6470 162.2342 161.8484 161.4877 161.1506
## Sep Oct Nov Dec
## 2024 177.6319 176.2414 174.9416 173.7266
## 2025 165.8041 165.1853 164.6070 164.0663
## 2026
# PFE
AIC(arima(PFEclose, order = c(1, 0, 0)))
## [1] 315.2573
AIC(arima(PFEclose, order = c(0, 0, 1)))
## [1] 355.5958
AIC(arima(PFEclose, order = c(1, 0, 1)))
## [1] 314.8829
# NVDA
AIC(arima(NVDAclose, order = c(1, 1, 0)))
## [1] 603.9763
AIC(arima(NVDAclose, order = c(0, 0, 1)))
## [1] 724.6851
AIC(arima(NVDAclose, order = c(1, 1, 1)))
## [1] 604.3895
# BIMBOA
AIC(arima(BIMBOAclose, order = c(1, 0, 0)))
## [1] 356.4011
AIC(arima(BIMBOAclose, order = c(0, 0, 1)))
## [1] 474.8038
AIC(arima(BIMBOAclose, order = c(1, 0, 1)))
## [1] 357.4653
# TSLA
AIC(arima(TSLAclose, order = c(1, 0, 0)))
## [1] 606.703
AIC(arima(TSLAclose, order = c(0, 0, 1)))
## [1] 680.1641
AIC(arima(TSLAclose, order = c(1, 0, 1)))
## [1] 608.4775
# PFE
armamodelPFEclose <- arima(PFEclose, order = c(1, 0, 1))
armamodelPFEclose
##
## Call:
## arima(x = PFEclose, order = c(1, 0, 1))
##
## Coefficients:
## ar1 ma1 intercept
## 0.8308 0.2974 39.2887
## s.e. 0.0808 0.1546 2.8423
##
## sigma^2 estimated as 9.473: log likelihood = -153.44, aic = 314.88
armamodelPFEclose_pred <- forecast::forecast(armamodelPFEclose, h = 30)
plot(armamodelPFEclose_pred)
# NVDA
armamodelNVDAclose <- arima(NVDAclose, order = c(1, 1, 1))
armamodelNVDAclose
##
## Call:
## arima(x = NVDAclose, order = c(1, 1, 1))
##
## Coefficients:
## ar1 ma1
## 0.8114 -0.4400
## s.e. 0.2234 0.2941
##
## sigma^2 estimated as 1477: log likelihood = -299.19, aic = 604.39
armamodelNVDAclose_pred <- forecast::forecast(armamodelNVDAclose, h = 30)
plot(armamodelNVDAclose_pred)
# BIMBOA
armamodelBIMBOAclose <- arima(BIMBOAclose, order = c(1, 0, 1))
armamodelBIMBOAclose
##
## Call:
## arima(x = BIMBOAclose, order = c(1, 0, 1))
##
## Coefficients:
## ar1 ma1 intercept
## 0.9792 -0.1240 57.3040
## s.e. 0.0196 0.1239 14.7607
##
## sigma^2 estimated as 18.87: log likelihood = -174.73, aic = 357.47
armamodelBIMBOAclose_pred <- forecast::forecast(armamodelBIMBOAclose, h = 30)
plot(armamodelBIMBOAclose_pred)
# TSLA
armamodelTSLAclose <- arima(TSLAclose, order = c(1, 0, 1))
armamodelTSLAclose
##
## Call:
## arima(x = TSLAclose, order = c(1, 0, 1))
##
## Coefficients:
## ar1 ma1 intercept
## 0.9348 0.0774 156.3211
## s.e. 0.0459 0.1596 63.2541
##
## sigma^2 estimated as 1253: log likelihood = -300.24, aic = 608.48
armamodelTSLAclose_pred <- forecast::forecast(armamodelTSLAclose, h = 30)
plot(armamodelTSLAclose_pred)
# PFE
autoARPFE <- auto.arima(PFEclose)
autoARPFE
## Series: PFEclose
## ARIMA(0,1,0)(0,0,1)[12]
##
## Coefficients:
## sma1
## 0.3256
## s.e. 0.1585
##
## sigma^2 = 9.602: log likelihood = -150.61
## AIC=305.23 AICc=305.44 BIC=309.38
autoARPFE$aic
## [1] 305.2272
# NVDA
autoARNVDA <- auto.arima(NVDAclose)
autoARNVDA
## Series: NVDAclose
## ARIMA(0,2,1)(0,0,1)[12]
##
## Coefficients:
## ma1 sma1
## -0.6353 0.3112
## s.e. 0.1907 0.1544
##
## sigma^2 = 1434: log likelihood = -292.92
## AIC=591.84 AICc=592.29 BIC=598.02
autoARNVDA$aic
## [1] 591.8434
# BIMBOA
autoARBIMBOA <- auto.arima(BIMBOAclose)
autoARBIMBOA
## Series: BIMBOAclose
## ARIMA(0,1,0)
##
## sigma^2 = 19.48: log likelihood = -171.31
## AIC=344.62 AICc=344.69 BIC=346.7
autoARBIMBOA$aic
## [1] 344.6243
# TSLA
autoARTSLA <- auto.arima(TSLAclose)
autoARTSLA
## Series: TSLAclose
## ARIMA(0,1,0)
##
## sigma^2 = 1296: log likelihood = -295.14
## AIC=592.28 AICc=592.35 BIC=594.36
autoARTSLA$aic
## [1] 592.2837
# PFE
proy <- forecast::forecast(autoARPFE, h = 30)
proy
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## Feb 2024 27.14601 23.1748161 31.11720 21.0725929 33.21943
## Mar 2024 26.54661 20.9305127 32.16272 17.9575281 35.13570
## Apr 2024 26.20954 19.3312514 33.08782 15.6901069 36.72897
## May 2024 25.89121 17.9488572 33.83357 13.7444277 38.03800
## Jun 2024 25.19460 16.3147805 34.07442 11.6140866 38.77512
## Jul 2024 24.90126 15.1739067 34.62862 10.0245555 39.77797
## Aug 2024 24.95389 14.4471414 35.46063 8.8852071 41.02256
## Sep 2024 25.40151 14.1693276 36.63369 8.2233703 42.57965
## Oct 2024 24.74500 12.8314761 36.65853 6.5248365 42.96517
## Nov 2024 23.64518 11.0872268 36.20314 4.4394454 42.85092
## Dec 2024 23.52964 10.3587380 36.70053 3.3864863 43.67278
## Jan 2025 23.06713 9.3105734 36.82368 2.0282943 44.10596
## Feb 2025 23.06713 8.3378017 37.79645 0.5405684 45.59368
## Mar 2025 23.06713 7.4254110 38.70884 -0.8548128 46.98906
## Apr 2025 23.06713 6.5633840 39.57087 -2.1731694 48.30742
## May 2025 23.06713 5.7442003 40.39005 -3.4260027 49.56025
## Jun 2025 23.06713 4.9620436 41.17221 -4.6222081 50.75646
## Jul 2025 23.06713 4.2123053 41.92195 -5.7688339 51.90309
## Aug 2025 23.06713 3.4912603 42.64299 -6.8715770 53.00583
## Sep 2025 23.06713 2.7958466 43.33841 -7.9351206 54.06937
## Oct 2025 23.06713 2.1235106 44.01074 -8.9633697 55.09762
## Nov 2025 23.06713 1.4720970 44.66216 -9.9596209 56.09387
## Dec 2025 23.06713 0.8397660 45.29449 -10.9266876 57.06094
## Jan 2026 23.06713 0.2249329 45.90932 -11.8669937 58.00125
## Feb 2026 23.06713 -0.3737793 46.50803 -12.7826450 58.91690
## Mar 2026 23.06713 -0.9575757 47.09183 -13.6754846 59.80974
## Apr 2026 23.06713 -1.5275187 47.66177 -14.5471372 60.68139
## May 2026 23.06713 -2.0845499 48.21880 -15.3990429 61.53330
## Jun 2026 23.06713 -2.6295091 48.76376 -16.2324860 62.36674
## Jul 2026 23.06713 -3.1631487 49.29740 -17.0486173 63.18287
plot(proy)
# NVDA
proy1 <- forecast::forecast(autoARNVDA, h = 30)
proy1
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## Feb 2024 890.7522 842.2269 939.2775 816.5392 964.9652
## Mar 2024 990.8583 908.7593 1072.9572 865.2987 1116.4178
## Apr 2024 1113.6146 996.2133 1231.0160 934.0648 1293.1645
## May 2024 1223.3095 1068.0367 1378.5823 985.8403 1460.7787
## Jun 2024 1325.2199 1129.3976 1521.0423 1025.7355 1624.7043
## Jul 2024 1428.2714 1189.2740 1667.2689 1062.7565 1793.7864
## Aug 2024 1503.6898 1218.9860 1788.3935 1068.2730 1939.1065
## Sep 2024 1586.7781 1253.9386 1919.6177 1077.7440 2095.8123
## Oct 2024 1695.4675 1312.1607 2078.7743 1109.2503 2281.6846
## Nov 2024 1796.6241 1360.6099 2232.6383 1129.7979 2463.4503
## Dec 2024 1919.0362 1428.1578 2409.9146 1168.3025 2669.7699
## Jan 2025 2060.5022 1512.6792 2608.3252 1222.6792 2898.3252
## Feb 2025 2180.2086 1566.7848 2793.6324 1242.0579 3118.3593
## Mar 2025 2299.9150 1617.4079 2982.4222 1256.1105 3343.7196
## Apr 2025 2419.6215 1664.7911 3174.4518 1265.2081 3574.0349
## May 2025 2539.3279 1709.1325 3369.5233 1269.6536 3809.0022
## Jun 2025 2659.0343 1750.5963 3567.4723 1269.6983 4048.3704
## Jul 2025 2778.7408 1789.3209 3768.1606 1265.5537 4291.9278
## Aug 2025 2898.4472 1825.4246 3971.4698 1257.4008 4539.4936
## Sep 2025 3018.1536 1859.0099 4177.2974 1245.3963 4790.9110
## Oct 2025 3137.8601 1890.1667 4385.5535 1229.6777 5046.0424
## Nov 2025 3257.5665 1918.9746 4596.1584 1210.3668 5304.7662
## Dec 2025 3377.2729 1945.5048 4809.0411 1187.5725 5566.9734
## Jan 2026 3496.9794 1969.8216 5024.1371 1161.3932 5832.5656
## Feb 2026 3616.6858 1991.9835 5241.3881 1131.9180 6101.4536
## Mar 2026 3736.3922 2012.0438 5460.7407 1099.2288 6373.5557
## Apr 2026 3856.0987 2030.0516 5682.1458 1063.4007 6648.7967
## May 2026 3975.8051 2046.0524 5905.5578 1024.5030 6927.1072
## Jun 2026 4095.5115 2060.0884 6130.9347 982.6004 7208.4226
## Jul 2026 4215.2180 2072.1989 6358.2371 937.7531 7492.6828
plot(proy1)
# BIMBOA
proy2 <- forecast::forecast(autoARBIMBOA, h = 30)
proy2
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## Feb 2024 72.68 67.02393 78.33607 64.02978 81.33022
## Mar 2024 72.68 64.68111 80.67889 60.44675 84.91325
## Apr 2024 72.68 62.88340 82.47660 57.69739 87.66261
## May 2024 72.68 61.36786 83.99214 55.37957 89.98043
## Jun 2024 72.68 60.03264 85.32736 53.33753 92.02247
## Jul 2024 72.68 58.82551 86.53449 51.49139 93.86861
## Aug 2024 72.68 57.71544 87.64456 49.79368 95.56632
## Sep 2024 72.68 56.68221 88.67779 48.21350 97.14650
## Oct 2024 72.68 55.71178 89.64822 46.72935 98.63065
## Nov 2024 72.68 54.79393 90.56607 45.32562 100.03438
## Dec 2024 72.68 53.92093 91.43907 43.99048 101.36952
## Jan 2025 72.68 53.08679 92.27321 42.71478 102.64522
## Feb 2025 72.68 52.28674 93.07326 41.49121 103.86879
## Mar 2025 72.68 51.51692 93.84308 40.31386 105.04614
## Apr 2025 72.68 50.77413 94.58587 39.17786 106.18214
## May 2025 72.68 50.05571 95.30429 38.07914 107.28086
## Jun 2025 72.68 49.35942 96.00058 37.01425 108.34575
## Jul 2025 72.68 48.68332 96.67668 35.98025 109.37975
## Aug 2025 72.68 48.02576 97.33424 34.97459 110.38541
## Sep 2025 72.68 47.38528 97.97472 33.99506 111.36494
## Oct 2025 72.68 46.76062 98.59938 33.03973 112.32027
## Nov 2025 72.68 46.15067 99.20933 32.10689 113.25311
## Dec 2025 72.68 45.55443 99.80557 31.19503 114.16497
## Jan 2026 72.68 44.97102 100.38898 30.30277 115.05723
## Feb 2026 72.68 44.39964 100.96036 29.42892 115.93108
## Mar 2026 72.68 43.83958 101.52042 28.57238 116.78762
## Apr 2026 72.68 43.29019 102.06981 27.73216 117.62784
## May 2026 72.68 42.75088 102.60912 26.90736 118.45264
## Jun 2026 72.68 42.22112 103.13888 26.09717 119.26283
## Jul 2026 72.68 41.70042 103.65958 25.30082 120.05918
plot(proy2)
# TSLA
proy3 <- forecast::forecast(autoARTSLA, h = 30)
proy3
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## Feb 2024 191.97 145.836586 238.1034 121.415032 262.5250
## Mar 2024 191.97 126.727500 257.2125 92.190207 291.7498
## Apr 2024 191.97 112.064583 271.8754 69.765211 314.1748
## May 2024 191.97 99.703172 284.2368 50.860064 333.0799
## Jun 2024 191.97 88.812551 295.1274 34.204295 349.7357
## Jul 2024 191.97 78.966676 304.9733 19.146330 364.7937
## Aug 2024 191.97 69.912460 314.0275 5.299101 378.6409
## Sep 2024 191.97 61.485001 322.4550 -7.589585 391.5296
## Oct 2024 191.97 53.569758 330.3702 -19.694904 403.6349
## Nov 2024 191.97 46.083336 337.8567 -31.144399 415.0844
## Dec 2024 191.97 38.962776 344.9772 -42.034356 425.9744
## Jan 2025 191.97 32.159166 351.7808 -52.439579 436.3796
## Feb 2025 191.97 25.633611 358.3064 -62.419555 446.3596
## Mar 2025 191.97 19.354571 364.5854 -72.022517 455.9625
## Apr 2025 191.97 13.296056 370.6439 -81.288216 465.2282
## May 2025 191.97 7.436344 376.5037 -90.249872 474.1899
## Jun 2025 191.97 1.757062 382.1829 -98.935585 482.8756
## Jul 2025 191.97 -3.757499 387.6975 -107.369378 491.3094
## Aug 2025 191.97 -9.120889 393.0609 -115.571975 499.5120
## Sep 2025 191.97 -14.344899 398.2849 -123.561409 507.5014
## Oct 2025 191.97 -19.439861 403.3799 -131.353481 515.2935
## Nov 2025 191.97 -24.414892 408.3549 -138.962134 522.9021
## Dec 2025 191.97 -29.278081 413.2181 -146.399740 530.3397
## Jan 2026 191.97 -34.036648 417.9766 -153.677341 537.6173
## Feb 2026 191.97 -38.697069 422.6371 -160.804840 544.7448
## Mar 2026 191.97 -43.265178 427.2052 -167.791159 551.7312
## Apr 2026 191.97 -47.746250 431.6863 -174.644368 558.5844
## May 2026 191.97 -52.145081 436.0851 -181.371798 565.3118
## Jun 2026 191.97 -56.466037 440.4060 -187.980131 571.9201
## Jul 2026 191.97 -60.713114 444.6531 -194.475475 578.4155
plot(proy3)
garchspecs <- ugarchspec(mean.model = list(armaOrder = c(0,0)),
variance.model = list(model = "sGARCH"),
distribution.model = "norm")
# PFE
PFEfitoilbrent <- ugarchfit(data = PFEclose, spec = garchspecs)
## Warning in .sgarchfit(spec = spec, data = data, out.sample = out.sample, :
## ugarchfit-->waring: using less than 100 data
## points for estimation
ugarchforecast(fitORspec = PFEfitoilbrent, n.ahead = 30)
##
## *------------------------------------*
## * GARCH Model Forecast *
## *------------------------------------*
## Model: sGARCH
## Horizon: 30
## Roll Steps: 0
## Out of Sample: 0
##
## 0-roll forecast [T0=Jan 2024]:
## Series Sigma
## T+1 36.22 7.718
## T+2 36.22 7.997
## T+3 36.22 8.266
## T+4 36.22 8.527
## T+5 36.22 8.780
## T+6 36.22 9.025
## T+7 36.22 9.264
## T+8 36.22 9.496
## T+9 36.22 9.723
## T+10 36.22 9.944
## T+11 36.22 10.160
## T+12 36.22 10.372
## T+13 36.22 10.579
## T+14 36.22 10.782
## T+15 36.22 10.980
## T+16 36.22 11.176
## T+17 36.22 11.367
## T+18 36.22 11.556
## T+19 36.22 11.741
## T+20 36.22 11.923
## T+21 36.22 12.102
## T+22 36.22 12.278
## T+23 36.22 12.452
## T+24 36.22 12.623
## T+25 36.22 12.792
## T+26 36.22 12.958
## T+27 36.22 13.122
## T+28 36.22 13.284
## T+29 36.22 13.444
## T+30 36.22 13.601
# NVDA
NVDAfitoilbrent <- ugarchfit(data = NVDAclose, spec = garchspecs)
## Warning in .sgarchfit(spec = spec, data = data, out.sample = out.sample, :
## ugarchfit-->waring: using less than 100 data
## points for estimation
ugarchforecast(fitORspec = NVDAfitoilbrent, n.ahead = 30)
##
## *------------------------------------*
## * GARCH Model Forecast *
## *------------------------------------*
## Model: sGARCH
## Horizon: 30
## Roll Steps: 0
## Out of Sample: 0
##
## 0-roll forecast [T0=Jan 2024]:
## Series Sigma
## T+1 134.2 632.4
## T+2 134.2 632.3
## T+3 134.2 632.1
## T+4 134.2 632.0
## T+5 134.2 631.9
## T+6 134.2 631.8
## T+7 134.2 631.7
## T+8 134.2 631.5
## T+9 134.2 631.4
## T+10 134.2 631.3
## T+11 134.2 631.2
## T+12 134.2 631.1
## T+13 134.2 630.9
## T+14 134.2 630.8
## T+15 134.2 630.7
## T+16 134.2 630.6
## T+17 134.2 630.5
## T+18 134.2 630.3
## T+19 134.2 630.2
## T+20 134.2 630.1
## T+21 134.2 630.0
## T+22 134.2 629.9
## T+23 134.2 629.7
## T+24 134.2 629.6
## T+25 134.2 629.5
## T+26 134.2 629.4
## T+27 134.2 629.3
## T+28 134.2 629.1
## T+29 134.2 629.0
## T+30 134.2 628.9
# BIMBOA
BIMBOAfitoilbrent <- ugarchfit(data = BIMBOAclose, spec = garchspecs)
## Warning in .sgarchfit(spec = spec, data = data, out.sample = out.sample, :
## ugarchfit-->waring: using less than 100 data
## points for estimation
ugarchforecast(fitORspec = BIMBOAfitoilbrent, n.ahead = 30)
##
## *------------------------------------*
## * GARCH Model Forecast *
## *------------------------------------*
## Model: sGARCH
## Horizon: 30
## Roll Steps: 0
## Out of Sample: 0
##
## 0-roll forecast [T0=Jan 2024]:
## Series Sigma
## T+1 41.16 31.55
## T+2 41.16 31.58
## T+3 41.16 31.61
## T+4 41.16 31.63
## T+5 41.16 31.66
## T+6 41.16 31.69
## T+7 41.16 31.72
## T+8 41.16 31.74
## T+9 41.16 31.77
## T+10 41.16 31.80
## T+11 41.16 31.83
## T+12 41.16 31.85
## T+13 41.16 31.88
## T+14 41.16 31.91
## T+15 41.16 31.94
## T+16 41.16 31.96
## T+17 41.16 31.99
## T+18 41.16 32.02
## T+19 41.16 32.04
## T+20 41.16 32.07
## T+21 41.16 32.10
## T+22 41.16 32.12
## T+23 41.16 32.15
## T+24 41.16 32.18
## T+25 41.16 32.20
## T+26 41.16 32.23
## T+27 41.16 32.26
## T+28 41.16 32.28
## T+29 41.16 32.31
## T+30 41.16 32.34
# TSLA
TSLAfitoilbrent <- ugarchfit(data = TSLAclose, spec = garchspecs)
## Warning in .sgarchfit(spec = spec, data = data, out.sample = out.sample, :
## ugarchfit-->waring: using less than 100 data
## points for estimation
ugarchforecast(fitORspec = TSLAfitoilbrent, n.ahead = 30)
##
## *------------------------------------*
## * GARCH Model Forecast *
## *------------------------------------*
## Model: sGARCH
## Horizon: 30
## Roll Steps: 0
## Out of Sample: 0
##
## 0-roll forecast [T0=Jan 2024]:
## Series Sigma
## T+1 222.9 32.38
## T+2 222.9 31.92
## T+3 222.9 31.48
## T+4 222.9 31.05
## T+5 222.9 30.63
## T+6 222.9 30.23
## T+7 222.9 29.83
## T+8 222.9 29.45
## T+9 222.9 29.08
## T+10 222.9 28.72
## T+11 222.9 28.37
## T+12 222.9 28.03
## T+13 222.9 27.71
## T+14 222.9 27.39
## T+15 222.9 27.08
## T+16 222.9 26.78
## T+17 222.9 26.49
## T+18 222.9 26.21
## T+19 222.9 25.94
## T+20 222.9 25.68
## T+21 222.9 25.43
## T+22 222.9 25.18
## T+23 222.9 24.95
## T+24 222.9 24.72
## T+25 222.9 24.50
## T+26 222.9 24.28
## T+27 222.9 24.07
## T+28 222.9 23.87
## T+29 222.9 23.68
## T+30 222.9 23.49