Professional Documents
Culture Documents
packages("survival")
library(survival)
install.packages("FAdist")
library(FAdist)
install.packages("fitdistrplus")
library(fitdistrplus)
install.packages("goftest")
library(goftest)
install.packages("zoo")
library(zoo)
library(hydroTSM)
install.packages("MASS")
library(MASS)
install.packages("moments")
library(moments)
elibor_max_precipitation<-precmaxelibor
lautaro_max_precipitation<-precmaxlautaro
loros_max_precipitation<-precmaxloros
annual_max_flow_rate<-caud_max
winter_temp<-t_invierno
summer_temp<-t_verano
spring_temp<-t_primavera
autumn_temp<-t_otono
#PARTE 2
#esta parte del codigo realiza los graficos de homogeneidad
# Dato entrada: Precipitaciones diarias en [mm]
library(xts)
library(hydroTSM)
#Ubicaci�n .txt
direccion<-"C:/Users/usuari/Desktop/datos
tp4/cr2_prDaily_2017/cr2_prDaily_2017.txt"
#Carga datos
e.caracter<-read.csv(direccion,header = FALSE, na.strings =-9999)
e.numeric<-read.csv(direccion,header = FALSE,skip = 15,na.strings =-9999)
#Fecha inter�s
fecha.inicio.datos<-"1985-01-01" #Primera fecha de datos
fecha.inicio<-"1985-01-01"
fecha.final<-"2014-12-31"
Datosestaciones<-function(x,y){columinteres<-y[c(143,145,148)]}
#Selecciona las columnas de interes.
datoshuasco<-Datosestaciones(L_huasco,e.numeric)
# Aqu� se almacenan las columnas seleccionadas.
row.names(pcpmean_estacional)<-as.character(t(nombre_estaciones[c(3,5,7)]))
nombre<-apply(nombre_estaciones[c(3,5,7)],2,as.character)
colnames(pcpmean_anual)<-nombre
#Homogeneidad
x.barra<-apply(pcp.anual,1,mean)
dates<-time(pcp.anual)
names(x.barra)<-dates
pcp.acumulado<-apply(pcp.anual,2,cumsum)
x.barra.acum<-apply.monthly(x.barra,cumsum)
#Plot de los gr�ficos de homogeneidad de las estaciones pluviom�tricas
seleccionadas.
for(i in 1:length(pcp.acumulado[1,])){
plot(pcp.acumulado[,i],x.barra.acum,xlab = "Accumulated precipitation [mm]", ylab
= "Station's Accumulated precipitation [mm]",main
=(paste0(nombre[i],"\n",codigo_estaciones[i])) )
}
#PARTE 3
#grafico ajuste distribuciones de probabilidad
# fit2<-fitdist(elibor_max_precipitation,"lnorm")
#Error in start.arg.default(data10, distr = distname) :
#values must be positive to fit a lognormal distribution
denscomp(pbb.list1,legendtext = pbb.legend1)
qqcomp(pbb.list1,legendtext = pbb.legend1)
denscomp(pbb.list1,legendtext = pbb.legend1)
qqcomp(pbb.list1,legendtext = pbb.legend1)
denscomp(pbb.list1,legendtext = pbb.legend1)
qqcomp(pbb.list1,legendtext = pbb.legend1)
denscomp(pbb.list1,legendtext = pbb.legend1)
qqcomp(pbb.list1,legendtext = pbb.legend1)
denscomp(pbb.list1,legendtext = pbb.legend1)
qqcomp(pbb.list1,legendtext = pbb.legend1)
denscomp(pbb.list1,legendtext = pbb.legend1)
qqcomp(pbb.list1,legendtext = pbb.legend1)
denscomp(pbb.list1,legendtext = pbb.legend1)
qqcomp(pbb.list1,legendtext = pbb.legend1)
denscomp(pbb.list1,legendtext = pbb.legend1)
qqcomp(pbb.list1,legendtext = pbb.legend1)
#PARTE 4
#parametros distribuciones de probabilidad
ks.test(elibor_max_precipitation,"pnorm",mean=15.13,sd=20.46)
ks.test(lautaro_max_precipitation,"pnorm",mean=17.91,sd=19)
ks.test(loros_max_precipitation,"pnorm",mean=17.76,sd=22.47)
ks.test(annual_max_flow_rate,"pnorm",mean=3.37,sd=3.22)
ks.test(summer_temp,"pnorm",mean=22.99,sd=0.43)
ks.test(autumn_temp,"pnorm",mean=20.35,sd=0.394)
ks.test(winter_temp,"pnorm",mean=17.13,sd=0.81)
ks.test(spring_temp,"pnorm",mean=20.36,sd=0.46)
ad.test(elibor_max_precipitation)
ad.test(lautaro_max_precipitation)
ad.test(loros_max_precipitation)
ad.test(annual_max_flow_rate)
ad.test(summer_temp)
ad.test(autumn_temp)
ad.test(winter_temp)
ad.test(spring_temp)
ks.test(elibor_max_precipitation,"plnorm",mean=0.874,sd=2.995)
ks.test(lautaro_max_precipitation,"plnorm",mean=2.138,sd=1.698)
ks.test(loros_max_precipitation,"plnorm",mean=1.58,sd=2.428)
ks.test(annual_max_flow_rate,"plnorm",mean=0.9242,sd=0.6992)
ks.test(summer_temp,"plnorm",mean=3.1347,sd=0.0178)
ks.test(autumn_temp,"plnorm",mean=3.01,sd=0.018)
ks.test(winter_temp,"plnorm",mean=2.84,sd=0.04)
ks.test(spring_temp,"plnorm",mean=3.01,sd=0.02)
ks.test(elibor_max_precipitation,"pgamma",shape=0.363,rate=0.024)
ks.test(lautaro_max_precipitation,"pgamma",shape=0.795,rate=0.044)
ks.test(loros_max_precipitation,"pgamma",shape=0.491,rate=0.028)
ks.test(annual_max_flow_rate,"pgamma",shape=1.862,rate=0.552)
ks.test(summer_temp,"pgamma",shape=3140.8,rate=136.64)
ks.test(autumn_temp,"pgamma",shape=2959.5,rate=145.4)
ks.test(winter_temp,"pgamma",shape=504.4,rate=29.4)
ks.test(spring_temp,"pgamma",shape=2221.8,rate=109.1)
ks.test(elibor_max_precipitation,"pweibull",shape=0.489,scale=8.987)
ks.test(lautaro_max_precipitation,"pweibull",shape=0.884,scale=16.941)
ks.test(loros_max_precipitation,"pweibull",shape=0.629,scale=13.429)
ks.test(annual_max_flow_rate,"pweibull",shape=1.263,scale=3.6776)
ks.test(summer_temp,"pweibull",shape=50.68,scale=23.2)
ks.test(autumn_temp,"pweibull",shape=60.0,scale=20.5)
ks.test(winter_temp,"pweibull",shape=23.23,scale=17.51)
ks.test(spring_temp,"pweibull",shape=50.94,scale=20.58)
ks.test(elibor_max_precipitation,"pexp",rate=0.0661)
ks.test(lautaro_max_precipitation,"pexp",rate=0.0558)
ks.test(loros_max_precipitation,"pexp",rate=0.0563)
ks.test(annual_max_flow_rate,"pexp",rate=0.2964)
ks.test(summer_temp,"pexp",rate=0.0435)
ks.test(autumn_temp,"pexp",rate=0.049)
ks.test(winter_temp,"pexp",rate=0.06)
ks.test(spring_temp,"pexp",rate=0.05)
chisq.test(elibor_max_precipitation)
chisq.test(lautaro_max_precipitation)
chisq.test(loros_max_precipitation)
chisq.test(annual_max_flow_rate)
chisq.test(summer_temp)
chisq.test(autumn_temp)
chisq.test(winter_temp)
chisq.test(spring_temp)
#PARTE 5
#cuantiles teoricos y empiricos
n<-c(0.025,0.05,0.25,0.5,0.75,0.95,0.975)
quantile(elibor_max_precipitation,n)
quantile(lautaro_max_precipitation,n)
quantile(loros_max_precipitation,n)
quantile(annual_max_flow_rate,n)
quantile(winter_temp,n)
quantile(summer_temp,n)
quantile(spring_temp,n)
quantile(autumn_temp,n)
qgamma(n,shape=0.363,rate=0.024)#elibor
qexp(n,rate = 0.0558)#lautaro
qweibull(n,shape = 0.629,scale = 13.429)
qexp(n,rate = 0.2964)#caudal
qweibull(n,shape = 50.68,scale = 23.2)#verano
qweibull(n,shape = 60,scale = 20.5)#oto�o
qnorm(n,mean = 17.13 ,sd = 0.81)#invierno
qnorm(n,mean = 20.36 ,sd = 0.46)#primavea