DistrCollection: DistrCollection-class: Class 'DistrCollection'

DistrCollectionR Documentation

DistrCollection-class: Class 'DistrCollection'

Description

R6 Class for Managing a Collection of Distribution Objects

Public fields

distr

List of Distr objects.

Methods

Public methods


Method new()

Initialize the fields of the DistrCollection object.

Usage
DistrCollection$new()

Method add()

Add a Distr object to the collection.

Usage
DistrCollection$add(distr)
Arguments
distr

A Distr object to add to the collection.


Method get()

Get a Distr object from the collection by its index.

Usage
DistrCollection$get(i)
Arguments
i

Integer index of the Distr object to retrieve.

Returns

A Distr object.


Method print()

Print the summary of all distributions in the collection.

Usage
DistrCollection$print()

Method summary()

Summarize the goodness of fit for all distributions in the collection.

Usage
DistrCollection$summary()
Returns

A data frame with distribution names, Anderson-Darling test statistics, and p-values.


Method plot()

Plot all distributions in the collection.

Usage
DistrCollection$plot(
  xlab = NULL,
  ylab = NULL,
  xlim = NULL,
  ylim = NULL,
  line.col = "red",
  fill.col = "lightblue",
  border.col = "black",
  line.width = 1,
  box = TRUE
)
Arguments
xlab

Character string for the x-axis label.

ylab

Character string for the y-axis label.

xlim

Numeric vector specifying the x-axis limits.

ylim

Numeric vector specifying the y-axis limits.

line.col

Character string for the color of the plot line. Default is "red".

fill.col

Character string for the color of the histogram fill. Default is "lightblue".

border.col

Character string for the color of the histogram border. Default is "black".

line.width

Numeric value specifying the width of the plot line. Default is 1.

box

Logical value indicating whether to draw a box with the parameters in the plot. Default is TRUE.


Method clone()

The objects of this class are cloneable with this method.

Usage
DistrCollection$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

See Also

Distr, distribution, FitDistr

Examples

set.seed(123)
data1 <- rnorm(100, mean = 5, sd = 2)
parameters1 <- list(mean = 5, sd = 2)
distr1 <- Distr$new(x = data1, name = "normal",
                    parameters = parameters1, sd = 2,
                    n = 100, loglik = -120)

data2 <- rpois(100, lambda = 3)
parameters2 <- list(lambda = 3)
distr2 <- Distr$new(x = data2, name = "poisson",
                    parameters = parameters2, sd = sqrt(3),
                    n = 100, loglik = -150)
collection <- DistrCollection$new()
collection$add(distr1)
collection$add(distr2)
collection$summary()
collection$plot()

r6qualitytools documentation built on Oct. 4, 2024, 1:09 a.m.