aov
位於 stats
包(package)。 說明
通過調用 lm
擬合方差模型分析(如果使用 Error(.)
,則針對每個層)。
用法
aov(formula, data = NULL, projections = FALSE, qr = TRUE,
contrasts = NULL, ...)
參數
formula |
指定模型的公式。 |
data |
將在其中找到公式中指定的變量的 DataFrame 。如果丟失,則以標準方式搜索變量。 |
projections |
邏輯標誌:是否應該返回投影? |
qr |
邏輯標誌:是否應該返回 QR 分解? |
contrasts |
用於公式中某些因子的對比列表。這些不用於任何 |
... |
要傳遞給 |
細節
這為 lm
提供了一個包裝器,用於將線性模型擬合到平衡或不平衡的實驗設計。
與 lm
的主要區別在於 print
、summary
等處理擬合的方式:這是用方差分析的傳統語言而不是線性模型的語言來表達的。
如果公式包含單個 Error
項,則用於指定誤差層,並在每個誤差層內擬合適當的模型。
該公式可以指定多個響應。
權重可以由 weights
參數指定,但不應與 Error
術語一起使用,並且不完全支持(例如,不受 model.tables
支持)。
值
類 c("aov", "lm")
的對象或用於類 c("maov", "aov", "mlm", "lm")
的多個響應或用於類 c("aovlist", "listof")
的多個錯誤層。有 print
和 summary
方法可用於這些方法。
注意
aov
專為平衡設計而設計,如果沒有平衡,結果可能很難解釋:請注意,響應中缺少值可能會失去平衡。如果有兩個或更多錯誤層,則所使用的方法在統計上效率低下且不平衡,並且最好使用 nlme
包中的lme
。
可以使用replications
函數檢查餘額。
默認‘contrasts’R不是正交對比,並且aov
其輔助函數在這種對比下會更好地工作:請參閱示例以了解如何選擇這些函數。
例子
## From Venables and Ripley (2002) p.165.
## Set orthogonal contrasts.
op <- options(contrasts = c("contr.helmert", "contr.poly"))
( npk.aov <- aov(yield ~ block + N*P*K, npk) )
summary(npk.aov)
coefficients(npk.aov)
## to show the effects of re-ordering terms contrast the two fits
aov(yield ~ block + N * P + K, npk)
aov(terms(yield ~ block + N * P + K, keep.order = TRUE), npk)
## as a test, not particularly sensible statistically
npk.aovE <- aov(yield ~ N*P*K + Error(block), npk)
npk.aovE
## IGNORE_RDIFF_BEGIN
summary(npk.aovE)
## IGNORE_RDIFF_END
options(op) # reset to previous
作者
The design was inspired by the S function of the same name described in Chambers et al (1992).
參考
Chambers, J. M., Freeny, A and Heiberger, R. M. (1992) Analysis of variance; designed experiments. Chapter 5 of Statistical Models in S eds J. M. Chambers and T. J. Hastie, Wadsworth & Brooks/Cole.
也可以看看
lm
, summary.aov
, replications
, alias
, proj
, model.tables
, TukeyHSD
相關用法
- R aggregate 計算數據子集的匯總統計
- R alias 查找模型中的別名(依賴項)
- R anova.glm 廣義線性模型擬合的偏差分析
- R anova.mlm 多元線性模型之間的比較
- R addmargins 在多維表或數組上設置任意邊距
- R anova 方差分析表
- R asOneSidedFormula 轉換為單邊公式
- R as.hclust 將對象轉換為 hclust 類
- R ar.ols 通過 OLS 將自回歸模型擬合到時間序列
- R arima.sim 從 ARIMA 模型進行模擬
- R ar 將自回歸模型擬合到時間序列
- R arima 時間序列的 ARIMA 建模
- R ansari.test 安薩裏-布拉德利檢驗
- R approxfun 插值函數
- R add1 在模型中添加或刪除所有可能的單項
- R acf 自協方差和互協方差以及相關函數估計
- R ave 因子水平組合的組平均值
- R arima0 時間序列的 ARIMA 建模 – 初步版本
- R acf2AR 計算精確擬合 ACF 的 AR 過程
- R anova.lm 線性模型擬合的方差分析
- R stlmethods STL 對象的方法
- R medpolish 矩陣的中值波蘭(穩健雙向分解)
- R naprint 調整缺失值
- R summary.nls 總結非線性最小二乘模型擬合
- R summary.manova 多元方差分析的匯總方法
注:本文由純淨天空篩選整理自R-devel大神的英文原創作品 Fit an Analysis of Variance Model。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。