Learn R Programming

MoTBFs (version 2.0)

coercion-motbf: Coerce MOTBF Objects to Character or Function

Description

Converts 'motbf' and 'jointmotbf' objects into character string expressions or executable R functions.

Usage

# S3 method for motbf
as.character(x, ...)

# S3 method for motbf as.function(x, ...)

# S3 method for jointmotbf as.character(x, ...)

# S3 method for jointmotbf as.function(x, ...)

Value

  • as.character: Returns a character string representing the mathematical expression of the object.

  • as.function: Returns an executable R function that accepts numeric arguments to evaluate the MoTBF expression.

Arguments

x

An object of class 'motbf' or 'jointmotbf'.

...

Further arguments passed to or from other methods. Not used currently.

Examples

Run this code

## Example 1
X <- rchisq(5000, df = 3)
P <- univMoTBF(X, POTENTIAL_TYPE = "MOP"); P
as.function(P)(10)

## Example 2
data <- data.frame(X = rnorm(100), Y = rexp(100))
dim <- c(3,2)
P <- jointmotbf.fit(data, dimensions = dim)
density <- as.function(P)(data[,1], data[,2])
sum(log(density))

Run the code above in your browser using DataLab