Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Rpackages
IDF
Commits
3535fd24
Commit
3535fd24
authored
Sep 10, 2019
by
Jana Ulrich
Browse files
be able to pass init.vals, so that in iterations init.vals need to only be calculated once
parent
10e8be56
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
4 deletions
+16
-4
R/gevdfit.R
R/gevdfit.R
+9
-2
man/gev.d.fit.Rd
man/gev.d.fit.Rd
+7
-2
No files found.
R/gevdfit.R
View file @
3535fd24
...
@@ -31,6 +31,7 @@
...
@@ -31,6 +31,7 @@
#' @param show Logical; if TRUE (the default), print details of the fit.
#' @param show Logical; if TRUE (the default), print details of the fit.
#' @param method The optimization method used in \code{\link{optim}}.
#' @param method The optimization method used in \code{\link{optim}}.
#' @param maxit The maximum number of iterations.
#' @param maxit The maximum number of iterations.
#' @param init.vals vector of length 5, giving initial values for parameter intercepts
#' @param ... Other control parameters for the optimization.
#' @param ... Other control parameters for the optimization.
#' @return A list containing the following components.
#' @return A list containing the following components.
#' A subset of these components are printed after the fit.
#' A subset of these components are printed after the fit.
...
@@ -47,6 +48,9 @@
...
@@ -47,6 +48,9 @@
#' A zero indicates successful convergence.}
#' A zero indicates successful convergence.}
#' \item{data}{data is standardized to standart Gumbel.}
#' \item{data}{data is standardized to standart Gumbel.}
#' \item{cov}{The covariance matrix.}
#' \item{cov}{The covariance matrix.}
#' \item{vals}{Parameter values for every data point.}
#' \item{init.vals}{Initial values that where used.}
#' \item{ds}{Durations for every data point.}
#' @seealso \code{\link{dgev.d}}, \code{\link{IDF.agg}}, \code{\link{gev.fit}}, \code{\link{optim}}
#' @seealso \code{\link{dgev.d}}, \code{\link{IDF.agg}}, \code{\link{gev.fit}}, \code{\link{optim}}
#' @export
#' @export
#' @importFrom stats optim
#' @importFrom stats optim
...
@@ -69,7 +73,7 @@ gev.d.fit<-
...
@@ -69,7 +73,7 @@ gev.d.fit<-
function
(
xdat
,
ds
,
ydat
=
NULL
,
mul
=
NULL
,
sigl
=
NULL
,
shl
=
NULL
,
thetal
=
NULL
,
etal
=
NULL
,
function
(
xdat
,
ds
,
ydat
=
NULL
,
mul
=
NULL
,
sigl
=
NULL
,
shl
=
NULL
,
thetal
=
NULL
,
etal
=
NULL
,
mulink
=
identity
,
siglink
=
identity
,
shlink
=
identity
,
thetalink
=
identity
,
etalink
=
identity
,
mulink
=
identity
,
siglink
=
identity
,
shlink
=
identity
,
thetalink
=
identity
,
etalink
=
identity
,
muinit
=
NULL
,
siginit
=
NULL
,
shinit
=
NULL
,
thetainit
=
NULL
,
etainit
=
NULL
,
muinit
=
NULL
,
siginit
=
NULL
,
shinit
=
NULL
,
thetainit
=
NULL
,
etainit
=
NULL
,
show
=
TRUE
,
method
=
"Nelder-Mead"
,
maxit
=
10000
,
...
)
show
=
TRUE
,
method
=
"Nelder-Mead"
,
maxit
=
10000
,
init.vals
=
NULL
,
...
)
{
{
#
#
# obtains mles etc for d-gev distn
# obtains mles etc for d-gev distn
...
@@ -88,7 +92,9 @@ gev.d.fit<-
...
@@ -88,7 +92,9 @@ gev.d.fit<-
z
$
trans
<-
FALSE
# indicates if fit is non-stationary
z
$
trans
<-
FALSE
# indicates if fit is non-stationary
# calculate initial values for mu.d, sigma_0, xi, eta using IDF.init: (thetainit=0)
# calculate initial values for mu.d, sigma_0, xi, eta using IDF.init: (thetainit=0)
if
(
any
(
is.null
(
c
(
muinit
,
siginit
,
shinit
,
etainit
)))){
if
(
!
is.null
(
init.vals
)){
init.vals
<-
data.frame
(
mu
=
init.vals
[
1
],
sigma
=
init.vals
[
2
],
xi
=
init.vals
[
3
]
,
theta
=
init.vals
[
4
],
eta
=
init.vals
[
5
])}
if
(
any
(
is.null
(
c
(
muinit
,
siginit
,
shinit
,
etainit
)))
&
is.null
(
init.vals
)){
init.vals
<-
gev.d.init
(
xdat
,
ds
,
ifelse
(
is.null
(
thetainit
),
0
,
thetainit
[
1
]))
init.vals
<-
gev.d.init
(
xdat
,
ds
,
ifelse
(
is.null
(
thetainit
),
0
,
thetainit
[
1
]))
}
}
# TODO: transform initial values with link function
# TODO: transform initial values with link function
...
@@ -217,6 +223,7 @@ gev.d.fit<-
...
@@ -217,6 +223,7 @@ gev.d.fit<-
}
}
z
$
se
<-
sqrt
(
diag
(
z
$
cov
))
# sqrt(digonal entries) = standart error of mle's
z
$
se
<-
sqrt
(
diag
(
z
$
cov
))
# sqrt(digonal entries) = standart error of mle's
z
$
vals
<-
cbind
(
mut
,
sc0
,
xi
,
theta
,
eta
)
z
$
vals
<-
cbind
(
mut
,
sc0
,
xi
,
theta
,
eta
)
z
$
init.vals
<-
as.numeric
(
init.vals
)
colnames
(
z
$
vals
)
<-
c
(
'mut'
,
'sigma0'
,
'xi'
,
'theta'
,
'eta'
)
colnames
(
z
$
vals
)
<-
c
(
'mut'
,
'sigma0'
,
'xi'
,
'theta'
,
'eta'
)
z
$
ds
<-
ds
z
$
ds
<-
ds
if
(
show
)
{
if
(
show
)
{
...
...
man/gev.d.fit.Rd
View file @
3535fd24
...
@@ -9,7 +9,7 @@ gev.d.fit(xdat, ds, ydat = NULL, mul = NULL, sigl = NULL,
...
@@ -9,7 +9,7 @@ gev.d.fit(xdat, ds, ydat = NULL, mul = NULL, sigl = NULL,
siglink = identity, shlink = identity, thetalink = identity,
siglink = identity, shlink = identity, thetalink = identity,
etalink = identity, muinit = NULL, siginit = NULL, shinit = NULL,
etalink = identity, muinit = NULL, siginit = NULL, shinit = NULL,
thetainit = NULL, etainit = NULL, show = TRUE,
thetainit = NULL, etainit = NULL, show = TRUE,
method = "Nelder-Mead", maxit = 10000, ...)
method = "Nelder-Mead", maxit = 10000,
init.vals = NULL,
...)
}
}
\arguments{
\arguments{
\item{xdat}{A vector containing maxima for different durations.
\item{xdat}{A vector containing maxima for different durations.
...
@@ -41,6 +41,8 @@ duration dependency of the location and shape parameter.}
...
@@ -41,6 +41,8 @@ duration dependency of the location and shape parameter.}
\item{maxit}{The maximum number of iterations.}
\item{maxit}{The maximum number of iterations.}
\item{init.vals}{vector of length 5, giving initial values for parameter intercepts}
\item{...}{Other control parameters for the optimization.}
\item{...}{Other control parameters for the optimization.}
}
}
\value{
\value{
...
@@ -58,7 +60,10 @@ duration offset and duration exponent, resp.}
...
@@ -58,7 +60,10 @@ duration offset and duration exponent, resp.}
\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.}
\item{data}{data is standardized to standart Gumbel.}
\item{data}{data is standardized to standart Gumbel.}
\item{cov}{The covariance matrix.}
\item{cov}{The covariance matrix.}
\item{vals}{Parameter values for every data point.}
\item{init.vals}{Initial values that where used.}
\item{ds}{Durations for every data point.}
}
}
\description{
\description{
Modified \code{\link[ismev]{gev.fit}} function for Maximum-likelihood fitting
Modified \code{\link[ismev]{gev.fit}} function for Maximum-likelihood fitting
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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