I'm trying to run a mixed phylogenetic model using the MCMCglmm function in the R package of the same name. In this model, I want to estimate slopes and intercepts for each level of a given variable (modeled as a random effect). I tried to run the model with the following code. However, the estimates of slopes and intercepts for the random effect are crazy! (i.e. when running separate models for each level, the results are reasonable) There is something wrong with my code (in the syntax of the model, or likely in the prior specification)

prior<- list(G=list(G1=list(V=1, nu=0.002), G2=list(V=diag(2), nu=2, alpha.mu= rep(0,2), alpha.V=diag(1000,2,2))), R=list(V=1, nu=0.002))

model<-MCMCglmm(y~x, random=~phylo + us(1+x):group,family="gaussian",ginverse=list(phylo=inv.phylo$Ainv),prior=prior,data=data,nitt=nitt,burnin=burn,thin=thin, pr=TRUE)


p.s the same model, but in the syntax used by brms has the form:

model <- brm(y ~ x +(1|phylo)+(1+x|group), cov_ranef = list(phylo = A)...  

(But it's too slow for my amount of data)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.