是的,您可以使用model.tables()。尝试?model.tables 熟悉它。你想要的可能是(我会用一个例子):
aov_out <- aov(yield ~ N*P, npk)
model.tables(aov_out, "means") # This will give you the means.
model.tables(aov_out, se = TRUE) # Will give you standard errors for the effects.
model.tables(aov_out, "means", se = TRUE) # Will give you the standard error for the differences of means.
但是请注意,最后一个命令仅在您的模型中没有任何随机效应时才有效。因此,对于像这样的模型:
aov_out_ran <- aov(yield ~ N*P + Error(block), npk)
最后一个命令将不起作用,因为它尚未实现。但无论如何,您都会在警告消息中看到这一点。
您也可以轻松地手动计算均值。使用对比编码重新调整您的模型:
aov_out_contr <- aov(yield ~ N*P, npk, contrasts = list (N = "contr.sum", P = "contr.sum"))
使用coef()获取模型的系数:
coef_aov_out <- coef(aov_out)
因为我们使用对比编码,所以coef_aov_out[1] 位置处的(Intercept) 将是总均值,coef_aov_out 中的进一步系数将是需要减去或添加到主效应或交互效应的影响大均值,以获得该组的特定均值。您可以像这样手动计算它们:
# Compute mean of N0:
N0 <- coef_aov_out[1]+coef_aov_out[2]
# Compute mean of N1:
N1 <- coef_aov_out[1]-coef_aov_out[2]
# Compute mean of P0:
P0 <- coef_aov_out[1]+coef_aov_out[3]
# Compute mean of P1:
P1 <- coef_aov_out[1]-coef_aov_out[3]
# Compute mean of N0xP0:
NOP0 <- coef_aov_out[1]+coef_aov_out[2]+coef_aov_out[3]+coef_aov_out[4]
# Compute mean of N0xP1:
N0P1 <- coef_aov_out[1]+coef_aov_out[2]-coef_aov_out[3]-coef_aov_out[4]
# Compute mean of N1xP0:
N1P0 <- coef_aov_out[1]-coef_aov_out[2]+coef_aov_out[3]-coef_aov_out[4]
# Compute mean of N1xP1:
N1P1 <- coef_aov_out[1]-coef_aov_out[2]-coef_aov_out[3]+coef_aov_out[4]
您可以将结果与model.tables(aov_out_contr, "means") 进行比较。这是一个很好的练习来了解正在发生的事情。