Skip to content

Commit

Permalink
bump version, adjusting CRAN checks
Browse files Browse the repository at this point in the history
  • Loading branch information
bgctw committed Mar 10, 2021
1 parent 2dc6142 commit 9cc622e
Show file tree
Hide file tree
Showing 17 changed files with 90 additions and 61 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: lognorm
Title: Functions for the Lognormal Distribution
Version: 0.1.8
Version: 0.1.9
Author: Thomas Wutzler
Maintainer: Thomas Wutzler <[email protected]>
Description: The lognormal distribution
Expand All @@ -13,7 +13,7 @@ Description: The lognormal distribution
difference of two correlated lognormally distributed variables
(Lo 2012 <doi:10.1155/2012/838397>).
Imports: Matrix
Suggests: testthat, knitr, dplyr, ggplot2, mvtnorm, purrr, tidyr
Suggests: markdown, rmarkdown, testthat, knitr, dplyr, ggplot2, mvtnorm, purrr, tidyr
VignetteBuilder: knitr
License: GPL-2
LazyData: true
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# lognorm 0.1.9
- Improved handling of missing values in computeEffectiveNumObs
- Less bias with missing values in computeEffectiveNumObs
- New function varCor to compute unbiased variance of uncorrelated time series
- seCor now based on varCor, which reduces bias for small number of effective
observations.
Expand Down
4 changes: 2 additions & 2 deletions R/coefLognorm.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ getParmsLognormForLowerAndUpperLog <- function(
#' i.e. practical maximum
#' @param sigmaFac sigmaFac=2 is 95\% sigmaFac=2.6 is 99\% interval.
#'
#' @return numeric matrix wiht columns `mu` and `sigma`, the parameter of the
#' @return numeric matrix with columns `mu` and `sigma`, the parameter of the
#' lognormal distribution. Rows correspond to rows of inputs.
#' @export
#' @examples
Expand Down Expand Up @@ -171,7 +171,7 @@ getParmsLognormForExpval <- function(mean, sigmaStar){
#' NA values should be stripped before the computation proceeds.
#'
#' @return numeric vector with components \code{mu} and \code{sigma},
#' ie.., the center parameter (mean at log scale, log(median)) and
#' i.e., the center parameter (mean at log scale, log(median)) and
#' the scale parameter (standard deviation at log scale)
#'
#' @examples
Expand Down
2 changes: 1 addition & 1 deletion R/lognormalDiff.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' Inference on the difference of two lognormals
#'
#' The distribtuion of y = a - b + s, where a and b are two lognormal random
#' The distribution of y = a - b + s, where a and b are two lognormal random
#' variables and s is a constant to be estimated, can be approximated
#' by a lognormal distribution.
#'
Expand Down
2 changes: 1 addition & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ abline(v = getLognormMode(coefSum["mu"], coefSum["sigma"]), lty = "dashed")
abline(v = getLognormMedian(coefSum["mu"], coefSum["sigma"]), lty = "dotdash")
```

The sum of the expected values is conserved, while the mutliplicative standard
The sum of the expected values is conserved, while the multiplicative standard
deviation decreases during aggregation:

```{r}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ abline(v = getLognormMedian(coefSum["mu"], coefSum["sigma"]), lty = "dotdash")

![](tools/README-example-1.png)

The sum of the expected values is conserved, while the mutliplicative standard deviation decreases during aggregation:
The sum of the expected values is conserved, while the multiplicative standard deviation decreases during aggregation:

``` r
c(
Expand Down
36 changes: 11 additions & 25 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,17 @@
## Note
Added support for computing moments and statistics.

Changed doi format (brackets) in DESCRIPTION according to
comment from Uwe Ligges from
10.1641/0006-3568(2001)051[0341:lndats]2.0.co;2
to
10.1641/0006-3568(2001)051%5B0341:lndats%5D2.0.co;2

And changed back to original doi after second comment
by Uwe Ligges

Changed again to escaped form after email from Kurt Hornik.

Removed link to md file in vignette. (The link worked nice on github but not
for the installed package.)
* better support for missing values

## Test environments
with old doi
* local R 3.4.4 on Mint17 64bit
* Ubuntu 14.04.5 LTS (on travis-ci), 14.04
* win-builder (devel)
* R-Hub

with updated doi and link:
* local R 3.4.4 on Mint17 64bit
* local R 4.0.4 on Mint21 64bit
* R-hub
** Ubuntu Linux 20.04.1 LTS, R-release, GCC
** Fedora Linux, R-devel, clang, gfortran
** windows-x86_64-devel (with env_vars=c(R_COMPILE_AND_INSTALL_PACKAGES = "always")

## R CMD check results
Note on problem with doi
* 1 Note on (possibly) invalid DOIs:
** After changing to escaped form after email from Kurt Hornik in a previous release.
*** In contrast Uwe Ligges was in favour of the plain version. This went back and forth
already several times
** The plain correct version is: 10.1641/0006-3568(2001)051[0341:LNDATS]2.0.CO;2


42 changes: 42 additions & 0 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
Limpert
Zieba
aggregateCorrelated
al
ams
anc
autocorrelated
computeEffectiveNumObs
doi
effCor
estimateDiffLognormal
estimateSumLognormal
et
gapfilled
getParmsLognormForLowerAndUpper
getParmsLognormForLowerAndUpperLog
ij
inlinedocs
isGapFilled
isTransScale
ln
lndats
logmean
lognormalSum
lognormally
md
nObs
na
nfin
operatorname
pDiffLognormalSample
precomputed
roxygen
scaleLogToOrig
sd
seCor
sigmaFac
sigmaStar
varCor
μ
ρ
σ
2 changes: 1 addition & 1 deletion man/estimateDiffLognormal.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/estimateParmsLognormFromSample.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/getParmsLognormForModeAndUpper.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion tests/testthat/test_autoCorr.R
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ test_that("computeEffectiveNumObs",{

test_that("computeEffectiveNumObs with NA",{
# generate autocorrelated time series
set.seed(0815)
res <- stats::filter(rnorm(1000), filter = rep(1,8), circular = TRUE)
effAcfFull <- computeEffectiveAutoCorr(res)
# tail NA
Expand All @@ -84,7 +85,7 @@ test_that("computeEffectiveNumObs with NA",{
expect_true(nEff <= sum(is.finite(res)))
# positive bias not accounting for missings
nEff3 <- computeEffectiveNumObs(res, na.rm = TRUE, exact.na = FALSE)
expect_true(nEff3 > nEff)
expect_true(nEff3 > nEff) # may fail due to only 7 random numbers
nEff <- computeEffectiveNumObs(res, na.rm = TRUE, effAcf = effAcfFull)
expect_true(nEff <= sum(is.finite(res)))
expect_true(nEff >= 1)
Expand Down
8 changes: 4 additions & 4 deletions vignettes/lognorm.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ vignette: >
---
```{r eval=FALSE, include=FALSE}
# twDev::genVigs()
rmarkdown::render("lognorm.Rmd","md_document")
#rmarkdown::render("lognorm.Rmd","md_document")
```

```{r setup, include=FALSE}
Expand All @@ -32,10 +32,10 @@ knit_hooks$set(spar = function(before, options, envir) {
})
library(lognorm)
if (!require(ggplot2) || !require(dplyr) || !require(purrr)) {
print("To generate this vignette, ggplo2, dplyr, and purrr are required.")
exit(0)
print("To generate this vignette, ggplot2, dplyr, and purrr are required.")
knit_exit()
}
themeTw <- theme_bw(base_size = 10) +
themeTw <- ggplot2::theme_bw(base_size = 10) +
theme(axis.title = element_text(size = 9))
```

Expand Down
12 changes: 6 additions & 6 deletions vignettes/lognormalDiff.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ vignette: >
---
```{r eval=FALSE, include=FALSE}
# twDev::genVigs()
rmarkdown::render("lognormalDiff.Rmd","md_document")
#rmarkdown::render("lognormalDiff.Rmd","md_document")
```

```{r setup, include=FALSE}
Expand All @@ -31,10 +31,10 @@ knit_hooks$set(spar = function(before, options, envir) {
})
library(lognorm)
if (!require(ggplot2) || !require(dplyr) || !require(tidyr) || !require(purrr)) {
print("To generate this vignette, ggplo2, dplyr, tidyr, and purrr are required.")
exit(0)
print("To generate this vignette, ggplot2, dplyr, tidyr, and purrr are required.")
knit_exit()
}
themeTw <- theme_bw(base_size = 10) +
themeTw <- ggplot2::theme_bw(base_size = 10) +
theme(axis.title = element_text(size = 9))
```

Expand Down Expand Up @@ -108,12 +108,12 @@ theme(axis.title.x = element_blank())

## Test if difference is significantly different from zero

The probability of the zero quantile needs to be larger than a significane
The probability of the zero quantile needs to be larger than a significance
level.
We can compute it based on the lognormal approximation.

Since Lo12 is only accurate if the expected difference is small compared
to the expected sum, the probiblity of the difference being larger than zero can be estimated by a sampling both terms.
to the expected sum, the probability of the difference being larger than zero can be estimated by a sampling both terms.

```{r}
mu1 = log(120)
Expand Down
4 changes: 2 additions & 2 deletions vignettes/lognormalDiff.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ A check by random numbers (dotted lines) shows close correspondence.

## Test if difference is significantly different from zero

The probability of the zero quantile needs to be larger than a significane
The probability of the zero quantile needs to be larger than a significance
level.
We can compute it based on the lognormal approximation.

Since Lo12 is only accurate if the expected difference is small compared
to the expected sum, the probiblity of the difference being larger than zero can be estimated by a sampling both terms.
to the expected sum, the probability of the difference being larger than zero can be estimated by a sampling both terms.


```r
Expand Down
16 changes: 8 additions & 8 deletions vignettes/lognormalSum.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ vignette: >
---
```{r eval=FALSE, include=FALSE}
# twDev::genVigs()
rmarkdown::render("lognormalSum.Rmd","md_document")
#rmarkdown::render("lognormalSum.Rmd","md_document")
```

```{r setup, include=FALSE}
Expand All @@ -31,10 +31,10 @@ knit_hooks$set(spar = function(before, options, envir) {
})
library(lognorm)
if (!require(ggplot2) || !require(dplyr) || !require(tidyr) || !require(purrr)) {
print("To generate this vignette, ggplo2, dplyr, tidyr, and purrr are required.")
exit(0)
print("To generate this vignette, ggplot2, dplyr, tidyr, and purrr are required.")
knit_exit()
}
themeTw <- theme_bw(base_size = 10) +
themeTw <- ggplot2::theme_bw(base_size = 10) +
theme(axis.title = element_text(size = 9))
```

Expand Down Expand Up @@ -172,7 +172,7 @@ coefSum <- estimateSumLognormal( theta[,1], theta[,2], effAcf = c(1,acf1) )
setNames(exp(coefSum["sigma"]), "sigmaStar")
```

Its expected value corresponds to the summ of expected values (100*10).
Its expected value corresponds to the sum of expected values (100*10).

```{r}
(sumExp <- getLognormMoments( coefSum[1], coefSum[2])[1,"mean"])
Expand Down Expand Up @@ -201,9 +201,9 @@ theme(axis.title.x = element_blank()) +
theme(legend.title = element_blank())
```

The mean is the sum devided by the number of observations, $n$.
While the multiplicatie standard deviation does not change by this operation,
the location parameter is obtained by deviding by $n$ at original scale, hence,
The mean is the sum divided by the number of observations, $n$.
While the multiplicative standard deviation does not change by this operation,
the location parameter is obtained by dividing by $n$ at original scale, hence,
subtracting $log(n)$ at log-scale.
```{r}
(coefMean <- setNames(c(coefSum["mu"] - log(nObs), coefSum["sigma"]), c("mu","sigma")))
Expand Down
8 changes: 4 additions & 4 deletions vignettes/lognormalSum.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ variables. The multiplicative uncertainty has decreased from 1.7.
## sigmaStar
## 1.077687

Its expected value corresponds to the summ of expected values (100\*10).
Its expected value corresponds to the sum of expected values (100\*10).

(sumExp <- getLognormMoments( coefSum[1], coefSum[2])[1,"mean"])

Expand All @@ -124,9 +124,9 @@ the distribution of the 10000 repetitions.

<img src="lognormalSum_files/figure-markdown_strict/pdfSum100-1.png" style="display:block; margin: auto" />

The mean is the sum devided by the number of observations, *n*. While
the multiplicatie standard deviation does not change by this operation,
the location parameter is obtained by deviding by *n* at original scale,
The mean is the sum divided by the number of observations, *n*. While
the multiplicative standard deviation does not change by this operation,
the location parameter is obtained by dividing by *n* at original scale,
hence, subtracting *l**o**g*(*n*) at log-scale.

(coefMean <- setNames(c(coefSum["mu"] - log(nObs), coefSum["sigma"]), c("mu","sigma")))
Expand Down

0 comments on commit 9cc622e

Please sign in to comment.