univMoTBF {MoTBFs} | R Documentation |
Fitting MoTBFs
Description
Function for fitting univariate mixture of truncated basis functions. Least square optimization is used to minimize the quadratic error between the empirical cumulative distribution and the estimated one.
Usage
univMoTBF(
data,
POTENTIAL_TYPE,
evalRange = NULL,
nparam = NULL,
maxParam = NULL
)
Arguments
data |
A |
POTENTIAL_TYPE |
A |
evalRange |
A |
nparam |
Number of parameters of the function. By default: it is |
maxParam |
A |
Value
An "motbf"
function learned from data.
Examples
## 1. EXAMPLE
## Data
X <- rnorm(5000)
## Learning
f1 <- univMoTBF(X, POTENTIAL_TYPE = "MTE"); f1
f2 <- univMoTBF(X, POTENTIAL_TYPE = "MOP"); f2
## Plots
hist(X, prob = TRUE, main = "")
plot(f1, xlim = range(X), col = 1, add = TRUE)
plot(f2, xlim = range(X), col = 2, add = TRUE)
## Data test
Xtest <- rnorm(1000)
## Filtered data test
Xtest <- Xtest[Xtest>=min(X) && Xtest<=max(X)]
## Log-likelihood
sum(log(as.function(f1)(Xtest)))
sum(log(as.function(f2)(Xtest)))
## 2. EXAMPLE
## Data
X <- rchisq(5000, df = 5)
## Learning
f1 <- univMoTBF(X, POTENTIAL_TYPE = "MTE", nparam = 11); f1
f2 <- univMoTBF(X, POTENTIAL_TYPE = "MOP", maxParam = 10); f2
## Plots
hist(X, prob = TRUE, main = "")
plot(f1, xlim = range(X), col = 3, add = TRUE)
plot(f2, xlim = range(X), col = 4, add = TRUE)
## Data test
Xtest <- rchisq(1000, df = 5)
## Filtered data test
Xtest <- Xtest[Xtest>=min(X) && Xtest<=max(X)]
## Log-likelihood
sum(log(as.function(f1)(Xtest)))
sum(log(as.function(f2)(Xtest)))