Description Usage Arguments Value Note Examples

The function to export the mean vector and covariance matrix of Bayesian posteriori MVN distribution in the basis of given priori information (priori MVN) and observation data (a design matrix containing all variables).

1 2 3 4 5 | ```
# Given the data as design matrix, priori mean vector and priori covariance
# matrix, this function will export a list which contains mean ($mean) and
# covariance ($var) of Bayesian posteriori multivariate normal distribution.
MVN_BayesianPosteriori(data, pri_mean, pri_var)
``` |

`data` |
A data.frame or matrix-like data: obervations should be arrayed in rows while variables should be arrayed in columns. |

`pri_mean` |
A numeric vector to assign priori mean for MVN. Default value applies |

`pri_var` |
A matrix-like parameter to assign priori covariance matrix. Default value uses unit matrix. |

return a double level list containing:

`mean` |
mean vector of Bayesian posteriori MVN distribution |

`var` |
covariance of Bayesian posteriori MVN distribution |

It is strongly recommanded that users should have some prior knowledge of ill-conditioned system before using this function. Simply, ill-conditioned system, or singular matrix, is caused by a) insufficient data or b) almostly linear dependency of two certain parameters, which two can result in a excessively small eigenvalue then cause a ill-conditioned (singular) system. Therefore users must diagnose their data firstly to confirm the fact that the it contains enough observations, and the degree of freedom is strictly equal to the number of parameters as well. Additionally, for the argument `pri_var`

, a real symmetric matrix is desired by definition.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | ```
# Demo using dataset1:
head(dataset1)
BPos <- MVN_BayesianPosteriori(dataset1, c(80,16,3))
BPos$mean
BPos$var
# Singular system caused by insufficient data
eigen(var(dataset1[1:3,]))$values
rcond(var(dataset1[1:3,]))
eigen(var(dataset1[1:6,]))$values
rcond(var(dataset1[1:6,]))
# Singular system caused by improper degree of freedom
K <- cbind(dataset1, dataset1[,3]*(-2)+3)
eigen(var(K[,2:4]))$values
rcond(var(K[,2:4]))
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.