Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Rpackages
IDF
Commits
f98603f3
Commit
f98603f3
authored
Aug 20, 2020
by
Laura Mack
Browse files
use RcppRoll-package instead of zoo::rollapplyr in IDF.agg
parent
dc65bf7c
Changes
7
Hide whitespace changes
Inline
Side-by-side
DESCRIPTION
View file @
f98603f3
...
...
@@ -17,7 +17,7 @@ Description: Intensity-duration-frequency (IDF) curves are a widely used analysi
Imports: stats4,
evd,
ismev,
zoo
,
RcppRoll
,
pbapply
License: GPL (>=2)
Encoding: UTF-8
...
...
NAMESPACE
View file @
f98603f3
...
...
@@ -10,6 +10,7 @@ export(gev.d.params)
export(pgev.d)
export(qgev.d)
export(rgev.d)
importFrom(RcppRoll,roll_sum)
importFrom(evd,dgev)
importFrom(evd,pgev)
importFrom(evd,qgev)
...
...
@@ -30,5 +31,3 @@ importFrom(stats,lm)
importFrom(stats,make.link)
importFrom(stats,median)
importFrom(stats,optim)
importFrom(zoo,as.zoo)
importFrom(zoo,rollapplyr)
R/IDF.R
View file @
f98603f3
...
...
@@ -34,8 +34,7 @@
#'
#' @export
#' @importFrom pbapply pbsapply
#' @importFrom zoo rollapplyr
#' @importFrom zoo as.zoo
#' @importFrom RcppRoll roll_sum
#'
#' @examples
#' dates <- as.Date("2019-01-01")+0:729
...
...
@@ -69,10 +68,11 @@
# function 1: aggregate over single durations and find annual maxima:
agg.ts
<-
function
(
ds
){
runmean
<-
rollapplyr
(
as.zoo
(
data.s
[,
names
[
2
]]),
ds
/
dtime
,
FUN
=
sum
,
fill
=
NA
,
align
=
'right'
)
runmean
<-
runmean
/
ds
#intensity per hour
runsum
=
RcppRoll
::
roll_sum
(
data.s
[,
names
[
2
]],
ds
/
dtime
,
fill
=
NA
)
#runmean <- rollapplyr(as.zoo(data.s[,names[2]]),ds/dtime,FUN=sum,fill =NA,align='right')
runsum
<-
runsum
/
ds
#intensity per hour
subset
<-
is.element
(
as.POSIXlt
(
data.s
[,
names
[
1
]])
$
mon
,
which.mon
)
max
<-
tapply
(
run
mean
[
subset
],(
as.POSIXlt
(
data.s
[,
names
[
1
]])
$
year
+1900
)[
subset
],
max
<-
tapply
(
run
sum
[
subset
],(
as.POSIXlt
(
data.s
[,
names
[
1
]])
$
year
+1900
)[
subset
],
function
(
vec
){
n.na
<-
sum
(
is.na
(
vec
))
max
<-
ifelse
(
n.na
<=
na.accept
,
max
(
vec
,
na.rm
=
TRUE
),
NA
)
...
...
R/gevdfit.R
View file @
f98603f3
...
...
@@ -13,7 +13,8 @@
#' modelling of each parameter.
#' @param xdat A vector containing maxima for different durations.
#' This can be obtained from \code{\link{IDF.agg}}.
#' @param ds A vector of aggregation levels corresponding to the maxima in xdat.
#' @param ds A vector of aggregation levels corresponding to the maxima in xdat.
#' 1/60 corresponds to 1 minute, 1 corresponds to 1 hour.
#' @param ydat A matrix of covariates for generalized linear modelling of the parameters
#' (or NULL (the default) for stationary fitting). The number of rows should be the same as the
#' length of xdat.
...
...
@@ -261,7 +262,6 @@ gev.d.fit<-
#' @description obtain initial values by fitting every duration seperately
#' @param xdat vector of maxima for differnt durations
#' @param ds vector of durations belonging to maxima in xdat
#' @param thetainit initial parameter for theta
#' @param link list of 5, link functions for parameters, created with \code{\link{make.link}}
#' @return list of initail values for mu_tilde, sigma_0, xi, eta
#' @importFrom stats lm
...
...
@@ -300,7 +300,7 @@ gev.d.init <- function(xdat,ds,link){
#' computes negative log-likelihood of d-gev model
#'
#' @param xdat numeric vector containing observations
#' @param ds numeric vector containing coresponding durations
#' @param ds numeric vector containing coresponding durations
(1/60 corresponds to 1 minute, 1 corresponds to 1 hour)
#' @param mut,sig0,xi,theta,eta numeric vectors containing corresponding mles for each of the parameters
#'
#' @return single value containing negative log likelihood
...
...
man/gev.d.fit.Rd
View file @
f98603f3
...
...
@@ -30,7 +30,8 @@ gev.d.fit(
\item{xdat}{A vector containing maxima for different durations.
This can be obtained from \code{\link{IDF.agg}}.}
\item{ds}{A vector of aggregation levels corresponding to the maxima in xdat.}
\item{ds}{A vector of aggregation levels corresponding to the maxima in xdat.
1/60 corresponds to 1 minute, 1 corresponds to 1 hour.}
\item{ydat}{A matrix of covariates for generalized linear modelling of the parameters
(or NULL (the default) for stationary fitting). The number of rows should be the same as the
...
...
man/gev.d.init.Rd
View file @
f98603f3
...
...
@@ -12,8 +12,6 @@ gev.d.init(xdat, ds, link)
\item{ds}{vector of durations belonging to maxima in xdat}
\item{link}{list of 5, link functions for parameters, created with \code{\link{make.link}}}
\item{thetainit}{initial parameter for theta}
}
\value{
list of initail values for mu_tilde, sigma_0, xi, eta
...
...
man/gev.d.nll.Rd
View file @
f98603f3
...
...
@@ -9,7 +9,7 @@ gev.d.nll(xdat, ds, mut, sig0, xi, theta, eta)
\arguments{
\item{xdat}{numeric vector containing observations}
\item{ds}{numeric vector containing coresponding durations}
\item{ds}{numeric vector containing coresponding durations
(1/60 corresponds to 1 minute, 1 corresponds to 1 hour)
}
\item{mut, sig0, xi, theta, eta}{numeric vectors containing corresponding mles for each of the parameters}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment