Skip to content

Commit

Permalink
Added the Semi-Parametric Distribution
Browse files Browse the repository at this point in the history
* Some additional fixes for CRAN Additional Issues
  • Loading branch information
alexiosg committed May 10, 2024
1 parent 00ec126 commit eaeb751
Show file tree
Hide file tree
Showing 44 changed files with 1,126 additions and 48 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
^\.github$
README.Rmd
README.md
^cran-comments\.md$
7 changes: 4 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
Package: tsdistributions
Type: Package
Title: Location Scale Standardized Distributions
Version: 1.0.0
Version: 1.0.1
Authors@R: c(person("Alexios", "Galanos", role = c("aut", "cre","cph"), email = "[email protected]"))
Maintainer: Alexios Galanos <[email protected]>
Depends: R (>= 3.5.0), methods, tsmethods
LinkingTo: TMB, RcppEigen
Imports: TMB (>= 1.7.20), GeneralizedHyperbolic, SkewHyperbolic, stats, utils, data.table, zoo, Rsolnp, sandwich, future.apply, future, progressr
Description: Location-Scale based distributions parameterized in terms of mean, standard deviation, skew and shape parameters and estimation using automatic differentiation. Distributions include the Normal, Student and GED as well as their skewed variants ('Fernandez and Steel'), the 'Johnson SU', and the Generalized Hyperbolic.
Imports: TMB (>= 1.7.20), Rdpack, GeneralizedHyperbolic, KernSmooth, SkewHyperbolic, mev, stats, utils, data.table, zoo, Rsolnp, sandwich, future.apply, future, progressr
Description: Location-Scale based distributions parameterized in terms of mean, standard deviation, skew and shape parameters and estimation using automatic differentiation. Distributions include the Normal, Student and GED as well as their skewed variants ('Fernandez and Steel'), the 'Johnson SU', and the Generalized Hyperbolic. Also included is the semi-parametric piecewise distribution ('spd') with pareto tails and kernel interior.
License: GPL-2
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.3.1
VignetteBuilder: knitr
RdMacros: Rdpack
URL: https://www.nopredict.com/packages/tsdistributions, https://github.com/tsmodels/tsdistributions
Suggests:
knitr, rmarkdown, testthat (>= 3.0.0)
Expand Down
25 changes: 25 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
# Generated by roxygen2: do not edit by hand

S3method(AIC,tsdistribution.estimate)
S3method(AIC,tsdistribution.spdestimate)
S3method(BIC,tsdistribution.estimate)
S3method(BIC,tsdistribution.spdestimate)
S3method(bread,tsdistribution.estimate)
S3method(bread,tsdistribution.spdestimate)
S3method(coef,tsdistribution.estimate)
S3method(coef,tsdistribution.spdestimate)
S3method(estfun,tsdistribution.estimate)
S3method(estimate,tsdistribution.spdspec)
S3method(estimate,tsdistribution.spec)
S3method(logLik,tsdistribution.estimate)
S3method(logLik,tsdistribution.spdestimate)
S3method(print,summary.spd)
S3method(print,summary.tsdistribution)
S3method(print,summary.tsdistribution.profile)
S3method(summary,tsdistribution.estimate)
S3method(summary,tsdistribution.profile)
S3method(summary,tsdistribution.spdestimate)
S3method(tsmoments,tsdistribution.estimate)
S3method(tsprofile,tsdistribution.spec)
S3method(vcov,tsdistribution.estimate)
S3method(vcov,tsdistribution.spdestimate)
export(authorized_domain)
export(ddist)
export(dged)
Expand All @@ -27,6 +36,7 @@ export(dnig)
export(dsged)
export(dskewness)
export(dsnorm)
export(dspd)
export(dsstd)
export(dstd)
export(ghyptransform)
Expand All @@ -39,6 +49,7 @@ export(pjsu)
export(pnig)
export(psged)
export(psnorm)
export(pspd)
export(psstd)
export(pstd)
export(qdist)
Expand All @@ -49,6 +60,7 @@ export(qjsu)
export(qnig)
export(qsged)
export(qsnorm)
export(qspd)
export(qsstd)
export(qstd)
export(rdist)
Expand All @@ -59,19 +71,28 @@ export(rjsu)
export(rnig)
export(rsged)
export(rsnorm)
export(rspd)
export(rsstd)
export(rstd)
export(spd_modelspec)
import(data.table)
import(methods)
import(tsmethods)
importFrom(GeneralizedHyperbolic,ghypMom)
importFrom(GeneralizedHyperbolic,rghyp)
importFrom(KernSmooth,bkde)
importFrom(Rdpack,reprompt)
importFrom(Rsolnp,solnp)
importFrom(SkewHyperbolic,pskewhyp)
importFrom(SkewHyperbolic,qskewhyp)
importFrom(TMB,MakeADFun)
importFrom(future,"%<-%")
importFrom(future.apply,future_lapply)
importFrom(mev,dgp)
importFrom(mev,fit.gpd)
importFrom(mev,pgp)
importFrom(mev,qgp)
importFrom(mev,rgp)
importFrom(progressr,handlers)
importFrom(progressr,progressor)
importFrom(sandwich,bread)
Expand All @@ -81,6 +102,7 @@ importFrom(sandwich,vcovHAC)
importFrom(sandwich,vcovOPG)
importFrom(stats,AIC)
importFrom(stats,BIC)
importFrom(stats,approx)
importFrom(stats,ar)
importFrom(stats,coef)
importFrom(stats,dnorm)
Expand All @@ -91,13 +113,16 @@ importFrom(stats,na.omit)
importFrom(stats,nlminb)
importFrom(stats,optim)
importFrom(stats,pnorm)
importFrom(stats,ppoints)
importFrom(stats,printCoefmat)
importFrom(stats,qnorm)
importFrom(stats,rexp)
importFrom(stats,rnorm)
importFrom(stats,runif)
importFrom(stats,sd)
importFrom(stats,spline)
importFrom(stats,uniroot)
importFrom(stats,var)
importFrom(stats,vcov)
importFrom(utils,tail)
importFrom(zoo,coredata)
Expand Down
13 changes: 12 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# tsdistributions 1.0.1

* Added the semi-parametric piece-wise distribution (`spd`). As this is a special
type of distribution, it gets its own class for specification and estimation.
Added p, d, q, r functions and other methods (summary, vcov, coef etc).
* Fixed the noRemap Additional Issue on CRAN checks (renames error to Rf_error
in C++ code).
* Added a unit test for the spd in the test-quantile.R file.
* Added an html vignette for the spd.


# tsdistributions 1.0.0

* Initial CRAN submission.
Expand Down Expand Up @@ -40,4 +51,4 @@ distributions used signum function but this distribution seems to have missed th
0 case for some reason.
* Added vcov methods and other sandwich estimators (QMLE, OP, NW).
* Added BIC and AIC and created a print method for the summary.
* Fixed some code fomatting issues
* Fixed some code formatting issues
2 changes: 1 addition & 1 deletion R/moments.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#' @param shape shape parameter.
#' @param lambda additional shape parameter for the Generalized Hyperbolic
#' distribution.
#' @returns A numeric value.
#' @returns A numeric value for the skewness and excess kurtosis.
#' @rdname dskewness
#' @export
#'
Expand Down
20 changes: 10 additions & 10 deletions R/pdqr.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#' @param lower_tail if TRUE (default), probabilities are \eqn{P[X \le x]} otherwise, \eqn{P[X > x]}.
#' @returns d gives the density, p gives the distribution function, q gives the quantile function
#' and r generates random deviates. Output depends on x or q length, or n for the random number
#' generator
#' generator.
#' @rdname ghst
#' @export
#'
Expand Down Expand Up @@ -171,7 +171,7 @@ qghst <- function(p, mu = 0, sigma = 1, skew = 1, shape = 8, lower_tail = TRUE,
#' @param lower_tail if TRUE (default), probabilities are \eqn{P[X \le x]} otherwise, \eqn{P[X > x]}.
#' @returns d gives the density, p gives the distribution function, q gives the quantile function
#' and r generates random deviates. Output depends on x or q length, or n for the random number
#' generator
#' generator.
#' @rdname snorm
#' @export
#'
Expand Down Expand Up @@ -279,7 +279,7 @@ rsnorm <- function(n, mu = 0, sigma = 1, skew = 1.5)
#' @param lower_tail if TRUE (default), probabilities are \eqn{P[X \le x]} otherwise, \eqn{P[X > x]}.
#' @returns d gives the density, p gives the distribution function, q gives the quantile function
#' and r generates random deviates. Output depends on x or q length, or n for the random number
#' generator
#' generator.
#' @rdname ged
#' @export
#'
Expand Down Expand Up @@ -388,7 +388,7 @@ rged <- function(n, mu = 0, sigma = 1, shape = 2)
#' @param lower_tail if TRUE (default), probabilities are \eqn{P[X \le x]} otherwise, \eqn{P[X > x]}.
#' @returns d gives the density, p gives the distribution function, q gives the quantile function
#' and r generates random deviates. Output depends on x or q length, or n for the random number
#' generator
#' generator.
#' @rdname sged
#' @export
#'
Expand Down Expand Up @@ -507,7 +507,7 @@ Heaviside <- function(x, a = 0)
#' @param lower_tail if TRUE (default), probabilities are \eqn{P[X \le x]} otherwise, \eqn{P[X > x]}.
#' @returns d gives the density, p gives the distribution function, q gives the quantile function
#' and r generates random deviates. Output depends on x or q length, or n for the random number
#' generator
#' generator.
#' @rdname std
#' @export
#'
Expand Down Expand Up @@ -616,7 +616,7 @@ rstd <- function(n, mu = 0, sigma = 1, shape = 5)
#' @param lower_tail if TRUE (default), probabilities are \eqn{P[X \le x]} otherwise, \eqn{P[X > x]}.
#' @returns d gives the density, p gives the distribution function, q gives the quantile function
#' and r generates random deviates. Output depends on x or q length, or n for the random number
#' generator
#' generator.
#' @rdname sstd
#' @export
#'
Expand Down Expand Up @@ -873,7 +873,7 @@ qghyp <- function(p, alpha = 1, beta = 0, delta = 1, mu = 0, lambda = 1, lower_t
#' @param lower_tail if TRUE (default), probabilities are \eqn{P[X \le x]} otherwise, \eqn{P[X > x]}.
#' @return d gives the density, p gives the distribution function, q gives the quantile function
#' and r generates random deviates. Output depends on x or q length, or n for the random number
#' generator
#' generator.
#' @rdname gh
#' @export
#'
Expand Down Expand Up @@ -967,7 +967,7 @@ rgh <- function(n, mu = 0, sigma = 1, skew = 0, shape = 1, lambda = 1)
#' @param lower_tail if TRUE (default), probabilities are \eqn{P[X \le x]} otherwise, \eqn{P[X > x]}.
#' @returns d gives the density, p gives the distribution function, q gives the quantile function
#' and r generates random deviates. Output depends on x or q length, or n for the random number
#' generator
#' generator.
#' @rdname nig
#' @export
#'
Expand Down Expand Up @@ -1032,7 +1032,7 @@ rnig <- function(n, mu = 0, sigma = 1, skew = 0, shape = 1)
#' @param lower_tail if TRUE (default), probabilities are \eqn{P[X \le x]} otherwise, \eqn{P[X > x]}.
#' @returns d gives the density, p gives the distribution function, q gives the quantile function
#' and r generates random deviates. Output depends on x or q length, or n for the random number
#' generator
#' generator.
#' @rdname jsu
#' @export
#'
Expand Down Expand Up @@ -1243,7 +1243,7 @@ ghyptransform <- function(mu = 0, sigma = 1, skew = 0, shape = 3, lambda = -0.5
#' @param lower_tail if TRUE (default), probabilities are \eqn{P[X \le x]} otherwise, \eqn{P[X > x]}.
#' @returns d gives the density, p gives the distribution function, q gives the quantile function
#' and r generates random deviates. Output depends on x or q length, or n for the random number
#' generator
#' generator.
#' @rdname ddist
#' @export
#'
Expand Down
15 changes: 14 additions & 1 deletion R/sandwich.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#'
#' @param x an object of class \dQuote{tsdistribution.estimate}.
#' @param ... not currently used.
#' @returns The score matrix
#' @returns The score matrix.
#' @details The function returns the scores of likelihood at the optimal solution.
#' @method estfun tsdistribution.estimate
#' @aliases estfun
Expand All @@ -18,6 +18,19 @@ estfun.tsdistribution.estimate <- function(x, ...)
}


#' @method bread tsdistribution.spdestimate
#' @aliases bread
#' @rdname bread.tsdistribution.estimate
#' @author Alexios Galanos
#' @export
#'
bread.tsdistribution.spdestimate <- function(x, ...)
{
H <- bdiag(x$gpd$lower$hessian, x$gpd$upper$hessian)
return(H)
}


#' Bread Method
#'
#' @param x an object of class \dQuote{tsdistribution.estimate}.
Expand Down
Loading

0 comments on commit eaeb751

Please sign in to comment.