如何为MCMCglmm进行模型简化?

时间:2016-06-23 15:44:45

标签: r mixed-models mcmc

我有一个混合效果模型,我在RMC的包MCMCglmm中运行。我有兴趣探索几种可能的预测器。 如何进行模型简化以从模型中排除无信息预测变量?

在其他情况下,我使用逐步向后回归,即以" full"包含我感兴趣的所有预测变量的模型,并使用drop1()查找无信息变量,然后update()将其从模型中删除。

这些功能似乎都不适用于MCMCglmm对象。什么是我最好的选择?我想drop1()不起作用的一个原因是MCMCglmm对象没有AIC值。 DIC值是否可以以类似的方式使用?我不太了解DIC值,但在下面的示例中,它们似乎不像AIC那样:从模型中删除变量后,DIC减少了100以上。

对于update(),显然可以从头开始再次指定模型,但它涉及复制/粘贴相当长的函数调用,并且对于包含交互的较长模型公式会变得更加复杂。我想知道是否有更简单的替代方案。

我还想知道是否有一个原因是没有为这些函数编写的方法来处理MCMCglmm对象 - 我试图以某种方式做什么无效?

使用部分发明数据的可重复示例:

set.seed(1234)
library(MCMCglmm)

data(bird.families) 
n <- Ntip(bird.families)

# Create some dummy variables
d <- data.frame(taxon = bird.families$tip.label, 
                X1 = rnorm(n),
                X2 = rnorm(n),
                X3 = sample(c("A", "B", "C"), n, replace = T),
                X4 = sample(c("A", "B", "C"), n, replace = T))

# Simulate a phenotype composed of phylogenetic, fixed and residual effects
d$phenotype <- rbv(bird.families, 1, nodes="TIPS") +
               d$X1*0.7 + 
               ifelse(d$X3 == "B", 0.5, 0) + 
               ifelse(d$X3 == "C", 0.8, 0) +
               rnorm(n, 0, 1)  

# Inverse matrix of shared phyloegnetic history
Ainv <- inverseA(bird.families)$Ainv

# Set priors
prior <- list(R = list(V = 1, nu = 0.002), 
              G = list(G1 = list(V = 1, nu = 0.002)))

# Run model
model <- MCMCglmm(phenotype ~ X1 + X2 + X3 + X4, 
                  random = ~taxon, 
                  ginverse = list(taxon=Ainv),
                  data = d, 
                  prior = prior, 
                  verbose = FALSE)

summary(model)

# drop1(model, test = "Chisq") # doesn't work
# update(model, ~.- X2)        # doesn't work

model2 <- MCMCglmm(phenotype ~ X1 + X3 + X4, 
                  random = ~taxon, 
                  ginverse = list(taxon=Ainv),
                  data = d, 
                  prior = prior, 
                  verbose = FALSE)

summary(model2)

完整型号输出:

 Iterations = 3001:12991
 Thinning interval  = 10
 Sample size  = 1000 

 DIC: 145.2228 

 G-structure:  ~taxon

      post.mean l-95% CI u-95% CI eff.samp
taxon     1.808   0.2167    3.347    17.88

 R-structure:  ~units

      post.mean  l-95% CI u-95% CI eff.samp
units    0.6712 0.0003382    1.585    20.98

 Location effects: phenotype ~ X1 + X2 + X3 + X4 

             post.mean   l-95% CI   u-95% CI eff.samp  pMCMC    
(Intercept) -0.6005279 -1.5753606  0.2689091   1000.0  0.198    
X1           0.7506249  0.5220491  1.0033785    506.8 <0.001 ***
X2          -0.0339347 -0.2452923  0.2085228    900.7  0.712    
X3B          0.6276852  0.1238884  1.1727409   1000.0  0.022 *  
X3C          1.0533919  0.4244092  1.5095804   1000.0 <0.001 ***
X4B         -0.0002833 -0.5099753  0.5103896    478.3  0.978    
X4C          0.0723440 -0.4435520  0.6193011   1000.0  0.776    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

减少模型输出:

 Iterations = 3001:12991
 Thinning interval  = 10
 Sample size  = 1000 

 DIC: 296.4755 

 G-structure:  ~taxon

      post.mean l-95% CI u-95% CI eff.samp
taxon     1.542  0.07175      3.1    26.33

 R-structure:  ~units

      post.mean  l-95% CI u-95% CI eff.samp
units    0.8155 0.0004526    1.661    21.89

 Location effects: phenotype ~ X1 + X3 + X4 

            post.mean  l-95% CI  u-95% CI eff.samp  pMCMC    
(Intercept) -0.606920 -1.380267  0.335225   1000.0  0.172    
X1           0.750929  0.540667  1.011041   1000.0 <0.001 ***
X3B          0.633123  0.149282  1.243790   1000.0  0.032 *  
X3C          1.047085  0.518664  1.570641   1000.0 <0.001 ***
X4B          0.007019 -0.528080  0.512161    509.2  0.998    
X4C          0.063093 -0.490103  0.590965   1000.0  0.818    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

0 个答案:

没有答案