Commit 109388cb authored by Felix Fauer's avatar Felix Fauer
Browse files

merge parametrization (with multiscaling and flattening) into master, which...

merge parametrization (with multiscaling and flattening) into master, which had minor bugfixes in the meantime (aggregation function and likelihood sign)

Merge branch 'parametrization' into development
parents 1871bd41 43f461b4
...@@ -27,6 +27,11 @@ ...@@ -27,6 +27,11 @@
#' and shape parameter \eqn{\xi\in R}, \eqn{\xi\neq 0}. #' and shape parameter \eqn{\xi\in R}, \eqn{\xi\neq 0}.
#' The parameters \eqn{\theta \leq 0} and \eqn{0<\eta<1} are duration offset and duration exponent #' The parameters \eqn{\theta \leq 0} and \eqn{0<\eta<1} are duration offset and duration exponent
#' and describe the slope and curvature in the resulting IDF curves, respectively. #' and describe the slope and curvature in the resulting IDF curves, respectively.
#' * The dependence of scale and location parameter on duration, \eqn{\sigma(d)} and \eqn{\mu(d)}, can be extended by multiscaling
#' and flattening, if requested. Multiscaling introduces a second duration exponent \eqn{\eta_2}, enabling the model to change slope
#' linearly with return period. Flattening adds a parameter \eqn{\tau}, that flattens the IDF curve for long durations:
#' \deqn{\sigma(x)=\sigma_0(d+\theta)^{-\eta_2}+\tau }
#' \deqn{\mu(x)=\tilde{\mu}(\sigma_0(d+\theta)^{-\eta_1}+\tau)}
#' * A useful introduction to __Maximum Likelihood Estimation__ for fitting for the #' * A useful introduction to __Maximum Likelihood Estimation__ for fitting for the
#' generalized extreme value distribution (GEV) is provided by Coles (2001). It should be noted, however, that this method uses #' generalized extreme value distribution (GEV) is provided by Coles (2001). It should be noted, however, that this method uses
#' the assumption that block maxima (of different durations or stations) are independent of each other. #' the assumption that block maxima (of different durations or stations) are independent of each other.
...@@ -225,13 +230,11 @@ NULL ...@@ -225,13 +230,11 @@ NULL
IDF.plot <- function(durations,fitparams,probs=c(0.5,0.9,0.99), IDF.plot <- function(durations,fitparams,probs=c(0.5,0.9,0.99),
cols=4:2,add=FALSE, cols=4:2,add=FALSE,
legend=TRUE,...){ legend=TRUE,...){
# if cols is too short, make longer
# if cols is to short, make longer
if(length(cols)!=length(probs))cols <- rep_len(cols,length.out=length(probs)) if(length(cols)!=length(probs))cols <- rep_len(cols,length.out=length(probs))
## calculate IDF values for given probability and durations ## calculate IDF values for given probability and durations
qs <- lapply(durations,qgev.d,p=probs,mut=fitparams[1],sigma0=fitparams[2],xi=fitparams[3], qs <- lapply(durations,qgev.d,p=probs,mut=fitparams[1],sigma0=fitparams[2],xi=fitparams[3],
theta=fitparams[4],eta=fitparams[5]) theta=fitparams[4],eta=fitparams[5], eta2=fitparams[6], tau=fitparams[7])
idf.array <- matrix(unlist(qs),length(probs),length(durations)) # array[probs,durs] idf.array <- matrix(unlist(qs),length(probs),length(durations)) # array[probs,durs]
if(!add){ #new plot if(!add){ #new plot
## initialize plot window ## initialize plot window
...@@ -249,7 +252,6 @@ IDF.plot <- function(durations,fitparams,probs=c(0.5,0.9,0.99), ...@@ -249,7 +252,6 @@ IDF.plot <- function(durations,fitparams,probs=c(0.5,0.9,0.99),
# empty plot # empty plot
plot(NA,xlim=xlim,ylim=ylim,xlab="Duration [h]",ylab="Intensity [mm/h]",log="xy",main=main) plot(NA,xlim=xlim,ylim=ylim,xlab="Duration [h]",ylab="Intensity [mm/h]",log="xy",main=main)
} }
## plot IDF curves ## plot IDF curves
for(i in 1:length(probs)){ for(i in 1:length(probs)){
lines(durations,idf.array[i,],col=cols[i],...) lines(durations,idf.array[i,],col=cols[i],...)
......
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
#' shape parameter \eqn{\xi}. #' shape parameter \eqn{\xi}.
#' @param theta numeric value, giving duration offset \eqn{\theta} (defining curvature of the IDF curve) #' @param theta numeric value, giving duration offset \eqn{\theta} (defining curvature of the IDF curve)
#' @param eta numeric value, giving duration exponent \eqn{\eta} (defining slope of the IDF curve) #' @param eta numeric value, giving duration exponent \eqn{\eta} (defining slope of the IDF curve)
#' @param eta2 numeric value, giving a second duration exponent \eqn{\eta_2} (needed for multiscaling). Default: NULL, treated as \eqn{\eta_2=\eta}.
#' @param tau numeric value, giving intensity offset \eqn{\tau} (defining flattening of the IDF curve). Default: \eqn{\tau=0}.
#' @param d positive numeric value, giving duration #' @param d positive numeric value, giving duration
#' @param ... additional parameters passed to \code{\link[evd]{dgev}} #' @param ... additional parameters passed to \code{\link[evd]{dgev}}
#' #'
...@@ -37,9 +39,10 @@ ...@@ -37,9 +39,10 @@
#' lines(x,dens[[i]],lty=i) #' lines(x,dens[[i]],lty=i)
#' } #' }
#' legend('topright',title = 'Duration',legend = 1:4,lty=1:4) #' legend('topright',title = 'Duration',legend = 1:4,lty=1:4)
dgev.d <- function(q,mut,sigma0,xi,theta,eta,d,...) { dgev.d <- function(q,mut,sigma0,xi,theta,eta,d,eta2=NULL,tau=0,...) {
if(any(c(length(mut),length(sigma0),length(xi),length(theta),length(eta))>1)){ if(is.null(eta2)){eta2=eta}
message('One of the parameters mut, sigma0, xi, theta, eta is a vector. ', if(any(c(length(mut),length(sigma0),length(xi),length(theta),length(eta),length(eta2),length(tau))>1)){
message('One of the parameters mut, sigma0, xi, theta, eta, tau is a vector. ',
'This is not intended and might cause an error.')} 'This is not intended and might cause an error.')}
if (d<=0) {stop('The duration d has to be positive.')} if (d<=0) {stop('The duration d has to be positive.')}
if(any(d+theta<=0)){ if(any(d+theta<=0)){
...@@ -47,8 +50,12 @@ dgev.d <- function(q,mut,sigma0,xi,theta,eta,d,...) { ...@@ -47,8 +50,12 @@ dgev.d <- function(q,mut,sigma0,xi,theta,eta,d,...) {
,theta, ' this will prododuce NAs.')} ,theta, ' this will prododuce NAs.')}
# if denominator is negative NAs will be returned # if denominator is negative NAs will be returned
if(d+theta<=0){return(rep(NA,length(q)))}else{ if(d+theta<=0){return(rep(NA,length(q)))}else{
sigma.d <-sigma0/(d+theta)^eta
return(dgev(q,loc=mut*sigma.d,scale=sigma.d,shape=xi,...))} #sigma.d <-sigma0/(d+theta)^eta+ tau # old
sigma.d <- sigma0/(d+theta)^eta2 +tau
mu.d <- mut*(sigma0/(d+theta)^eta +tau)
return(dgev(q,loc=mu.d,scale=sigma.d,shape=xi,...))}
} }
...@@ -61,6 +68,8 @@ dgev.d <- function(q,mut,sigma0,xi,theta,eta,d,...) { ...@@ -61,6 +68,8 @@ dgev.d <- function(q,mut,sigma0,xi,theta,eta,d,...) {
#' @param mut,sigma0,xi numeric value, giving modified location, modified scale and shape parameter #' @param mut,sigma0,xi numeric value, giving modified location, modified scale and shape parameter
#' @param theta numeric value, giving duration offset (defining curvature of the IDF curve) #' @param theta numeric value, giving duration offset (defining curvature of the IDF curve)
#' @param eta numeric value, giving duration exponent (defining slope of the IDF curve) #' @param eta numeric value, giving duration exponent (defining slope of the IDF curve)
#' @param eta2 numeric value, giving a second duration exponent \eqn{\eta_2} (needed for multiscaling). Default: NULL, treated as \eqn{\eta_2=\eta}.
#' @param tau numeric value, giving intensity offset \eqn{\tau} (defining flattening of the IDF curve). Default: \eqn{\tau=0}.
#' @param d positive numeric value, giving duration #' @param d positive numeric value, giving duration
#' @param ... additional parameters passed to \code{\link[evd]{pgev}} #' @param ... additional parameters passed to \code{\link[evd]{pgev}}
#' #'
...@@ -83,9 +92,10 @@ dgev.d <- function(q,mut,sigma0,xi,theta,eta,d,...) { ...@@ -83,9 +92,10 @@ dgev.d <- function(q,mut,sigma0,xi,theta,eta,d,...) {
#' @examples #' @examples
#' x <- seq(4,20,0.1) #' x <- seq(4,20,0.1)
#' prob <- pgev.d(q=x,mut=4,sigma0=2,xi=0,theta=0.1,eta=0.1,d=1) #' prob <- pgev.d(q=x,mut=4,sigma0=2,xi=0,theta=0.1,eta=0.1,d=1)
pgev.d <- function(q,mut,sigma0,xi,theta,eta,d,...) { pgev.d <- function(q,mut,sigma0,xi,theta,eta,d,tau=0,eta2=NULL, ...) {
if(any(c(length(mut),length(sigma0),length(xi),length(theta),length(eta))>1)){ if(is.null(eta2)){eta2=eta}
message('One of the parameters mut, sigma0, xi, theta, eta is a vector. ', if(any(c(length(mut),length(sigma0),length(xi),length(theta),length(eta),length(eta2),length(tau))>1)){
message('One of the parameters mut, sigma0, xi, theta, eta, tau is a vector. ',
'This is not intended and might cause an error.')} 'This is not intended and might cause an error.')}
if (d<=0) {stop('The duration d has to be positive.')} if (d<=0) {stop('The duration d has to be positive.')}
if(any(d+theta<=0)){ if(any(d+theta<=0)){
...@@ -93,8 +103,12 @@ pgev.d <- function(q,mut,sigma0,xi,theta,eta,d,...) { ...@@ -93,8 +103,12 @@ pgev.d <- function(q,mut,sigma0,xi,theta,eta,d,...) {
,theta, ' this will prododuce NAs.')} ,theta, ' this will prododuce NAs.')}
# if denominator is negative NAs will be returned # if denominator is negative NAs will be returned
if(d+theta<=0){return(rep(NA,length(q)))}else{ if(d+theta<=0){return(rep(NA,length(q)))}else{
sigma.d <-sigma0/(d+theta)^eta
return(pgev(q,loc=mut*sigma.d,scale=sigma.d,shape=xi,...))} #sigma.d <-sigma0/(d+theta)^eta+tau # old
sigma.d <- sigma0/(d+theta)^eta2 +tau
mu.d <- mut*(sigma0/(d+theta)^eta +tau)
return(pgev(q,loc=mu.d,scale=sigma.d,shape=xi,...))}
} }
...@@ -105,8 +119,10 @@ pgev.d <- function(q,mut,sigma0,xi,theta,eta,d,...) { ...@@ -105,8 +119,10 @@ pgev.d <- function(q,mut,sigma0,xi,theta,eta,d,...) {
#' @description Quantile function of duration-dependent GEV distribution (inverse of the cumulative probability distribution function) #' @description Quantile function of duration-dependent GEV distribution (inverse of the cumulative probability distribution function)
#' @param p vector of probabilities #' @param p vector of probabilities
#' @param mut,sigma0,xi numeric value, giving modified location, modified scale and shape parameter #' @param mut,sigma0,xi numeric value, giving modified location, modified scale and shape parameter
#' @param theta numeric value, giving duration offset (defining curvature of the IDF curve) #' @param theta numeric value, giving duration offset (defining curvature of the IDF curve for short durations)
#' @param eta numeric value, giving duration exponent (defining slope of the IDF curve) #' @param eta numeric value, giving duration exponent (defining slope of the IDF curve)
#' @param eta2 numeric value, giving a second duration exponent \eqn{\eta_2} (needed for multiscaling). Default: NULL, treated as \eqn{\eta_2=\eta}.
#' @param tau numeric value, giving intensity offset \eqn{\tau} (defining flattening of the IDF curve). Default: \eqn{\tau=0}.
#' @param d positive numeric value, giving duration #' @param d positive numeric value, giving duration
#' @param ... additional parameters passed to \code{\link[evd]{qgev}} #' @param ... additional parameters passed to \code{\link[evd]{qgev}}
#' #'
...@@ -129,7 +145,7 @@ pgev.d <- function(q,mut,sigma0,xi,theta,eta,d,...) { ...@@ -129,7 +145,7 @@ pgev.d <- function(q,mut,sigma0,xi,theta,eta,d,...) {
#' @examples #' @examples
#' p <- c(0.5,0.9,0.99) #' p <- c(0.5,0.9,0.99)
#' # calulate quantiles for one duration #' # calulate quantiles for one duration
#' qgev.d(p=p,mut=4,sigma0=2,xi=0,theta=0.1,eta=0.3,d=1) #' qgev.d(p=p,mut=4,sigma0=2,xi=0,theta=0.1,eta=0.3, d=1)
#' #'
#' # calculate quantiles for sequence of durations #' # calculate quantiles for sequence of durations
#' ds <- 2^seq(0,4,0.1) #' ds <- 2^seq(0,4,0.1)
...@@ -142,9 +158,10 @@ pgev.d <- function(q,mut,sigma0,xi,theta,eta,d,...) { ...@@ -142,9 +158,10 @@ pgev.d <- function(q,mut,sigma0,xi,theta,eta,d,...) {
#' } #' }
#' legend('topright',title = 'p-quantile', #' legend('topright',title = 'p-quantile',
#' legend = p,lty=1:3,bty = 'n') #' legend = p,lty=1:3,bty = 'n')
qgev.d <- function(p,mut,sigma0,xi,theta,eta,d,...) { qgev.d <- function(p,mut,sigma0,xi,theta,eta,d,tau=0,eta2=NULL, ...) {
if(any(c(length(mut),length(sigma0),length(xi),length(theta),length(eta))>1)){ if (is.null(eta2)){eta2=eta}
message('One of the parameters mut, sigma0, xi, theta, eta is a vector. ', if(any(c(length(mut),length(sigma0),length(xi),length(theta),length(eta), length(eta2), length(tau))>1)){
message('One of the parameters mut, sigma0, xi, theta, eta, eta2, tau is a vector. ',
'This is not intended and might cause an error.')} 'This is not intended and might cause an error.')}
if (d<=0) {stop('The duration d has to be positive.')} if (d<=0) {stop('The duration d has to be positive.')}
if(any(d+theta<=0)){ if(any(d+theta<=0)){
...@@ -152,9 +169,17 @@ qgev.d <- function(p,mut,sigma0,xi,theta,eta,d,...) { ...@@ -152,9 +169,17 @@ qgev.d <- function(p,mut,sigma0,xi,theta,eta,d,...) {
,theta, ' this will prododuce NAs.')} ,theta, ' this will prododuce NAs.')}
# if denominator is negative NAs will be returned # if denominator is negative NAs will be returned
if(d+theta<=0){return(rep(NA,length(p)))}else{ if(d+theta<=0){return(rep(NA,length(p)))}else{
sigma.d <-sigma0/(d+theta)^eta #sigma.d <-sigma0/(d+theta)^eta
return(qgev(p,loc=as.numeric(mut*sigma.d) #sigma.d <-sigma0/(d+theta)^eta+tau
sigma.d <- sigma0/(d+theta)^eta2 +tau
mu.d <- mut*(sigma0/(d+theta)^eta +tau)
return(qgev(p,loc=as.numeric(mu.d)
,scale=as.numeric(sigma.d),shape=as.numeric(xi),...))} ,scale=as.numeric(sigma.d),shape=as.numeric(xi),...))}
#return(qgev(p,loc=as.numeric(mut*sigma.d) # old
# ,scale=as.numeric(sigma.d),shape=as.numeric(xi),...))} # old
} }
...@@ -167,6 +192,8 @@ qgev.d <- function(p,mut,sigma0,xi,theta,eta,d,...) { ...@@ -167,6 +192,8 @@ qgev.d <- function(p,mut,sigma0,xi,theta,eta,d,...) {
#' @param mut,sigma0,xi numeric value, giving modified location, modified scale and shape parameter #' @param mut,sigma0,xi numeric value, giving modified location, modified scale and shape parameter
#' @param theta numeric value, giving duration offset (defining curvature of the IDF curve) #' @param theta numeric value, giving duration offset (defining curvature of the IDF curve)
#' @param eta numeric value, giving duration exponent (defining slope of the IDF curve) #' @param eta numeric value, giving duration exponent (defining slope of the IDF curve)
#' @param eta2 numeric value, giving a second duration exponent \eqn{\eta_2} (needed for multiscaling). Default: NULL, treated as \eqn{\eta_2=\eta}.
#' @param tau numeric value, giving intensity offset \eqn{\tau} (defining flattening of the IDF curve). Default: \eqn{\tau=0}.
#' @param d positive numeric value, giving duration #' @param d positive numeric value, giving duration
#' #'
#' @details For details on the d-GEV and the parameter definitions, see \link{IDF-package} #' @details For details on the d-GEV and the parameter definitions, see \link{IDF-package}
...@@ -193,9 +220,10 @@ qgev.d <- function(p,mut,sigma0,xi,theta,eta,d,...) { ...@@ -193,9 +220,10 @@ qgev.d <- function(p,mut,sigma0,xi,theta,eta,d,...) {
#' hist(samp[[2]],breaks = 10,add=TRUE,col=rgb(0,0,1,0.5),freq = FALSE) #' hist(samp[[2]],breaks = 10,add=TRUE,col=rgb(0,0,1,0.5),freq = FALSE)
#' legend('topright',fill = c(rgb(1,0,0,0.5),rgb(0,0,1,0.5)), #' legend('topright',fill = c(rgb(1,0,0,0.5),rgb(0,0,1,0.5)),
#' legend = paste('d=',1:2,'h'),title = 'Duration') #' legend = paste('d=',1:2,'h'),title = 'Duration')
rgev.d <- function(n,mut,sigma0,xi,theta,eta,d) { rgev.d <- function(n,mut,sigma0,xi,theta,eta,d,tau=0,eta2=NULL) {
if(any(c(length(mut),length(sigma0),length(xi),length(theta),length(eta))>1)){ if (is.null(eta2)){eta2=eta}
message('One of the parameters mut, sigma0, xi, theta, eta is a vector. ', if(any(c(length(mut),length(sigma0),length(xi),length(theta),length(eta),length(eta2),length(tau))>1)){
message('One of the parameters mut, sigma0, xi, theta, eta, tau is a vector. ',
'This is not intended and might cause an error.')} 'This is not intended and might cause an error.')}
if (d<=0) {stop('The duration d has to be positive.')} if (d<=0) {stop('The duration d has to be positive.')}
if(any(d+theta<=0)){ if(any(d+theta<=0)){
...@@ -203,8 +231,12 @@ rgev.d <- function(n,mut,sigma0,xi,theta,eta,d) { ...@@ -203,8 +231,12 @@ rgev.d <- function(n,mut,sigma0,xi,theta,eta,d) {
,theta, ' this will prododuce NAs.')} ,theta, ' this will prododuce NAs.')}
# if denominator is negative NAs will be returned # if denominator is negative NAs will be returned
if(d+theta<=0){return(rep(NA,n))}else{ if(d+theta<=0){return(rep(NA,n))}else{
sigma.d <-sigma0/(d+theta)^eta
return(rgev(n,loc=mut*sigma.d,scale=sigma.d,shape=xi))} #sigma.d <-sigma0/(d+theta)^eta+tau # old
sigma.d <- sigma0/(d+theta)^eta2 +tau
mu.d <- mut*(sigma0/(d+theta)^eta +tau)
return(rgev(n,loc=mu.d,scale=sigma.d,shape=xi))}
} }
This diff is collapsed.
...@@ -83,7 +83,7 @@ for(d in 1:2){ # d=1h and d=2h ...@@ -83,7 +83,7 @@ for(d in 1:2){ # d=1h and d=2h
hist(ann.max$xdat[ann.max$ds==d],main = paste('d=',d),q.min:q.max hist(ann.max$xdat[ann.max$ds==d],main = paste('d=',d),q.min:q.max
,freq = FALSE,add=TRUE,border = d) ,freq = FALSE,add=TRUE,border = d)
# etimated prob. density: # etimated prob. density:
lines(q,dgev.d(q,params$mut,params$sigma0,params$xi,params$theta,params$eta,d = d),col=d) lines(q,dgev.d(q,params$mut,params$sigma0,params$xi,params$theta,params$eta,params$tau,d = d),col=d)
} }
legend('topright',col=1:2,lwd=1,legend = paste('d=',1:2,'h'),title = 'Duration') legend('topright',col=1:2,lwd=1,legend = paste('d=',1:2,'h'),title = 'Duration')
``` ```
......
...@@ -25,6 +25,11 @@ modified location parameter \eqn{\tilde{\mu}=\mu/\sigma(d)\in R} ...@@ -25,6 +25,11 @@ modified location parameter \eqn{\tilde{\mu}=\mu/\sigma(d)\in R}
and shape parameter \eqn{\xi\in R}, \eqn{\xi\neq 0}. and shape parameter \eqn{\xi\in R}, \eqn{\xi\neq 0}.
The parameters \eqn{\theta \leq 0} and \eqn{0<\eta<1} are duration offset and duration exponent The parameters \eqn{\theta \leq 0} and \eqn{0<\eta<1} are duration offset and duration exponent
and describe the slope and curvature in the resulting IDF curves, respectively. and describe the slope and curvature in the resulting IDF curves, respectively.
\item The dependence of scale and location parameter on duration, \eqn{\sigma(d)} and \eqn{\mu(d)}, can be extended by multiscaling
and flattening, if requested. Multiscaling introduces a second duration exponent \eqn{\eta_2}, enabling the model to change slope
linearly with return period. Flattening adds a parameter \eqn{\tau}, that flattens the IDF curve for long durations:
\deqn{\sigma(x)=\sigma_0(d+\theta)^{-\eta_2}+\tau }
\deqn{\mu(x)=\tilde{\mu}(\sigma_0(d+\theta)^{-\eta_1}+\tau)}
\item A useful introduction to \strong{Maximum Likelihood Estimation} for fitting for the \item A useful introduction to \strong{Maximum Likelihood Estimation} for fitting for the
generalized extreme value distribution (GEV) is provided by Coles (2001). It should be noted, however, that this method uses generalized extreme value distribution (GEV) is provided by Coles (2001). It should be noted, however, that this method uses
the assumption that block maxima (of different durations or stations) are independent of each other. the assumption that block maxima (of different durations or stations) are independent of each other.
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
\alias{dgev.d} \alias{dgev.d}
\title{d-GEV probability density function} \title{d-GEV probability density function}
\usage{ \usage{
dgev.d(q, mut, sigma0, xi, theta, eta, d, ...) dgev.d(q, mut, sigma0, xi, theta, eta, d, eta2 = NULL, tau = 0, ...)
} }
\arguments{ \arguments{
\item{q}{vector of quantiles} \item{q}{vector of quantiles}
...@@ -18,6 +18,10 @@ shape parameter \eqn{\xi}.} ...@@ -18,6 +18,10 @@ shape parameter \eqn{\xi}.}
\item{d}{positive numeric value, giving duration} \item{d}{positive numeric value, giving duration}
\item{eta2}{numeric value, giving a second duration exponent \eqn{\eta_2} (needed for multiscaling). Default: NULL, treated as \eqn{\eta_2=\eta}.}
\item{tau}{numeric value, giving intensity offset \eqn{\tau} (defining flattening of the IDF curve). Default: \eqn{\tau=0}.}
\item{...}{additional parameters passed to \code{\link[evd]{dgev}}} \item{...}{additional parameters passed to \code{\link[evd]{dgev}}}
} }
\value{ \value{
......
...@@ -22,6 +22,8 @@ d-GEV parameters used for sampling: ...@@ -22,6 +22,8 @@ d-GEV parameters used for sampling:
\item \eqn{\sigma_0 = 2+0.5 cov_1} \item \eqn{\sigma_0 = 2+0.5 cov_1}
\item \eqn{\xi = 0.5} \item \eqn{\xi = 0.5}
\item \eqn{\theta = 0} \item \eqn{\theta = 0}
\item \eqn{\eta = 0.5}} \item \eqn{\eta = 0.5}
\item \eqn{\eta_2 = 0.5}
\item \eqn{\tau = 0}}
} }
\keyword{datasets} \keyword{datasets}
...@@ -13,13 +13,19 @@ gev.d.fit( ...@@ -13,13 +13,19 @@ gev.d.fit(
xil = NULL, xil = NULL,
thetal = NULL, thetal = NULL,
etal = NULL, etal = NULL,
taul = NULL,
eta2l = NULL,
mutlink = make.link("identity"), mutlink = make.link("identity"),
sigma0link = make.link("identity"), sigma0link = make.link("identity"),
xilink = make.link("identity"), xilink = make.link("identity"),
thetalink = make.link("identity"), thetalink = make.link("identity"),
etalink = make.link("identity"), etalink = make.link("identity"),
init.vals = as.list(rep(NA, 5)), taulink = make.link("identity"),
eta2link = make.link("identity"),
init.vals = NULL,
theta_zero = FALSE, theta_zero = FALSE,
tau_zero = TRUE,
eta2_zero = TRUE,
show = TRUE, show = TRUE,
method = "Nelder-Mead", method = "Nelder-Mead",
maxit = 10000, maxit = 10000,
...@@ -37,23 +43,27 @@ This can be obtained from \code{\link{IDF.agg}}.} ...@@ -37,23 +43,27 @@ This can be obtained from \code{\link{IDF.agg}}.}
(or NULL (the default) for stationary fitting). The number of rows should be the same as the (or NULL (the default) for stationary fitting). The number of rows should be the same as the
length of xdat.} length of xdat.}
\item{mutl, sigma0l, xil, thetal, etal}{Numeric vectors of integers, giving the columns of ydat that contain \item{mutl, sigma0l, xil, thetal, etal, taul, eta2l}{Numeric vectors of integers, giving the columns of ydat that contain
covariates for generalized linear modeling of the parameters (or NULL (the default) covariates for generalized linear modeling of the parameters (or NULL (the default)
if the corresponding parameter is stationary). if the corresponding parameter is stationary).
Parameters are: modified location, scale offset, shape, duration offset, duration exponent, respectively.} Parameters are: modified location, scale offset, shape, duration offset, duration exponent, respectively.}
\item{mutlink, sigma0link, xilink, thetalink, etalink}{Link functions for generalized linear \item{mutlink, sigma0link, xilink, thetalink, etalink, eta2link, taulink}{Link functions for generalized linear
modeling of the parameters, created with \code{\link{make.link}}. The default is \code{make.link("identity")}.} modeling of the parameters, created with \code{\link{make.link}}. The default is \code{make.link("identity")}.}
\item{init.vals}{list of length 5, giving initial values for all or some parameters \item{init.vals}{list, giving initial values for all or some parameters
(order: mut, sigma0, xi, theta, eta). If as.list(rep(NA,5)) (the default) is given, initial parameters are obtained (order: mut, sigma0, xi, theta, eta, eta2, tau). If one of those parameters shall not be used (see theta_zero, eta2_zero, tau_zero),
the number of parameters has to be reduced accordingly. If some or all given values in init.vals are NA or
no init.vals at all is declared (the default), initial parameters are obtained
internally by fitting the GEV separately for each duration and applying a linear model to obtain the internally by fitting the GEV separately for each duration and applying a linear model to obtain the
duration dependency of the location and shape parameter. duration dependency of the location and shape parameter.
Initial values for covariate parameters are assumed as 0 if not given.} Initial values for covariate parameters are assumed as 0 if not given.}
\item{theta_zero}{Logical value, indicating if theta should be estimated (FALSE, the default) or \item{theta_zero}{Logical value, indicating whether theta should be estimated (FALSE, the default) or
should stay zero.} should stay zero.}
\item{tau_zero, eta2_zero}{Logical values, indicating whether tau,eta2 should be estimated (TRUE, the default).}
\item{show}{Logical; if TRUE (the default), print details of the fit.} \item{show}{Logical; if TRUE (the default), print details of the fit.}
\item{method}{The optimization method used in \code{\link{optim}}.} \item{method}{The optimization method used in \code{\link{optim}}.}
...@@ -69,10 +79,10 @@ If \code{show} is TRUE, then assuming that successful convergence is indicated, ...@@ -69,10 +79,10 @@ If \code{show} is TRUE, then assuming that successful convergence is indicated,
the components nllh, mle and se are always printed. the components nllh, mle and se are always printed.
\item{nllh}{single numeric giving the negative log-likelihood value} \item{nllh}{single numeric giving the negative log-likelihood value}
\item{mle}{numeric vector giving the MLE's for the modified location, scale_0, shape, \item{mle}{numeric vector giving the MLE's for the modified location, scale_0, shape,
duration offset and duration exponent, resp.} duration offset and duration exponent, resp. If requested, contains also second duration exponent and intensity-offset}
\item{se}{numeric vector giving the standard errors for the MLE's (in the same order)} \item{se}{numeric vector giving the standard errors for the MLE's (in the same order)}
\item{trans}{A logical indicator for a non-stationary fit.} \item{trans}{A logical indicator for a non-stationary fit.}
\item{model}{A list with components mutl, sigma0l, xil, thetal and etal.} \item{model}{A list with components mutl, sigma0l, xil, thetal and etal. If requested, contains also eta2l and taul}
\item{link}{A character vector giving inverse link functions.} \item{link}{A character vector giving inverse link functions.}
\item{conv}{The convergence code, taken from the list returned by \code{\link{optim}}. \item{conv}{The convergence code, taken from the list returned by \code{\link{optim}}.
A zero indicates successful convergence.} A zero indicates successful convergence.}
...@@ -99,6 +109,8 @@ For details on the d-GEV and the parameter definitions, see \link{IDF-package}. ...@@ -99,6 +109,8 @@ For details on the d-GEV and the parameter definitions, see \link{IDF-package}.
# xi = 0.5 # xi = 0.5
# theta = 0 # theta = 0
# eta = 0.5 # eta = 0.5
# eta2 = 0.5
# tau = 0
data('example',package ='IDF') data('example',package ='IDF')
......
...@@ -14,7 +14,7 @@ gev.d.init(xdat, ds, link) ...@@ -14,7 +14,7 @@ gev.d.init(xdat, ds, link)
\item{link}{list of 5, link functions for parameters, created with \code{\link{make.link}}} \item{link}{list of 5, link functions for parameters, created with \code{\link{make.link}}}
} }
\value{ \value{
list of initial values for mu_tilde, sigma_0, xi, eta list of initial values for mu_tilde, sigma_0, xi, theta, eta, eta2, tau
} }
\description{ \description{
obtain initial values by fitting every duration separately obtain initial values by fitting every duration separately
......
...@@ -4,14 +4,25 @@ ...@@ -4,14 +4,25 @@
\alias{gev.d.lik} \alias{gev.d.lik}
\title{d-GEV Likelihood} \title{d-GEV Likelihood}
\usage{ \usage{
gev.d.lik(xdat, ds, mut, sigma0, xi, theta, eta, log = FALSE) gev.d.lik(
xdat,
ds,
mut,
sigma0,
xi,
theta,
eta,
log = FALSE,
tau = 0,
eta2 = NULL
)
} }
\arguments{ \arguments{
\item{xdat}{numeric vector containing observations} \item{xdat}{numeric vector containing observations}
\item{ds}{numeric vector containing corresponding durations (1/60 corresponds to 1 minute, 1 corresponds to 1 hour)} \item{ds}{numeric vector containing corresponding durations (1/60 corresponds to 1 minute, 1 corresponds to 1 hour)}
\item{mut, sigma0, xi, theta, eta}{numeric vectors containing corresponding estimates for each of the parameters} \item{mut, sigma0, xi, theta, eta, eta2, tau}{numeric vectors containing corresponding estimates for each of the parameters}
\item{log}{Logical; if TRUE, the log likelihood is returned.} \item{log}{Logical; if TRUE, the log likelihood is returned.}
} }
......
...@@ -12,11 +12,11 @@ gev.d.params(fit, ydat = NULL) ...@@ -12,11 +12,11 @@ gev.d.params(fit, ydat = NULL)
\item{ydat}{A matrix containing the covariates in the same order as used in \code{gev.d.fit}.} \item{ydat}{A matrix containing the covariates in the same order as used in \code{gev.d.fit}.}
} }
\value{ \value{
data.frame containing mu_tilde, sigma0, xi, theta, eta (or mu, sigma, xi for gev.fit objects) data.frame containing mu_tilde, sigma0, xi, theta, eta, eta2, tau (or mu, sigma, xi for gev.fit objects)
} }
\description{ \description{
function to calculate mut, sigma0, xi, theta, eta function to calculate mut, sigma0, xi, theta, eta, eta2, tau
(modified location, scale offset, shape, duration offset, duration exponent) (modified location, scale offset, shape, duration offset, duration exponent, second duration exponent, intensity offset)
from results of \code{\link{gev.d.fit}} with covariates or link functions other than identity. from results of \code{\link{gev.d.fit}} with covariates or link functions other than identity.
} }
\examples{ \examples{
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
\alias{pgev.d} \alias{pgev.d}
\title{d-GEV cumulative distribution function} \title{d-GEV cumulative distribution function}
\usage{ \usage{
pgev.d(q, mut, sigma0, xi, theta, eta, d, ...) pgev.d(q, mut, sigma0, xi, theta, eta, d, tau = 0, eta2 = NULL, ...)
} }
\arguments{ \arguments{
\item{q}{vector of quantiles} \item{q}{vector of quantiles}
...@@ -17,6 +17,10 @@ pgev.d(q, mut, sigma0, xi, theta, eta, d, ...) ...@@ -17,6 +17,10 @@ pgev.d(q, mut, sigma0, xi, theta, eta, d, ...)
\item{d}{positive numeric value, giving duration} \item{d}{positive numeric value, giving duration}
\item{tau}{numeric value, giving intensity offset \eqn{\tau} (defining flattening of the IDF curve). Default: \eqn{\tau=0}.}
\item{eta2}{numeric value, giving a second duration exponent \eqn{\eta_2} (needed for multiscaling). Default: NULL, treated as \eqn{\eta_2=\eta}.}
\item{...}{additional parameters passed to \code{\link[evd]{pgev}}} \item{...}{additional parameters passed to \code{\link[evd]{pgev}}}
} }
\value{ \value{
......
...@@ -4,19 +4,23 @@ ...@@ -4,19 +4,23 @@
\alias{qgev.d} \alias{qgev.d}
\title{d-GEV quantile function} \title{d-GEV quantile function}
\usage{ \usage{
qgev.d(p, mut, sigma0, xi, theta, eta, d, ...) qgev.d(p, mut, sigma0, xi, theta, eta, d, tau = 0, eta2 = NULL, ...)
} }
\arguments{ \arguments{
\item{p}{vector of probabilities} \item{p}{vector of probabilities}
\item{mut, sigma0, xi}{numeric value, giving modified location, modified scale and shape parameter} \item{mut, sigma0, xi}{numeric value, giving modified location, modified scale and shape parameter}
\item{theta}{numeric value, giving duration offset (defining curvature of the IDF curve)} \item{theta}{numeric value, giving duration offset (defining curvature of the IDF curve for short durations)}
\item{eta}{numeric value, giving duration exponent (defining slope of the IDF curve)} \item{eta}{numeric value, giving duration exponent (defining slope of the IDF curve)}
\item{d}{positive numeric value, giving duration} \item{d}{positive numeric value, giving duration}
\item{tau}{numeric value, giving intensity offset \eqn{\tau} (defining flattening of the IDF curve). Default: \eqn{\tau=0}.}
\item{eta2}{numeric value, giving a second duration exponent \eqn{\eta_2} (needed for multiscaling). Default: NULL, treated as \eqn{\eta_2=\eta}.}
\item{...}{additional parameters passed to \code{\link[evd]{qgev}}} \item{...}{additional parameters passed to \code{\link[evd]{qgev}}}
} }
\value{ \value{
...@@ -38,7 +42,7 @@ For details on the d-GEV and the parameter definitions, see \link{IDF-package}. ...@@ -38,7 +42,7 @@ For details on the d-GEV and the parameter definitions, see \link{IDF-package}.
\examples{ \examples{
p <- c(0.5,0.9,0.99) p <- c(0.5,0.9,0.99)
# calulate quantiles for one duration # calulate quantiles for one duration
qgev.d(p=p,mut=4,sigma0=2,xi=0,theta=0.1,eta=0.3,d=1) qgev.d(p=p,mut=4,sigma0=2,xi=0,theta=0.1,eta=0.3, d=1)
# calculate quantiles for sequence of durations # calculate quantiles for sequence of durations
ds <- 2^seq(0,4,0.1) ds <- 2^seq(0,4,0.1)
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
\alias{rgev.d} \alias{rgev.d}
\title{Generation of random variables from d-GEV}