gpt4 book ai didi

r - "Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) : 0 (non-NA) cases"做 2-way 重复测量 anova 测试时

转载 作者:行者123 更新时间:2023-12-04 13:57:22 24 4
gpt4 key购买 nike

我一直在尝试对数据集进行 2-Way 重复测量测试,年份和疫苗类型是自变量,覆盖率是因变量。我用代码运行它:

sat = anova_test(
data=SA, dv = coverage, wid = country,
within=c(vaccine, year)
)

但后来我得到了错误
Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) : 
0 (non-NA) cases

我跑了 all(is.na())在所有变量上,并且所有变量都变成了错误,所以不应该有任何 NA 情况。覆盖率绝对是一个数字,而国家、疫苗、年份绝对是因素。

任何帮助将不胜感激!!

编辑:
我使用了 rstatix 包中的 anova_test 函数
这是数据的摘要
> summary(SA)  
unicef_region iso3 country vaccine year
Length:1360 Length:1360 Afghanistan:170 BCG :272 1985 : 40
Class :character Class :character Bangladesh :170 DTP1:272 1986 : 40
Mode :character Mode :character Bhutan :170 DTP3:272 1987 : 40
India :170 MCV1:272 1988 : 40
Maldives :170 POL3:272 1989 : 40
Nepal :170 1990 : 40
(Other) :340 (Other):1120
coverage decade logitv
Min. : 1.00 Length:1360 Min. :-4.5951
1st Qu.:63.00 Class :character 1st Qu.: 0.5322
Median :83.00 Mode :character Median : 1.5856
Mean :75.97 Mean : 1.7595
3rd Qu.:96.00 3rd Qu.: 3.1781
Max. :99.00 Max. : 4.5951

> head(SA)
# A tibble: 6 x 8
unicef_region iso3 country vaccine year coverage decade logitv
<chr> <chr> <fct> <fct> <fct> <dbl> <chr> <dbl>
1 South Asia AFG Afghanistan BCG 1985 17 80s -1.59
2 South Asia BGD Bangladesh BCG 1985 2 80s -3.89
3 South Asia BTN Bhutan BCG 1985 54 80s 0.160
4 South Asia IND India BCG 1985 8 80s -2.44
5 South Asia MDV Maldives BCG 1985 45 80s -0.201
6 South Asia NPL Nepal BCG 1985 67 80s 0.708

最佳答案

您可以尝试对我有用的公式界面。

sat = anova_test(
data = SA,
coverage ~ vaccine * year,
wid = country
)

关于r - "Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) : 0 (non-NA) cases"做 2-way 重复测量 anova 测试时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59612766/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com