3.4 Bayesian hierarchical model
Below runs a logistic MCMCglmm model treating cow and yard as random effects for 800 posterior samples. Should specify burnin=125000, nitt=625000 and thin=100 for 5000 posterior samples with lower autocorrelation. Aim for effective sample sizes of at least 2000.
<- MCMCglmm(HP ~ Diet + Time, random=~Cow + Yard, family="categorical", data=Milk, saveX=TRUE, verbose=F, burnin=2000, nitt=10000, thin=10, pr=TRUE, prior=prior2RE);
model1
#autocorr.diag(model1$VCV); #use this to choose thinning interval, autocorrelation less than 0.01 ideally;
<- nice_mcmcglmm(model1, Milk);
mcmcglmm_mva options(knitr.kable.NA = '');
::kable(mcmcglmm_mva); knitr
Variable | Levels | OR (95% HPDI) | MCMCp | eff.samp |
---|---|---|---|---|
Diet | barley | reference | ||
barley+lupins | 0.38 (0.16, 0.90) | 0.038 | 300.51 | |
lupins | 0.20 (0.08, 0.45) | 0.001 | 437.26 | |
Time | 0.96 (0.94, 1.00) | 0.020 | 215.79 |
Random effects ICC and 95% highest posterior density interval:
ICC | lower | upper | |
---|---|---|---|
Cow | 0.6075 | 0.5073 | 0.7373 |
Yard | 0.0037 | 0.0006 | 0.1000 |
units | 0.3290 | 0.2478 | 0.4559 |
R-squared calculation with 95% credible intervals for marginal model - considers only the variance of the fixed effects (without the random effects):
R_Squared | lower | upper | |
---|---|---|---|
0.1674635 | 0.0359335 | 0.2639823 |
R-squared calculation with 95% credible intervals for conditional model - takes both the fixed and random effects into account:
R_Squared | lower | upper | |
---|---|---|---|
0.71336 | 0.6263963 | 0.7995373 |
3.4.2 Caterpillar plot for random effect of cow
Odds ratio of high protein milk among cows is below. Highest posterior density intervals are not necessarily symmetric, but should be close to symmetric upon running more model iterations. Note that cows L23 and L27 have a higher odds estimate for high protein milk in random effect, even though those cows were fed a diet of lupins and should in theory have lower protein milk. Cow B01 also has higher odds of high protein milk, but was always fed a better diet (barley).