Donny
We have learned about posterior predictive checks and KL-divergence.
How might we use those in our research ?
Reframing the idea of model checking
Suppose we wanted to compare these “networks”
# stack data
Y <- rbind(Y_m, Y_f)
# scatter matrix
S <- t(Y) %*% Y
# posterior assuming equality
post_samp <- rWishart(1000, nrow(Y) - 1, solve(S))
# for s samples
sapply(1:1000, function(s){
# Precision matrix
Theta_s <- post_samp[,,s]
# Covariance matrix
Sigma_s <- solve(Theta_s)
# Correlation matrix
R_s <- diag(1/sqrt(diag(Sigma_s))) %*% Sigma_s %*% diag(1/sqrt(diag(Sigma_s)))
# Yrep males
Yrep_m <- MASS::mvrnorm(nrow(Y_m), diag(0, 25), R_s)
# Yrep females
Yrep_f <- MASS::mvrnorm(nrow(Y_f), diag(0, 25), R_s)
# KL
0.5 * (KL(Yrep_m, Yrep_f) + KL(Yrep_f, Yrep_m))
})
Custom network comparisons