Alumno: Ávila Castillo Uriel
options(scipen = 999)
library(readxl)
Bitcoin=read_excel("Bitcoin.xlsx")
print(Bitcoin, n= 93)
## # A tibble: 93 × 2
## Fecha Cierre
## <dttm> <dbl>
## 1 2015-01-01 00:00:00 218.
## 2 2015-02-01 00:00:00 254.
## 3 2015-03-01 00:00:00 244.
## 4 2015-04-01 00:00:00 236.
## 5 2015-05-01 00:00:00 230.
## 6 2015-06-01 00:00:00 264.
## 7 2015-07-01 00:00:00 284.
## 8 2015-08-01 00:00:00 230.
## 9 2015-09-01 00:00:00 236.
## 10 2015-10-01 00:00:00 311.
## 11 2015-11-01 00:00:00 378
## 12 2015-12-01 00:00:00 430
## 13 2016-01-01 00:00:00 370.
## 14 2016-02-01 00:00:00 436.
## 15 2016-03-01 00:00:00 416.
## 16 2016-04-01 00:00:00 448.
## 17 2016-05-01 00:00:00 529.
## 18 2016-06-01 00:00:00 670
## 19 2016-07-01 00:00:00 622.
## 20 2016-08-01 00:00:00 574.
## 21 2016-09-01 00:00:00 608.
## 22 2016-10-01 00:00:00 699.
## 23 2016-11-01 00:00:00 742.
## 24 2016-12-01 00:00:00 963.
## 25 2017-01-01 00:00:00 966.
## 26 2017-02-01 00:00:00 1189.
## 27 2017-03-01 00:00:00 1079.
## 28 2017-04-01 00:00:00 1352.
## 29 2017-05-01 00:00:00 2303.
## 30 2017-06-01 00:00:00 2481.
## 31 2017-07-01 00:00:00 2883.
## 32 2017-08-01 00:00:00 4735.
## 33 2017-09-01 00:00:00 4361.
## 34 2017-10-01 00:00:00 6451.
## 35 2017-11-01 00:00:00 9947.
## 36 2017-12-01 00:00:00 13850.
## 37 2018-01-01 00:00:00 10265.
## 38 2018-02-01 00:00:00 10334.
## 39 2018-03-01 00:00:00 6938.
## 40 2018-04-01 00:00:00 9245.
## 41 2018-05-01 00:00:00 7503.
## 42 2018-06-01 00:00:00 6399.
## 43 2018-07-01 00:00:00 7729.
## 44 2018-08-01 00:00:00 7034.
## 45 2018-09-01 00:00:00 6635.
## 46 2018-10-01 00:00:00 6366.
## 47 2018-11-01 00:00:00 4040.
## 48 2018-12-01 00:00:00 3709.
## 49 2019-01-01 00:00:00 3437.
## 50 2019-02-01 00:00:00 3817.
## 51 2019-03-01 00:00:00 4102.
## 52 2019-04-01 00:00:00 5321.
## 53 2019-05-01 00:00:00 8558.
## 54 2019-06-01 00:00:00 10819.
## 55 2019-07-01 00:00:00 10082
## 56 2019-08-01 00:00:00 9594.
## 57 2019-09-01 00:00:00 8284.
## 58 2019-10-01 00:00:00 9153.
## 59 2019-11-01 00:00:00 7547.
## 60 2019-12-01 00:00:00 7196.
## 61 2020-01-01 00:00:00 9349.
## 62 2020-02-01 00:00:00 8544.
## 63 2020-03-01 00:00:00 6412.
## 64 2020-04-01 00:00:00 8629
## 65 2020-05-01 00:00:00 9455.
## 66 2020-06-01 00:00:00 9135.
## 67 2020-07-01 00:00:00 11333.
## 68 2020-08-01 00:00:00 11644.
## 69 2020-09-01 00:00:00 10776.
## 70 2020-10-01 00:00:00 13797.
## 71 2020-11-01 00:00:00 19698.
## 72 2020-12-01 00:00:00 28949.
## 73 2021-01-01 00:00:00 33108.
## 74 2021-02-01 00:00:00 45164
## 75 2021-03-01 00:00:00 58764.
## 76 2021-04-01 00:00:00 57720.
## 77 2021-05-01 00:00:00 37299.
## 78 2021-06-01 00:00:00 35027.
## 79 2021-07-01 00:00:00 41554.
## 80 2021-08-01 00:00:00 47130.
## 81 2021-09-01 00:00:00 43823.
## 82 2021-10-01 00:00:00 61310.
## 83 2021-11-01 00:00:00 56883.
## 84 2021-12-01 00:00:00 46220.
## 85 2022-01-01 00:00:00 38499.
## 86 2022-02-01 00:00:00 43188.
## 87 2022-03-01 00:00:00 45525
## 88 2022-04-01 00:00:00 37650
## 89 2022-05-01 00:00:00 31793.
## 90 2022-06-01 00:00:00 19927.
## 91 2022-07-01 00:00:00 23303.
## 92 2022-08-01 00:00:00 20044.
## 93 2022-09-01 00:00:00 19385.
summary(Bitcoin$Cierre)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 218.5 963.4 7196.4 13195.0 13850.4 61309.6
attach(Bitcoin)
library(moments)
kurtosis(Bitcoin$Cierre)
## [1] 3.99902
skewness(Bitcoin$Cierre)
## [1] 1.476649
precio=ts(Bitcoin$Cierre,
start = c(2015,1),
frequency = 12)
print(precio)
## Jan Feb Mar Apr May Jun Jul Aug Sep
## 2015 218.5 254.1 244.1 235.8 229.8 264.1 283.7 229.5 235.9
## 2016 369.8 436.2 415.7 448.5 528.9 670.0 621.9 573.9 608.1
## 2017 965.5 1189.3 1079.1 1351.9 2303.3 2480.6 2883.3 4735.1 4360.6
## 2018 10265.4 10333.9 6938.2 9245.1 7502.6 6398.9 7729.4 7033.8 6635.2
## 2019 3437.2 3816.6 4102.3 5320.8 8558.3 10818.6 10082.0 9594.4 8284.3
## 2020 9349.1 8543.7 6412.5 8629.0 9454.8 9135.4 11333.4 11644.2 10776.1
## 2021 33108.1 45164.0 58763.7 57720.3 37298.6 35026.9 41553.7 47130.4 43823.3
## 2022 38498.6 43188.2 45525.0 37650.0 31793.4 19926.6 23303.4 20043.9 19384.8
## Oct Nov Dec
## 2015 311.2 378.0 430.0
## 2016 698.7 742.5 963.4
## 2017 6451.2 9946.8 13850.4
## 2018 6365.9 4039.7 3709.4
## 2019 9152.6 7546.6 7196.4
## 2020 13797.3 19698.1 28949.4
## 2021 61309.6 56882.9 46219.5
## 2022
plot(precio, type = 'l', col = '#54008B',lwd = '2',
main ='Bitcoin 2015-2022',
xlab = 'Periodo',
ylab = 'USD')

hist(precio, probability = T, col = '#17BAAE',
main = 'Histograma del precio del Bitcoin',
xlab = 'USD',
ylab = 'Densidad')
lines(density(precio), col = '#A40A8A', lwd = '2')

boxplot(precio, col = '#FFFF00', horizontal = T,
main ='Diagrama de caja del Bitcoin')

#Serie de tiempo desestacionalizada
library(seasonal)
precio_n= seas(precio, x11 = '')
plot(precio_n,
xlab = 'Periodo',
ylab = 'USD',
main ='Serie original y ajustada del Bitcoin')
grid()

#Descomposición serie de tiempo
precio_des=decompose(precio, 'multiplicative')
plot(precio_des, col = '#00FA9A', lwd = '2',
xlab = 'Periodo',)

plot(precio, col = '#AE347B', lwd = '2.5',xlab = 'Periodo',)

plot(precio_des$trend, col = '#C0DE35', lwd = '2.5', xlab = 'Periodo',)

plot(precio_des$seasonal, col = '#0BD0D9', lwd = '2.5', xlab = 'Periodo',)

plot(precio_des$random, col = '#FD9B6B', lwd = '2.5', xlab = 'Periodo',)

#Gráfica del índice estacional
plot(precio_des$figure,
type = 'b',
xlab = 'Mes',
ylab = '',
col = '#7B68EE',
las = 1,
main = 'Índice Estacional')
grid()
library(ggplot2)

library(forecast)
## Registered S3 method overwritten by 'quantmod':
## method from
## as.zoo.data.frame zoo
ggseasonplot(precio,
year.labels = T,
year.labels.left = T)+
ylab('USD')+
xlab('Mes') +
ggtitle('Desgloce del Bitcoin')

#Gráfico polar
ggseasonplot(precio,
polar = T)+
ylab('USD')+
xlab('Mes')+
ggtitle('Gráfico polar del Bitcoin')

#Filtro Holdrick Prescott
library("mFilter")
hplambda=14400
preciohp=hpfilter(precio,
type="lambda",
freq=hplambda)
plot(preciohp)

#Filtro Christiano Fitzgerald
preciocf=cffilter(precio)
plot(preciocf)
