"ape"
(Paradis et al 2004)
"MCMCglmm"
(Hadfield, 2010a)
Count data ("data_pois_missing.txt"
), Data frame containing the Poisson data with missing values
Phylogeny ("phylo.nex"
), Phylogeny file (NEXUS file)
We will use the same data set as in the OPM section 11.4, but this time, we are missing one half of trait data phen_pois (100 out of 200 species). However, we have a complete data set for the cofactor, which, in this case, was related to missingness; we deleted the 50 trait values that had the 50 lowest values for the cofactor. Therefore, missing data in this data set is MAR. Let's look at the data:
library(ape) library(MCMCglmm) phylo<-read.nexus("phylo.nex") data<-read.table("data_pois_missing.txt",header=TRUE) head(data)
## phen_pois cofactor phylo ## 1 NA 7.8703 sp_1 ## 2 NA 3.4691 sp_2 ## 3 NA 2.5479 sp_3 ## 4 14 18.2287 sp_4 ## 5 NA 2.5303 sp_5 ## 6 NA 0.5146 sp_6
inv.phylo<-inverseA(phylo,nodes="TIPS",scale=TRUE) prior<-list(G=list(G1=list(V=1,nu=0.02)),R=list(V=1,nu=0.02)) model_missing<-MCMCglmm(phen_pois~cofactor,random=~phylo, family="poisson",ginverse=list(phylo=inv.phylo$Ainv), prior=prior,data=data,nitt=5000000,burnin=1000,thin=500)
Warning message: In MCMCglmm(phen_pois ~ cofactor, random = ~phylo, family = "poisson", : some combinations in phylo do not exist and 198 missing records have been generated
summary(model_missing)
## ## Iterations = 1001:4999501 ## Thinning interval = 500 ## Sample size = 9998 ## ## DIC: 615.5 ## ## G-structure: ~animal ## ## post.mean l-95% CI u-95% CI eff.samp ## animal 0.0467 0.00239 0.128 8679 ## ## R-structure: ~units ## ## post.mean l-95% CI u-95% CI eff.samp ## units 0.0399 0.00281 0.0923 8954 ## ## Location effects: phen_pois ~ cofactor ## ## post.mean l-95% CI u-95% CI eff.samp pMCMC ## (Intercept) -2.246 -2.723 -1.775 9050 <1e-04 *** ## cofactor 0.260 0.234 0.287 9432 <1e-04 *** ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1