Librerías Implementadas
library(raster)
library(tiff)
library(ggplot2)
library(forecast)
Condiciones Necesarias
n=16 # numero de mapas de Covid19
Representante<- matrix(nrow = n, ncol = 1)
Semana <- matrix(nrow = n, ncol = 1)
Lectura de Imágenes y ejecución de la descomposición
for(k in 1:n){
concat <- gsub(' ','',paste(k,'.tif'))
direc <- file.path('C:/Users/Fabian Navarro/Google Drive/Proyecto_Covid19DMD/mapas',concat)
mapa_matriz <- readTIFF(direc)
dimen<- dim(mapa_matriz)
for(j in 1:dimen[1]){
for(i in 1:dimen[2]){
if(mapa_matriz[i,j]<(-1)){
mapa_matriz[i,j]=0
}
}
}
Des_svd <- svd(mapa_matriz)
Representante[k,1]<- Des_svd$d[1]
Semana[k,1]<- paste('Semana',k)
}
Serie de Tiempo
DB <- data.frame(Semana,Representante)
Representantes <- ts(DB$Representante, frequency = 2)
plot(Representantes, xlab= "Semanas", main= "COVID19")

Comportamiento \(ARMA(p,q)\)
auto.arima(Representantes)
## Series: Representantes
## ARIMA(0,0,0)(1,0,0)[2] with non-zero mean
##
## Coefficients:
## sar1 mean
## -0.5469 61.8728
## s.e. 0.2618 4.2920
##
## sigma^2 estimated as 731.6: log likelihood=-74.75
## AIC=155.5 AICc=157.5 BIC=157.82
Descomposición de la serie de tiempo
var<- stl(Representantes, s.window="periodic", robust = TRUE)
plot(var)

Modelo Lineal Polinomial de Orden 3
modelo3<-lm(Representantes~time(Representantes)+I(time(Representantes)^2)+I(time(Representantes)^3))
summary(modelo3)#mod.cub #original
##
## Call:
## lm(formula = Representantes ~ time(Representantes) + I(time(Representantes)^2) +
## I(time(Representantes)^3))
##
## Residuals:
## Min 1Q Median 3Q Max
## -37.408 -14.805 -2.118 9.191 53.841
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -36.7563 53.2156 -0.691 0.503
## time(Representantes) 66.6097 44.0420 1.512 0.156
## I(time(Representantes)^2) -13.9456 10.3356 -1.349 0.202
## I(time(Representantes)^3) 0.9303 0.7183 1.295 0.220
##
## Residual standard error: 27.04 on 12 degrees of freedom
## Multiple R-squared: 0.3341, Adjusted R-squared: 0.1676
## F-statistic: 2.007 on 3 and 12 DF, p-value: 0.1668