[R-sig-ME] MCMCglmm with missing values

Monica Anderson Berdal m@@nder@on@berd@| @end|ng |rom gm@||@com
Mon Mar 16 14:24:35 CET 2020


Sorry, here is a plain text version with CSV data.

I’m trying to run a MCMCglmm where two of the response variables and
three of the fixed effects are sex specific. Each line represents one
individual, and the data looks like this:

Sex,Fitness_M,Fitness_F,Age_M,Age_F,Mate_mass,Behaviour,Mass,Temperature,Line

M,743,NA,140,NA,NA,69,229,21,X

M,515,NA,188,NA,NA,50,220,19,X

M,390,NA,231,NA,NA,50,109,17,Y

M,266,NA,96,NA,NA,39,113,19,Y

M,323,NA,105,NA,NA,55,171,25,Y

F,NA,112,NA,74,205,67,247,20,Y

F,NA,107,NA,74,163,60,139,26,Z

F,NA,8,NA,53,193,71,118,24,Z

F,NA,207,NA,55,74,37,219,21,Z

F,NA,300,NA,56,160,68,261,18,Z

All individuals have a behaviour mass recorded, and only the sex
specific variables have NAs. I’ve been using the at.level function to
control for these missing values, but still get the error: Missing
values in the fixed predictors

cricketMCMC <- MCMCglmm(cbind(Fitness_F, Fitness_M, Behaviour, Mass)~

                          at.level(trait, 1):(Age_F + Mate_mass) +

                          at.level(trait, 2):(Age_M) +

                          at.level(trait, 3):(Sex + Temperature) +

                          at.level(trait, 4):(Sex + Temperature),

                        random=~us(trait):Line,rcov=~us(trait):units,

                        family=rep("gaussian",4), nitt=260000,
thin=200, burnin=60000,

                        verbose=FALSE, prior=prior.4t, pr=TRUE, data=Data)



To avoid the issues of missing values I added mean values for Age_F
and Mate_mass for the males and Age_M for the females, while still
using the at.level function. The idea was to overcome the problem with
the missing values while also ignoring the mean values for the sex
specific traits. This model ran without problems, and to see if the
model ran properly, I compared it to a second model where I added a
random value instead of mean values. I used set.seed() before running
both models, but the outputs are not the same, which means that the
added values are still affecting the results.

How can I avoid the problems of NAs when running an MCMCglmm on a data
set with this structure?



More information about the R-sig-mixed-models mailing list