Learn R Programming

boodist (version 1.0.0)

InverseGamma: Inverse Gamma distribution

Description

A R6 class to represent an inverse Gamma distribution.

Arguments

Active bindings

alpha

Get or set the value of alpha.

beta

Get or set the value of beta.

Methods


Method new()

New inverse Gamma distribution.

Usage

InverseGamma$new(alpha, beta)

Arguments

alpha

shape parameter, >0

beta

scale parameter, >0

Returns

An inverseGamma object.


Method d()

Density function of the inverse Gamma distribution.

Usage

InverseGamma$d(x, log = FALSE)

Arguments

x

vector of positive numbers

log

Boolean, whether to return the logarithm of the density

Returns

The density or the log-density evaluated at x.


Method p()

Cumulative distribution function of the inverse Gamma distribution.

Usage

InverseGamma$p(q, lower = TRUE)

Arguments

q

numeric vector of quantiles

lower

Boolean, whether to deal with the lower tail

Returns

The cumulative probabilities corresponding to q.


Method q()

Quantile function of the inverse Gamma distribution.

Usage

InverseGamma$q(p, lower = TRUE)

Arguments

p

numeric vector of probabilities

lower

Boolean, whether to deal with the lower tail

Returns

The quantiles corresponding to p.


Method r()

Sampling from the inverse Gamma distribution.

Usage

InverseGamma$r(n)

Arguments

n

number of simulations

Returns

A numeric vector of length n.


Method mean()

Mean of the inverse Gamma distribution.

Usage

InverseGamma$mean()

Returns

The mean of the inverse Gamma distribution.


Method median()

Median of the inverse Gamma distribution.

Usage

InverseGamma$median()

Returns

The median of the inverse Gamma distribution.


Method mode()

Mode of the inverse Gamma distribution.

Usage

InverseGamma$mode()

Returns

The mode of the inverse Gamma distribution.


Method sd()

Standard deviation of the inverse Gamma distribution.

Usage

InverseGamma$sd()

Returns

The standard deviation of the inverse Gamma distribution.


Method variance()

Variance of the inverse Gamma distribution.

Usage

InverseGamma$variance()

Returns

The variance of the inverse Gamma distribution.


Method skewness()

Skewness of the inverse Gamma distribution.

Usage

InverseGamma$skewness()

Returns

The skewness of the inverse Gamma distribution.


Method kurtosis()

Kurtosis of the inverse Gamma distribution.

Usage

InverseGamma$kurtosis()

Returns

The kurtosis of the inverse Gamma distribution.


Method kurtosisExcess()

Kurtosis excess of the inverse Gamma distribution.

Usage

InverseGamma$kurtosisExcess()

Returns

The kurtosis excess of the inverse Gamma distribution.


Method clone()

The objects of this class are cloneable with this method.

Usage

InverseGamma$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Details

See Wikipedia.

Examples

Run this code
if(require("plotly")) {
x_ <- seq(0, 2, length.out = 100L)
alpha_ <- seq(0.5, 2.5, length.out = 100L)
dsty <- vapply(alpha_, function(alpha) {
  InverseGamma$new(alpha, beta = 1)$d(x_)
}, numeric(length(x_)))
#
txt <- matrix(NA_character_, nrow = length(x_), ncol = length(alpha_))
for(i in 1L:nrow(txt)) {
  for(j in 1L:ncol(txt)) {
    txt[i, j] <- paste0(
      "x: ", formatC(x_[i]),
      " alpha: ", formatC(alpha_[j]),
      " density: ", formatC(dsty[i, j])
    )
  }
}
#
plot_ly(
  x = ~alpha_, y = ~x_, z = ~dsty, type = "surface",
  text = txt, hoverinfo = "text", showscale = FALSE
) %>% layout(
  title = "Inverse Gamma distribution",
  margin = list(t = 40, r= 5, b = 5, l = 5),
  scene = list(
    xaxis = list(
      title = "alpha"
    ),
    yaxis = list(
      title = "x"
    ),
    zaxis = list(
      title = "density"
    )
  )
)
}

Run the code above in your browser using DataLab