DistributionFit: General distribution fitting algorithms

Description Super class Methods

Description

General distribution fitting algorithms

General distribution fitting algorithms

Super class

ukcovidtools::PassthroughFilesystemCache -> DistributionFit

Methods

Public methods

Inherited methods

Method new()

New distribution fitter

Usage
DistributionFit$new(
  distributions = c("weibull", "gamma", "lnorm", "exp", "norm", "tnorm"),
  shifted = 0,
  ...
)
Arguments
distributions

- the distributions to fit

shifted

- a shift to apply to all data

...

for compatibility

Returns

Method setModels()

Usage
DistributionFit$setModels(
  distributions = c("weibull", "gamma", "lnorm", "exp", "norm", "tnorm"),
  shifted = 0
)

Method fromUncensoredData()

Usage
DistributionFit$fromUncensoredData(
  groupedDf,
  valueExpr = value,
  truncate = TRUE,
  bootstraps = 100,
  seed = 101,
  ...
)

Method fromCensoredData()

Usage
DistributionFit$fromCensoredData(
  groupedDf,
  lowerValueExpr,
  upperValueExpr,
  truncate = TRUE,
  bootstraps = 100,
  seed = 101,
  ...
)

Method withSingleDistribution()

Usage
DistributionFit$withSingleDistribution(
  dist,
  paramDf,
  bootstraps = 1000,
  epiestimMode = FALSE,
  ...
)

Method fromBootstrappedDistributions()

Usage
DistributionFit$fromBootstrappedDistributions(
  fittedDistributions,
  confint = c(0.025, 0.975),
  ...
)

Method fromBootstrappedData()

Usage
DistributionFit$fromBootstrappedData(
  bootstrappedDf,
  valueExpr = value,
  truncate = TRUE,
  ...
)

Method plot()

Usage
DistributionFit$plot(
  xlim,
  binwidth = 1,
  summary = FALSE,
  pts = 8,
  facet2d = TRUE
)

Method extractFitted()

Usage
DistributionFit$extractFitted(
  distFit,
  isCensored,
  bootstraps = 100,
  seed = 101
)

Method filterModels()

Usage
DistributionFit$filterModels(...)

Method generateSamples()

Usage
DistributionFit$generateSamples(sampleExpr = 1000, seed = 101)

Method calculateDensities()

calculates a set of pdfs from bootstrapped distributions

Usage
DistributionFit$calculateDensities(x, summarise = TRUE)
Arguments
support

- the range of values of X for which to calculate the density.

Returns

a list of randomly selected bootstraps from the fitted models.


Method calculateCumulativeDistributions()

calculates a set of pdfs from bootstrapped distributions

Usage
DistributionFit$calculateCumulativeDistributions(q, summarise = TRUE)
Arguments
support

- the range of values of X for which to calculate the density.

Returns

a list of randomly selected bootstraps from the fitted models.


Method calculateQuantiles()

calculates a set of quantiles from bootstrapped distributions

Usage
DistributionFit$calculateQuantiles(p, summarise = TRUE)
Arguments
support

- the range of values of X for which to calculate the density.

Returns

a list of randomly selected bootstraps from the fitted models.


Method discreteProbabilities()

Usage
DistributionFit$discreteProbabilities(q, summarise = TRUE)

Method discreteSurvival()

Usage
DistributionFit$discreteSurvival(q, summarise = TRUE)

Method sampledProbabilities()

Usage
DistributionFit$sampledProbabilities(q, summarise = TRUE)

Method sevenNumbers()

Usage
DistributionFit$sevenNumbers(groupedDf, colVar)

Method printDistributionSummary()

Usage
DistributionFit$printDistributionSummary(confint = c(0.025, 0.975))

Method printDistributionDetail()

Usage
DistributionFit$printDistributionDetail(confint = c(0.025, 0.975))

Method tsParameterizedConvolution()

applies a set of parameterised convolution functions groupwise to input data

Usage
DistributionFit$tsParameterizedConvolution(
  groupedDf,
  distributionsDf,
  outputVar = "output",
  valueVar = "value",
  dateVar = "date",
  distributionVar = "dist",
  paramNameVar = "param",
  paramValueVar = "paramValue",
  days = 30,
  timepoints = 0:days,
  padLeft = NA_real_,
  padRight = NA_real_
)
Arguments
groupedDf

- an optionally grouped dataframe, containing at dateVar, and a valueVar to be colvolved

distributionsDf

- a dataframe containing the same grouping columns as groupedDf plus "distribution", and relevant distribution parameter columns

dateVar

-

days

-

timepoints

- the times to

padLeft

- what can we assume about the run in to the current values? default NA.

Returns

a list of matrices


Method tsDiscreteConvolution()

applies a set of parameterised convolution functions groupwise to input data

Usage
DistributionFit$tsDiscreteConvolution(
  groupedDf,
  discreteDistDf,
  outputVar = "output",
  valueVar = "value",
  dateVar = "date",
  pExpr = "prob",
  padLeft = NA_real_,
  padRight = NA_real_
)
Arguments
groupedDf

- an optionally grouped dataframe, containing at dateVar, and a valueVar to be colvolved

discreteDistDf

- a dataframe containing the same grouping columns as groupedDf plus "start", "end" and "prob" columns

dateVar

-

padLeft

- what can we assume about the run in to the current values? default NA.

padRight

- what can we assume about the run in to the current values? default NA.

Returns

a list of matrices


Method tsBootstrapConvolution()

executes a convolution using bootstrapped parameterized distributions

Usage
DistributionFit$tsBootstrapConvolution(
  groupedDf,
  distributionDistDf,
  bootstraps = 100,
  outputVar = "output",
  valueVar = "value",
  dateVar = "date",
  days = 30,
  timepoints = 0:days,
  padLeft = NA_real_,
  padRight = NA_real_
)
Arguments
distributionDistDf

- a grouped data frame containing the same columns as those grouped in groupedDf, plus "distribution" and columns for "<parameter>_mean","<parameter>_sd","<parameter>_min","<parameter>_max" e.g. shape_mean, shape_sd, shape_min, shape_max, rate_mean, rate_sd, rate_min, rate_max

bootstraps

- number of bootstrap iterations

Returns

the full bootstrap result (i.e. not summarized) which can be futher convoluted (asd long as the number of bootstrap iterations are kept the same).


Method summariseBootstrap()

summarise the result of a bootstrapped convolution using parameterized distributions

Usage
DistributionFit$summariseBootstrap(
  groupedDf,
  outputVars = vars(output),
  dateVar = "date"
)
Arguments
distributionDistDf

- a grouped data frame containing the same columns as those grouped in groupedDf, plus "distribution" and columns for "<parameter>_mean","<parameter>_sd","<parameter>_min","<parameter>_max" e.g. shape_mean, shape_sd, shape_min, shape_max, rate_mean, rate_sd, rate_min, rate_max

bootstraps

- number of bootstrap iterations

Returns

the full bootstrap result (i.e. not summarized) which can be futher convoluted (asd long as the number of bootstrap iterations are kept the same).


Method clone()

The objects of this class are cloneable with this method.

Usage
DistributionFit$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.


terminological/uk-covid-datatools documentation built on June 24, 2021, 8:16 p.m.