biv.norm.post

Description

A function to calculate posterior quantities of the bivariate normal. See page 94.

Usage

1
biv.norm.post(data.mat,alpha,beta,m,n0=5)

Arguments

data.mat

A matrix with two columns of normally distributed data

alpha

Wishart first (scalar) parameter

beta

Wishart second (matrix) parameter

m

prior mean for mu

n0

prior confidence parameter

Value

Returns

mu2

posterior mean, dimension 1

sig1

posterior mean, dimension 2

sig2

posterior variance, dimension 1

rho

posterior variance, dimension 2

Author(s)

Jeff Gill

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
 rwishart <- function(df, p = nrow(SqrtSigma), SqrtSigma = diag(p))  { 
 if((Ident <- missing(SqrtSigma)) && missing(p)) stop("either p or SqrtSigma must be specified") 
 Z <- matrix(0, p, p) 
 diag(Z) <- sqrt(rchisq(p, df:(df-p+1))) 
 if(p > 1) { 
   pseq <- 1:(p-1) 
   Z[rep(p*pseq, pseq) + unlist(lapply(pseq, seq))] <- rnorm(p*(p-1)/2) 
 } 
 if(Ident) crossprod(Z) 
 else crossprod(Z %*% SqrtSigma)
 }
  
  data.n10 <- rmultinorm(10, c(1,3), matrix(c(1.0,0.7,0.7,3.0),2,2))
  rep.mat <- NULL; reps <- 1000
  for (i in 1:reps){
    rep.mat <- rbind(rep.mat, biv.norm.post(data.n10,3, matrix(c(10,5,5,10),2,2),c(2,2)))
  }
  round(normal.posterior.summary(rep.mat),3)