mop.learning: Fitting mixtures of polynomials

View source: R/mop.R

mop.learningR Documentation

Fitting mixtures of polynomials

Description

These functions fit mixtures of polynomials (MOPs). Least square optimization is used to minimize the quadratic error between the empirical cumulative distribution and the estimated one.

Usage

mop.learning(X, nparam, domain)

bestMOP(X, domain, maxParam = NULL)

Arguments

X

A "numeric" data vector.

nparam

Number of parameters of the function.

domain

A "numeric" containing the interval over which the function is defined.

maxParam

A "numeric" value indicating the maximum number of coefficients in the function. By default it is NULL, which means that the number of parameter is not limited. The output is the function which gets the best BIC (with at mostmaxParam parameters if not NULL).

Details

mop.learning(): The returned value $Function is the only visible element which contains the algebraic expression. Using attributes the name of the others elements are shown and also they can be extracted with $. The summary of the function also shows all these elements.

bestMOP(): The first returned value $bestPx contains the output of the mop.learning() function with the number of parameters which gets the best BIC values, taking into account the BIC score to penalize the functions. It evaluates the two next functions, if the BIC score does not improve then the function with the last best BIC is returned.

Value

mop.lerning() returns a list of n elements:

Function

An "motbf" object of the 'mop' subclass.

Subclass

'mop'.

Domain

The range where the function is defined to be a legal density function.

Iterations

The number of iterations that the optimization problem takes to minimize the errors.

Time

The CPU time employed.

bestMOP() returns a list including the polynomial function with the best BIC score, the number of parameters and an array with the BIC values of the evaluated functions.

See Also

univMoTBF A complete function for learning MOPs which includes extra options.

Examples

## 1. EXAMPLE 
data <- rnorm(1000)

## MOP with fix number of degrees
fx <- mop.learning(data, nparam=7, domain=range(data))
fx
hist(data, prob=TRUE, main="")
plot(fx, col=2, xlim=range(data), add=TRUE)

## Best MOP in terms of BIC
fMOP <- bestMOP(data, domain=range(data))
attributes(fMOP)
fMOP$bestPx
hist(data, prob=TRUE, main="")
plot(fMOP$bestPx, col=2, xlim=range(data), add=TRUE)

## 2. EXAMPLE
data <- rbeta(4000, shape1=1/2, shape2=1/2)

## MOP with fix number of degrees 
fx <- mop.learning(data, nparam=6, domain=range(data))
fx
hist(data, prob=TRUE, main="")
plot(fx, col=2, xlim=range(data), add=TRUE)

## Best MOP in terms of BIC
fMOP <- bestMOP(data, domain=range(data), maxParam=6)
attributes(fMOP)
fMOP$bestPx
attributes(fMOP$bestPx)
hist(data, prob=TRUE, main="")
plot(fMOP$bestPx, col=2, xlim=range(data), add=TRUE)

MoTBFs documentation built on April 18, 2022, 5:06 p.m.

Related to mop.learning in MoTBFs...