Descomposición de Series de Tiempo
A continuación se presentan cuatro funciones. La primera corresponde a la obtención de la tendencia a través de medias móviles para una serie de tiempo, la segunda regresa la estacionalidad de la misma serie de tiempo. La tercera consiste en la extracción del componente aleatorio de una serie de tiempo. Por último, la función descomponer, regresa una lista que incluye un data frame con la tendencia, estacionalidad, componente aleatorio de una serie de tiempo, además de un gráfico que presenta el comportamiento de estos tres elementos.
Además de presentar las funciones, se presentan ejemplos del funcionamiento de cada una de éstas. Las tres bases da datos que se utilizan para los ejemplos son AirPassengers, austourists y births, ambas obtenidas de paqueterías de R.
Función TENDENCIA
Función que regresa la tendencia, calculada a través de medias móviles, de una determinada serie de tiempo y representación gráfica de ésta.
Parámetros:
- s: objeto de la clase ts. En caso contrario, la función regresa un error.
- mm: orden de la media móvil con la que se desea trabajar.
tendencia<-function(s,mm) {
if(class(s)=="ts"){
s<-as.numeric(s)
mean_number<-ma(s, mm, centre=TRUE)
mm<-na.omit(mean_number); mean_number<-as.numeric(mean_number)
if(mm[1]<mm[length(mm)]){tendencia <-"La tendencia de la serie es creciente"
} else if(mm[1]>mm[length(mm)]){tendencia <- "La tendencia de la serie es decreciente"
}else{ tendencia<-"La tendencias de la serie es constante"}
Tiempo<-c(1:length(s))
Tiempo1<-c(1:length(mean_number))
g1<-ggplot()+geom_line(aes(x=Tiempo, y=mean_number), color="dodgerblue2", size=1.1)+
labs(x="Tiempo", y="Tendencia", title = "Tendencia con Medias Moviles",
subtitle = tendencia)+theme_bw()+theme(plot.title = element_text(hjust = 0.5))+theme(plot.subtitle = element_text(hjust = 0.5))
return(list(g1, mean_number))
return(list(g1, mean_number))
}else{
stop('class(s) is not ts')
}
}Ejemplos Funcionamiento tendencia
tendencia(AirPassengers,12)## [[1]]
##
## [[2]]
## [1] NA NA NA NA NA NA 126.7917
## [8] 127.2500 127.9583 128.5833 129.0000 129.7500 131.2500 133.0833
## [15] 134.9167 136.4167 137.4167 138.7500 140.9167 143.1667 145.7083
## [22] 148.4167 151.5417 154.7083 157.1250 159.5417 161.8333 164.1250
## [29] 166.6667 169.0833 171.2500 173.5833 175.4583 176.8333 178.0417
## [36] 180.1667 183.1250 186.2083 189.0417 191.2917 193.5833 195.8333
## [43] 198.0417 199.7500 202.2083 206.2500 210.4167 213.3750 215.8333
## [50] 218.5000 220.9167 222.9167 224.0833 224.7083 225.3333 225.3333
## [57] 224.9583 224.5833 224.4583 225.5417 228.0000 230.4583 232.2500
## [64] 233.9167 235.6250 237.7500 240.5000 243.9583 247.1667 250.2500
## [71] 253.5000 257.1250 261.8333 266.6667 271.1250 275.2083 278.5000
## [78] 281.9583 285.7500 289.3333 293.2500 297.1667 301.0000 305.4583
## [85] 309.9583 314.4167 318.6250 321.7500 324.5000 327.0833 329.5417
## [92] 331.8333 334.4583 337.5417 340.5417 344.0833 348.2500 353.0000
## [99] 357.6250 361.3750 364.5000 367.1667 369.4583 371.2083 372.1667
## [106] 372.4167 372.7500 373.6250 375.2500 377.9167 379.5000 380.0000
## [113] 380.7083 380.9583 381.8333 383.6667 386.5000 390.3333 394.7083
## [120] 398.6250 402.5417 407.1667 411.8750 416.3333 420.5000 425.5000
## [127] 430.7083 435.1250 437.7083 440.9583 445.8333 450.6250 456.3333
## [134] 461.3750 465.2083 469.3333 472.7500 475.0417 NA NA
## [141] NA NA NA NA
tendencia(austourists,4)## [[1]]
##
## [[2]]
## [1] NA NA 25.78053 26.57595 27.51317 28.84949 30.38628
## [8] 31.17142 31.64208 31.11912 30.29069 30.11820 29.79408 30.00233
## [15] 30.20401 29.51495 29.04504 29.42736 30.53539 32.15744 32.85228
## [22] 32.76858 32.90685 32.63683 32.81611 33.58934 34.41724 35.64101
## [29] 36.82342 38.04890 39.09107 39.65636 40.03997 39.87465 39.84313
## [36] 40.21967 40.71559 41.54218 42.50517 43.29460 43.67732 44.04831
## [43] 44.80807 45.50171 45.94975 46.51410 NA NA
tendencia(birthsts,12)## [[1]]
##
## [[2]]
## [1] NA NA NA NA NA NA 23.98433
## [8] 23.66213 23.42333 23.16112 22.86425 22.54521 22.35350 22.30871
## [15] 22.30258 22.29479 22.29354 22.30562 22.33483 22.31167 22.26279
## [22] 22.25796 22.27767 22.35400 22.43038 22.43667 22.38721 22.35242
## [29] 22.32458 22.27458 22.23754 22.21988 22.16983 22.07721 22.01396
## [36] 22.02604 22.06375 22.08033 22.13317 22.16604 22.17542 22.21342
## [43] 22.27625 22.35750 22.48862 22.70992 22.98563 23.16346 23.21663
## [50] 23.26967 23.33492 23.42679 23.50638 23.57017 23.63888 23.75713
## [57] 23.86354 23.89533 23.87342 23.88150 24.00083 24.12350 24.20917
## [64] 24.28208 24.35450 24.43242 24.49496 24.48379 24.43879 24.36829
## [71] 24.29192 24.27642 24.27204 24.27300 24.28942 24.30129 24.31325
## [78] 24.35175 24.40558 24.44475 24.49325 24.58517 24.70429 24.76017
## [85] 24.78646 24.84992 24.92692 25.02362 25.16308 25.26963 25.30154
## [92] 25.34125 25.42779 25.57588 25.73904 25.87513 25.92446 25.92317
## [99] 25.92967 25.92137 25.89567 25.89458 25.92963 25.98246 26.01054
## [106] 25.88617 25.67087 25.57312 25.64612 25.78679 25.93192 26.06388
## [113] 26.16329 26.25388 26.35471 26.40496 26.45379 26.64933 26.95183
## [120] 27.14683 27.21104 27.21900 27.20700 27.26925 27.35050 27.37983
## [127] 27.39975 27.44150 27.45229 27.43354 27.44488 27.46996 27.44221
## [134] 27.40283 27.44300 27.45717 27.44429 27.48975 27.54354 27.56933
## [141] 27.63167 27.67804 27.62579 27.61212 27.68642 27.76067 27.75963
## [148] 27.71037 27.65783 27.58125 27.49075 27.46183 27.42262 27.34175
## [155] 27.25129 27.08558 26.96858 27.00512 27.09250 27.17263 27.26208
## [162] 27.36033 NA NA NA NA NA NA
Función SEAS
Función que regresa la estacionalidad de una determinada serie de tiempo y representación gráfica de este elemento.
Parámetros:
- s: objeto de la clase ts. En caso contrario, la función regresa un error.
- tipo: tipo de descomposición de la serie de tiempo. Únicamente acepta los valores aditiva y multiplicativa. En caso contrario, la función regresa un error.
- temporalidad: periodicidad que se supone tiene la serie de tiempo
- mm: orden de la media móvil con la que se desea trabajar.
seas <- function(s, tipo, temporalidad, mm){
if(class(s)=="ts"){
if(tipo=="aditiva"){
tend<-tendencia(s,mm); s<-as.numeric(s)
detrend<-s-tend[[2]]
m<-t(matrix(data = detrend, nrow = 4))
seas<-colMeans(m, na.rm=TRUE)
seas<-rep_len(seas, length.out = length(s))
df<-data.frame(Tiempo=c(1:length(s)), Serie=s, Tendencia=tend[[2]], Estacionalidad=seas)
g1<-ggplot(df)+geom_line(aes(x=Tiempo, y=Estacionalidad), color="olivedrab4", size=1.1)+
geom_point(aes(x=Tiempo, y=Estacionalidad), color="deepskyblue4")+
labs(x="Tiempo", y="Estacionalidad", title = "Estacionalidad de Serie de Tiempo")+theme_bw()+
theme(plot.title = element_text(hjust = 0.5))
return(list(g1, df$Estacionalidad))
}else if(tipo=="multiplicativa"){
tend<-tendencia(s,mm); s<-as.numeric(s)
detrend<-s/tend[[2]]
m<-t(matrix(data = detrend, nrow = 4))
seas<-colMeans(m, na.rm=TRUE)
seas<-rep_len(seas, length.out = length(s))
df<-data.frame(Tiempo=c(1:length(s)), Serie=s, Tendencia=tend[[2]], Estacionalidad=seas)
g1<-ggplot(df)+geom_line(aes(x=Tiempo, y=Estacionalidad), color="olivedrab4", size=1.1)+
geom_point(aes(x=Tiempo, y=Estacionalidad), color="deepskyblue4")+
labs(x="Tiempo", y="Estacionalidad", title = "Estacionalidad de Serie de Tiempo")+theme_bw()+
theme(plot.title = element_text(hjust = 0.5))
return(list(g1, df$Estacionalidad))
}else {stop('the parameter is not correct')}
}else{stop('class(s1) is not ts')}
}Ejemplos Funcionamiento estacionalidad
seas(AirPassengers, "multiplicativa",12,12)## [[1]]
##
## [[2]]
## [1] 0.9822973 0.9710033 1.0099150 1.0297271 0.9822973 0.9710033 1.0099150
## [8] 1.0297271 0.9822973 0.9710033 1.0099150 1.0297271 0.9822973 0.9710033
## [15] 1.0099150 1.0297271 0.9822973 0.9710033 1.0099150 1.0297271 0.9822973
## [22] 0.9710033 1.0099150 1.0297271 0.9822973 0.9710033 1.0099150 1.0297271
## [29] 0.9822973 0.9710033 1.0099150 1.0297271 0.9822973 0.9710033 1.0099150
## [36] 1.0297271 0.9822973 0.9710033 1.0099150 1.0297271 0.9822973 0.9710033
## [43] 1.0099150 1.0297271 0.9822973 0.9710033 1.0099150 1.0297271 0.9822973
## [50] 0.9710033 1.0099150 1.0297271 0.9822973 0.9710033 1.0099150 1.0297271
## [57] 0.9822973 0.9710033 1.0099150 1.0297271 0.9822973 0.9710033 1.0099150
## [64] 1.0297271 0.9822973 0.9710033 1.0099150 1.0297271 0.9822973 0.9710033
## [71] 1.0099150 1.0297271 0.9822973 0.9710033 1.0099150 1.0297271 0.9822973
## [78] 0.9710033 1.0099150 1.0297271 0.9822973 0.9710033 1.0099150 1.0297271
## [85] 0.9822973 0.9710033 1.0099150 1.0297271 0.9822973 0.9710033 1.0099150
## [92] 1.0297271 0.9822973 0.9710033 1.0099150 1.0297271 0.9822973 0.9710033
## [99] 1.0099150 1.0297271 0.9822973 0.9710033 1.0099150 1.0297271 0.9822973
## [106] 0.9710033 1.0099150 1.0297271 0.9822973 0.9710033 1.0099150 1.0297271
## [113] 0.9822973 0.9710033 1.0099150 1.0297271 0.9822973 0.9710033 1.0099150
## [120] 1.0297271 0.9822973 0.9710033 1.0099150 1.0297271 0.9822973 0.9710033
## [127] 1.0099150 1.0297271 0.9822973 0.9710033 1.0099150 1.0297271 0.9822973
## [134] 0.9710033 1.0099150 1.0297271 0.9822973 0.9710033 1.0099150 1.0297271
## [141] 0.9822973 0.9710033 1.0099150 1.0297271
seas(austourists, "aditiva",4,4)## [[1]]
##
## [[2]]
## [1] 8.592085 -8.321386 -1.770521 1.505685 8.592085 -8.321386 -1.770521
## [8] 1.505685 8.592085 -8.321386 -1.770521 1.505685 8.592085 -8.321386
## [15] -1.770521 1.505685 8.592085 -8.321386 -1.770521 1.505685 8.592085
## [22] -8.321386 -1.770521 1.505685 8.592085 -8.321386 -1.770521 1.505685
## [29] 8.592085 -8.321386 -1.770521 1.505685 8.592085 -8.321386 -1.770521
## [36] 1.505685 8.592085 -8.321386 -1.770521 1.505685 8.592085 -8.321386
## [43] -1.770521 1.505685 8.592085 -8.321386 -1.770521 1.505685
seas(birthsts, "aditiva", 12, 12)## [[1]]
##
## [[2]]
## [1] 0.04554594 -0.53013568 0.35978953 -0.04777991 0.04554594
## [6] -0.53013568 0.35978953 -0.04777991 0.04554594 -0.53013568
## [11] 0.35978953 -0.04777991 0.04554594 -0.53013568 0.35978953
## [16] -0.04777991 0.04554594 -0.53013568 0.35978953 -0.04777991
## [21] 0.04554594 -0.53013568 0.35978953 -0.04777991 0.04554594
## [26] -0.53013568 0.35978953 -0.04777991 0.04554594 -0.53013568
## [31] 0.35978953 -0.04777991 0.04554594 -0.53013568 0.35978953
## [36] -0.04777991 0.04554594 -0.53013568 0.35978953 -0.04777991
## [41] 0.04554594 -0.53013568 0.35978953 -0.04777991 0.04554594
## [46] -0.53013568 0.35978953 -0.04777991 0.04554594 -0.53013568
## [51] 0.35978953 -0.04777991 0.04554594 -0.53013568 0.35978953
## [56] -0.04777991 0.04554594 -0.53013568 0.35978953 -0.04777991
## [61] 0.04554594 -0.53013568 0.35978953 -0.04777991 0.04554594
## [66] -0.53013568 0.35978953 -0.04777991 0.04554594 -0.53013568
## [71] 0.35978953 -0.04777991 0.04554594 -0.53013568 0.35978953
## [76] -0.04777991 0.04554594 -0.53013568 0.35978953 -0.04777991
## [81] 0.04554594 -0.53013568 0.35978953 -0.04777991 0.04554594
## [86] -0.53013568 0.35978953 -0.04777991 0.04554594 -0.53013568
## [91] 0.35978953 -0.04777991 0.04554594 -0.53013568 0.35978953
## [96] -0.04777991 0.04554594 -0.53013568 0.35978953 -0.04777991
## [101] 0.04554594 -0.53013568 0.35978953 -0.04777991 0.04554594
## [106] -0.53013568 0.35978953 -0.04777991 0.04554594 -0.53013568
## [111] 0.35978953 -0.04777991 0.04554594 -0.53013568 0.35978953
## [116] -0.04777991 0.04554594 -0.53013568 0.35978953 -0.04777991
## [121] 0.04554594 -0.53013568 0.35978953 -0.04777991 0.04554594
## [126] -0.53013568 0.35978953 -0.04777991 0.04554594 -0.53013568
## [131] 0.35978953 -0.04777991 0.04554594 -0.53013568 0.35978953
## [136] -0.04777991 0.04554594 -0.53013568 0.35978953 -0.04777991
## [141] 0.04554594 -0.53013568 0.35978953 -0.04777991 0.04554594
## [146] -0.53013568 0.35978953 -0.04777991 0.04554594 -0.53013568
## [151] 0.35978953 -0.04777991 0.04554594 -0.53013568 0.35978953
## [156] -0.04777991 0.04554594 -0.53013568 0.35978953 -0.04777991
## [161] 0.04554594 -0.53013568 0.35978953 -0.04777991 0.04554594
## [166] -0.53013568 0.35978953 -0.04777991
Función E_ALEATORIO
Función que regresa el error/componente aleatorio de una determinada serie de tiempo y representación gráfica de este elemento.
Parámetros:
- s: objeto de la clase ts. En caso contrario, la función regresa un error.
- tipo: tipo de descomposición de la serie de tiempo. Únicamente acepta los valores aditiva y multiplicativa. En caso contrario, la función regresa un error.
- temporalidad: periodicidad que se supone tiene la serie de tiempo
- mm: orden de la media móvil con la que se desea trabajar.
e_aleatorio<-function(s, tipo, temporalidad, mm){
if(class(s)=="ts"){
if(tipo=="aditiva"){
tend<-tendencia(s,mm)
est <- seas(s, tipo, temporalidad, mm)
s<-as.numeric(s)
error<-s-tend[[2]]-est[[2]]
df<-data.frame(Tiempo=c(1:length(s)), Error=error)
g1<-ggplot(df)+geom_line(aes(x=Tiempo, y=Error), color="mediumpurple1", size=1.1)+
geom_point(aes(x=Tiempo, y=Error), color="purple4")+
labs(x="Tiempo", y="Error Aleatorio", title = "Error Aleatorio de Serie de Tiempo")+theme_bw()+
theme(plot.title = element_text(hjust = 0.5))
return(list(g1,error))
}else if(tipo=="multiplicativa"){
tend<-tendencia(s,mm)
est <- seas(s, tipo, temporalidad, mm)
s<-as.numeric(s)
error<-s/(tend[[2]]*est[[2]])
df<-data.frame(Tiempo=c(1:length(s)), Error=as.numeric(error))
g1<-ggplot(df)+geom_line(aes(x=Tiempo, y=Error), color="mediumpurple1", size=1.1)+
geom_point(aes(x=Tiempo, y=Error), color="purple4")+
labs(x="Tiempo", y="Error Aleatorio", title = "Error Aleatorio de Serie de Tiempo")+theme_bw()+
theme(plot.title = element_text(hjust = 0.5))
return(list(g1,error))
}else(stop('the parameter is not correct'))
}else{stop('class(s1) is not ts')}
}Ejemplos Funcionamiento e_aleatorio
e_aleatorio(AirPassengers, "multiplicativa",12,12)## [[1]]
##
## [[2]]
## [1] NA NA NA NA NA NA 1.1558093
## [8] 1.1294884 1.0820003 0.9531069 0.7982866 0.8831866 0.8919810 0.9750484
## [15] 1.0348292 0.9610460 0.9260356 1.1059426 1.1945429 1.1531475 1.1039001
## [22] 0.9228865 0.7448828 0.8788043 0.9394632 0.9682699 1.0890986 0.9644744
## [29] 1.0505985 1.0841728 1.1506353 1.1133274 1.0675811 0.9434746 0.8119820
## [36] 0.8947702 0.9506169 0.9955262 1.0109157 0.9188833 0.9623658 1.1464344
## [43] 1.1499698 1.1765393 1.0522145 0.9537152 0.8094005 0.8829499 0.9244738
## [50] 0.9238127 1.0577882 1.0237718 1.0403584 1.1136954 1.1600953 1.1722529
## [57] 1.0725149 0.9675741 0.7940575 0.8654602 0.9108616 0.8401266 1.0019068
## [64] 0.9424158 1.0110009 1.1435699 1.2433891 1.1663525 1.0667605 0.9424118
## [71] 0.7929271 0.8649062 0.9409087 0.8998425 0.9751173 0.9492236 0.9869511
## [78] 1.1505485 1.2613347 1.1646860 1.0831127 0.9495761 0.7796452 0.8838339
## [85] 0.9327647 0.9073055 0.9851324 0.9447211 0.9976300 1.1775856 1.2409518
## [92] 1.1852579 1.0805463 0.9336269 0.7879782 0.8636457 0.9208237 0.8781549
## [99] 0.9856831 0.9351881 0.9914890 1.1836642 1.2462428 1.2217350 1.1050984
## [106] 0.9595767 0.8102096 0.8733357 0.9223915 0.8665834 0.9445218 0.8893516
## [113] 0.9706693 1.1759561 1.2732768 1.2782481 1.0641159 0.9471922 0.7776794
## [120] 0.8210001 0.9104345 0.8650341 0.9760584 0.9237019 1.0168113 1.1424094
## [127] 1.2598315 1.2476007 1.0768451 0.9505526 0.8039911 0.8728057 0.9302741
## [134] 0.8727744 0.8918293 0.9538880 1.0164067 1.1598488 NA NA
## [141] NA NA NA NA
e_aleatorio(austourists, "aditiva",4,4)## [[1]]
##
## [[2]]
## [1] NA NA 1.3076859 -0.4902018 -4.0287966 2.9598589
## [7] -0.1398198 2.4466508 -3.3956851 2.2092809 2.2020659 -2.9301234
## [13] -1.7451768 2.1436669 0.8781962 0.7496747 -2.4592448 -1.3307317
## [19] 0.8368778 0.8757206 -0.1707630 2.2086686 -2.8564703 1.0486361
## [25] 0.3192624 -1.2260994 -0.3186173 0.1820096 0.7976445 -0.3811887
## [31] -0.8376422 1.8156767 0.2694747 -0.3730411 -0.3547245 -1.3051443
## [37] 1.8991844 -1.3335623 0.2436100 -1.0277926 3.2891579 -1.8760132
## [43] -0.9611616 -1.3651062 5.2249426 -3.0008391 NA NA
e_aleatorio(birthsts, "aditiva", 12, 12)## [[1]]
##
## [[2]]
## [1] NA NA NA NA NA
## [6] NA 0.132877137 0.286654915 -0.293879274 0.596010684
## [11] -1.552039530 -0.627428419 -0.960045940 -0.689572650 1.046627137
## [16] -0.578011752 -0.587087607 -1.014489316 0.784377137 1.560113248
## [21] 0.796662393 1.382177350 -0.878456197 -0.233220085 -0.538920940
## [26] -1.871530983 0.843002137 -0.632636752 -0.148129274 0.378552350
## [31] 1.352668803 1.331904915 0.022620726 1.594927350 -1.314747863
## [36] -0.405261752 -0.561295940 -1.550197650 -0.068956197 -1.503261752
## [41] -0.459962607 1.190719017 1.467960470 1.438279915 0.727829060
## [46] 0.727219017 -1.826414530 -1.090678419 -0.658170940 -1.845530983
## [51] 0.982293803 0.293988248 1.768079060 0.542969017 0.672335470
## [56] 0.744654915 0.212912393 0.886802350 -2.149206197 -0.842720085
## [61] -0.759379274 -0.544364316 0.507043803 -0.197303419 0.029954060
## [66] 0.764719017 1.596252137 1.181988248 0.529662393 1.271844017
## [71] -1.687706197 -0.247636752 -0.519587607 -1.472864316 0.125793803
## [76] -1.607511752 -0.370795940 0.915385684 1.510627137 1.419029915
## [81] 0.671204060 1.143969017 -1.902081197 -0.005386752 -0.468004274
## [86] -1.675780983 0.278293803 -0.913845085 0.222370726 -0.104489316
## [91] 1.347668803 1.312529915 0.794662393 1.416260684 -0.852831197
## [96] -0.647345085 -1.313004274 -2.089030983 0.692543803 0.325404915
## [101] 1.268787393 0.757552350 0.416585470 0.943321581 0.095912393
## [106] 1.022969017 -1.318664530 0.162654915 -0.701670940 -1.017655983
## [111] 0.429293803 -2.541095085 -1.441837607 0.495260684 1.646502137
## [116] 2.241821581 1.414662393 1.664802350 -1.618622863 -0.218053419
## [121] -1.039587607 -2.470864316 0.347210470 -0.246470085 1.130954060
## [126] 0.289302350 1.222460470 0.775279915 0.558162393 2.232594017
## [131] -1.513664530 -0.435178419 -0.898754274 -2.024697650 -0.259789530
## [136] -0.513386752 1.388162393 0.430385684 0.161668803 0.619446581
## [141] 1.370787393 1.336094017 -1.351581197 0.170654915 -0.599962607
## [146] -2.306530983 0.843585470 -1.073595085 0.227620726 0.957885684
## [151] 1.378460470 1.344946581 0.936829060 1.133385684 -1.699081197
## [156] -0.418803419 -0.938129274 -1.188989316 0.207710470 -1.173845085
## [161] -0.909629274 -1.265197650 NA NA NA
## [166] NA NA NA
Función DESCOMPONER
Función que regresa una lista de dos elementos. El primero, una base de datos con los valores de la serie de tiempo, la tendencia, estacionalidad y componente aleatorio de ésta en cada punto. Además, regresa un gráfico que muestra el comportamiento de cada uno de los componentes mencionados anteriormente.
Parámetros:
- s: objeto de la clase ts. En caso contrario, la función regresa un error.
- tipo: tipo de descomposición de la serie de tiempo. Únicamente acepta los valores aditiva y multiplicativa. En caso contrario, la función regresa un error.
- temporalidad: periodicidad que se supone tiene la serie de tiempo
- mm: orden de la media móvil con la que se desea trabajar.
descomponer <- function(s, tipo, temporalidad, mm){
if(class(s)=="ts"){
if(tipo=="aditiva" | tipo=="multiplicativa"){
tend<-tendencia(s,mm)
est<-seas(s, tipo, temporalidad, mm)
error <- e_aleatorio(s, tipo, temporalidad, mm)
df<-data.frame(Tiempo=c(1:length(s)), Serie=as.numeric(s), Tendencia=tend[[2]], Estacionalidad=est[[2]], Comp_Aleatorio=error[[2]])
g1<-ggplot(df)+geom_line(aes(x=Tiempo, y=Serie), color="sienna2", size=1.2)+
geom_point(aes(x=Tiempo, y=Serie), color="sienna4")+labs(x="Tiempo", y="Serie", title = "Serie de Tiempo")+
theme_bw()+theme(plot.title = element_text(hjust = 0.5))
plots<-grid.arrange(g1, tend[[1]], est[[1]], error[[1]], ncol=1)
return(list(df, plots))
} else{stop('the parameter is not correct')}
}else{stop('class(s) is not ts')}
}Ejemplos Funcionamiento descomponer
descomponer(AirPassengers, "multiplicativa",12 ,12)## [[1]]
## Tiempo Serie Tendencia Estacionalidad Comp_Aleatorio
## 1 1 112 NA 0.9822973 NA
## 2 2 118 NA 0.9710033 NA
## 3 3 132 NA 1.0099150 NA
## 4 4 129 NA 1.0297271 NA
## 5 5 121 NA 0.9822973 NA
## 6 6 135 NA 0.9710033 NA
## 7 7 148 126.7917 1.0099150 1.1558093
## 8 8 148 127.2500 1.0297271 1.1294884
## 9 9 136 127.9583 0.9822973 1.0820003
## 10 10 119 128.5833 0.9710033 0.9531069
## 11 11 104 129.0000 1.0099150 0.7982866
## 12 12 118 129.7500 1.0297271 0.8831866
## 13 13 115 131.2500 0.9822973 0.8919810
## 14 14 126 133.0833 0.9710033 0.9750484
## 15 15 141 134.9167 1.0099150 1.0348292
## 16 16 135 136.4167 1.0297271 0.9610460
## 17 17 125 137.4167 0.9822973 0.9260356
## 18 18 149 138.7500 0.9710033 1.1059426
## 19 19 170 140.9167 1.0099150 1.1945429
## 20 20 170 143.1667 1.0297271 1.1531475
## 21 21 158 145.7083 0.9822973 1.1039001
## 22 22 133 148.4167 0.9710033 0.9228865
## 23 23 114 151.5417 1.0099150 0.7448828
## 24 24 140 154.7083 1.0297271 0.8788043
## 25 25 145 157.1250 0.9822973 0.9394632
## 26 26 150 159.5417 0.9710033 0.9682699
## 27 27 178 161.8333 1.0099150 1.0890986
## 28 28 163 164.1250 1.0297271 0.9644744
## 29 29 172 166.6667 0.9822973 1.0505985
## 30 30 178 169.0833 0.9710033 1.0841728
## 31 31 199 171.2500 1.0099150 1.1506353
## 32 32 199 173.5833 1.0297271 1.1133274
## 33 33 184 175.4583 0.9822973 1.0675811
## 34 34 162 176.8333 0.9710033 0.9434746
## 35 35 146 178.0417 1.0099150 0.8119820
## 36 36 166 180.1667 1.0297271 0.8947702
## 37 37 171 183.1250 0.9822973 0.9506169
## 38 38 180 186.2083 0.9710033 0.9955262
## 39 39 193 189.0417 1.0099150 1.0109157
## 40 40 181 191.2917 1.0297271 0.9188833
## 41 41 183 193.5833 0.9822973 0.9623658
## 42 42 218 195.8333 0.9710033 1.1464344
## 43 43 230 198.0417 1.0099150 1.1499698
## 44 44 242 199.7500 1.0297271 1.1765393
## 45 45 209 202.2083 0.9822973 1.0522145
## 46 46 191 206.2500 0.9710033 0.9537152
## 47 47 172 210.4167 1.0099150 0.8094005
## 48 48 194 213.3750 1.0297271 0.8829499
## 49 49 196 215.8333 0.9822973 0.9244738
## 50 50 196 218.5000 0.9710033 0.9238127
## 51 51 236 220.9167 1.0099150 1.0577882
## 52 52 235 222.9167 1.0297271 1.0237718
## 53 53 229 224.0833 0.9822973 1.0403584
## 54 54 243 224.7083 0.9710033 1.1136954
## 55 55 264 225.3333 1.0099150 1.1600953
## 56 56 272 225.3333 1.0297271 1.1722529
## 57 57 237 224.9583 0.9822973 1.0725149
## 58 58 211 224.5833 0.9710033 0.9675741
## 59 59 180 224.4583 1.0099150 0.7940575
## 60 60 201 225.5417 1.0297271 0.8654602
## 61 61 204 228.0000 0.9822973 0.9108616
## 62 62 188 230.4583 0.9710033 0.8401266
## 63 63 235 232.2500 1.0099150 1.0019068
## 64 64 227 233.9167 1.0297271 0.9424158
## 65 65 234 235.6250 0.9822973 1.0110009
## 66 66 264 237.7500 0.9710033 1.1435699
## 67 67 302 240.5000 1.0099150 1.2433891
## 68 68 293 243.9583 1.0297271 1.1663525
## 69 69 259 247.1667 0.9822973 1.0667605
## 70 70 229 250.2500 0.9710033 0.9424118
## 71 71 203 253.5000 1.0099150 0.7929271
## 72 72 229 257.1250 1.0297271 0.8649062
## 73 73 242 261.8333 0.9822973 0.9409087
## 74 74 233 266.6667 0.9710033 0.8998425
## 75 75 267 271.1250 1.0099150 0.9751173
## 76 76 269 275.2083 1.0297271 0.9492236
## 77 77 270 278.5000 0.9822973 0.9869511
## 78 78 315 281.9583 0.9710033 1.1505485
## 79 79 364 285.7500 1.0099150 1.2613347
## 80 80 347 289.3333 1.0297271 1.1646860
## 81 81 312 293.2500 0.9822973 1.0831127
## 82 82 274 297.1667 0.9710033 0.9495761
## 83 83 237 301.0000 1.0099150 0.7796452
## 84 84 278 305.4583 1.0297271 0.8838339
## 85 85 284 309.9583 0.9822973 0.9327647
## 86 86 277 314.4167 0.9710033 0.9073055
## 87 87 317 318.6250 1.0099150 0.9851324
## 88 88 313 321.7500 1.0297271 0.9447211
## 89 89 318 324.5000 0.9822973 0.9976300
## 90 90 374 327.0833 0.9710033 1.1775856
## 91 91 413 329.5417 1.0099150 1.2409518
## 92 92 405 331.8333 1.0297271 1.1852579
## 93 93 355 334.4583 0.9822973 1.0805463
## 94 94 306 337.5417 0.9710033 0.9336269
## 95 95 271 340.5417 1.0099150 0.7879782
## 96 96 306 344.0833 1.0297271 0.8636457
## 97 97 315 348.2500 0.9822973 0.9208237
## 98 98 301 353.0000 0.9710033 0.8781549
## 99 99 356 357.6250 1.0099150 0.9856831
## 100 100 348 361.3750 1.0297271 0.9351881
## 101 101 355 364.5000 0.9822973 0.9914890
## 102 102 422 367.1667 0.9710033 1.1836642
## 103 103 465 369.4583 1.0099150 1.2462428
## 104 104 467 371.2083 1.0297271 1.2217350
## 105 105 404 372.1667 0.9822973 1.1050984
## 106 106 347 372.4167 0.9710033 0.9595767
## 107 107 305 372.7500 1.0099150 0.8102096
## 108 108 336 373.6250 1.0297271 0.8733357
## 109 109 340 375.2500 0.9822973 0.9223915
## 110 110 318 377.9167 0.9710033 0.8665834
## 111 111 362 379.5000 1.0099150 0.9445218
## 112 112 348 380.0000 1.0297271 0.8893516
## 113 113 363 380.7083 0.9822973 0.9706693
## 114 114 435 380.9583 0.9710033 1.1759561
## 115 115 491 381.8333 1.0099150 1.2732768
## 116 116 505 383.6667 1.0297271 1.2782481
## 117 117 404 386.5000 0.9822973 1.0641159
## 118 118 359 390.3333 0.9710033 0.9471922
## 119 119 310 394.7083 1.0099150 0.7776794
## 120 120 337 398.6250 1.0297271 0.8210001
## 121 121 360 402.5417 0.9822973 0.9104345
## 122 122 342 407.1667 0.9710033 0.8650341
## 123 123 406 411.8750 1.0099150 0.9760584
## 124 124 396 416.3333 1.0297271 0.9237019
## 125 125 420 420.5000 0.9822973 1.0168113
## 126 126 472 425.5000 0.9710033 1.1424094
## 127 127 548 430.7083 1.0099150 1.2598315
## 128 128 559 435.1250 1.0297271 1.2476007
## 129 129 463 437.7083 0.9822973 1.0768451
## 130 130 407 440.9583 0.9710033 0.9505526
## 131 131 362 445.8333 1.0099150 0.8039911
## 132 132 405 450.6250 1.0297271 0.8728057
## 133 133 417 456.3333 0.9822973 0.9302741
## 134 134 391 461.3750 0.9710033 0.8727744
## 135 135 419 465.2083 1.0099150 0.8918293
## 136 136 461 469.3333 1.0297271 0.9538880
## 137 137 472 472.7500 0.9822973 1.0164067
## 138 138 535 475.0417 0.9710033 1.1598488
## 139 139 622 NA 1.0099150 NA
## 140 140 606 NA 1.0297271 NA
## 141 141 508 NA 0.9822973 NA
## 142 142 461 NA 0.9710033 NA
## 143 143 390 NA 1.0099150 NA
## 144 144 432 NA 1.0297271 NA
##
## [[2]]
## TableGrob (4 x 1) "arrange": 4 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (2-2,1-1) arrange gtable[layout]
## 3 3 (3-3,1-1) arrange gtable[layout]
## 4 4 (4-4,1-1) arrange gtable[layout]
descomponer(austourists, "aditiva",4,4)## [[1]]
## Tiempo Serie Tendencia Estacionalidad Comp_Aleatorio
## 1 1 30.05251 NA 8.592085 NA
## 2 2 19.14850 NA -8.321386 NA
## 3 3 25.31769 25.78053 -1.770521 1.3076859
## 4 4 27.59144 26.57595 1.505685 -0.4902018
## 5 5 32.07646 27.51317 8.592085 -4.0287966
## 6 6 23.48796 28.84949 -8.321386 2.9598589
## 7 7 28.47594 30.38628 -1.770521 -0.1398198
## 8 8 35.12375 31.17142 1.505685 2.4466508
## 9 9 36.83848 31.64208 8.592085 -3.3956851
## 10 10 25.00702 31.11912 -8.321386 2.2092809
## 11 11 30.72223 30.29069 -1.770521 2.2020659
## 12 12 28.69376 30.11820 1.505685 -2.9301234
## 13 13 36.64099 29.79408 8.592085 -1.7451768
## 14 14 23.82461 30.00233 -8.321386 2.1436669
## 15 15 29.31168 30.20401 -1.770521 0.8781962
## 16 16 31.77031 29.51495 1.505685 0.7496747
## 17 17 35.17788 29.04504 8.592085 -2.4592448
## 18 18 19.77524 29.42736 -8.321386 -1.3307317
## 19 19 29.60175 30.53539 -1.770521 0.8368778
## 20 20 34.53884 32.15744 1.505685 0.8757206
## 21 21 41.27360 32.85228 8.592085 -0.1707630
## 22 22 26.65586 32.76858 -8.321386 2.2086686
## 23 23 28.27986 32.90685 -1.770521 -2.8564703
## 24 24 35.19115 32.63683 1.505685 1.0486361
## 25 25 41.72746 32.81611 8.592085 0.3192624
## 26 26 24.04185 33.58934 -8.321386 -1.2260994
## 27 27 32.32810 34.41724 -1.770521 -0.3186173
## 28 28 37.32871 35.64101 1.505685 0.1820096
## 29 29 46.21315 36.82342 8.592085 0.7976445
## 30 30 29.34633 38.04890 -8.321386 -0.3811887
## 31 31 36.48291 39.09107 -1.770521 -0.8376422
## 32 32 42.97772 39.65636 1.505685 1.8156767
## 33 33 48.90152 40.03997 8.592085 0.2694747
## 34 34 31.18022 39.87465 -8.321386 -0.3730411
## 35 35 37.71788 39.84313 -1.770521 -0.3547245
## 36 36 40.42021 40.21967 1.505685 -1.3051443
## 37 37 51.20686 40.71559 8.592085 1.8991844
## 38 38 31.88723 41.54218 -8.321386 -1.3335623
## 39 39 40.97826 42.50517 -1.770521 0.2436100
## 40 40 43.77249 43.29460 1.505685 -1.0277926
## 41 41 55.55857 43.67732 8.592085 3.2891579
## 42 42 33.85092 44.04831 -8.321386 -1.8760132
## 43 43 42.07638 44.80807 -1.770521 -0.9611616
## 44 44 45.64229 45.50171 1.505685 -1.3651062
## 45 45 59.76678 45.94975 8.592085 5.2249426
## 46 46 35.19188 46.51410 -8.321386 -3.0008391
## 47 47 44.31974 NA -1.770521 NA
## 48 48 47.91374 NA 1.505685 NA
##
## [[2]]
## TableGrob (4 x 1) "arrange": 4 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (2-2,1-1) arrange gtable[layout]
## 3 3 (3-3,1-1) arrange gtable[layout]
## 4 4 (4-4,1-1) arrange gtable[layout]
descomponer(birthsts, "aditiva",12,12)## [[1]]
## Tiempo Serie Tendencia Estacionalidad Comp_Aleatorio
## 1 1 26.663 NA 0.04554594 NA
## 2 2 23.598 NA -0.53013568 NA
## 3 3 26.931 NA 0.35978953 NA
## 4 4 24.740 NA -0.04777991 NA
## 5 5 25.806 NA 0.04554594 NA
## 6 6 24.364 NA -0.53013568 NA
## 7 7 24.477 23.98433 0.35978953 0.132877137
## 8 8 23.901 23.66213 -0.04777991 0.286654915
## 9 9 23.175 23.42333 0.04554594 -0.293879274
## 10 10 23.227 23.16112 -0.53013568 0.596010684
## 11 11 21.672 22.86425 0.35978953 -1.552039530
## 12 12 21.870 22.54521 -0.04777991 -0.627428419
## 13 13 21.439 22.35350 0.04554594 -0.960045940
## 14 14 21.089 22.30871 -0.53013568 -0.689572650
## 15 15 23.709 22.30258 0.35978953 1.046627137
## 16 16 21.669 22.29479 -0.04777991 -0.578011752
## 17 17 21.752 22.29354 0.04554594 -0.587087607
## 18 18 20.761 22.30562 -0.53013568 -1.014489316
## 19 19 23.479 22.33483 0.35978953 0.784377137
## 20 20 23.824 22.31167 -0.04777991 1.560113248
## 21 21 23.105 22.26279 0.04554594 0.796662393
## 22 22 23.110 22.25796 -0.53013568 1.382177350
## 23 23 21.759 22.27767 0.35978953 -0.878456197
## 24 24 22.073 22.35400 -0.04777991 -0.233220085
## 25 25 21.937 22.43038 0.04554594 -0.538920940
## 26 26 20.035 22.43667 -0.53013568 -1.871530983
## 27 27 23.590 22.38721 0.35978953 0.843002137
## 28 28 21.672 22.35242 -0.04777991 -0.632636752
## 29 29 22.222 22.32458 0.04554594 -0.148129274
## 30 30 22.123 22.27458 -0.53013568 0.378552350
## 31 31 23.950 22.23754 0.35978953 1.352668803
## 32 32 23.504 22.21988 -0.04777991 1.331904915
## 33 33 22.238 22.16983 0.04554594 0.022620726
## 34 34 23.142 22.07721 -0.53013568 1.594927350
## 35 35 21.059 22.01396 0.35978953 -1.314747863
## 36 36 21.573 22.02604 -0.04777991 -0.405261752
## 37 37 21.548 22.06375 0.04554594 -0.561295940
## 38 38 20.000 22.08033 -0.53013568 -1.550197650
## 39 39 22.424 22.13317 0.35978953 -0.068956197
## 40 40 20.615 22.16604 -0.04777991 -1.503261752
## 41 41 21.761 22.17542 0.04554594 -0.459962607
## 42 42 22.874 22.21342 -0.53013568 1.190719017
## 43 43 24.104 22.27625 0.35978953 1.467960470
## 44 44 23.748 22.35750 -0.04777991 1.438279915
## 45 45 23.262 22.48862 0.04554594 0.727829060
## 46 46 22.907 22.70992 -0.53013568 0.727219017
## 47 47 21.519 22.98563 0.35978953 -1.826414530
## 48 48 22.025 23.16346 -0.04777991 -1.090678419
## 49 49 22.604 23.21663 0.04554594 -0.658170940
## 50 50 20.894 23.26967 -0.53013568 -1.845530983
## 51 51 24.677 23.33492 0.35978953 0.982293803
## 52 52 23.673 23.42679 -0.04777991 0.293988248
## 53 53 25.320 23.50638 0.04554594 1.768079060
## 54 54 23.583 23.57017 -0.53013568 0.542969017
## 55 55 24.671 23.63888 0.35978953 0.672335470
## 56 56 24.454 23.75713 -0.04777991 0.744654915
## 57 57 24.122 23.86354 0.04554594 0.212912393
## 58 58 24.252 23.89533 -0.53013568 0.886802350
## 59 59 22.084 23.87342 0.35978953 -2.149206197
## 60 60 22.991 23.88150 -0.04777991 -0.842720085
## 61 61 23.287 24.00083 0.04554594 -0.759379274
## 62 62 23.049 24.12350 -0.53013568 -0.544364316
## 63 63 25.076 24.20917 0.35978953 0.507043803
## 64 64 24.037 24.28208 -0.04777991 -0.197303419
## 65 65 24.430 24.35450 0.04554594 0.029954060
## 66 66 24.667 24.43242 -0.53013568 0.764719017
## 67 67 26.451 24.49496 0.35978953 1.596252137
## 68 68 25.618 24.48379 -0.04777991 1.181988248
## 69 69 25.014 24.43879 0.04554594 0.529662393
## 70 70 25.110 24.36829 -0.53013568 1.271844017
## 71 71 22.964 24.29192 0.35978953 -1.687706197
## 72 72 23.981 24.27642 -0.04777991 -0.247636752
## 73 73 23.798 24.27204 0.04554594 -0.519587607
## 74 74 22.270 24.27300 -0.53013568 -1.472864316
## 75 75 24.775 24.28942 0.35978953 0.125793803
## 76 76 22.646 24.30129 -0.04777991 -1.607511752
## 77 77 23.988 24.31325 0.04554594 -0.370795940
## 78 78 24.737 24.35175 -0.53013568 0.915385684
## 79 79 26.276 24.40558 0.35978953 1.510627137
## 80 80 25.816 24.44475 -0.04777991 1.419029915
## 81 81 25.210 24.49325 0.04554594 0.671204060
## 82 82 25.199 24.58517 -0.53013568 1.143969017
## 83 83 23.162 24.70429 0.35978953 -1.902081197
## 84 84 24.707 24.76017 -0.04777991 -0.005386752
## 85 85 24.364 24.78646 0.04554594 -0.468004274
## 86 86 22.644 24.84992 -0.53013568 -1.675780983
## 87 87 25.565 24.92692 0.35978953 0.278293803
## 88 88 24.062 25.02362 -0.04777991 -0.913845085
## 89 89 25.431 25.16308 0.04554594 0.222370726
## 90 90 24.635 25.26963 -0.53013568 -0.104489316
## 91 91 27.009 25.30154 0.35978953 1.347668803
## 92 92 26.606 25.34125 -0.04777991 1.312529915
## 93 93 26.268 25.42779 0.04554594 0.794662393
## 94 94 26.462 25.57588 -0.53013568 1.416260684
## 95 95 25.246 25.73904 0.35978953 -0.852831197
## 96 96 25.180 25.87513 -0.04777991 -0.647345085
## 97 97 24.657 25.92446 0.04554594 -1.313004274
## 98 98 23.304 25.92317 -0.53013568 -2.089030983
## 99 99 26.982 25.92967 0.35978953 0.692543803
## 100 100 26.199 25.92137 -0.04777991 0.325404915
## 101 101 27.210 25.89567 0.04554594 1.268787393
## 102 102 26.122 25.89458 -0.53013568 0.757552350
## 103 103 26.706 25.92963 0.35978953 0.416585470
## 104 104 26.878 25.98246 -0.04777991 0.943321581
## 105 105 26.152 26.01054 0.04554594 0.095912393
## 106 106 26.379 25.88617 -0.53013568 1.022969017
## 107 107 24.712 25.67087 0.35978953 -1.318664530
## 108 108 25.688 25.57312 -0.04777991 0.162654915
## 109 109 24.990 25.64612 0.04554594 -0.701670940
## 110 110 24.239 25.78679 -0.53013568 -1.017655983
## 111 111 26.721 25.93192 0.35978953 0.429293803
## 112 112 23.475 26.06388 -0.04777991 -2.541095085
## 113 113 24.767 26.16329 0.04554594 -1.441837607
## 114 114 26.219 26.25388 -0.53013568 0.495260684
## 115 115 28.361 26.35471 0.35978953 1.646502137
## 116 116 28.599 26.40496 -0.04777991 2.241821581
## 117 117 27.914 26.45379 0.04554594 1.414662393
## 118 118 27.784 26.64933 -0.53013568 1.664802350
## 119 119 25.693 26.95183 0.35978953 -1.618622863
## 120 120 26.881 27.14683 -0.04777991 -0.218053419
## 121 121 26.217 27.21104 0.04554594 -1.039587607
## 122 122 24.218 27.21900 -0.53013568 -2.470864316
## 123 123 27.914 27.20700 0.35978953 0.347210470
## 124 124 26.975 27.26925 -0.04777991 -0.246470085
## 125 125 28.527 27.35050 0.04554594 1.130954060
## 126 126 27.139 27.37983 -0.53013568 0.289302350
## 127 127 28.982 27.39975 0.35978953 1.222460470
## 128 128 28.169 27.44150 -0.04777991 0.775279915
## 129 129 28.056 27.45229 0.04554594 0.558162393
## 130 130 29.136 27.43354 -0.53013568 2.232594017
## 131 131 26.291 27.44488 0.35978953 -1.513664530
## 132 132 26.987 27.46996 -0.04777991 -0.435178419
## 133 133 26.589 27.44221 0.04554594 -0.898754274
## 134 134 24.848 27.40283 -0.53013568 -2.024697650
## 135 135 27.543 27.44300 0.35978953 -0.259789530
## 136 136 26.896 27.45717 -0.04777991 -0.513386752
## 137 137 28.878 27.44429 0.04554594 1.388162393
## 138 138 27.390 27.48975 -0.53013568 0.430385684
## 139 139 28.065 27.54354 0.35978953 0.161668803
## 140 140 28.141 27.56933 -0.04777991 0.619446581
## 141 141 29.048 27.63167 0.04554594 1.370787393
## 142 142 28.484 27.67804 -0.53013568 1.336094017
## 143 143 26.634 27.62579 0.35978953 -1.351581197
## 144 144 27.735 27.61212 -0.04777991 0.170654915
## 145 145 27.132 27.68642 0.04554594 -0.599962607
## 146 146 24.924 27.76067 -0.53013568 -2.306530983
## 147 147 28.963 27.75963 0.35978953 0.843585470
## 148 148 26.589 27.71037 -0.04777991 -1.073595085
## 149 149 27.931 27.65783 0.04554594 0.227620726
## 150 150 28.009 27.58125 -0.53013568 0.957885684
## 151 151 29.229 27.49075 0.35978953 1.378460470
## 152 152 28.759 27.46183 -0.04777991 1.344946581
## 153 153 28.405 27.42262 0.04554594 0.936829060
## 154 154 27.945 27.34175 -0.53013568 1.133385684
## 155 155 25.912 27.25129 0.35978953 -1.699081197
## 156 156 26.619 27.08558 -0.04777991 -0.418803419
## 157 157 26.076 26.96858 0.04554594 -0.938129274
## 158 158 25.286 27.00512 -0.53013568 -1.188989316
## 159 159 27.660 27.09250 0.35978953 0.207710470
## 160 160 25.951 27.17263 -0.04777991 -1.173845085
## 161 161 26.398 27.26208 0.04554594 -0.909629274
## 162 162 25.565 27.36033 -0.53013568 -1.265197650
## 163 163 28.865 NA 0.35978953 NA
## 164 164 30.000 NA -0.04777991 NA
## 165 165 29.261 NA 0.04554594 NA
## 166 166 29.012 NA -0.53013568 NA
## 167 167 26.992 NA 0.35978953 NA
## 168 168 27.897 NA -0.04777991 NA
##
## [[2]]
## TableGrob (4 x 1) "arrange": 4 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (2-2,1-1) arrange gtable[layout]
## 3 3 (3-3,1-1) arrange gtable[layout]
## 4 4 (4-4,1-1) arrange gtable[layout]