Hello Kamal,
One way to do this with MCMCglmm is to use the at.level() function.
You can determine for which level of your categorical variable you
want the interaction, ex. at.level(tactic,2):a.level(period,2):env.
However, in doing so you are only estimating the coefficient for that
specific interaction and ignoring the rest. That to me would seem a
bit odd given that for the 2-way interactions you are still including
the other levels, but of course it depends on what assumptions?you are
making for your?model.
and regarding automating the computation of the posterior mean, I
think (not sure though) that the broom package offers some wrap
functions for MCMCglmm and computing posterior estimates.
Good luck
--
Walid Crampton-Mawass
Ph.D. candidate in Evolutionary Biology
Population Genetics Laboratory
University of Qu?bec at Trois-Rivi?res
3351, boul. des Forges, C.P. 500
Trois-Rivi?res (Qu?bec) G9A 5H7
Telephone: 819-376-5011 poste 3384
On Wed, Mar 3, 2021 at 4:19 PM Kamal Atmeh <kamal.atmeh at hotmail.com
<mailto:kamal.atmeh at hotmail.com>> wrote:
Dear all,
I have some questions, which may sound trivial, pertaining to
interaction models with MCMCglmm.
I am running the following model with a gaussian distribution and a
3-way interaction between two categorical two-level variables
(tactic:
F/H and period PB/B) and one continuous variable (env):
model <- MCMCglmm(lD ~ tactic*period*env
????????????????????????????????????? , random =
~sp_phylo+species2+phylo_pop+phylo_popY+phylo_pop_id
????????????????????????????????????? , family = "gaussian"
????????????????????????????????????? , ginverse = list(sp_phylo =
inv.phylo$Ainv) # include a custom matrix for argument phylo
????????????????????????????????????? , prior = prior1
????????????????????????????????????? , data = Data
????????????????????????????????????? , nitt = 22e+04
????????????????????????????????????? , burnin = 20000
????????????????????????????????????? , thin = 100
????????????????????????????????????? , pr=TRUE)
After looking at the results, I found that the 2-way interaction
tactic*env from the tactic*period*env interaction was not
significant,
however the 3-way interaction itself was, with the following
output in
the summary:
?>>>?? tacticH:periodB:env????? 0.17831? 0.05360 0.30512???? 5000
0.0052 ** (the intercept represents tactic F and period PB)
I tried to run the model again in order to simplify it using ":" and
therefore remove the non-significant 2-way interaction:
model2 <- MCMCglmm(lD ~ tactic*period + period*env +
*tactic:period:env*
????????????????????????????????????? , random =
~sp_phylo+species2+phylo_pop+phylo_popY+phylo_pop_id
????????????????????????????????????? , family = "gaussian"
????????????????????????????????????? , ginverse = list(sp_phylo =
inv.phylo$Ainv) # include a custom matrix for argument phylo
????????????????????????????????????? , prior = prior1
????????????????????????????????????? , data = Data
????????????????????????????????????? , nitt = 22e+04
????????????????????????????????????? , burnin = 20000
????????????????????????????????????? , thin = 100
????????????????????????????????????? , pr=TRUE)
When using ":", the output of my model returns the posterior mean for
each level of the categorical variables instead of one level as
before:
tacticF:periodPB:env -0.1668620 -0.3554264? 0.0005143??? 195.0
0.0923 .
tacticF:periodB:env? -0.2018706 -0.3783204 -0.0174366??? 195.0
0.0410 *
tacticH:periodPB:env -0.1561097 -0.2066183 -0.1093840??? 118.2
<0.005 **
How should I define the interaction in the model in order to
obtain an
output similar to the one when the "*" interaction was used
(tacticH:periodB:env) while simplifying and removing the
non-significant
interaction from the 3-way interaction?
Finally, is there a way to automatically compute the posterior
mean of
the continuous variable for each modality of the interaction?
Thank you and stay safe!
Kamal
? ? ? ? [[alternative HTML version deleted]]