简体   繁体   English

在猿中运行 PGLS 时出错:“未指定协变量”

[英]Error running PGLS in ape: “no covariate specified”

I just re-visited an old r script to double check my analyses.我刚刚重新访问了一个旧的 r 脚本来仔细检查我的分析。 I'm getting this new error when I try to run PGLS:当我尝试运行 PGLS 时出现这个新错误:

No covariate specified, species will be taken as ordered in the data frame.未指定协变量,物种将按数据框中的顺序排列。 To avoid this message, specify a covariate containing the species names with the 'form' argument.为避免出现此消息,请使用“form”参数指定包含物种名称的协变量。

I wonder if it has to do with a new update?我想知道这是否与新的更新有关? I don't think there's anything wrong with my script because I also got this error when I tried to replicate previous tutorials.我认为我的脚本没有任何问题,因为当我尝试复制以前的教程时也遇到了这个错误。 But just in case I'm wrong, I've pasted my script below:但以防万一我错了,我在下面粘贴了我的脚本:

gls(Diet_PC1~Habitat_PC1,correlation = corBrownian(phy = PrimateTree.phy), data=traits, method="ML")

Does anyone have any solutions?有没有人有任何解决方案?

Thanks!谢谢! MD医学博士

I ran into similar issues while running through a tutorial a while back.不久前,我在浏览教程时遇到了类似的问题。 From what I figured out, it's related to an update to 'ape' that was pushed in June.据我了解,这与 6 月份推出的“ape”更新有关。 the cor[MODEL] functions now require a formula specifying the taxa covariate. cor[MODEL] 函数现在需要一个指定分类群协变量的公式。 Per the reference manual:根据参考手册:

a one sided formula of the form ~ t, or ~ t |形式为 ~ t 或 ~ t | 的单边公式g, specifying the taxa covariate t and, optionally, a grouping factor g. g,指定分类群协变量 t 和可选的分组因子 g。 A covariate for this correlation structure must be character valued, with entries matching the tip labels in the phylogenetic tree.此相关结构的协变量必须是字符值,其条目与系统发育树中的尖端标签匹配。 When a grouping factor is present in form, the correlation structure is assumed to apply only to observations within the same grouping level;当表格中存在分组因子时,假设相关结构仅适用于同一分组级别内的观察; observations with different grouping levels are assumed to be uncorrelated.假设具有不同分组级别的观察是不相关的。 Defaults to ~ 1, which corresponds to using the order of the observations in the data as a covariate, and no groups.默认为 ~ 1,这对应于使用数据中观察的顺序作为协变量,并且没有组。

Code example from the manual:手册中的代码示例:

gls(Y ~ X, dat, correlation=corBrownian(1, tree.primates, form = ~Species))

At the time, I wasn't able to figure out how to use the "form" parameter with the tutorial I was using and get the expected results.当时,我无法弄清楚如何在我正在使用的教程中使用“form”参数并获得预期的结果。 So, I installed the prior version of "ape" released and everything ran perfectly fine (obtained the expected results for the tutorial).所以,我安装了之前发布的“ape”版本,一切都运行得很好(获得了本教程的预期结果)。 I'm sure this is a really useful paramter, but I wasn't able to find any good resources on how to correctly use it at the time.我确信这是一个非常有用的参数,但我当时找不到任何关于如何正确使用它的好资源。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM