Commit 9838eed6 authored by Christoph Ritschel's avatar Christoph Ritschel
Browse files

Version_1.2

parent 096be90e
Package: IDF
Type: Package
Title: Estimation and Plotting of IDF Curves
Version: 1.1
Date: 2017-09-29
Version: 1.2
Date: 2018-01-22
Author: Christoph Ritschel, Carola Detring, Sarah Joedicke
Maintainer: Christoph Ritschel <christoph.ritschel@met.fu-berlin.de>
Description: Intensity-duration-frequency (IDF) curves are a widely used analysis-tool in hydrology to assess extreme values of precipitation [e.g. Mailhot et al., 2007, <doi:10.1016/j.jhydrol.2007.09.019>]. The package 'IDF' provides a function to read precipitation data from German weather service (DWD) 'webwerdis' <http://www.dwd.de/EN/ourservices/webwerdis/webwerdis.html> files and Berlin station data from 'Stadtmessnetz' <http://www.geo.fu-berlin.de/en/met/service/stadtmessnetz/index.html> files, and additionally IDF parameters can be estimated also from a given data.frame containing a precipitation time series. The data is aggregated to given levels yearly intensity maxima are calculated either for the whole year or given months. From these intensity maxima IDF parameters are estimated on the basis of a duration-dependent generalised extreme value distribution [Koutsoyannis et al., 1998, <doi:10.1016/S0022-1694(98)00097-3>]. IDF curves based on these estimated parameters can be plotted.
......
export(IDF.read,IDF.fit,IDF.plot,TS.acc)
export(IDF.read,IDF,IDF.plot,TS.acc)
import(ismev,
stats4,
......
......@@ -230,7 +230,7 @@ rgev.d <- function(n,mu=0,sigma=1,xi=0,theta=0,eta=1,d=1) {
x[which(is.nan(x))] <- NA
return(x)
}
}
#######################################################################
#' @title Negativ log-likelihood of modified GEV
......@@ -289,7 +289,7 @@ IDF.nll <- function(mu=0,sigma=1,xi=0,theta=0,eta=1,x,d,use.log=F,DEBUG=F) {
return(nll/length(x))
} # end of function IDF.nll
} # end of function IDF.nll
######################################################################################################
#' @title Fitting function to optimize IDF model parameters
......@@ -393,6 +393,24 @@ fit.fun <- function(obs,dur,mu=1,sigma=1,xi=0.5,theta=1,eta=1,use.log=F,DEBUG=F,
} ## end of function fit.fun
##################################################################################
#' @title Data aggregation for IDF parameter estimation
#' @description The function \code{IDF.agg} aggregates a data.frame of observations \code{data} with temporal inforamtion (at least years) and values of precipitation
#' at a given temporal resoultion at given aggregation levels \code{agg.lev} and yearly maxima of intensity are caluclated for a specific month or the whole year/dataset.
#' @param data a \code{data,frame}, preferably generated by function \code{IDF.read}. It should at least contain a \code{$RR} and \code{$year} element for the
#' function tow work properly. Also an option to use \code{moving.sum} is given. The function returns a vector of intensities and durations as well as the number of years of data.
#' @param agg.lev a vector of aggregation levels used to fit the IDF curves.
#' @param month \code{integer} value specifying the month to be used for estimating the IDF parameters. Type "all" for all months or if
#' the whole time series should be fitted.
#' @param moving.sum \code{logical} specifying if moving sum filtering should be applied for time series aggregation.
#' @return $ints.vec vector of sorted intensities for selected aggregation levels
#' @return $durs vector of sorted aggregation levels
#' @return $n.y number of years of data
#' @examples
#' RR <- rgamma(10*30*24,shape=1)
#' year <- sort(rep(1:(10),30*24))
#' data <- data.frame(RR,year)
#' data.agg <- IDF.agg(data)
#' @author Christoph Ritschel \email{christoph.ritschel@@met.fu-berlin.de}
IDF.agg <- function(data,agg.lev=c(2,3,6,12,24,48,72,96),month="all",moving.sum="FALSE",DEBUG=FALSE) {
......@@ -405,7 +423,7 @@ IDF.agg <- function(data,agg.lev=c(2,3,6,12,24,48,72,96),month="all",moving.sum=
agg.1 <- array(NA,dim=c(n.y))
ints <- array(NA,dim=c(n.y*n.a))
###loop over years
###loop over years
for(y in 1:n.y) {
if(month[1]=="all") {
......@@ -417,7 +435,7 @@ IDF.agg <- function(data,agg.lev=c(2,3,6,12,24,48,72,96),month="all",moving.sum=
RR.year <- RR[index]
agg.1[y] <- max(RR.year,na.rm=T)
###loop over agg.lev
###loop over agg.lev
for(a in 1:n.a) {
ints[y+((a-1)*n.y)] <- max(TS.acc(RR.year,agg.lev[a],moving.sum=moving.sum),na.rm=T)/agg.lev[a]
......@@ -435,7 +453,80 @@ IDF.agg <- function(data,agg.lev=c(2,3,6,12,24,48,72,96),month="all",moving.sum=
durs <- rep(d.all,each=n.y)
return(list(int.vec=int.vec,durs=durs,n.y=n.y))
}
} #
###############################################################################
#' @title Estimation of initial values for IDF fitting.
#' @description The function \code{IDF.init} estimates inital values for \code{mu,sigma,xi and eta} assuming \code{theta}
#' equals zero. A generalized extreme value distribution is fitted individually for each year and then the inital values
#' for the duration dependent gev fit are estimated from those by applying a linear regression to the scale parameters of each year.
#' @param int.vec a \code{vector} of yearly maxima of intensity sorted by year and aggregatin level
#' @param durs a \code{vector} of durations used to fit the model. Has to have same length and order as \code{int.vec}
#' @param n.y \code{integer} value specifying the number of years of data.
#' @param method \code{character} defining the method to be used in \code{optim}, preferences are: "Nelder-Mead", "BFGS", "L-BFGS-B"e
#' @return $mu initial estimation of location parameter
#' @return $sigma initial estimation of scale parameter
#' @return $xi inital estimation of shape parameter
#' @return $eta intial estimation of slope parameter for sigma-power law.
#' @examples
#' RR <- rgamma(10*30*24,shape=1)
#' year <- sort(rep(1:(10),30*24))
#' data <- data.frame(RR,year)
#' data.agg <- IDF.agg(data,agg.lev=c(2,6,12,24))
#' pars.init <- IDF.init(data.agg$int.vec,data.agg$durs,data.agg$n.y)
#' @author Christoph Ritschel \email{christoph.ritschel@@met.fu-berlin.de}
IDF.init <- function(int.vec,durs,n.y,method="Nelder-Mead") {
## Fit a generalized extreme value distribution to the maximum intensities of each year for a single
## aggregation level and write the estimated parameters in an array for further analyisis.
d.all <- unique(durs)
ints.all <- matrix(int.vec,nrow=n.y) ## sort intensities in a matrix, rows are years, columns are aggregation levels
pars <- array(NA,dim=c(3,length(d.all)))
## In case of NA values the optimization fails, therefore years with NA values need to be removed.
ints.all <- matrix(ints.all[rowSums(!is.na(ints.all)) == length(d.all)],ncol=length(d.all))
if(nrow(ints.all)<3) {
cat("Warning: optimization did not converge and no parameters were estimated. Time Series contains less than 3 years of valid data. \n")
mu=NA
sigma=NA
xi=NA
eta=NA
}else{
## loop over all aggregation levels
for(d in 1:length(d.all)) {
#fit <- fit.fun.emp(obs=ints.all[,d],mu=mu,sigma=sigma,xi=xi,use.log=use.log,
# DEBUG=DEBUG,method=method,upper=upper,lower=lower)
fit <- gev.fit(xdat=ints.all[,d],method=method,show=F)
pars[,d] <- fit$mle
} ## end loop over aggregation levels
#############################################################
### Derive starting parameters for duration-dependent GEV ###
#############################################################
## Fit a linear model to the individual sigmas for individual aggregation times in a log-log environment
## The slope coefficient is an estimate for the slope in the duration-dependent GEV, namely parameter eta
## The intersection is an estimation of the starting parameter sigma
## Parameter mu is estimated as mean value of individual mus divided by indiviudal sigmas
## The initial value for xi will be the mean of all individual xi, since it is approximately independent of duration
formel <- lm(log(pars[2,]) ~ log(d.all))
sigma <- as.numeric(exp(formel$coefficients[1]))
mu <- mean(pars[1,]/pars[2,])
eta <- as.numeric(-formel$coefficients[2])
xi <- max(0,mean(pars[3,],na.rm=T))
}
return(list("mu"=mu,"sigma"=sigma,"xi"=xi,"eta"=eta))
} # EOF
#################################################################################
#' @title Fitting IDF model parameters to observations at different durations
#' @description The function \code{IDF.fit} fits the IDF model parameters \code{mu,sigma,xi,eta,theta}
......@@ -451,6 +542,10 @@ IDF.agg <- function(data,agg.lev=c(2,3,6,12,24,48,72,96),month="all",moving.sum=
#' @param month \code{integer} value specifying the month to be used for estimating the IDF parameters. Type "all" for all months or if
#' the whole time series should be fitted.
#' @param moving.sum \code{logical} specifying if moving sum filtering should be applied for time series aggregation.
#' @param mu.init initial estimation of location parameter, default is NA. Initial value estimated by fitting individual gev parameters
#' @param sigma.init initial estimation of scale parameter,default is NA. Initial value estimated by fitting individual gev parameters
#' @param xi.init inital estimation of shape parameter, default is NA. Initial value estimated by fitting individual gev parameters
#' @param eta.init intial estimation of slope parameter for sigma-power law, default is NA. Initial value estimated by fitting individual gev parameters
#' @param theta.init inital value defining the curvature of the IDF, default is zero, it is not recommended to change it
#' @param use.log \code{logical} value for usage of logarithmic values, default is \code{FALSE}
#' @param DEBUG \code{logical} value for usage of debugging, if \code{TRUE} the input parameters and the value of negative
......@@ -475,7 +570,7 @@ IDF.agg <- function(data,agg.lev=c(2,3,6,12,24,48,72,96),month="all",moving.sum=
#' pars <- fit$par
#' @author Christoph Ritschel \email{christoph.ritschel@@met.fu-berlin.de}
IDF.fit <- function(data,agg.lev=c(2,3,6,12,24,48,72,96),month="all",moving.sum="FALSE",theta.init=0,
IDF <- function(data,agg.lev=c(2,3,6,12,24,48,72,96),month="all",moving.sum="FALSE",mu.init=NA,sigma.init=NA,xi.init=NA,theta.init=0,eta.init=NA,
use.log=FALSE,DEBUG=FALSE,method="Nelder-Mead",upper=Inf,lower=-Inf,plot=FALSE,
probs=c(0.5,0.9,0.99),cols=c(rgb(1,0,0,1),rgb(0,1,0,1),rgb(0,0,1,1)),station.name="Berlin",data.name="obs") {
......@@ -487,61 +582,29 @@ IDF.fit <- function(data,agg.lev=c(2,3,6,12,24,48,72,96),month="all",moving.sum=
durs <- dummy.list$durs
n.y <- dummy.list$n.y
###############################################
### Estimate Parameters for single duration ###
###############################################
## Fit a generalized extreme value distribution to the maximum intensities of each year for a single
## aggregation level and write the estimated parameters in an array for further analyisis.
ints.all <- matrix(int.vec,nrow=n.y) ## sort intensities in a matrix, rows are years, columns are aggregation levels
pars <- array(NA,dim=c(3,length(d.all)))
d.all <- unique(durs)
###################################################################################
### Estimate Parameters for single duration if not given initial values by user ###
###################################################################################
if(is.na(mu.init) | is.na(sigma.init) | is.na(xi.init) | is.na(eta.init)) {
## In case of NA values the optimization fails, therefore years with NA values need to be removed.
ints.all <- matrix(ints.all[rowSums(!is.na(ints.all)) == length(d.all)],ncol=length(d.all))
pars.init <- IDF.init(int.vec,durs,n.y,method)
mu.init <- pars.init$mu
sigma.init <- pars.init$sigma
xi.init <- pars.init$xi
eta.init <- pars.init$eta
if(length(ints.all)==0) {
cat("Warning: optimization did not converge and no parameters were estimated. Time Series contains too many NA values. \n")
}else{
## loop over all aggregation levels
for(d in 1:length(d.all)) {
#fit <- fit.fun.emp(obs=ints.all[,d],mu=mu,sigma=sigma,xi=xi,use.log=use.log,
# DEBUG=DEBUG,method=method,upper=upper,lower=lower)
if(method=="L-BFGS-B"){
fit <- gev.fit(xdat=ints.all[,d],method=method,upper=upper,lower=lower,show=F)
}else{
fit <- gev.fit(xdat=ints.all[,d],method=method,show=F)
}
pars[,d] <- fit$mle
} ## end loop over aggregation levels
#############################################################
### Derive starting parameters for duration-dependent GEV ###
#############################################################
## Fit a linear model to the individual sigmas for individual aggregation times in a log-log environment
## The slope coefficient is an estimate for the slope in the duration-dependent GEV, namely parameter eta
## The intersection is an estimation of the starting parameter sigma
## Parameter mu is estimated as mean value of individual mus divided by indiviudal sigmas
## The initial value for xi will be the mean of all individual xi, since it is approximately independent of duration
formel <- lm(log(pars[2,]) ~ log(d.all))
sigma.est <- as.numeric(exp(formel$coefficients[1]))
mu.est <- mean(pars[1,]/pars[2,])
eta.est <- as.numeric(-formel$coefficients[2])
xi.est <- max(0,mean(pars[3,],na.rm=T))
######################################################
### Estimate parameters for duration-dependent GEV ###
######################################################
fit <- fit.fun(obs=int.vec,dur=durs,mu=mu.est,sigma=sigma.est,xi=xi.est,theta=theta.init,eta=eta.est,use.log=use.log,
if(!is.na(mu.init) | !is.na(sigma.init) | !is.na(xi.init) | !is.na(eta.init)) {
fit <- fit.fun(obs=int.vec,dur=durs,mu=mu.init,sigma=sigma.init,xi=xi.init,theta=theta.init,eta=eta.init,use.log=use.log,
DEBUG=DEBUG,method=method,upper=upper,lower=lower)
}else {
cat("Warning: Optimization not carried out due to invalid initial values. \n")
fit.min <- NA
}
######################################################
### success? Than plot! ###
######################################################
......@@ -551,7 +614,6 @@ IDF.fit <- function(data,agg.lev=c(2,3,6,12,24,48,72,96),month="all",moving.sum=
IDF.plot(pars=fit$par,probs,st.name=station.name,dt.name=data.name,ints=int.vec,ds=durs)
}
}
if(!plot && is.na(fit$min)) {
cat("Warning: optimization did not converge and no parameters were estimated. \n")
......@@ -563,34 +625,34 @@ IDF.fit <- function(data,agg.lev=c(2,3,6,12,24,48,72,96),month="all",moving.sum=
return(list("ints"=int.vec,"durs"=durs,"min"=fit$min,"par"=fit$par))
} ## End of function IDF.fit
######################################################################################################################
########################################################################################################
#' @title Plotting IDF curves
#' @description The function \code{IDF.plot} plots a set of IDF curves with given IDF model parameters \code{pars} for
#' several probability levels \code{probs} at given durations \code{dur}. The colors of the curves can be defined with
#' parameter \code{cols} (need to have same length as \code{probs}). The \code{station.name} will be printed in the legend.
#' @param pars a vector of IDF model parameters mu,sigma,xi,eta,theta
#' @param probs a vector of probabilities for which the IDF curves are calculated
#' @param dur a vector of durations at which the IDF curves are calculated
#' @param cols a vector of colors for the seperate IDF curves, needs same length as \code{probs}
#' @param st.name \code{character} overall naming of the IDF plot, e.g. name of location or model name
#' @param dt.name \code{character} naming the data points, e.g. obs or model name
#' @param ints \code{vector} of observational intensities (surted by durations)
#' @param ds \code{vector} of durations (same length as intensities)
#' @examples
#' RR <- rgamma(10*30*24,shape=1)
#' year <- sort(rep(1:(10),30*24))
#' data <- data.frame(RR,year)
#' fit <- IDF.fit(data)
#' param <- fit$par
#' IDF.plot(pars=param,st.name="example",dt.name="rgamma")
#' @author Christoph Ritschel \email{christoph.ritschel@@met.fu-berlin.de}
IDF.plot <- function(pars,probs=c(0.5,0.9,0.99),dur=c(0.5,1,2,3,6,12,24,48,72,96),cols=c(rgb(1,0,0,1),rgb(0,1,0,1),rgb(0,0,1,1)),st.name="Berlin-Dahlem",dt.name="obs",ints=NA,ds=NA) {
## initialize array for IDF values at different durations and for different probabilities
} ## End of function IDF.fit
######################################################################################################################
########################################################################################################
#' @title Plotting IDF curves
#' @description The function \code{IDF.plot} plots a set of IDF curves with given IDF model parameters \code{pars} for
#' several probability levels \code{probs} at given durations \code{dur}. The colors of the curves can be defined with
#' parameter \code{cols} (need to have same length as \code{probs}). The \code{station.name} will be printed in the legend.
#' @param pars a vector of IDF model parameters mu,sigma,xi,eta,theta
#' @param probs a vector of probabilities for which the IDF curves are calculated
#' @param dur a vector of durations at which the IDF curves are calculated
#' @param cols a vector of colors for the seperate IDF curves, needs same length as \code{probs}
#' @param st.name \code{character} overall naming of the IDF plot, e.g. name of location or model name
#' @param dt.name \code{character} naming the data points, e.g. obs or model name
#' @param ints \code{vector} of observational intensities (surted by durations)
#' @param ds \code{vector} of durations (same length as intensities)
#' @examples
#' RR <- rgamma(10*30*24,shape=1)
#' year <- sort(rep(1:(10),30*24))
#' data <- data.frame(RR,year)
#' fit <- IDF.fit(data)
#' param <- fit$par
#' IDF.plot(pars=param,st.name="example",dt.name="rgamma")
#' @author Christoph Ritschel \email{christoph.ritschel@@met.fu-berlin.de}
IDF.plot <- function(pars,probs=c(0.5,0.9,0.99),dur=c(0.5,1,2,3,6,12,24,48,72,96),cols=c(rgb(1,0,0,1),rgb(0,1,0,1),rgb(0,0,1,1)),st.name="Berlin-Dahlem",dt.name="obs",ints=NA,ds=NA) {
## initialize array for IDF values at different durations and for different probabilities
idf.array <- array(NA,dim=c(length(dur),length(probs)))
## loop over probabilities
......@@ -619,7 +681,8 @@ IDF.plot <- function(pars,probs=c(0.5,0.9,0.99),dur=c(0.5,1,2,3,6,12,24,48,72,96
legend(x="topright",legend=c(st.name,dt.name,paste(probs,legend.text.2,sep=" ")),
col=c(1,rgb(0,0,0,0.5),cols),lty=c(NA,NA,rep(1,length(cols))),pch=c(NA,16,rep(NA,length(cols))))
} ## end of function IDF.plot
###################################################################################
} ## end of function IDF.plot
###################################################################################
\ No newline at end of file
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/IDF.R
\name{IDF}
\alias{IDF}
\title{Fitting IDF model parameters to observations at different durations}
\usage{
IDF(data, agg.lev = c(2, 3, 6, 12, 24, 48, 72, 96), month = "all",
moving.sum = "FALSE", mu.init = NA, sigma.init = NA, xi.init = NA,
theta.init = 0, eta.init = NA, use.log = FALSE, DEBUG = FALSE,
method = "Nelder-Mead", upper = Inf, lower = -Inf, plot = FALSE,
probs = c(0.5, 0.9, 0.99), cols = c(rgb(1, 0, 0, 1), rgb(0, 1, 0, 1),
rgb(0, 0, 1, 1)), station.name = "Berlin", data.name = "obs")
}
\arguments{
\item{data}{a \code{data,frame}, preferably generated by function \code{IDF.read}. It should at least contain a \code{$RR} and \code{$year} element for the
function tow work properly.}
\item{agg.lev}{a vector of aggregation levels used to fit the IDF curves.}
\item{month}{\code{integer} value specifying the month to be used for estimating the IDF parameters. Type "all" for all months or if
the whole time series should be fitted.}
\item{moving.sum}{\code{logical} specifying if moving sum filtering should be applied for time series aggregation.}
\item{mu.init}{initial estimation of location parameter, default is NA. Initial value estimated by fitting individual gev parameters}
\item{sigma.init}{initial estimation of scale parameter,default is NA. Initial value estimated by fitting individual gev parameters}
\item{xi.init}{inital estimation of shape parameter, default is NA. Initial value estimated by fitting individual gev parameters}
\item{theta.init}{inital value defining the curvature of the IDF, default is zero, it is not recommended to change it}
\item{eta.init}{intial estimation of slope parameter for sigma-power law, default is NA. Initial value estimated by fitting individual gev parameters}
\item{use.log}{\code{logical} value for usage of logarithmic values, default is \code{FALSE}}
\item{DEBUG}{\code{logical} value for usage of debugging, if \code{TRUE} the input parameters and the value of negative}
\item{method}{\code{character} defining the method to be used in \code{optim}, preferences are: "Nelder-Mead", "BFGS", "L-BFGS-B"e}
\item{upper}{\code{vector} specifying the upper boundary of parameters for "L-BFGS-B" method}
\item{lower}{\code{vector} specifying the lower boundary of parameters for "L-BFGS-B" method}
\item{plot}{\code{logical} option of creating a plot of IDF curves with estimated parameters.}
\item{probs}{a vector of probabilities for which the IDF curves are calculated}
\item{cols}{a vector of colors for the seperate IDF curves, needs same length as \code{probs}}
\item{station.name}{\code{character} overall naming of the IDF plot, e.g. name of location or model name}
\item{data.name}{\code{character} naming the data points, e.g. obs or model name}
}
\value{
$ints vector of sorted intensities for selected aggregation levels
$durs vector of sorted aggregation levels
$min minimum value of negative log-likelihood during optimization
$par vector of estimated IDF model parameters mu,sigma,xi,theta,eta at minimum value of negative log-likelihood.
}
\description{
The function \code{IDF.fit} fits the IDF model parameters \code{mu,sigma,xi,eta,theta}
to a data.frame of observations \code{data} with temporal inforamtion (at least years) and values of precipitation
at a given temporal resoultion. This precipitation time series gets aggregated at given aggregation levels.
\code{agg.lev} and yearly maxima of intensity are caluclated for a specific month or the whole year/dataset.
The starting values of the IDF model parameters can be determined by the user as well as specific options to use
during optimization. Logartihmic transformation, debugging, the optimization method, and an option to plot the
IDF curves.
}
\examples{
RR <- rgamma(10*30*24,shape=1)
year <- sort(rep(1:(10),30*24))
data <- data.frame(RR,year)
fit <- IDF.fit(data)
pars <- fit$par
}
\author{
Christoph Ritschel \email{christoph.ritschel@met.fu-berlin.de}
}
% Generated by roxygen2 (4.1.1): do not edit by hand
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/IDF.R
\name{IDF.agg}
\alias{IDF.agg}
\title{Aggregation of a time series for seperated time steps}
\title{Data aggregation for IDF parameter estimation}
\usage{
IDF.agg(x, ks=c(2,4,8,16,32,64,128))
IDF.agg(data, agg.lev = c(2, 3, 6, 12, 24, 48, 72, 96), month = "all",
moving.sum = "FALSE", DEBUG = FALSE)
}
\arguments{
\item{x}{a \code{list} containing a \code{data.frame} named 't1', preferably generated by function \code{IDF.read}.}
\item{data}{a \code{data,frame}, preferably generated by function \code{IDF.read}. It should at least contain a \code{$RR} and \code{$year} element for the
function tow work properly. Also an option to use \code{moving.sum} is given. The function returns a vector of intensities and durations as well as the number of years of data.}
\item{ks}{a numeric \code{vector} of aggregatation levels. Each value represents an aggregation level and will create
a new \code{data.frame} in the output list.}
\item{agg.lev}{a vector of aggregation levels used to fit the IDF curves.}
\item{month}{\code{integer} value specifying the month to be used for estimating the IDF parameters. Type "all" for all months or if
the whole time series should be fitted.}
\item{moving.sum}{\code{logical} specifying if moving sum filtering should be applied for time series aggregation.}
}
\value{
Liste a \code{list} containing \code{data.frames} of original and aggregated precipitation time series with time information and
precipitation values.
$ints.vec vector of sorted intensities for selected aggregation levels
$durs vector of sorted aggregation levels
$n.y number of years of data
}
\description{
The function \code{IDF.agg} aggregates the precipitation values of a \code{data.frame} in a \code{list} in groups.
The list should be created by function \code{IDF.read} in a previous step.
The function \code{IDF.agg} aggregates a data.frame of observations \code{data} with temporal inforamtion (at least years) and values of precipitation
at a given temporal resoultion at given aggregation levels \code{agg.lev} and yearly maxima of intensity are caluclated for a specific month or the whole year/dataset.
}
\details{
This function is designed to aggregate data which has been read by function \code{IDF.read}.
The time given in the data is the end time, so the precipitation was added up to that time.
In this process the data will be summed up in groups, depending on the chosen aggregation levels. In the end,
the aggregated \code{data.frames} will be much shorter than the original one.
In the end, a new \code{list} containing several \code{data.frames} will be created. The first one will be the
initial data frame, now named agg0. The other data frames will be named 'agg' + the aggregation level number from ks.
\examples{
RR <- rgamma(10*30*24,shape=1)
year <- sort(rep(1:(10),30*24))
data <- data.frame(RR,year)
data.agg <- IDF.agg(data)
}
\author{
Sarah Joedicke \email{sarah.joedicke@fu-berlin.de}
}
\seealso{
read.data, agg.f().
Christoph Ritschel \email{christoph.ritschel@met.fu-berlin.de}
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/IDF.R
\name{IDF.init}
\alias{IDF.init}
\title{Estimation of initial values for IDF fitting.}
\usage{
IDF.init(int.vec, durs, n.y, method = "Nelder-Mead")
}
\arguments{
\item{int.vec}{a \code{vector} of yearly maxima of intensity sorted by year and aggregatin level}
\item{durs}{a \code{vector} of durations used to fit the model. Has to have same length and order as \code{int.vec}}
\item{n.y}{\code{integer} value specifying the number of years of data.}
\item{method}{\code{character} defining the method to be used in \code{optim}, preferences are: "Nelder-Mead", "BFGS", "L-BFGS-B"e}
}
\value{
$mu initial estimation of location parameter
$sigma initial estimation of scale parameter
$xi inital estimation of shape parameter
$eta intial estimation of slope parameter for sigma-power law.
}
\description{
The function \code{IDF.init} estimates inital values for \code{mu,sigma,xi and eta} assuming \code{theta}
equals zero. A generalized extreme value distribution is fitted individually for each year and then the inital values
for the duration dependent gev fit are estimated from those by applying a linear regression to the scale parameters of each year.
}
\examples{
RR <- rgamma(10*30*24,shape=1)
year <- sort(rep(1:(10),30*24))
data <- data.frame(RR,year)
data.agg <- IDF.agg(data,agg.lev=c(2,6,12,24))
pars.init <- IDF.init(data.agg$int.vec,data.agg$durs,data.agg$n.y)
}
\author{
Christoph Ritschel \email{christoph.ritschel@met.fu-berlin.de}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment