基于后验预测模拟的模型拟合检验——P4

Published at 2020-06-26 13:19

Author:zhixy

View:379


读取数据设定模型

p4> read('brpo.ali')
p4> d = Data()
p4> read('bayes_cons.nwk')
p4> t = var.trees[0]
p4> t.data = d
## 模型 LG2C
p4> t.newRMatrix(free=0, spec='lg')
p4> t.setPInvar(free=0, val=0)
p4> t.setNGammaCat(nGammaCat=1)

p4> t.newComp(free=1, spec='empirical')
p4> t.newComp(free=1, spec='empirical')
p4> t.setModelThingsRandomly()

后验预测模拟 posterior predictive simulations

p4> t.simsForModelFitTests(reps=100)

模拟数据会保存在以sims_CompStats_ 开头以pid结束的文件中,且因为该模拟操作比较耗时,所以reps=100次的重复,可以给不同的进程来分别进行。

模型拟合检验 model fit test

p4> t.modelFitTests()

modelFitTests()函数会读取当前文件加下所有sims_CompStats_ 开头的文件,然后进行统计检验。结果存入model_fit_tests_out文件中。