Learn R Programming

rriskDistributions (version 2.1.1)

rriskMMEdist: Fitting univariate distributions by matching moments

Description

Fits a univariate distribution by matching moments.

Usage

rriskMMEdist(data, distr)

Arguments

data
a numerical vector.
distr
A character string "name" naming a distribution or directly the density function dname. The estimated values of the distribution parameters are provided only for the following distributions : "norm", "lnorm", "exp", "pois", "gamma", "logis", "nbinom" , "geom", "beta" and "unif".

Value

rriskMMEdist returns the named parameter or a named vector of parameters.

Details

This function is an alias of the function mmedist from the package fitdistrplus (Version 0.1-2). The original function was extended to fitting additional distributions. Parameter of the following distribution families can be estimated in this function: normal, lognormal, exponential, Poisson, gamma, logistic, negative binomial, geometric, Beta and continuous univariate. For more details see the assistance page of the function mmedist from the package fitdistrplus. This function is not intended to be called directly but is internally called in rriskFitdist.cont.

Examples

Run this code
## Continuous distributions
set.seed(1)
x1 <- stats::rnorm(500, mean = 2, sd = 0.7)
rriskMMEdist(x1, "norm")
rriskMMEdist(x1, "exp")
rriskMMEdist(x1, "gamma")
rriskMMEdist(x1, "logis")
rriskMMEdist(x1, "unif")

## produces an error:
# rriskMMEdist(x1, "lnorm")
# rriskMMEdist(x1, "beta")

## Discrete distributions
set.seed(2)
x2 <- rpois(500, lambda = 3)
rriskMMEdist(x2, "pois")
rriskMMEdist(x2, "nbinom")
rriskMMEdist(x2, "geom")

Run the code above in your browser using DataLab