library(readr)
library(dplyr)
library(purrr)
library(tidyverse)
library(fs)
library(lubridate)
library(copula)
library(seas)
library(MASS)
library(fitdistrplus)
library(lmomco)
library(PearsonDS)
# library(latticeExtra)
library(e1071)
library(VineCopula)
library(scatterplot3d)
library(invgamma)
library(janitor)
library(cowplot)
theme_set(theme_cowplot())
library(reshape2)
library(lubridate)
library(forecast)
library(tseries)
library(xtable)
library(VC2copula)
# library(ismev)
# library(extRemes)Proyecto Perdidas
Base de datos del clima
The data was obtained from the National Aeronautics and Space Administration (NASA) Langley Research Center (LaRC) Prediction of Worldwide Energy Resource (POWER) Project funded through the NASA Earth Science/Applied Science Program.
The data was obtained from the POWER Project’s Hourly 2.x.x version on 2023/09/03.
https://power.larc.nasa.gov/data-access-viewer/
https://power.larc.nasa.gov/docs/referencing/
clima <- read_csv("POWER_Point_Daily_19810101_20211231_040d7819N_073d9658W_LST.csv",
skip = 19)
# clima <- clima %>% dcast()
clima %>% glimpse()Rows: 14,975
Columns: 13
$ YEAR <dbl> 1981, 1981, 1981, 1981, 1981, 1981, 1981, 1981, 1981…
$ DOY <dbl> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1…
$ QV2M <dbl> 1.77, 2.01, 1.46, 0.73, 1.28, 1.89, 2.75, 1.10, 1.16…
$ RH2M <dbl> 80.56, 77.88, 81.19, 74.50, 83.56, 87.94, 88.44, 80.…
$ PRECTOTCORR <dbl> 0.69, 1.72, 1.44, 0.00, 0.05, 4.21, 6.14, 0.02, 0.07…
$ T2M <dbl> -6.70, -4.84, -8.85, -15.00, -10.31, -7.06, -2.99, -…
$ T2MDEW <dbl> -9.78, -8.49, -11.83, -18.46, -12.96, -8.99, -4.84, …
$ T2MWET <dbl> -8.24, -6.66, -10.34, -16.73, -11.63, -8.02, -3.92, …
$ TS <dbl> -6.18, -4.48, -8.02, -13.74, -9.60, -6.82, -2.71, -1…
$ T2M_RANGE <dbl> 3.84, 9.37, 5.12, 6.14, 9.42, 9.34, 10.84, 6.87, 8.5…
$ T2M_MAX <dbl> -4.52, 0.13, -6.03, -11.26, -4.79, -2.77, 1.13, -8.3…
$ T2M_MIN <dbl> -8.37, -9.24, -11.15, -17.40, -14.21, -12.10, -9.71,…
$ ALLSKY_SFC_LW_DWN <dbl> -999, -999, -999, -999, -999, -999, -999, -999, -999…
clima %>% head()# A tibble: 6 × 13
YEAR DOY QV2M RH2M PRECTOTCORR T2M T2MDEW T2MWET TS T2M_RANGE
<dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
1 1981 1 1.77 80.6 0.69 -6.7 -9.78 -8.24 -6.18 3.84
2 1981 2 2.01 77.9 1.72 -4.84 -8.49 -6.66 -4.48 9.37
3 1981 3 1.46 81.2 1.44 -8.85 -11.8 -10.3 -8.02 5.12
4 1981 4 0.73 74.5 0 -15 -18.5 -16.7 -13.7 6.14
5 1981 5 1.28 83.6 0.05 -10.3 -13.0 -11.6 -9.6 9.42
6 1981 6 1.89 87.9 4.21 -7.06 -8.99 -8.02 -6.82 9.34
# ℹ 3 more variables: T2M_MAX <dbl>, T2M_MIN <dbl>, ALLSKY_SFC_LW_DWN <dbl>
# Limpieza de datos
# Crea la columna de fecha
clima$DATE <- ymd(paste(clima$YEAR, "-01-01")) + days(clima$DOY - 1)
# Elimina las columnas DOY y YEAR
clima <- clima[, !(names(clima) %in% c("DOY", "YEAR"))]
clima1 <- clima[,c("DATE","RH2M","PRECTOTCORR","T2M")]
clima1 <- clima1 %>% mutate(grupo = "hist")
colnames(clima1) <- c("fecha", "hum", "prcp", "temp", "grupo")
# Temperatura y humedad
historic1 <- clima1[,c("fecha","hum", "temp", "grupo")]
historic1# A tibble: 14,975 × 4
fecha hum temp grupo
<date> <dbl> <dbl> <chr>
1 1981-01-01 80.6 -6.7 hist
2 1981-01-02 77.9 -4.84 hist
3 1981-01-03 81.2 -8.85 hist
4 1981-01-04 74.5 -15 hist
5 1981-01-05 83.6 -10.3 hist
6 1981-01-06 87.9 -7.06 hist
7 1981-01-07 88.4 -2.99 hist
8 1981-01-08 80.8 -11.7 hist
9 1981-01-09 79.4 -11.0 hist
10 1981-01-10 80.9 -9.52 hist
# ℹ 14,965 more rows
Transformacion de la humedad especifica a la relativa usando esta formula y el punto de saturacion: https://study.com/academy/lesson/what-is-relative-humidity-definition-equation-calculation.html
rcp2.6 = bind_cols(c(
read.sdsm(file = 'db adicionales/ces2shumgl.dat',
start = 2006, end = 2100, calendar = "365_day"),
read.sdsm(file = 'db adicionales/ces2tempgl.dat',
start = 2006, end = 2100, calendar = "365_day"))) %>%
mutate(humesp=V1...1*3.64+7.23, temp=V1...3*9.3+10.78) %>%
dplyr::select(-c(1,2,3)) %>%
rename(fecha = 1)%>%filter(2006<=year(fecha),year(fecha)<=2040) %>%
mutate(sat=6.11*10^((7.5*temp)/(273.3+temp))) %>%
mutate(hum=humesp*100/sat, grupo='rcp2.6') %>%
dplyr::select(-c(2,4))
rcp4.5 = bind_cols(c(
read.sdsm(file = 'db adicionales/ces4shumgl.dat',
start = 2006, end = 2100, calendar = "365_day"),
read.sdsm(file = 'db adicionales/ces4tempgl.dat',
start = 2006, end = 2100, calendar = "365_day"))) %>%
mutate(humesp=V1...1*3.64+7.23, temp=V1...3*9.3+10.78) %>%
dplyr::select(-c(1,2,3)) %>%
rename(fecha = 1)%>%filter(2006<=year(fecha),year(fecha)<=2040) %>%
mutate(sat=6.11*10^((7.5*temp)/(273.3+temp))) %>%
mutate(hum=humesp*100/sat, grupo='rcp4.5') %>%
dplyr::select(-c(2,4))
rcp8.5 = bind_cols(c(
read.sdsm(file = 'db adicionales/ces8shumgl.dat',
start = 2006, end = 2100, calendar = "365_day"),
read.sdsm(file = 'db adicionales/ces8tempgl.dat',
start = 2006, end = 2100, calendar = "365_day"))) %>%
mutate(humesp=V1...1*3.64+7.23, temp=V1...3*9.3+10.78) %>%
dplyr::select(-c(1,2,3)) %>%
rename(fecha = 1)%>%filter(2006<=year(fecha),year(fecha)<=2040) %>%
mutate(sat=6.11*10^((7.5*temp)/(273.3+temp))) %>%
mutate(hum=humesp*100/sat, grupo='rcp8.5') %>%
dplyr::select(-c(2,4))data <- rbind(historic1, rcp2.6, rcp4.5, rcp8.5) %>%
mutate (year=year(ymd(fecha)), mes=month(ymd(fecha)))
means <- data %>% group_by(mes,grupo,year) %>%
summarise_at(vars(temp,hum),mean)
correlation <- means %>% group_by(mes,grupo) %>%
summarize(t = cor.test(temp,hum,method="kendall")$estimate,
p = cor.test(temp,hum,method="kendall")$p.value) %>%
arrange(t)
correlation# A tibble: 48 × 4
# Groups: mes [12]
mes grupo t p
<dbl> <chr> <dbl> <dbl>
1 7 rcp8.5 -0.466 0.0000485
2 7 rcp2.6 -0.387 0.00109
3 9 rcp4.5 -0.382 0.00105
4 7 hist -0.378 0.000391
5 8 rcp4.5 -0.368 0.00162
6 7 rcp4.5 -0.361 0.00199
7 8 rcp8.5 -0.334 0.00437
8 6 rcp2.6 -0.328 0.00527
9 6 rcp4.5 -0.318 0.00693
10 8 hist -0.290 0.00720
# ℹ 38 more rows
Se escoge la data de Julio como la que tiene la mayor correlacion, graficamos las observaciones y pseudo obervaciones de temperatura-humedad
mesescogido <- 7
datafinalhist <- data %>% filter(mes==mesescogido, grupo=='hist')
datafinalrcp2.6 <- data %>% filter(mes==mesescogido, grupo=='rcp2.6')
datafinalrcp4.5 <- data %>% filter(mes==mesescogido, grupo=='rcp4.5')
datafinalrcp8.5 <- data %>% filter(mes==mesescogido, grupo=='rcp8.5')
histmat <- as.matrix(pobs(dplyr::select(datafinalhist,-c(1,4:6))))
rcp2.6mat <- as.matrix(pobs(dplyr::select(datafinalrcp2.6,-c(1,4:6))))
rcp4.5mat <- as.matrix(pobs(dplyr::select(datafinalrcp4.5,-c(1,4:6))))
rcp8.5mat <- as.matrix(pobs(dplyr::select(datafinalrcp8.5,-c(1,4:6))))
pdf(file = "Pseudoobservaciones.pdf",
width = 6, height = 6)
par(mfrow=c(2,2))
plot(histmat, main="Histórico", ylab= "Temperatura", xlab="Humedad")
plot(rcp2.6mat, main="RCP 2.6 \n (Bajas emisiones)", ylab= "Temperatura", xlab="Humedad")
plot(rcp4.5mat, main="RCP 4.5 \n (Emisiones intermedias)", ylab= "Temperatura", xlab="Humedad")
plot(rcp8.5mat, main="RCP 8.5 \n (Altas emisiones)", ylab= "Temperatura", xlab="Humedad")
dev.off()quartz_off_screen
2
histmat <- as.matrix(dplyr::select(datafinalhist,-c(1,4:6)))
rcp2.6mat <- as.matrix(dplyr::select(datafinalrcp2.6,-c(1,4:6)))
rcp4.5mat <- as.matrix(dplyr::select(datafinalrcp4.5,-c(1,4:6)))
rcp8.5mat <- as.matrix(dplyr::select(datafinalrcp8.5,-c(1,4:6)))
pdf(file = "Observaciones.pdf",
width = 6, height = 6)
par(mfrow=c(2,2))
plot(histmat, main="Histórico", ylab= "Temperatura", xlab="Humedad")
plot(rcp2.6mat, main="RCP 2.6 \n (Bajas emisiones)", ylab= "Temperatura", xlab="Humedad")
plot(rcp4.5mat, main="RCP 4.5 \n (Emisiones intermedias)", ylab= "Temperatura", xlab="Humedad")
plot(rcp8.5mat, main="RCP 8.5 \n (Altas emisiones)", ylab= "Temperatura", xlab="Humedad")
dev.off()quartz_off_screen
2
Comportamiento de la data y sus densidades para pensar en distribuciones marginales parametricas posibles.
datafinal <- means %>% filter(mes==7)
tplot <- ggplot(datafinal%>%filter(grupo!="hist"), aes(year, temp, colour= grupo)) + geom_line()
tplothplot <- ggplot(datafinal%>%filter(grupo!="hist"), aes(year, hum, colour= grupo)) + geom_line()
hplottden <- ggplot(datafinal, aes(temp)) + geom_histogram() + facet_wrap(~grupo)
tdenhden <- ggplot(datafinal, aes(hum)) + geom_histogram() + facet_wrap(~grupo)
hdenFit de distribuciones para las marginales de humedad y temperatura
dgumbel <- function(a, b) return(function(x){1/bexp((a-x)/b)exp(-exp((a-x)/b))})
dgumbel <- function(x, a, b) {1/bexp((a-x)/b)exp(-exp((a-x)/b))}
library(fitdistrplus)
library(extraDistr)
humfits <- datafinal %>% group_by(grupo) %>%
summarise(norm = fitdist(hum,'norm')$aic,
gam = fitdist(hum,'gamma')$aic,
chi = fitdist(hum,'chisq',start = list(df = 3))$aic,
wei = fitdist(hum,'weibull')$aic,
t = fitdist(hum,'t', start = list(df = 1))$aic,
cauchy = fitdist(hum,'cauchy')$aic,
lnorm = fitdist(hum,'lnorm')$aic,
gumbel = fitdist(hum,'gumbel',start=list(mu=10, sigma=10))$aic)
humfits# A tibble: 4 × 9
grupo norm gam chi wei t cauchy lnorm gumbel
<chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
1 hist 272. 274. 294. 270. 637. 287. 275. 283.
2 rcp2.6 193. 193. 231. 192. 510. 210. 194. 199.
3 rcp4.5 190. 190. 230. 200. 508. 200. 189. 189.
4 rcp8.5 197. 196. 231. 206. 507. 206. 196. 197.
tempfits <- datafinal %>% group_by(grupo) %>%
summarise(norm = fitdist(temp,'norm')$aic,
t = fitdist(temp,'t', start = list(df = 1))$aic,
cauchy = fitdist(temp,'cauchy')$aic,
gumbel = fitdist(temp,'gumbel',start=list(mu=10, sigma=10))$aic)
tempfits# A tibble: 4 × 5
grupo norm t cauchy gumbel
<chr> <dbl> <dbl> <dbl> <dbl>
1 hist 145. 523. 166. 149.
2 rcp2.6 113. 457. 125. 123.
3 rcp4.5 122. 458. 138. 125.
4 rcp8.5 120. 458. 137. 125.
besttempfit<-tempfits%>%pivot_longer(cols = -grupo,names_to ="Distribution")%>%
group_by(grupo)%>%mutate(minAIC=min(value))%>%filter(value==minAIC)
besthumfit<-humfits%>%pivot_longer(cols = -grupo,names_to ="Distribution")%>%
group_by(grupo)%>%mutate(minAIC=min(value))%>%filter(value==minAIC)Se escogen las distribuciones con menor AIC para cada grupo de temperatura y humedad
Humedad historica
library("gridExtra")
humhist <- filter(datafinal, grupo == 'hist')
estHistHum <- fitdist(humhist$hum,'weibull')$estimate
estHistHum shape scale
13.99389 76.51329
humhistplot <- ggplot(humhist,aes(hum)) +
geom_histogram(bins = 10, aes(y = ..density..), fill = "lightblue", color = "black") +
geom_function(aes(colour ="Weibull"), fun = dweibull,
args = list(shape = estHistHum[1],scale = estHistHum[2]),color = "orange", size=1.5)+
labs(x="Humedad",y="Densidad",title="Ajuste humedad histórica \n Weibull(13.99, 76.51)")
humhistplothumrcp2.6 <- filter(datafinal, grupo == 'rcp2.6')
estrcp2.6Hum <- fitdist(humrcp2.6$hum,'weibull')$estimate
estrcp2.6Hum shape scale
15.95452 50.71101
humrcp2.6plot <- ggplot(humrcp2.6,aes(hum)) +
geom_histogram(bins = 10, aes(y = ..density..), fill = "lightblue", color = "black") +
geom_function(aes(colour ="Weibull"), fun = dweibull,
args = list(shape = estrcp2.6Hum[1],scale = estrcp2.6Hum[2]),color = "orange", size=1.5)+
labs(x="Humedad",y="Densidad",title="Ajuste humedad RCP 2.6 \n Weibull(15.95, 50.71)")
humrcp2.6plot## Humedad RCP4.5
humrcp4.5 <- filter(datafinal, grupo == 'rcp4.5')
estrcp4.5Hum <- fitdist(humrcp4.5$hum,'gumbel',start = list(mu=1,sigma=2))$estimate
estrcp4.5Hum mu sigma
46.19235 2.98248
humrcp4.5plot <- ggplot(humrcp4.5,aes(hum)) +
geom_histogram(bins = 10, aes(y = ..density..), fill = "lightblue", color = "black") +
geom_function(aes(colour ="gumbel"), fun = dgumbel,
args = list(mu = 46.19235,sigma = 2.98248),color = "orange", size=1.5)+
labs(x="Humedad",y="Densidad",title="Ajuste humedad RCP 4.5 \n Gumbel(46.19, 2.98)")
humrcp4.5plot## Humedad RCP8.5
humrcp8.5 <- filter(datafinal, grupo == 'rcp8.5')
estrcp8.5Hum <- fitdist(humrcp8.5$hum,'lnorm')$estimate
estrcp8.5Hum meanlog sdlog
3.85714872 0.07948179
humrcp8.5plot <- ggplot(humrcp8.5,aes(hum)) +
geom_histogram(bins = 10, aes(y = ..density..), fill = "lightblue", color = "black") +
geom_function(aes(colour ="lnorm"), fun = dlnorm,
args = list(estrcp8.5Hum[1],estrcp8.5Hum[2]),color = "orange", size=1.5)+
labs(x="Humedad",y="Densidad",title="Ajuste humedad RCP 8.5 \n Lognormal(3.85, 0.07)")
humrcp8.5plotpdf(file = "AjustesHum.pdf",
width = 8, height = 8)
grid.arrange(humhistplot,humrcp2.6plot ,humrcp4.5plot ,humrcp8.5plot, ncol = 2)
dev.off()quartz_off_screen
2
Temperatura historica
temphist <- filter(datafinal, grupo == 'hist')
esthisttemp <- fitdist(temphist$temp,'norm')$estimate
esthisttemp mean sd
23.522313 1.342523
temphistplot <- ggplot(temphist,aes(temp)) +
geom_histogram(bins = 10, aes(y = ..density..), fill = "lightblue", color = "black") +
geom_function(aes(colour ="norm"), fun = dnorm,
args = list(esthisttemp[1],esthisttemp[2]),color = "orange", size=1.5)+
labs(x="Temperatura",y="Densidad",title="Ajuste temperatura histórica \n Normal(23.52 1.34)")
temphistplot## Temperatura RCP2.6
temprcp2.6 <- filter(datafinal, grupo == 'rcp2.6')
estrcp2.6temp <- fitdist(temprcp2.6$temp,'norm')$estimate
estrcp2.6temp mean sd
26.621097 1.147568
temprcp2.6plot <- ggplot(temprcp2.6,aes(temp)) +
geom_histogram(bins = 10, aes(y = ..density..), fill = "lightblue", color = "black") +
geom_function(aes(colour ="norm"), fun = dnorm,
args = list(estrcp2.6temp[1],estrcp2.6temp[2]),color = "orange", size=1.5)+
labs(x="Temperatura",y="Densidad",title="Ajuste temperatura RCP 2.6 \n Normal(26.62 1.14)")
temphistplot## Temperatura RCP4.5
temprcp4.5 <- filter(datafinal, grupo == 'rcp4.5')
estrcp4.5temp <- fitdist(temprcp4.5$temp,'norm')$estimate
estrcp4.5temp mean sd
26.728060 1.301973
temprcp4.5plot <- ggplot(temprcp4.5,aes(temp)) +
geom_histogram(bins = 10, aes(y = ..density..), fill = "lightblue", color = "black") +
geom_function(aes(colour ="norm"), fun = dnorm,
args = list(estrcp4.5temp[1],estrcp4.5temp[2]),color = "orange", size=1.5)+
labs(x="Temperatura",y="Densidad",title="Ajuste temperatura RCP 4.5 \n Normal(26.72 1.30)")
temphistplot## Temperatura rcp8.5
temprcp8.5 <- filter(datafinal, grupo == 'rcp8.5')
estrcp8.5temp <- fitdist(temprcp8.5$temp,'norm')$estimate
estrcp8.5temp mean sd
26.819689 1.269698
temprcp8.5plot <- ggplot(temprcp8.5,aes(temp)) +
geom_histogram(bins = 10, aes(y = ..density..), fill = "lightblue", color = "black") +
geom_function(aes(colour ="norm"), fun = dnorm,
args = list(estrcp8.5temp[1],estrcp8.5temp[2]),color = "orange", size=1.5)+
labs(x="Temperatura",y="Densidad",title="Ajuste temperatura RCP 8.5 \n Normal(26.81 1.26)")
temphistplotpdf(file = "AjustesTemp.pdf",
width = 8, height = 8)
grid.arrange(temphistplot,temprcp2.6plot ,temprcp4.5plot ,temprcp8.5plot, ncol = 2)
dev.off()quartz_off_screen
2
Ajuste copulas
library(VineCopula)
library(VC2copula)
histmat <- as.matrix(pobs(dplyr::select(datafinalhist,-c(1,4:6))))
rcp2.6mat <- as.matrix(pobs(dplyr::select(datafinalrcp2.6,-c(1,4:6))))
rcp4.5mat <- as.matrix(pobs(dplyr::select(datafinalrcp4.5,-c(1,4:6))))
rcp8.5mat <- as.matrix(pobs(dplyr::select(datafinalrcp8.5,-c(1,4:6))))
copulafits <- data.frame(c("Historico", "RCP 2.6", "RCP 4.5", "RCP8.5"))
copulafits c..Historico....RCP.2.6....RCP.4.5....RCP8.5..
1 Historico
2 RCP 2.6
3 RCP 4.5
4 RCP8.5
for (i in c(0,1,2,4,5,6,7,8,9,10,13,14,16,17,18,19,20,23,24,
26,27,28,29,30,33,34,36,37,38,39,40,104,114,124,134,204,214,224,234)){
v<-c(BiCopEst(histmat[,1], histmat[,2], family = i, method = "itau")$AIC,
BiCopEst(rcp2.6mat[,1], rcp2.6mat[,2], family = i, method = "itau")$AIC,
BiCopEst(rcp4.5mat[,1], rcp4.5mat[,2], family = i, method = "itau")$AIC,
BiCopEst(rcp8.5mat[,1], rcp8.5mat[,2], family = i, method = "itau")$AIC)
copulafits <- cbind(copulafits, v)
}[1] "The BB1 or survival BB1 copula cannot be used for negatively dependent data."
[1] "The BB1 or survival BB1 copula cannot be used for negatively dependent data."
[1] "The BB1 or survival BB1 copula cannot be used for negatively dependent data."
[1] "The BB1 or survival BB1 copula cannot be used for negatively dependent data."
[1] "The BB6 or survival BB6 copula cannot be used for negatively dependent data."
[1] "The BB6 or survival BB6 copula cannot be used for negatively dependent data."
[1] "The BB6 or survival BB6 copula cannot be used for negatively dependent data."
[1] "The BB6 or survival BB6 copula cannot be used for negatively dependent data."
[1] "The BB7 or survival BB7 copula cannot be used for negatively dependent data."
[1] "The BB7 or survival BB7 copula cannot be used for negatively dependent data."
[1] "The BB7 or survival BB7 copula cannot be used for negatively dependent data."
[1] "The BB7 or survival BB7 copula cannot be used for negatively dependent data."
[1] "The BB8 or survival BB8 copula cannot be used for negatively dependent data."
[1] "The BB8 or survival BB8 copula cannot be used for negatively dependent data."
[1] "The BB8 or survival BB8 copula cannot be used for negatively dependent data."
[1] "The BB8 or survival BB8 copula cannot be used for negatively dependent data."
[1] "The BB1 or survival BB1 copula cannot be used for negatively dependent data."
[1] "The BB1 or survival BB1 copula cannot be used for negatively dependent data."
[1] "The BB1 or survival BB1 copula cannot be used for negatively dependent data."
[1] "The BB1 or survival BB1 copula cannot be used for negatively dependent data."
[1] "The BB6 or survival BB6 copula cannot be used for negatively dependent data."
[1] "The BB6 or survival BB6 copula cannot be used for negatively dependent data."
[1] "The BB6 or survival BB6 copula cannot be used for negatively dependent data."
[1] "The BB6 or survival BB6 copula cannot be used for negatively dependent data."
[1] "The BB7 or survival BB7 copula cannot be used for negatively dependent data."
[1] "The BB7 or survival BB7 copula cannot be used for negatively dependent data."
[1] "The BB7 or survival BB7 copula cannot be used for negatively dependent data."
[1] "The BB7 or survival BB7 copula cannot be used for negatively dependent data."
[1] "The BB8 or survival BB8 copula cannot be used for negatively dependent data."
[1] "The BB8 or survival BB8 copula cannot be used for negatively dependent data."
[1] "The BB8 or survival BB8 copula cannot be used for negatively dependent data."
[1] "The BB8 or survival BB8 copula cannot be used for negatively dependent data."
[1] "The Tawn or survival Tawn copula cannot be used for negatively dependent data."
[1] "The Tawn or survival Tawn copula cannot be used for negatively dependent data."
[1] "The Tawn or survival Tawn copula cannot be used for negatively dependent data."
[1] "The Tawn or survival Tawn copula cannot be used for negatively dependent data."
[1] "The Tawn or survival Tawn copula cannot be used for negatively dependent data."
[1] "The Tawn or survival Tawn copula cannot be used for negatively dependent data."
[1] "The Tawn or survival Tawn copula cannot be used for negatively dependent data."
[1] "The Tawn or survival Tawn copula cannot be used for negatively dependent data."
[1] "The Tawn2 or survival Tawn2 copula cannot be used for negatively dependent data."
[1] "The Tawn2 or survival Tawn2 copula cannot be used for negatively dependent data."
[1] "The Tawn2 or survival Tawn2 copula cannot be used for negatively dependent data."
[1] "The Tawn2 or survival Tawn2 copula cannot be used for negatively dependent data."
[1] "The Tawn2 or survival Tawn2 copula cannot be used for negatively dependent data."
[1] "The Tawn2 or survival Tawn2 copula cannot be used for negatively dependent data."
[1] "The Tawn2 or survival Tawn2 copula cannot be used for negatively dependent data."
[1] "The Tawn2 or survival Tawn2 copula cannot be used for negatively dependent data."
colnames(copulafits) <- c("Grupo","Indep","Gauss","T-student","Clayton","Gumbel","Frank","Joe",
"BB1" ,"BB7","BB8","Surv Clayton","Surv Gumbel","Surv Joe","Surv BB1",
"Surv BB6","Surv BB7","Surv BB8","Clayton rot90","Gumbel rot90",
"Joe rot90","BB1 rot90","BB6 rot90","BB7 rot90","BB8 rot90",
"Clayton rot270","Gumbel rot270","Joe rot270","BB1 rot270","BB6 rot270",
"BB7 rot270","BB8 rot270","Tawn T1","Tawn T1 180","Tawn T1 90",
"Tawn T1 270","Tawn T2","Tawn T2 180","Tawn T2 90", "Tawn T2 270")
copulafits%>%
dplyr::select(Grupo:Joe,`Tawn T2 90`)%>%
xtable(caption = "AIC para posibles cópulas",
label = "tab:AICcopulafit")% latex table generated in R 4.3.2 by xtable 1.8-4 package
% Fri Dec 8 16:03:24 2023
\begin{table}[ht]
\centering
\begin{tabular}{rlrrrrrrrr}
\hline
& Grupo & Indep & Gauss & T-student & Clayton & Gumbel & Frank & Joe & Tawn T2 90 \\
\hline
1 & Historico & 0.00 & -71.44 & -62.72 & 2.10 & -49.31 & 2.07 & 5.30 & -163.74 \\
2 & RCP 2.6 & 0.00 & -198.66 & -230.12 & 2.14 & -225.05 & 2.09 & 5.80 & -490.12 \\
3 & RCP 4.5 & 0.00 & -223.90 & -232.27 & 2.14 & -224.02 & 2.09 & 5.90 & -426.18 \\
4 & RCP8.5 & 0.00 & -282.44 & -292.31 & 2.15 & -275.91 & 2.09 & 6.08 & -441.27 \\
\hline
\end{tabular}
\caption{AIC para posibles cópulas}
\label{tab:AICcopulafit}
\end{table}
Historico tests
(exchT <- exchTest(histmat))
Test of exchangeability for bivariate copulas with argument 'm' set to
0
data: histmat
statistic = 0.24331, p-value = 0.0004995
(radSym <- radSymTest(histmat))
Test of radial symmetry based on the empirical copula
data: histmat
statistic = 0.61847, p-value = 0.0004995
(evT <- evTestC(histmat))
Max-stability based test of extreme-value dependence for multivariate
copulas
data: histmat
statistic = 0.72804, p-value = 0.0004995
Es decir, rechazamos la hipotesis de intercambiabilidad y símetria radial, y tenemos evidencia en contra de la hipotesis de que exista dependencia de valores extremos.
library(VC2copula)
histtawncop <- fitCopula(VC2copula::r90TawnT2Copula(),histmat)
summary(histtawncop)Call: fitCopula(copula, data = data)
Fit based on "mle" and 1271 2-dimensional observations.
r90TawnT2Copula copula, dim. d = 2
Estimate Std. Error
param1 -2.1923 NA
param2 0.1814 NA
The maximized loglikelihood is 83.87
Copula historica
histcop <- mvdc(VC2copula::r90TawnT2Copula(param=c(-2.1923, 0.1814)),
margins = c("weibull","norm"),
paramMargins = list(list(13.99,76.51),
list(mean = 23.53, sd = 1.34)))
pdf(file="copulahist.pdf", width=14, height=8)
par(mfrow = c(1, 2))
persp(histcop, dMvdc, xlim=c(50,90), ylim=c(15,35), xlab="Humedad",
ylab="Temperatura", zlab="Densidad")
persp(histcop, pMvdc, xlim=c(50,90), ylim=c(15,35), zlim=c(0,1), xlab="Humedad",
ylab="Temperatura", zlab="Distribución")
dev.off()quartz_off_screen
2
pdf(file="copulahistcontorno.pdf", width=5, height=5)
contour(histcop, dMvdc, xlim=c(65,85), ylim=c(15,35), nlevels=6, xlab="Humedad", ylab="Temperatura")
library(latticeExtra)
u <- seq(0, 1, length.out = 16)
grid <- as.matrix(expand.grid(u1 = u, u2 = u))
val <- cbind(grid, z = C.n(grid, X = histmat))
cpCn <- contourplot2(val, region = FALSE, labels = FALSE, col = 2)
cpJ <- contourplot2(histcop@copula,
FUN = pCopula,
region = FALSE,
key = list(corner = c(0.04, 0.04),
lines = list(col = 1:2, lwd = 2),
text = list(c("Copula Tawn ajustada",
"Copula empírica"))))
contourHist <- cpJ + cpCn
pdf(file="copulahistcon.pdf", width=5, height=5)
par(cex.lab=2, cex.axis=1.7)
contourHist
dev.off()quartz_off_screen
2
v <- rMvdc(1000, histcop)
pdf(file="copulahistcomp.pdf", width=5, height=5)
plot(histmat[1:1000, ], col = "red", xlab="Humedad", ylab="Temperatura")
par(new=TRUE, xpd=TRUE)
plot(pobs(v[1:1000,]), col = "black", xlab="", ylab="",xaxt="n",yaxt="n")
legend('top', inset=c(0, -0.2), c('Simulada', 'Observada'), col = c('black', 'red'), pch=21)
dev.off()quartz_off_screen
2
RCP2.6
Probamos dependencia de valores extremos
evTestC(rcp2.6mat)
Max-stability based test of extreme-value dependence for multivariate
copulas
data: rcp2.6mat
statistic = 4.7339, p-value = 0.0004995
exchTest(rcp2.6mat)
Test of exchangeability for bivariate copulas with argument 'm' set to
0
data: rcp2.6mat
statistic = 0.32773, p-value = 0.0004995
radSymTest(rcp2.6mat)
Test of radial symmetry based on the empirical copula
data: rcp2.6mat
statistic = 1.5124, p-value = 0.0004995
Rechazamos intercambiabilidad y simetria radial.
rcp2.6tawncop <- fitCopula(VC2copula::r90TawnT2Copula(),rcp2.6mat)
summary(rcp2.6tawncop)Call: fitCopula(copula, data = data)
Fit based on "mle" and 1085 2-dimensional observations.
r90TawnT2Copula copula, dim. d = 2
Estimate Std. Error
param1 -3.0419 NA
param2 0.3787 NA
The maximized loglikelihood is 247.1
Copula RCP2.6
library(extraDistr)
rcp2.6cop <- mvdc(VC2copula::r90TawnT2Copula(param=c(-3.0419, 0.378752)),
margins = c("weibull","norm"),
paramMargins = list(list(15.95452,50.71101),
list(estrcp2.6temp[1],estrcp2.6temp[2])))
pdf(file="copularcp2.6.pdf", width=14, height=8)
par(mfrow = c(1, 2))
persp(rcp2.6cop, dMvdc, xlim=c(30,65), ylim=c(15,35), xlab="Humedad",
ylab="Temperatura", zlab="Densidad")
persp(rcp2.6cop, pMvdc, xlim=c(30,55), ylim=c(20,35), zlim=c(0,1), xlab="Humedad",
ylab="Temperatura", zlab="Distribución")
dev.off()quartz_off_screen
2
pdf(file="copularcp2.6contorno.pdf", width=5, height=5)
contour(rcp2.6cop, dMvdc, xlim=c(40,60), ylim=c(20,35), nlevels=6, xlab="Humedad", ylab="Temperatura")
library(latticeExtra)
u <- seq(0, 1, length.out = 16)
grid <- as.matrix(expand.grid(u1 = u, u2 = u))
val <- cbind(grid, z = C.n(grid, X = rcp2.6mat))
cpCn <- contourplot2(val, region = FALSE, labels = FALSE, col = 2)
cpJ <- contourplot2(rcp2.6cop@copula,
FUN = pCopula,
region = FALSE,
key = list(corner = c(0.04, 0.04),
lines = list(col = 1:2, lwd = 2),
text = list(c("Copula Tawn ajustada",
"Copula empírica"))))
contourrcp2.6 <- cpJ + cpCn
pdf(file="copularcp2.6con.pdf", width=5, height=5)
par(cex.lab=2, cex.axis=1.7)
contourrcp2.6
dev.off()quartz_off_screen
2
v <- rMvdc(1000, rcp2.6cop)
pdf(file="copularcp2.6comp.pdf", width=5, height=5)
plot(rcp2.6mat[1:1000, ], col = "red", xlab="Humedad", ylab="Temperatura")
par(new=TRUE, xpd=TRUE)
plot(pobs(v[1:1000,]), col = "black", xlab="", ylab="",xaxt="n",yaxt="n")
legend('top', inset=c(0, -0.2), c('Simulada', 'Observada'), col = c('black', 'red'), pch=21)
dev.off()quartz_off_screen
2
RCP4.5
Probamos dependencia de valores extremos
evTestC(rcp4.5mat)
Max-stability based test of extreme-value dependence for multivariate
copulas
data: rcp4.5mat
statistic = 3.8034, p-value = 0.0004995
exchTest(rcp4.5mat)
Test of exchangeability for bivariate copulas with argument 'm' set to
0
data: rcp4.5mat
statistic = 0.088817, p-value = 0.02048
radSymTest(rcp4.5mat)
Test of radial symmetry based on the empirical copula
data: rcp4.5mat
statistic = 0.93635, p-value = 0.0004995
NO rechazamos intercambiabilidad pero sí se rechaza simetria radial.
Copula RCP4.5
rcp4.5tawncop <- fitCopula(VC2copula::r90TawnT2Copula(),rcp4.5mat)
summary(rcp4.5tawncop)Call: fitCopula(copula, data = data)
Fit based on "mle" and 1085 2-dimensional observations.
r90TawnT2Copula copula, dim. d = 2
Estimate Std. Error
param1 -2.8436 NA
param2 0.3694 NA
The maximized loglikelihood is 215.1
rcp4.5cop <- mvdc(VC2copula::r90TawnT2Copula(param=c(-2.8436, 0.3694)),
margins = c("gumbel","norm"),
paramMargins = list(list(mu=46.19235,sigma=2.98248),
list(estrcp4.5temp[1],estrcp4.5temp[2])))
pdf(file="copularcp4.5.pdf", width=14, height=8)
par(mfrow = c(1, 2))
persp(rcp4.5cop, dMvdc, xlim=c(30,65), ylim=c(15,35), xlab="Humedad",
ylab="Temperatura", zlab="Densidad")
persp(rcp4.5cop, pMvdc, xlim=c(30,55), ylim=c(20,35), zlim=c(0,1), xlab="Humedad",
ylab="Temperatura", zlab="Distribución")
dev.off()quartz_off_screen
2
pdf(file="copularcp4.5contorno.pdf", width=5, height=5)
contour(rcp4.5cop, dMvdc, xlim=c(40,60), ylim=c(20,35), nlevels=6, xlab="Humedad", ylab="Temperatura")
library(latticeExtra)
u <- seq(0, 1, length.out = 16)
grid <- as.matrix(expand.grid(u1 = u, u2 = u))
val <- cbind(grid, z = C.n(grid, X = rcp4.5mat))
cpCn <- contourplot2(val, region = FALSE, labels = FALSE, col = 2)
cpJ <- contourplot2(rcp4.5cop@copula,
FUN = pCopula,
region = FALSE,
key = list(corner = c(0.04, 0.04),
lines = list(col = 1:2, lwd = 2),
text = list(c("Copula Tawn ajustada",
"Copula empírica"))))
contourrcp4.5 <- cpJ + cpCn
pdf(file="copularcp4.5con.pdf", width=5, height=5)
par(cex.lab=2, cex.axis=1.7)
contourrcp4.5
dev.off()quartz_off_screen
2
v <- rMvdc(1000, rcp4.5cop)
pdf(file="copularcp4.5comp.pdf", width=5, height=5)
plot(rcp4.5mat[1:1000, ], col = "red", xlab="Humedad", ylab="Temperatura")
par(new=TRUE, xpd=TRUE)
plot(pobs(v[1:1000,]), col = "black", xlab="", ylab="",xaxt="n",yaxt="n")
legend('top', inset=c(0, -0.2), c('Simulada', 'Observada'), col = c('black', 'red'), pch=21)
dev.off()quartz_off_screen
2
rcp8.5
Probamos dependencia de valores extremos
evTestC(rcp8.5mat)
Max-stability based test of extreme-value dependence for multivariate
copulas
data: rcp8.5mat
statistic = 4.7428, p-value = 0.0004995
exchTest(rcp8.5mat)
Test of exchangeability for bivariate copulas with argument 'm' set to
0
data: rcp8.5mat
statistic = 0.09102, p-value = 0.02148
radSymTest(rcp8.5mat)
Test of radial symmetry based on the empirical copula
data: rcp8.5mat
statistic = 0.9531, p-value = 0.0004995
NO rechazamos intercambiabilidad y NO se rechaza simetria radial.
Ajuste cop 8.5
rcp8.5tawncop <- fitCopula(VC2copula::r90TawnT2Copula(),rcp8.5mat)
summary(rcp8.5tawncop)Call: fitCopula(copula, data = data)
Fit based on "mle" and 1085 2-dimensional observations.
r90TawnT2Copula copula, dim. d = 2
Estimate Std. Error
param1 -2.6502 NA
param2 0.4163 NA
The maximized loglikelihood is 222.6
rcp8.5cop <- mvdc(VC2copula::r90TawnT2Copula(param=c(-2.6502, 0.4163)),
margins = c("lnorm","norm"),
paramMargins = list(list(estrcp8.5Hum[1],estrcp8.5Hum[2]),
list(estrcp8.5temp[1],estrcp8.5temp[2])))
pdf(file="copularcp8.5.pdf", width=14, height=8)
par(mfrow = c(1, 2))
persp(rcp8.5cop, dMvdc, xlim=c(30,65), ylim=c(15,35), xlab="Humedad",
ylab="Temperatura", zlab="Densidad")
persp(rcp8.5cop, pMvdc, xlim=c(30,55), ylim=c(20,35), zlim=c(0,1), xlab="Humedad",
ylab="Temperatura", zlab="Distribución")
dev.off()quartz_off_screen
2
pdf(file="copularcp8.5contorno.pdf", width=5, height=5)
contour(rcp8.5cop, dMvdc, xlim=c(40,60), ylim=c(20,35), nlevels=6, xlab="Humedad", ylab="Temperatura")
library(latticeExtra)
u <- seq(0, 1, length.out = 16)
grid <- as.matrix(expand.grid(u1 = u, u2 = u))
val <- cbind(grid, z = C.n(grid, X = rcp8.5mat))
cpCn <- contourplot2(val, region = FALSE, labels = FALSE, col = 2)
cpJ <- contourplot2(rcp8.5cop@copula,
FUN = pCopula,
region = FALSE,
key = list(corner = c(0.04, 0.04),
lines = list(col = 1:2, lwd = 2),
text = list(c("Copula Tawn ajustada",
"Copula empírica"))))
contourrcp8.5 <- cpJ + cpCn
pdf(file="copularcp8.5con.pdf", width=5, height=5)
par(cex.lab=2, cex.axis=1.7)
contourrcp8.5
dev.off()quartz_off_screen
2
v <- rMvdc(1000, rcp8.5cop)
pdf(file="copularcp8.5comp.pdf", width=5, height=5)
plot(rcp8.5mat[1:1000, ], col = "red", xlab="Humedad", ylab="Temperatura")
par(new=TRUE, xpd=TRUE)
plot(pobs(v[1:1000,]), col = "black", xlab="", ylab="",xaxt="n",yaxt="n")
legend('top', inset=c(0, -0.2), c('Simulada', 'Observada'), col = c('black', 'red'), pch=21)
dev.off()quartz_off_screen
2
##Riesgo De Bonmanova J, Misztal, Colef JB. Temperature-Humity Indices as Indicators of Milk Production Losses due to Heat Stress. J. Dairy Sci. 2007; 90: 1947-1956 tomamos la def de THI5 usada para el disconfort del ganado en exteriores.
thi5Hist <- 0.81temp+0.143hum+0.0099humtemp+46.3
En Temperature-Humidity Indices as Indicators to Heat Stress of Climatic Conditions with Relation to Production and Reproduction of Farm Animals Alsaied Alnaimy Habeeb*, Ahmed Elsayed Gad and Mostafa Abas Atta se define la producción diaria de leche por una regresion lineal usando el THI como regresor de la producción diaria de leche según thi
yield = -0.1313*thi5 + 40.666
En Rachid Bouraoui, Mondher Lahmar, Abdessalem Majdoub, M’Nouer Djemali, Ronald Belyea. The relationship of temperature-humidity index with milk production of dairy cows in a Mediterrane se propone la siguiente relacion de producción diaria de leche según thi
yield = -0.4129*thi5 + 47.722
Simulamos observaciones de nuestras copulas y usamos la simulación historica como punto de referencia para la producción mensual de una cabeza de ganado de producción.
1 US gallon of milk weighs 3.67 kilograms. yield viene en kg, 1 gallon US vale USD5.76, entonces 1 kg de leche vale USD0.64
n <- 1271 #simulaciones
m <- 1000 #cantidad de cabezas de ganado
#simHist <- as.data.frame(rMvdc(n, histcop)) %>% #mutate(thi=0.81*V2+0.143*V1+0.0099*V1*V2+46.3) %>%
#mutate(yield = -0.4129*thi + 47.722)
simHist <- datafinalhist %>%
mutate(thi=0.81*temp+0.143*hum+0.0099*hum*temp+46.3) %>%
mutate(yield = -0.4129*thi + 47.722)
simRCP2.6 <- as.data.frame(rMvdc(n, rcp2.6cop)) %>%
mutate(thi=0.81*V2+0.143*V1+0.0099*V1*V2+46.3) %>%
mutate(yield = -0.4129*thi + 47.722)
simRCP4.5 <- as.data.frame(rMvdc(n, rcp4.5cop)) %>%
mutate(thi=0.81*V2+0.143*V1+0.0099*V1*V2+46.3) %>%
mutate(yield = -0.4129*thi + 47.722)
simRCP8.5 <- as.data.frame(rMvdc(n, rcp8.5cop)) %>%
mutate(thi=0.81*V2+0.143*V1+0.0099*V1*V2+46.3) %>%
mutate(yield = -0.4129*thi + 47.722)
resRCP2.6 <- (simRCP2.6$yield - simHist$yield)*0.64
tRCP2.6 <- quantile(resRCP2.6,0.95)
meanRCP2.6 <- mean(resRCP2.6[resRCP2.6>tRCP2.6])
resRCP4.5 <- (simRCP4.5$yield-simHist$yield)*0.64
tRCP4.5 <- quantile(resRCP4.5,0.95)
meanRCP4.5 <- mean(resRCP4.5[resRCP4.5>tRCP4.5])
resRCP8.5 <- (simRCP8.5$yield-simHist$yield)*0.64
tRCP8.5 <- quantile(resRCP8.5,0.95)
meanRCP8.5 <- mean(resRCP8.5[resRCP8.5>tRCP8.5])
VaRs <- c(meanRCP2.6*m, meanRCP4.5*m, meanRCP8.5*m)
VaRs[1] 3716.224 3924.712 3849.531
(resultados <- data.frame(
Escenario = c("RCP2.6", "RCP4.5", "RCP8.5"),
# Media = c(meanRCP2.6 * m, meanRCP4.5 * m, meanRCP8.5 * m),
"Var(95)" = c(tRCP2.6, tRCP4.5, tRCP8.5)*m,
"C-Var(95)"= VaRs
)) Escenario Var.95. C.Var.95.
1 RCP2.6 3386.729 3716.224
2 RCP4.5 3549.645 3924.712
3 RCP8.5 3472.281 3849.531
resultados %>% xtable(caption = "Resultados de simulación", label = "tab:resultados")% latex table generated in R 4.3.2 by xtable 1.8-4 package
% Fri Dec 8 16:04:14 2023
\begin{table}[ht]
\centering
\begin{tabular}{rlrr}
\hline
& Escenario & Var.95. & C.Var.95. \\
\hline
1 & RCP2.6 & 3386.73 & 3716.22 \\
2 & RCP4.5 & 3549.65 & 3924.71 \\
3 & RCP8.5 & 3472.28 & 3849.53 \\
\hline
\end{tabular}
\caption{Resultados de simulación}
\label{tab:resultados}
\end{table}
pdf(file="retornosSims.pdf", width=7, height=4)
par(mfrow = c(1, 3))
hist(resRCP2.6, main = "RCP 2.6", xlab = "Dolares (en miles)", ylab = "Frecuencia", col = "lightblue")
hist(resRCP4.5, main = "RCP 4.5", xlab = "Dolares (en miles)", ylab = "Frecuencia", col = "lightblue")
hist(resRCP8.5, main = "RCP 8.5", xlab = "Dolares (en miles)", ylab = "Frecuencia", col = "lightblue")
dev.off()quartz_off_screen
2
res <- data.frame(c("RCP2.6",summary(resRCP2.6)),
c("RCP4.5",summary(resRCP2.6)),
c("RCP8.5",summary(resRCP2.6))) %>% t()
res %>% t() %>%
xtable(caption = "Resultados de simulación",
label = "tab:resultados") %>%
print(include.colnames = FALSE)% latex table generated in R 4.3.2 by xtable 1.8-4 package
% Fri Dec 8 16:04:14 2023
\begin{table}[ht]
\centering
\begin{tabular}{rlll}
\hline
\hline
& RCP2.6 & RCP4.5 & RCP8.5 \\
Min. & -3.0241481051792 & -3.0241481051792 & -3.0241481051792 \\
1st Qu. & 0.478788682760639 & 0.478788682760639 & 0.478788682760639 \\
Median & 1.4913749863341 & 1.4913749863341 & 1.4913749863341 \\
Mean & 1.38022112133694 & 1.38022112133694 & 1.38022112133694 \\
3rd Qu. & 2.39517691215279 & 2.39517691215279 & 2.39517691215279 \\
Max. & 4.3465684553032 & 4.3465684553032 & 4.3465684553032 \\
\hline
\end{tabular}
\caption{Resultados de simulación}
\label{tab:resultados}
\end{table}
resT <- data.frame(c("RCP2.6",summary(datafinalrcp2.6$temp)),
c("RCP4.5",summary(datafinalrcp4.5$temp)),
c("RCP8.5",summary(datafinalrcp8.5$temp))) %>% t()
resT %>% t() %>%
xtable(caption = "Resumen de los datos de los escenarios de temperatura predichos",
label = "tab:resumenT") %>%
print(include.colnames = FALSE)% latex table generated in R 4.3.2 by xtable 1.8-4 package
% Fri Dec 8 16:04:14 2023
\begin{table}[ht]
\centering
\begin{tabular}{rlll}
\hline
\hline
& RCP2.6 & RCP4.5 & RCP8.5 \\
Min. & 19.4011 & 19.3732 & 17.5597 \\
1st Qu. & 24.6556 & 24.6091 & 24.5719 \\
Median & 26.3854 & 26.5249 & 26.5528 \\
Mean & 26.6210971428571 & 26.72806 & 26.8196885714286 \\
3rd Qu. & 28.3756 & 28.5523 & 28.7383 \\
Max. & 37.2106 & 35.4529 & 37.006 \\
\hline
\end{tabular}
\caption{Resumen de los datos de los escenarios de temperatura predichos}
\label{tab:resumenT}
\end{table}
resH <- data.frame(c("RCP2.6",summary(datafinalrcp2.6$hum)),
c("RCP4.5",summary(datafinalrcp4.5$hum)),
c("RCP8.5",summary(datafinalrcp8.5$hum))) %>% t()
resH %>% t() %>%
xtable(caption = "Resumen de los datos de los escenarios de humedad predichos",
label = "tab:resumenH") %>%
print(include.colnames = FALSE)% latex table generated in R 4.3.2 by xtable 1.8-4 package
% Fri Dec 8 16:04:14 2023
\begin{table}[ht]
\centering
\begin{tabular}{rlll}
\hline
\hline
& RCP2.6 & RCP4.5 & RCP8.5 \\
Min. & 18.7522037600792 & 21.9556414356858 & 21.5766093997064 \\
1st Qu. & 42.8728744696802 & 40.9177354406754 & 40.1132187047199 \\
Median & 49.9992430881329 & 48.0482269843561 & 47.4425045940286 \\
Mean & 49.0744472931554 & 47.8304781013842 & 47.4811937161771 \\
3rd Qu. & 56.2674854291067 & 54.6777846587422 & 54.9751855207287 \\
Max. & 71.7273272816795 & 71.9468167521768 & 72.3393712582624 \\
\hline
\end{tabular}
\caption{Resumen de los datos de los escenarios de humedad predichos}
\label{tab:resumenH}
\end{table}