Learn R Programming

MoTBFs (version 1.4.2)

as.function.jointmotbf: Coerce a "jointmotbf" Object to a Function

Description

Takes a "jointmotbf" object and contructs an R function to evaluate it at multidimensional points.

Usage

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

Value

It returns a function to evaluate an object of class "jointmotbf".

Arguments

x

An object of class "joinmotbf".

...

Further arguments to be passed to or from the method. Not necessary for this method.

Details

This is an S3 method for the generic function as.function.

See Also

parametersJointMoTBF and jointMoTBF

Examples

Run this code
## 1.EXAMPLE
## Dataset
data <- data.frame(X = rnorm(100), Y = rexp(100))

## Joint function
dim <- c(3,2)
param <- parametersJointMoTBF(data, dimensions = dim)
P <- jointMoTBF(param)
density <- as.function(P)(data[,1], data[,2])
density

## Log-likelihood
sum(log(density))

#############################################################################
## MORE EXAMPLES ############################################################
#############################################################################
# \donttest{
## Dataset
data <- data.frame(X = rnorm(100), Y = rexp(100), Z = rnorm(100))

## Joint function
dim <- c(2,3,4)
param <- parametersJointMoTBF(data, dimensions = dim)
P <- jointMoTBF(param)
density <- as.function(P)(data[,1], data[,2], data[,3])
density

## Log-likelihood
sum(log(density))
# }

Run the code above in your browser using DataLab