Skip to content

Commit

Permalink
remove Imports stabledist and add context and references to man files…
Browse files Browse the repository at this point in the history
… and readme v1.1.5
  • Loading branch information
swihart committed Feb 17, 2022
1 parent 88e41a9 commit 05ffab7
Show file tree
Hide file tree
Showing 13 changed files with 254 additions and 61 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Expand Up @@ -8,3 +8,4 @@
^LambertLindsey1999JRSSC\.pdf$
^nolan_stable_distributions_chap1\.pdf$
^CRAN-RELEASE$
^CRAN-SUBMISSION$
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -7,4 +7,5 @@ src/*.so
src/*.dll
stable.Rproj
README.Rmd
README_files/*
README_files/*
CRAN-SUBMISSION
12 changes: 7 additions & 5 deletions DESCRIPTION
@@ -1,24 +1,26 @@
Package: stable
Version: 1.1.4
Version: 1.1.5
Title: Probability Functions and Generalized Regression Models for Stable
Distributions
Authors@R: c(
person("Bruce", "Swihart", email="bruce.swihart@gmail.com", role=c("cre", "aut")),
person("Jim" , "Lindsey", email="jlindsey@gen.unimaas.nl", role="aut", comment="Jim created this package, Bruce is maintaining the CRAN version"),
person("Philippe", "Lambert", email="phlambert@stat.ucl.ac.be", role="aut")
)
Imports: stabledist
Depends:
R (>= 1.4),
rmutil
Description: Density, distribution, quantile and hazard functions of a
stable variate; generalized regression models for the parameters
of a stable distribution. See the README for how to make equivalent calls
to those of 'stabledist'. See github for Journal article.
to those of 'stabledist'. See github for Lambert and Lindsey 1999 JRSS-C journal article,
which details the parameterization of the Buck (1995) stable distribution which allowed
a Fourier inversion to arrive at a form of the $g_d$ function as detailed in Nolan (2020).
See the Details section of the `?dstable` help file for context and references.
License: GPL (>= 2)
URL: http://www.commanster.eu/rcode.html
URL: https://www.commanster.eu/rcode.html
BugReports: https://github.com/swihart/stable/issues
Encoding: UTF-8
LazyData: true
LazyLoad: true
RoxygenNote: 6.1.0
RoxygenNote: 7.1.2
11 changes: 10 additions & 1 deletion NEWS.md
@@ -1,3 +1,12 @@
#------------------------------------------------------------------------------
#version 1.1.5
#------------------------------------------------------------------------------

* http: --> https: where appropriate
* added references to contemporary stable distribution literature to help
contextualize this package to /man files and README
* Removed imports: stabledist from DESCRIPTION

#------------------------------------------------------------------------------
#version 1.1.4
#------------------------------------------------------------------------------
Expand Down Expand Up @@ -46,7 +55,7 @@ https://github.com/swihart/stable/issues.

**Above this line will be News/Changes for `stable` only**

**Below this line corresponds to [changes.txt](http://www.commanster.eu/rcode/changes.txt), which was Jim Lindsey's file for
**Below this line corresponds to [changes.txt](https://www.commanster.eu/rcode/changes.txt), which was Jim Lindsey's file for
detailing changes across the v1.0 packages `rmutil`, `repeated`, `gnlm`, `growth`, `event`, `stable` on his homepage**

#------------------------------------------------------------------------------
Expand Down
17 changes: 11 additions & 6 deletions R/pm1_to_pm0_and_pm0_to_pm1.R
@@ -1,8 +1,9 @@
#' Easy conversion of parameters between stabledist and stable
#' Easy conversion of parameters between stabledist Nolan 1-parameterization and 0-parameterization
#'
#' \code{pm0_to_pm1} has stabledist parameter inputs for pm=0 and returns pm=1 equivalent parameterization.
#' \code{pm1_to_pm0} has stabledist parameter inputs for pm=1 and returns pm=0 equivalent parameterization.
#'
#' See table Table 3.1 on page 97 of Nolan (2020).
#'
#' @name Parameter_Conversion_Nolan_pm1_pm0
#' @aliases pm1_to_pm0 pm0_to_pm1
Expand All @@ -15,10 +16,14 @@
#' @param c1 the stabledist 'gamma' for pm=1 in 'stabledist'
#' @param d1 the stabledist 'delta' for pm=1 in 'stabledist'
#'
#' @return What you need. See examples.
#' @references Nolan, John P. Univariate stable distributions. Berlin/Heidelberg, Germany: Springer, 2020.
#'
#' @return
#' \code{pm0_to_pm1} has stabledist parameter inputs for pm=0 and returns pm=1 equivalent parameterization.
#' \code{pm1_to_pm0} has stabledist parameter inputs for pm=1 and returns pm=0 equivalent parameterization.
#' @export
#' @examples
#' q <- -1
#' \dontrun{q <- -1
#' # nolan pm=1 parameters:
#' a1 <- 1.3
#' b1 <- -0.4
Expand All @@ -42,7 +47,7 @@
#' # only change delta=d0 for pm=0
#' stabledist::dstable(q, alpha=a1, beta=b1 , gamma=c1 , delta=d0, pm=0)
#' stabledist::dstable(q, alpha=a0, beta=b0 , gamma=c0 , delta=d0, pm=0)
#' #> [1] 0.0572133
#' #> [1] 0.0572133}
pm0_to_pm1 <- function(a0, b0, c0, d0){

if(a0!=1){
Expand All @@ -51,7 +56,7 @@ pm0_to_pm1 <- function(a0, b0, c0, d0){
c1 <- c1
d1 <- d0 - b1*c1*tan(pi*a1/2)
}

return(list(a1=a1, b1=b1, c1=c1, d1=d1 ))

}
Expand All @@ -65,7 +70,7 @@ pm1_to_pm0 <- function(a1, b1, c1, d1){
c0 <- c1
d0 <- d1 + b1*c1*tan(pi*a1/2)
}

return(list(a0=a0, b0=b0, c0=c0, d0=d0))

}
37 changes: 28 additions & 9 deletions R/sd2s_and_s2sd.R
@@ -1,12 +1,22 @@
#' Easy conversion of parameters between stabledist and stable
#' Easy conversion of parameters between stabledist (Nolan 1-parameterization) and stable (Lambert and Lindsey 1999)
#'
#' \code{sd2s} has stabledist parameter inputs and returns stable parameters.
#' \code{s2sd} has stable parameter inputs and returns stabledist parameters.
#' \code{sd2s} has stabledist parameter (Nolan 1-parameterization) inputs and returns stable parameters as put forth in Lambert and Lindsey (1999) and used in this package.
#' \code{s2sd} has stable parameter (Lambert and Lindsey (1999)) inputs and returns stabledist parameters (Nolan 1-parameterization).
#' See examples and the readme. There's also more context and references in `?stable::dstable`.
#'
#' This is a generic function: methods can be defined for it directly
#' or via the \code{\link{Summary}} group generic. For this to work properly,
#' the arguments \code{...} should be unnamed, and dispatch is on the
#' first argument.
#'
#' [Swihart 2022 update:] See the examples and README for how to make equivalent calls
#' to those of 'stabledist' (i.e., Nolan's 1-parameterization
#' as detailed in Nolan (2020)) using these functions and this package.
#' See github for Lambert and Lindsey 1999 JRSS-C journal article,
#' which details the parameterization of the Buck (1995) stable distribution which allowed
#' a Fourier inversion to arrive at a form of the $g_d$ function as detailed in Nolan (2020),
#' The Buck (1995) parameterization most closely resembles the Zolotarev B parameterization
#' outlined in Definition 3.6 on page 93 of Nolan (2020) -- except that Buck (1995) did
#' not allow the scale parameter to multiply with the location parameter.
#' This explains why the `Zolotarev B` entry in Table 3.1 on page 97 of Nolan (2020) has
#' the location parameter being multiplied by the scale parameter whereas in converting the Lindsey and Lambert (1999)
#' to Nolan 1-parameterization the location parameter stays the same.
#'
#' @name Parameter_Conversion
#' @aliases sd2s s2sd
Expand All @@ -20,9 +30,18 @@
#' @param disp the stable 'disp' analogous to 'gamma'
#' @param loc the stable 'loc' analogous to 'delta'
#'
#' @return What you need. See examples.
#' @references Lambert, P. and Lindsey, J.K. (1999) Analysing financial returns using
#' regression models based on non-symmetric stable distributions. Applied
#' Statistics, 48, 409-424.
#'
#' @references Nolan, John P. Univariate stable distributions. Berlin/Heidelberg, Germany: Springer, 2020.
#'
#' @return
#' \code{sd2s} returns stable parameters as put forth in Lambert and Lindsey (1999) and used in this package.
#' \code{s2sd} returns stabledist parameters (Nolan 1-parameterization).
#' @export
#' @examples
#' \dontrun{
#' q <- -1
#' # nolan pm=1 parameters:
#' a <- 1.3
Expand All @@ -33,7 +52,7 @@
#' stable::pstable(q, tail = s$tail, skew=s$skew, disp = s$disp, loc = s$loc)
#' stabledist::pstable(q, alpha=a, beta=b , gamma=c , delta=d, pm=1)
#' sd <- s2sd(tail = s$tail, skew=s$skew, disp = s$disp, loc = s$loc)
#' stabledist::pstable(q, alpha=sd$alpha, beta=sd$beta , gamma=sd$gamma , delta=sd$delta, pm=1)
#' stabledist::pstable(q, alpha=sd$alpha, beta=sd$beta , gamma=sd$gamma , delta=sd$delta, pm=1)}
sd2s <- function(alpha, beta, gamma, delta, pm=1){

if(pm==1){
Expand Down
24 changes: 23 additions & 1 deletion R/stable.r
Expand Up @@ -54,6 +54,23 @@
#'\code{npt} -- are only available when using \code{dstable}.
#'The other functions are all based on Romberg's algorithm.
#'
#' [Swihart 2022 update:] See the README for how to make equivalent calls
#' to those of 'stabledist' (i.e., Nolan's 0-parameterization and 1-parameterization
#' as detailed in Nolan (2020)).
#' See github for Lambert and Lindsey 1999 JRSS-C journal article,
#' which details the parameterization of the Buck (1995) stable distribution which allowed
#' a Fourier inversion to arrive at a form of the $g_d$ function as detailed in Nolan (2020),
#' Abdul-Hamid and Nolan (1998) and Nolan (1997).
#' The Nolan (2020) reference is a textbook that provides
#' an accessible and comprehensive summary of stable distributions in the 25 years or so
#' since this core of this R package was made.
#' The Buck (1995) parameterization most closely resembles the Zolotarev B parameterization
#' outlined in Definition 3.6 on page 93 of Nolan (2020) -- except that Buck (1995) did
#' not allow the scale parameter to multiply with the location parameter.
#' This explains why the `Zolotarev B` entry in Table 3.1 on page 97 of Nolan (2020) has
#' the location parameter being multiplied by the scale parameter whereas in converting the Lindsey and Lambert (1999)
#' to Nolan 1-parameterization the location parameter stays the same.
#'
#' @param x,q vector of quantiles.
#' @param p vector of probabilites.
#' @param n number of observations.
Expand All @@ -67,7 +84,13 @@
#' @references Lambert, P. and Lindsey, J.K. (1999) Analysing financial returns using
#' regression models based on non-symmetric stable distributions. Applied
#' Statistics, 48, 409-424.
#'
#' @references Nolan, John P. Univariate stable distributions. Berlin/Heidelberg, Germany: Springer, 2020.
#'
#' @references Nolan, John P. "Numerical calculation of stable densities and distribution functions." Communications in statistics. Stochastic models 13.4 (1997): 759-774.
#'
#' @references Abdul-Hamid, Husein, and John P. Nolan. "Multivariate stable densities as functions of one dimensional projections." Journal of multivariate analysis 67.1 (1998): 80-89.
#'
#' @seealso \code{\link[stable]{stablereg}} to fit generalized nonlinear regression models
#' for the stable distribution parameters.
#'
Expand Down Expand Up @@ -159,7 +182,6 @@
#' lines(x,dstable(x,loc=0,disp=1/sqrt(2),skew=0,tail=1.5))
#' lines(x,dstable(x,loc=0,disp=1/sqrt(2),skew=0,tail=2))
#'
#' stabledist::dstable(x=1, 1, 0)
dstable <- function(x, loc=0, disp=1/sqrt(2), skew=0, tail=2,
npt=501, up=10, eps=1.0e-6, integration="Romberg"){
y<-x
Expand Down
27 changes: 23 additions & 4 deletions README.md
@@ -1,13 +1,13 @@

<!-- README.md is generated from README.Rmd. Please edit README.Rmd -->
[![Travis-CI Build Status](https://travis-ci.org/swihart/stable.svg?branch=master)](https://travis-ci.org/swihart/stable) [![CRAN\_Status\_Badge](http://www.r-pkg.org/badges/version/stable)](https://cran.r-project.org/package=stable) ![downloads](http://cranlogs.r-pkg.org/badges/grand-total/stable)
[![Travis-CI Build Status](https://travis-ci.org/swihart/stable.svg?branch=master)](https://travis-ci.org/swihart/stable) [![CRAN\_Status\_Badge](https://www.r-pkg.org/badges/version/stable)](https://cran.r-project.org/package=stable) ![downloads](https://cranlogs.r-pkg.org/badges/grand-total/stable)

`stable` R package
==================

This package is intended to be the developmental version to the CRAN version of [Jim Lindsey's stable](http://www.commanster.eu/rcode.html). The .zip files listed on his homepage have been listed as version 1.0 since 2005. For the subsequent maintenance on this github and CRAN, we will start at 1.1.
This package is intended to be the developmental version to the CRAN version of [Jim Lindsey's stable](https://www.commanster.eu/rcode.html). The .zip files listed on his homepage have been listed as version 1.0 since 2005. For the subsequent maintenance on this github and CRAN, we will start at 1.1.

To compare this version with the static v1.0 files on [Jim Lindsey's Homepage](http://www.commanster.eu/rcode.html), it may be useful to use [the compare page for this repo's two branches](https://github.com/swihart/stable/compare/jim-lindsey-homepage-version-1.0...master?diff=split&name=master).
To compare this version with the static v1.0 files on [Jim Lindsey's Homepage](https://www.commanster.eu/rcode.html), it may be useful to use [the compare page for this repo's two branches](https://github.com/swihart/stable/compare/jim-lindsey-homepage-version-1.0...master?diff=split&name=master).

comparisons with `stabledist` R package
=======================================
Expand All @@ -21,7 +21,26 @@ In brief, the parameters have different names and are transformations for each o
| gamma | disp |
| delta | loc |

If you read the Lindsey PDF in this repo, be aware that location is given the greek letter gamma and scale is given the greek letter delta. The Nolan PDF does the opposite and is used for `stabledist`.
If you read the Lambert and Lindsey (1999 JRSS-C) PDF in this repo, be aware that location is given the greek letter gamma and scale is given the greek letter delta. The Nolan PDF does the opposite and is used for `stabledist`.


[Swihart 2022 update, see references in `?dstable`:] In this README we detail how to make equivalent calls
to those of 'stabledist' (i.e., Nolan's 0-parameterization and 1-parameterization
as detailed in Nolan (2020)).
See github for Lambert and Lindsey 1999 JRSS-C journal article,
which details the parameterization of the Buck (1995) stable distribution which allowed
a Fourier inversion to arrive at a form of the $g_d$ function as detailed in Nolan (2020),
Abdul-Hamid and Nolan (1998) and Nolan (1997).
The Nolan (2020) reference is a textbook that provides
an accessible and comprehensive summary of stable distributions in the 25 years or so
since this core of this R package was made.
The Buck (1995) parameterization most closely resembles the Zolotarev B parameterization
outlined in Definition 3.6 on page 93 of Nolan (2020) -- except that Buck (1995) did
not allow the scale parameter to multiply with the location parameter.
This explains why the `Zolotarev B` entry in Table 3.1 on page 97 of Nolan (2020) has
the location parameter being multiplied by the scale parameter whereas in converting the Lindsey and Lambert (1999)
to Nolan 1-parameterization the location parameter stays the same.


For some values for some distributions things match up nicely, as we see with Normal and Cauchy:

Expand Down
35 changes: 35 additions & 0 deletions cran-comments.md
@@ -1,3 +1,38 @@
# stable R package
Bruce Swihart
Feb 2022

## Submission 1

* http: -- > https: where appropriate
* added references to contemporary stable distribution literature to help
contextualize this package in the /man files and README
* Removed imports: stabledist from DESCRIPTION


## Test environments
Local OS X: R version 4.1.2 (2021-11-01)
* Platform: x86_64-apple-darwin17.0 (64-bit)
* Running under: macOS Mojave 10.14.6

rhub::check(platform = "debian-clang-devel"): Debian Linux, R-devel, clang, ISO-8859-15 locale
rhub::check(platform = "windows-x86_64-devel"): Windows Server 2022, R-devel, 64 bit
rhub::check(platform = "ubuntu-rchk")

devtools::check_win_devel()
devtools::check_win_release()
https://win-builder.r-project.org/326a56Lp6aAx/

macOS M1 Builder: https://mac.r-project.org/macbuilder/results/1645028678-c805840b15690b3d/

## R CMD check results
There were no ERRORs or WARNINGs or NOTEs.


## Downstream dependencies
There are currently no downstream dependencies for this package.


# stable R package
Bruce Swihart
Feb 2019
Expand Down
36 changes: 27 additions & 9 deletions man/Parameter_Conversion.Rd

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

0 comments on commit 05ffab7

Please sign in to comment.