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

View source: R/joint.R

as.function.jointmotbfR Documentation

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 class 'jointmotbf'
as.function(x, ...)

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.

Value

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

See Also

parametersJointMoTBF and jointMoTBF

Examples

## 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 ############################################################
#############################################################################

## 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))


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