对于下面的
ww
数据,我需要每天进行重复测量方差分析以检查组显着性。这是我下面的代码,但在我的摘要中我找不到 p 值。这是什么问题?还有其他更合适的方法吗?
ww<-structure(list(Group = structure(c(2L, 3L, 1L), levels = c("Cycling",
"OVX", "SHAM"), class = "factor"), `9` = c(19.6166666666667,
18.9666666666667, 19.4225), `10` = c(21.5916666666667, 19.2916666666667,
19.7025), `11` = c(22.2666666666667, 19.3666666666667, 19.7225
), `12` = c(22.25, 19.2166666666667, 19.5775), `13` = c(22.4,
19.8583333333333, 20.1275), `14` = c(23.2, 19.8083333333333,
20.1325), `15` = c(23.6166666666667, 20.525, 20.29), `16` = c(24.6166666666667,
21.3416666666667, 21.065), `17` = c(26.3583333333333, 21.5333333333333,
21.5325), `18` = c(27.025, 21.5583333333333, 21.4375), `19` = c(27.9833333333333,
21.8666666666667, 21.63), `20` = c(28.7916666666667, 22.0916666666667,
21.6175), `21` = c(28.975, 22.0416666666667, 21.875)), row.names = c(NA,
-3L), class = c("tbl_df", "tbl", "data.frame"))
# Load the required libraries
library(tidyverse)
# Convert 'Average Wt' to a factor to indicate groups
ww$Group <- as.factor(ww$Group)
# Reshape data for repeated measures ANOVA
ww_long <- ww %>%
pivot_longer(cols = -Group, names_to = "Day", values_to = "Weight")
# Perform repeated measures ANOVA
aov_results <- aov(Weight ~ Group + Error(Group/Day), data = ww_long)
summary(aov_results)
Error: Group
Df Sum Sq Mean Sq
Group 2 132.8 66.42
Error: Group:Day
Df Sum Sq Mean Sq F value Pr(>F)
Residuals 36 136.9 3.804
通过使用
Error(Group/Day)
,其中 Group/Day
扩展为 Group + Group:Day
(“组和日期嵌套在组内”),您(可能是错误/无意的)在固定效应和误差项中包含 Group
。
相反
aov_results <- aov(Weight ~ Group + Error(Group:Day), data = ww_long)
summary(aov_results)
会给你 p 值,但也会警告“Error() 模型是奇异的”。这是因为这实际上不是重复测量设计,尽管它看起来像这样,因为组内没有多个主题/集群。我认为在这种情况下,一个简单的
lm(Weight ~ Group, ...)
(或者可能是Weight ~ Group + Day
:尝试拟合交互模型Group*Day
将遇到相同类型的可识别性问题(每组/天组合只有一个观察)。