MVN_FConditional: Calculate full conditional normal ditribution of MVN

Description Usage Arguments Details Value See Also Examples

View source: R/MVN_FConditional.R

Description

Function to export parameters of full conditional normal distribution in basis of given MVN distribution, the undecided dimension, as well as all values in the rest dimensions.

Usage

1
2
3
4
5
# Bayesian posteriori as input data:
# data <- MVN_BayesianPosteriori(dataset1, c(80,16,3))

# inquire parameters of full-conditional distribution based on Bayesian posteriori:
MVN_FConditional(data, variable, z)

Arguments

data

A double level list containing all parameters of MVN distribution: mean vector (data$mean) and covariance matrix (data$var).

variable

A integer to specify the undecided dimension.

z

A nd-vector to assign conditions (n = dimensions of given MVN distribution). It should be noted that the value in dimension specified by variable doesn't participate in the calculation.

Details

It can be proved that any full conditional distribution from a given MVN will degenerate to an 1d-normal distribution.

Value

return a double level list containing the following parameters of full conditional normal distributions of given MVN in specified dimension:

mean

a numberic mean of a normal distribution

var

a numberic variance of a normal distribution

See Also

MVN_BayesianPosteriori, MatrixAlternative

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
head(dataset1)
BPos <- MVN_BayesianPosteriori(dataset1, c(80,16,3))
BPos # Bayesian Posteriori
result <- MVN_FConditional(BPos, variable = 1, z=c(75, 13, 4))
result$mean
class(result$mean)
result$var
class(result$var)

# compare the following results:
MVN_FConditional(BPos, variable = 2, z=c(75, 13, 4))
MVN_FConditional(BPos, variable = 2, z=c(75, 88, 4))
MVN_FConditional(BPos, variable = 1, z=c(75, 88, 4))

Example output

   fac1  fac2 fac3
1 76.13 15.07 4.97
2 78.65 12.94 4.43
3 76.88 14.80 4.87
4 75.85 15.64 4.74
5 75.91 15.11 4.08
6 76.38 14.83 4.81
$mean
         [,1]
fac1 77.90837
fac2 14.01146
fac3  4.12498

$var
           fac1        fac2        fac3
fac1  0.5344668 -0.28698530 -0.18252696
fac2 -0.2869853  0.27097011 -0.02952175
fac3 -0.1825270 -0.02952175  0.20718560

         [,1]
[1,] 79.22612
[1] "matrix" "array" 
            [,1]
[1,] 0.006428716
[1] "matrix" "array" 
$mean
         [,1]
[1,] 16.55765

$var
            [,1]
[1,] 0.004589548

$mean
         [,1]
[1,] 16.55765

$var
            [,1]
[1,] 0.004589548

$mean
         [,1]
[1,] -8.77132

$var
            [,1]
[1,] 0.006428716

MVNBayesian documentation built on May 2, 2019, 2:16 a.m.