Description Usage Arguments Details Value Author(s) Examples
Given a design matrix (data) and priori information, export the mean vector and covariance matrix of Bayesian posterior multivariate normal distribution.
| 1 2 3 4 5 6 7 8 | # 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 posterior multivariate normal distribution.
MVN_BayesianPosterior(data, pri_mean, pri_var)
# defualt pri_mean uses colMenas()
# defualt pri_var uses unit matrix
 | 
| data | Design matrix: data.frame or matrix-like data,  | 
| pri_mean | priori mean: necessary vector which should be of the identical dimensions of data ( | 
| pri_var | prior covariance matrix: a real symmetric matrix by definition; the default value is an unit matrix with the same dimension of priori mean vector. | 
Although this function is very simple, the observation data should be diagnosed firstly. it is strongly recommanded that researchers and developers 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 too small eigenvalue then cause a ill-conditioned (singular) system. Therefore users should make sure the data contains enough observations and the degree of freedom is strictly equal to the number of parameters.
return a list of:
| mean | mean vector of Bayesian posterior | 
| var | covariance of Bayesian posterior | 
ZHANG Chen
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | # Demo using dataset1:
head(dataset1)
BPos <- MVN_BayesianPosterior(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]))
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.