Learn R Programming

MoTBFs (version 2.0)

marginal.jointmotbf: Marginalization of MoTBFs

Description

Computes the marginal densities from a "jointmotbf" object.

Usage

marginal.jointmotbf(P, var)

Value

If 'var' is an atomic vector, the marginal distribution of the variable specified in 'var' is computed from the joint distribution and the result is an object of class "univmotbf", i.e., a univariate distribution.

If 'var' contains more than one variable, the joint distribution over this subset is computed, i.e., the variables NOT contained in 'var' are marginalized out and the result is an object of class "jointmotbf".

Arguments

P

An object of class "jointmotbf", i.e., the joint density function.

var

A vector containing the names of the marginal variables (those being retained in 'P'). This argument accepts the "numeric" position (w.r.t. P$Domain) or the "character" name of the variables.

See Also

jointmotbf.fit and eval.motbf

Examples

Run this code
## 1. EXAMPLE 
## Dataset with 2 variables
data <- data.frame(x = rnorm(100), y = rnorm(100))

## Joint function
dim <- c(4,3)
P <- jointmotbf.fit(data, dimensions = dim)

## Marginal
marginal.jointmotbf(P, var = "x")
marginal.jointmotbf(P, var = 2)

##############################################################################
## MORE EXAMPLES #############################################################
##############################################################################
# \donttest{
## Generate a dataset with 3 variables
data <- data.frame(x = rnorm(100), y = rnorm(100), z = rnorm(100))

## Joint function
dim <- c(2,2,3)
P <- jointmotbf.fit(data, dimensions = dim)

## Marginal
marginal.jointmotbf(P, var = "x")
marginal.jointmotbf(P, var = "y")
marginal.jointmotbf(P, var = c("x", "z"))
# }

Run the code above in your browser using DataLab