“观察次数<=随机效应数”错误

问题描述 投票:0回答:2

我正在使用一个名为diagmeta的包进行元分析。我可以使用这个包含一个名为Schneider2017的内置数据集。但是,当我创建自己的数据库/数据集时,我收到以下错误:

错误:观察次数(= 300)<=期限的随机效应数(= 3074)(组*截止|研究);随机效应参数和残差方差(或尺度参数)可能无法识别

SO上的另一个线程表明错误是由一列或多列的数据格式引起的。我确保每列的数据类型与Schneider2017数据集中的数据类型相匹配 - 没有效果。

Link to the other thread

我尝试将Schneider2017数据集中的所有数据提取到excel中,然后通过R studio从Excel导入数据集。这再次没有区别。这告诉我,数据格式中的某些内容可能会有所不同,尽管我看不出如何。

diag2 <- diagmeta(tpos, fpos, tneg, fneg, cutpoint,
                   studlab = paste(author,year,group),
                   data = SRschneider,
                   model = "DIDS", log.cutoff = FALSE,
                   check.nobs.vs.nRE = "ignore")

数据集如下所示:This is what the dataset looks like

我期望与内置数据集一样成功执行和绘图,但不断收到此错误。

执行str(mydataset)的结果:

> str(SRschneider)
Classes ‘tbl_df’, ‘tbl’ and 'data.frame':   150 obs. of  10 variables:
 $ ...1    : num  1 2 3 4 5 6 7 8 9 10 ...
 $ study_id: num  1 1 1 1 1 1 1 1 1 1 ...
 $ author  : chr  "Arora" "Arora" "Arora" "Arora" ...
 $ year    : num  2006 2006 2006 2006 2006 ...
 $ group   : chr  NA NA NA NA ...
 $ cutpoint: chr  "6" "7.0" "8.0" "9.0" ...
 $ tpos    : num  133 131 130 127 119 115 113 110 102 98 ...
 $ fneg    : num  5 7 8 11 19 23 25 28 36 40 ...
 $ fpos    : num  34 33 31 30 28 26 25 21 19 19 ...
 $ tneg    : num  0 1 3 4 6 8 9 13 15 15 ...
r mixed-models
2个回答
0
投票

你说你

确保每列的数据类型与Schneider2017数据集中的数据类型相匹配

但这似乎不是真的。除了num(数字)和int(整数)类型(实际上通常不重要)之间的差异,您的数据有

 $ cutpoint: chr  "6" "7.0" "8.0" "9.0" ...

str(Schneider2017)

 $ cutpoint: num  6 7 8 9 10 11 12 13 14 15 ...

将您的cutpoint设为字符而不是数字意味着R将尝试将其视为分类变量(具有许多离散级别)。这很可能是您问题的根源。

cutpoint变量可能是一个字符,因为R在此列中遇到了一些不能被解释为数字的值(这一点就像印刷错误一样简单)。您可以使用SRschneider$cutpoint <- as.numeric(SRschneider$cutpoint)通过强力将变量转换为数字(无法解释的值将设置为NA),但最好是上游并查看问题所在。

如果你使用tidyverse包来加载你的数据,你应该得到一个可能有用的“解析问题”列表。您也可以尝试使用cp <- SRschneider$cutpoint; cp[which(is.na(as.numeric(cp)))]来查看无法转换的值。


1
投票

只需快速跟进Ben的详细答案。

diagmeta()中实施的统计方法期望参数cutpoint是一个连续变量。我们在R package diagmeta的0.3-1版本中添加了对参数cutpoint(以及参数TP,FP,TN和FN)的相应检查;请参阅commit in GitHub repository了解技术细节。

因此,以下R命令将导致更多信息性错误消息:

data(Schneider2017)
diagmeta(tpos, fpos, tneg, fneg, as.character(cutpoint),
         studlab = paste(author, year, group), data = Schneider2017)
© www.soinside.com 2019 - 2024. All rights reserved.