| integrate.motbf | R Documentation |
Compute the integral of a one-dimensional mixture of truncated basis function
(objects of class "mop" or "mte") over a bounded or unbounded interval,
or compute the indefinite integral of a joint function (object of class "jointmotbf")
over a subset of variables or over all the variables in the function.
integrate.motbf(f, ...)
f |
An object of class |
... |
optional arguments to be passed to subsequent methods for the integrate.motfb() function. See details. |
This function is a wrapper of internal functions integrateMOP(), integrateMTE() and integrateJointmotbf().
If f is of class "mop" or "mte", valid optional arguments are 'lower'
(the lower integration limit) and 'upper' (the upper integration limit),
which represent the limits of the interval to compute the definite integral.
If 'lower' and 'upper' are not specified, then the output is the expression of the indefinite integral.
On the other hand, if f is of class "jointmotbf", the only valid optional argument is 'var', which
is a "character" vector containing the name of the variables that will be integrated out.
If not specified, then all the variables are integrated out.
Note that integrate.motfb() deprecates the following functions, included in previous versions of the package: integralMTE, integralMOP, integralMoTBF and integralJointMoTBF.
If f is of class "mop" or "mte", integrate.motfb() returns
either the indefinite integral of the MoTBF function, which is also an object of classes "motbf",
"univmotbf", and either "mop" or "mte"); or the definite integral, which is a "numeric" value.
If f is of class "jointmotbf", integrate.motfb() returns a multi-integral of the joint function,
which is also of class "jointmotbf".
univMoTBF and jointMoTBF
## 1. EXAMPLE
## Univariate MOP integral
X <- rexp(1000)
fx <- univMoTBF(X, POTENTIAL_TYPE = "MOP", scale = FALSE)
integrate.motbf(fx)
integrate.motbf(fx, 2, 6)
## 2. EXAMPLE
## Univariate MOP integral and plot of result
Y <- rnorm(1000)
fy <- univMoTBF(Y, POTENTIAL_TYPE = "MOP")
Fy <- integrate.motbf(fy)
plot(Fy)
integrate.motbf(fy, min(Y), max(Y))
## 3. EXAMPLE
## Univariate MTE integral
Z <- rchisq(1000, df = 3)
fz <- univMoTBF(Z, POTENTIAL_TYPE = "MTE", scale = FALSE)
integrate.motbf(fz)
integrate.motbf(fz, lower = 2, upper = 5)
## Not run:
## 4. EXAMPLE
Px <- "1+x+5"
class(Px)
integrate.motbf(Px)
## Error in integrate.motbf(Px) : Argument "f" is not of class "motbf"
## End(Not run)
## 5. EXAMPLE: Joint MOP integral
## Dataset with 2 variables
data <- data.frame(x = rnorm(100), y = rnorm(100))
## Joint function
dim <- c(2, 3)
P <- jointmotbf.fit(data, dimensions = dim)
## Integral
integrate.motbf(P)
integrate.motbf(P, var = "x")
integrate.motbf(P, var = "y")
##############################################################################
## MORE EXAMPLES #############################################################
##############################################################################
## Dataset with 3 variables
data <- data.frame(x = rnorm(50), y = rnorm(50), z = rnorm(50))
## Joint function
dim <- c(2,2,3)
P = jointmotbf.fit(data, dimensions = dim)
## Integral
integrate.motbf(P)
integrate.motbf(P, var="x")
integrate.motbf(P, var=c("x","z"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.