Skip to content

Commit 24d453d

Browse files
committed
profLik
1 parent 72fa053 commit 24d453d

19 files changed

+2859
-2017
lines changed

DESCRIPTION

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: beverstan
22
Title: Bayes Extreme-Value with Stan
3-
Version: 0.0.2
3+
Version: 0.0.3
44
Authors@R:
55
person(given = "Yves",
66
family = "Deville ",
@@ -12,7 +12,7 @@ License: GPL (>=3)
1212
Encoding: UTF-8
1313
LazyData: true
1414
Roxygen: list(markdown = TRUE)
15-
RoxygenNote: 7.2.1
15+
RoxygenNote: 7.3.2
1616
Biarch: true
1717
Depends:
1818
R (>= 3.4.0), NSGEV, bever, nieve, ggplot2
@@ -24,7 +24,9 @@ Imports:
2424
rstan (>= 2.18.1),
2525
rstantools (>= 2.1.1),
2626
dplyr,
27-
lubridate
27+
lubridate,
28+
data.table,
29+
grDevices
2830
LinkingTo:
2931
BH (>= 1.66.0),
3032
Rcpp (>= 0.12.0),

NAMESPACE

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,23 @@ S3method(RL,TVGEVBayes)
44
S3method(autolayer,timeMAXdata)
55
S3method(autoplot,TVGEVBayes)
66
S3method(autoplot,predRLTVGEVBayes)
7+
S3method(autoplot,profLik.TVGEVBayes)
78
S3method(autoplot,timeMAXdata)
89
S3method(coef,TVGEVBayes)
910
S3method(fitted,TVGEVBayes)
1011
S3method(predict,TVGEVBayes)
1112
S3method(print,TVGEVBayes)
13+
S3method(print,profLik.TVGEVBayes)
1214
S3method(print,summary.TVGEVBayes)
15+
S3method(profLik,TVGEVBayes)
1316
S3method(summary,TVGEVBayes)
1417
S3method(vcov,TVGEVBayes)
1518
export(RL)
1619
export(TVGEVBayes)
1720
export(blockCuts)
1821
export(byBlock)
1922
export(doIntersect)
23+
export(envProf)
2024
export(newTimeRange)
2125
export(timeMAXdata)
2226
export(timeRange)
@@ -25,25 +29,35 @@ import(Rcpp)
2529
import(ggplot2)
2630
import(methods)
2731
importFrom(NSGEV,modelMatrices)
32+
importFrom(NSGEV,parNames)
33+
importFrom(NSGEV,profLik)
2834
importFrom(RcppParallel,RcppParallelLibs)
2935
importFrom(bever,.gumBreaks_p)
3036
importFrom(bever,.gumbel_trans_p)
3137
importFrom(bever,credInt)
3238
importFrom(bever,formatLevel)
39+
importFrom(data.table,rbindlist)
3340
importFrom(dplyr,bind_rows)
3441
importFrom(ggplot2,autolayer)
3542
importFrom(ggplot2,autoplot)
43+
importFrom(grDevices,adjustcolor)
44+
importFrom(grDevices,chull)
45+
importFrom(graphics,abline)
46+
importFrom(graphics,points)
47+
importFrom(graphics,text)
3648
importFrom(lubridate,Date)
3749
importFrom(nieve,pGEV)
3850
importFrom(nieve,qGEV)
3951
importFrom(rstan,sampling)
4052
importFrom(rstan,stan)
4153
importFrom(rstantools,nsamples)
54+
importFrom(stats,approx)
4255
importFrom(stats,cov)
4356
importFrom(stats,fitted)
4457
importFrom(stats,median)
4558
importFrom(stats,ppoints)
4659
importFrom(stats,predict)
60+
importFrom(stats,qchisq)
4761
importFrom(stats,quantile)
4862
importFrom(stats,rexp)
4963
importFrom(stats,sd)

NEWS.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
**beverstan** Package News
3+
======================
4+
5+
# New in version 0.0.3
6+
7+
## Enhancements
8+
9+
- The `"TSGEVBayes"` class has now a `profLik` method that can be used
10+
to profile one or several function(s) of the parameter such as a
11+
quantile or a return period. Due to the re-definition of the S3
12+
generic function `profLik`, a conflict with the **`{NSGEV}`** package
13+
exists. So for now the methods must be called by their names as
14+
`beverstan:::profLik.TVGEVBayes`. This will be fixed in a future
15+
version.
16+
17+
- Some methods such as `autoplot` have been implemented for the class
18+
`"profLik.TVGEVBayes"` of the objects returned by the `profLik`
19+
method.
20+
21+

R/TVGEVBayes.R

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -37,25 +37,24 @@
3737
##'
3838
##' @param ... Further arguments to be passed to the
3939
##' \code{\link[rstan]{sampling}} of the \bold{rstan} package.
40-
##'
40+
##'
4141
##' @return An object with (S3) class \code{"TVGEVBayes"}. This is
4242
##' mainly a list with the following items
43-
##' \itemize{
44-
##' \item{stanFit }{The object with class \code{"stanfit"} returned
45-
##' by \code{\link[rstan]{sampling}}. \bold{Caution}: for now
46-
##' the parameter names do not match the parameter names
47-
##' of the \code{TVGEVBayes} object.
48-
##' }
49-
##' \item{MCMC }{The array of MCMC iterates with the warm-up
50-
##' iterations discarded. The dimensions are: \emph{MCMC iterate},
51-
##' \emph{chain} and \emph{parameter}. The parameters have names
52-
##' using prefixes \code{"mu"}, \code{"sigma"} and \code{"xi"}.
53-
##' The remaining part of the names is given by the
54-
##' \code{\link[stats]{terms}} hence conforms to what would be obtained
55-
##' using \code{lm} with the same formula. However an exception is for
56-
##' the intercepts. For instance the name \code{"mu_(Intercept)"} will be
57-
##' replaced by \code{"mu_0"}.
58-
##' }
43+
##'
44+
##' \item{stanFit }{The object with class \code{"stanfit"} returned
45+
##' by \code{\link[rstan]{sampling}}. \bold{Caution}: for now
46+
##' the parameter names do not match the parameter names
47+
##' of the \code{TVGEVBayes} object.
48+
##' }
49+
##' \item{MCMC }{The array of MCMC iterates with the warm-up
50+
##' iterations discarded. The dimensions are: \emph{MCMC iterate},
51+
##' \emph{chain} and \emph{parameter}. The parameters have names
52+
##' using prefixes \code{"mu"}, \code{"sigma"} and \code{"xi"}.
53+
##' The remaining part of the names is given by the
54+
##' \code{\link[stats]{terms}} hence conforms to what would be obtained
55+
##' using \code{lm} with the same formula. However an exception is for
56+
##' the intercepts. For instance the name \code{"mu_(Intercept)"} will be
57+
##' replaced by \code{"mu_0"}.
5958
##' }
6059
##'
6160
##' @importFrom rstan stan
@@ -202,7 +201,7 @@ TVGEVBayes <- function(data,
202201
width.cutoff = 500L)),
203202
loc = loc, scale = scale, shape = shape))
204203
fit$call <- "<generated call>"
205-
204+
206205
## ===========================================================================
207206
## Prepare the data. Mind that when a vector such as 'psi_sigma' or
208207
## 'mean_psi_sigma0' turns to be of length one Stan throws an error
@@ -260,7 +259,7 @@ TVGEVBayes <- function(data,
260259
yBar <- 35
261260

262261
if ("chains" %in% names(eDots)) {
263-
nChains <- eDots$chains
262+
nChains <- eDots$chains
264263
} else {
265264
nChains <- 4L
266265
}
@@ -275,7 +274,7 @@ TVGEVBayes <- function(data,
275274
psi_sigma = as.array(fit$psi[fit$ind[["scale"]]] * eps),
276275
psi_xi = as.array(fit$psi[fit$ind[["shape"]]] * eps),
277276
y_miss = as.array(rep(yBar * eps, data$n_miss) ),
278-
y_cens = as.array(rep(yBar * eps, data$n_cens)))
277+
y_cens = as.array(rep(yBar * eps, data$n_cens)))
279278
}
280279
}
281280

R/TVGEVBayesMethods.R

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,11 @@ print.TVGEVBayes <- function(x, ...) {
9999
##' @param ... Not used yet.
100100
##'
101101
##' @return Alist with the two elements
102-
##' \itemize{
103-
##' \item{\code{timeRange} }{ A character with length one
104-
##' describing the time range as in \code{"2020_2019"}.}
105-
##' \item{\code{date} }{ A \code{Date} vector with length 2
106-
##' giving the beginning and the end of the time-range.
107-
##' }
102+
##' \item{\code{timeRange} }{ A character with length one
103+
##' describing the time range as in \code{"2020_2019"}.
104+
##' }
105+
##' \item{\code{date} }{ A \code{Date} vector with length 2
106+
##' giving the beginning and the end of the time-range.
108107
##' }
109108
##'
110109
##' @export

R/beverstan-package.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@
1515
#' @references
1616
#' Stan Development Team (2020). RStan: the R interface to Stan. R package version 2.21.2. https://mc-stan.org
1717
#'
18-
NULL
18+
"_PACKAGE"

0 commit comments

Comments
 (0)