如何在MCMCglmm中指定更强的先验?

时间:2017-11-29 13:01:02

标签: r mcmc

我已经使用MCMCglmm R软件包工作了数周。这是我第一次使用它。我已经阅读了很多论文和指南,以便更好地理解,但我无法解决我的问题:

这是我的数据(仅适用于一个人):

Species Individual  Lineage Prevalence  day breeding    Year    phylo   
Aegithalos_caudatus I1  SGS1    0   125 Yes i2010   Aegithalos_caudatus   
Aegithalos_caudatus I1  CARDUEL1    0   125 Yes i2010   Aegithalos_caudatus 
Aegithalos_caudatus I1  CARDUEL2    0   125 Yes i2010   Aegithalos_caudatus 
Aegithalos_caudatus I1  CARDUEL3    0   125 Yes i2010   Aegithalos_caudatus 
Aegithalos_caudatus I1  DELURB1 0   125 Yes i2010   Aegithalos_caudatus 
Aegithalos_caudatus I1  DELURB2 0   125 Yes i2010   Aegithalos_caudatus 
Aegithalos_caudatus I1  DELURB3 0   125 Yes i2010   Aegithalos_caudatus 
Aegithalos_caudatus I1  DELURB5 0   125 Yes i2010   Aegithalos_caudatus 
Aegithalos_caudatus I1  DURB6   0   125 Yes i2010   Aegithalos_caudatus 
Aegithalos_caudatus I1  GRW2    0   125 Yes i2010   Aegithalos_caudatus 
Aegithalos_caudatus I1  GRW4    0   125 Yes i2010   Aegithalos_caudatus 
Aegithalos_caudatus I1  GRW9    0   125 Yes i2010   Aegithalos_caudatus 
Aegithalos_caudatus I1  RTSR1   0   125 Yes i2010   Aegithalos_caudatus 
Aegithalos_caudatus I1  ROBIN1  0   125 Yes i2010   Aegithalos_caudatus 
Aegithalos_caudatus I1  GRW9    0   125 Yes i2010   Aegithalos_caudatus 
Aegithalos_caudatus I1  HIPOL1  0   125 Yes i2010   Aegithalos_caudatus 
Aegithalos_caudatus I1  COLL1   0   125 Yes i2010   Aegithalos_caudatus 
Aegithalos_caudatus I1  GRW11   0   125 Yes i2010   Aegithalos_caudatus 
Aegithalos_caudatus I1  PADOM_5 0   125 Yes i2010   Aegithalos_caudatus 
Aegithalos_caudatus I1  PADOM01 0   125 Yes i2010   Aegithalos_caudatus 
Aegithalos_caudatus I1  PADOM08 0   125 Yes i2010   Aegithalos_caudatus 
Aegithalos_caudatus I1  PADOM22 0   125 Yes i2010   Aegithalos_caudatus 
Aegithalos_caudatus I1  PAHIS_01    0   125 Yes i2010   Aegithalos_caudatus 
Aegithalos_caudatus I1  CCF2    0   125 Yes i2010   Aegithalos_caudatus 
Aegithalos_caudatus I1  SYMEL1  0   125 Yes i2010   Aegithalos_caudatus 
Aegithalos_caudatus I1  SYAT_05 0   125 Yes i2010   Aegithalos_caudatus 
Aegithalos_caudatus I1  TURDUS3 0   125 Yes i2010   

我有815个人属于23种不同的物种。每个人有24个条目(每个寄生虫一个)。 我还想考虑系统发育宿主(鸟)树。 我的分析的主要目的是测试流行率(感染= 0或未感染= 1)是否可能受宿主物种或谱系的影响。

所以,我运行我的MCMCglmm模型,并收到有关我的先生的错误消息:

 data= read.table("data.txt", header = T)
 phylo<-read.nexus("tree.nex")
 inv.phylo<-inverseA(phylo,nodes="TIPS",scale=TRUE)
 prior.ex.<- list(G = list(G1 = list(V = 1, nu = 2, alpha.mu = 0, alpha.V = 10000),
                                     G2 = list(V = 1, nu = 2, alpha.mu = 0, alpha.V = 10000),
                                     G3 = list(V = 1, nu = 2, alpha.mu = 0, alpha.V = 10000),
                                     G4 = list(V = 1, nu = 2, alpha.mu = 0, alpha.V = 10000),
                                     R = list(R1 = list(V =1, nu = 0.02, fix = TRUE),
                                                  R2 = list(V =1, nu = 0.02, fix = TRUE))))
 model <- MCMCglmm(fixed = Prevalence ~ day + breeding, 
                    random =  ~ Year + Lineage + Individual + Individual:Species, 
                    data = data,
                    family = "categorical",  ginverse=list(phylo=inv.phyl$Ainv), nitt=300000, burnin=60000, thin=200, verbose = TRUE)

                           # MCMC iteration = 0

     # Acceptance ratio for liability set 1 = 0.000658

                           # MCMC iteration = 1000

     # Acceptance ratio for liability set 1 = 0.443318

                           # MCMC iteration = 2000

     # Acceptance ratio for liability set 1 = 0.428678

                           # MCMC iteration = 3000

     # Acceptance ratio for liability set 1 = 0.438693

                           # MCMC iteration = 4000

     # Acceptance ratio for liability set 1 = 0.437736

                           # MCMC iteration = 5000

     # Acceptance ratio for liability set 1 = 0.440917

                           # MCMC iteration = 6000

     # Acceptance ratio for liability set 1 = 0.430484

                           # MCMC iteration = 7000

     # Acceptance ratio for liability set 1 = 0.434346

                           # MCMC iteration = 8000

     # Acceptance ratio for liability set 1 = 0.428129

                           # MCMC iteration = 9000

     # Acceptance ratio for liability set 1 = 0.435863

                           # MCMC iteration = 10000

     # Acceptance ratio for liability set 1 = 0.437513

                           # MCMC iteration = 11000

     # Acceptance ratio for liability set 1 = 0.437331

                           # MCMC iteration = 12000

     # Acceptance ratio for liability set 1 = 0.431787

                           # MCMC iteration = 13000

     # Acceptance ratio for liability set 1 = 0.429239

                           # MCMC iteration = 14000

     # Acceptance ratio for liability set 1 = 0.435133

                           # MCMC iteration = 15000

     # Acceptance ratio for liability set 1 = 0.436029
    # Error in MCMCglmm(fixed = Prevalence ~ day + breeding, random = ~Year +  : 
      # Mixed model equations singular: use a (stronger) prior

我试图改变燃烧,燃烧和稀释,但最后它总是说同样的错误。但是,如果我减少这个值,我不会得到任何错误,但我的情节不是应该的。

1 个答案:

答案 0 :(得分:0)

首先,在模型规范中,您未能设置先前的&#39;要成为您的先前列表,因此您的模型规范应如下所示:

model <- MCMCglmm(fixed = Prevalence ~ day + breeding, 
                random =  ~ Year + Lineage + Individual + Individual:Species, 
                prior=prior.ex, data = data,
                family = "categorical",  ginverse=list(phylo=inv.phyl$Ainv), nitt=300000, burnin=60000, thin=200, verbose = TRUE)

此外,我认为您之前的操作并不完全正常,请尝试以下方法:

prior.ex<- list(G = list(G1 = list(V = 1, nu = 2, alpha.mu = 0, alpha.V = 10000),
                      G2 = list(V = 1, nu = 2, alpha.mu = 0, alpha.V = 10000),
                      G3 = list(V = 1, nu = 2, alpha.mu = 0, alpha.V = 10000),
                      G4 = list(V = 1, nu = 2, alpha.mu = 0, alpha.V = 10000)),
                      R = list(V=1, fix=1))

我希望这有帮助!