Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

fun.data.fit.hs

Fit RS and FMKL generalised distributions to data using discretised approach with weights.


Description

This function fits RS and FMKL generalised distribution to data using discretised approach with weights. It is designed to act as a smoother device rather than a definitive fit.

Usage

fun.data.fit.hs(data, rs.default = "Y", fmkl.default = "Y", rs.leap = 3, 
fmkl.leap = 3, rs.init = c(-1.5, 1.5), fmkl.init = c(-0.25, 1.5), no.c.rs = 50, 
no.c.fmkl = 50,FUN="runif.sobol", no=10000)

Arguments

data

Dataset to be fitted

rs.default

If yes, this function uses the default method fun.nclass.e to calculate number of classes required for the RS distribution fits.

fmkl.default

If yes, this function uses the default method fun.nclass.e to calculate number of classes required for the FMKL distribution fits.

rs.leap

Scrambling (0,1,2,3) for the Sobol sequence for the RS distribution fit. See scrambling/leap argument for runif.sobol, runif.halton or QUnif.

fmkl.leap

Scrambling (0,1,2,3) for the Sobol sequence for the FMKL distribution fit. See scrambling argument for See scrambling/leap argument for runif.sobol, runif.halton or QUnif.

rs.init

Initial values for RS distribution optimization, c(-1.5,1.5) tends to work well.

fmkl.init

Initial values for FMKL distribution optimization, c(-0.25,1.5) tends to work well.

no.c.rs

Number of classes or bins of histogram to be optimized over for the RS GLD. This argument is ineffective if default="Y".

no.c.fmkl

Number of classes or bins of histogram to be optimized over for the FMKL GLD. This argument is ineffective if default="Y".

FUN

A character string of either "runif.sobol" (default), "runif.halton" or "QUnif".

no

Number of initial random values to find the best initial values for optimisation.

Details

This function optimises the deviations of frequency of the bins to that of the theoretical so it has the effect of "fitting clothes" onto the data set. The user can decide the frequency of the bins they want the distribution to smooth over. The resulting fit may or may not be an adequate fit from a formal statistical point of view such as satisfying the goodness of fit for example, but it can be useful to suggest the range of different distributions exhibited by the data set. The default number of classes calculates the mean and variance after categorising the data into different bins and uses the number of classes that best matches the mean and variance of the original, ungrouped data.The weighting is designed to accentuate the peak or the dense part of the distribution and suppress the tails.

Value

A matrix showing the four parameters of the RS and FMKL distribution fit.

Note

In some cases, the resulting fit may not converge, there are currently no checking mechanism in place to ensure global convergence. The RPRS method can sometimes fail if there are no valid percentiles in the data set or if initial values do not give a valid distribution.

Author(s)

Steve Su

References

Su, S. (2005). A Discretized Approach to Flexibly Fit Generalized Lambda Distributions to Data. Journal of Modern Applied Statistical Methods (November): 408-424.

Su (2007). Fitting Single and Mixture of Generalized Lambda Distributions to Data via Discretized and Maximum Likelihood Methods: GLDEX in R. Journal of Statistical Software: *21* 9.

See Also

Examples

## Fitting normal(3,2) distriution using the default setting
# junk<-rnorm(1000,3,2)
# fun.data.fit.hs(junk)

GLDEX

Fitting Single and Mixture of Generalised Lambda Distributions (RS and FMKL) using Various Methods

v2.0.0.7
GPL (>= 3)
Authors
Steve Su, with contributions from: Diethelm Wuertz, Martin Maechler and Rmetrics core team members for low discrepancy algorithm, Juha Karvanen for L moments codes, Robert King for gld C codes and starship codes, Benjamin Dean for corrections and input in ks.gof code and R core team for histsu function.
Initial release
2020-02-04

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.