在MCMCglmm中定义优先级

时间:2019-05-13 19:25:09

标签: r bayesian glm mcmc

我在所有地方都发现了相同的问题,而且我似乎找不到任何适合我的数据的解决方案,我想知道我是否正在尝试将我的数据拟合到一个仅太复杂了。

我正在尝试将我的数据调整为来自MCMCglmm软件包的多项逻辑回归模型。我看过许多不同的文档,教程和MCMCglmm手册本身,主要是Florian Jaeger's tutorial,它非常详尽。但是,我迷失了他为先前的G结构和R结构选择值的方法,并且不断收到此错误消息

Error in priorformat(if (NOpriorG) { : 
  V is the wrong dimension for some prior$G/prior$R elements

特别是,我不确定两个数据都应赋予n值是什么,但是有点不透明的错误消息表明这是V的问题

这是我数据的(相关)子集:

CG_imm       locuteur   enquete       loc_age   loc_sexe      left    liquid   right    articulation_C1    voice_C1   NC_C1    NC_right    voice_right    right2          pos    logfreq      realization
abordable    44ajs1     Nantes        79         M            bl      l        p        stop               V          Vstop    stop        NV             NVstop          adj    NA           2
admettre     91adb1     Brunoy        54         M            tR      R        E        stop               N          NVstop   mid-vowel   V              mid-vowel       verb   6.52209279   0
adorable     91aal1     Brunoy        27         F            bl      l        break    stop               V          Vstop    break       break          weak break      adj    NA           0
agréable     92aaf2     PC            55         F            bl      l        break    stop               V          Vstop    break       break          strong break    adj    7.95191138   0
agréable     21abm1     Dijon         31         M            bl      l        k        stop               V          Vstop    stop        NV             NVstop          adj    7.95191138   1
agréable     75ccr2     Paris         NA         F            bl      l        break    stop               V          Vstop    break       break          break           adj    7.95191138   0
agréable     69ajl1     Lyon          52         M            bl      l        break    stop               V          Vstop    break       break          weak break      adj    7.95191138   0
Alexandre    91asl1     Brunoy        64         F            dR      R        break    stop               V          Vstop    break       break          weak break      noun   NA           0

从这个数据集中,我试图用许多不同的预测变量在三个级别上预测realization变量。这是我尝试过的模型之一:

k <- length(levels(df$realization))
I <- diag(k-1)
J <- matrix(rep(1, (k-1)^2), c(k-1, k-1))

prior1<-list(
  R = list(fix=1, V=0.5 * (I + J), n = 2
  ),
  G = list(
    G1 = list(V = diag(4), n = 4),
    G2 = list(V = diag(8), n = 8),
    G3 = list(V = diag(4), n = 4),
    G4 = list(V = diag(4), n = 4),
    G5 = list(V = diag(14), n = 14),
    G6 = list(V = 3, n = 3),
    G7 = list(V = 3, n = 3),
    G8 = list(V = diag(6), n = 6)))

m <- MCMCglmm(realization ~ -1 + trait + NC_C1*liquid + right2 + loc_age + logfreq + pos,
              random = ~ us(trait):CG_imm + us(NC_C1*liquid):CG_imm +
              us(trait):locuteur  + us(trait):enquete + us(right2):CG_imm +
              us(loc_age):locuteur + us(log_freq):CG_imm + us(pos):CG_imm,
              rcov = ~ us(trait):units,
              prior = prior1,
              burnin = 15000,
              nitt = 40000,
              family = "categorical",
              data = df)

在我的完整数据集中,我选择作为随机效应的预测变量具有以下级别:

> length(levels(ol_north$CG_imm))
[1] 181
> length(levels(ol_north$enquete))
[1] 13
> length(levels(ol_north$locuteur))
[1] 129

loc_agelog_freq以外,所有固定效应的预测变量都是分类的,固定的分类变量处于以下级别:

> length(levels(ol_north$NC_C1))
[1] 4
> length(levels(ol_north$liquid))
[1] 2
> length(levels(ol_north$right2))
[1] 14
> length(levels(ol_north$pos))
[1] 6

我已经在G结构列表和R结构中都使用了n值,并且已经将G结构中diag()参数中的值调整为无效。使用如此复杂的模型,我不确定错误在哪里发生。我已将模型简化为此模型,并使其收敛但带有警告:


m <- MCMCglmm(realization ~ -1 + trait + NC_C1*liquid + right2,
              random = ~ us(trait):CG_imm + us(NC_C1*liquid):CG_imm,
              rcov = ~ us(trait):units,
              prior = list(
                  R = list(fix=1, V=0.5 * (I + J), n = 2),
                  G = list(
                      G1 = list(V = diag(2), n = 22),
                      G2 = list(V = diag(8), n = 8))),
              burnin = 15000,
              nitt = 40000,
              family = "categorical",
              data = df)

Warning message:
In MCMCglmm(realization ~ -1 + trait + NC_C1 * liquid + right2,  :
  some fixed effects are not estimable and have been removed. Use singular.ok=TRUE to sample these effects, but use an informative prior!

非常感谢您提前提供的帮助!

0 个答案:

没有答案