[R-sig-ME] MCMCglmm and Contrast Part 2
Miguel Macias
mmaciasgonzalez at ucdavis.edu
Wed Aug 9 02:01:00 CEST 2017
Hello,
I would like to run some custom contrast on MCMCglmm. I have read how to do
this in the link <https://www.nceas.ucsb.edu/system/files/mixedlab.pdf> and
I have read previous posting about this issue <
https://stat.ethz.ch/pipermail/r-sig-mixed-models/2011q1/012415.html> but
the suggestions given have not resolved the problem I am having. I will
refer to data from <
https://github.com/bbolker/asaglmm/blob/master/data/culcitalogreg.csv> and
follow Ben Bolker's example <
https://www.nceas.ucsb.edu/system/files/mixedlab.pdf> to explain my problem.
I am using MCMCglmm version 2.24 and R version 3.4.1
My problem is that when I try to run a model with contrast I don't get back
the contrast results in the fixed effects summary. Please see below.
1) Running the Model without contrast
# setting seed to get reproducible results
set.seed(1)
# Running model with 'singular.ok = FALSE'
culcmod4 <-
MCMCglmm(cbind(predation,nopred)~ttt,random=~block,family="multinomial2",
data=culcdat,verbose=FALSE, singular.ok = FALSE)
# getting the summary results
# post.mean l-95% CI u-95% CI eff.samp pMCMC
# (Intercept) 228.11 43.33 408.20 340.0 0.008
**
# ttt2 -196.65 -340.14 -62.33 224.0
<0.001 ***
# ttt3 -164.87 -314.63 -22.33 246.5
0.016 *
# ttt4 -253.51 -397.38 -99.90 132.1
<0.001 ***
# ---
# Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
2) The contrast are constructed and assigned to the factor:
# Setting contrast to ttt which has levels 1, 2, 3, and 4
contrasts(culcdat$ttt) <- matrix(c(3,-1,-1,-1,
0, 1,-1, 0,
0, 1, 1,-2),
nrow=4,
dimnames=list(c("none","C","S","CS"), c("symb","C.vs.S","twosymb")))
3) Running the model with the contrast
# setting seed to get reproducible results
set.seed(1)
# Running model with 'singular.ok = TRUE'
culcmod4v2 <-
MCMCglmm(cbind(predation,nopred)~ttt,random=~block,family="multinomial2",
data=culcdat,verbose=FALSE, singular.ok = TRUE)
# getting the summary results: I get the same results as without the
contrasts
Why aren't the contrast working? I do not get any error messages indicating
that contrast were dropped from the model.
I can get the procedure above to work with glmer from the lme4 package but
my data has complete separation and I would like to use a bayesian model to
get around complete separation.
Thank you in advance,
--
Miguel Macias González
451 E. Health Sciences Dr.
4212A UC Davis Genome Center,
Davis, CA, 95616
Work: 530-752-8889
Cell: 530-760-7205
[[alternative HTML version deleted]]
More information about the R-sig-mixed-models
mailing list