ar
位於 stats
包(package)。 說明
將自回歸時間序列模型擬合到數據,默認情況下選擇 AIC 的複雜性。
用法
ar(x, aic = TRUE, order.max = NULL,
method = c("yule-walker", "burg", "ols", "mle", "yw"),
na.action, series, ...)
ar.burg(x, ...)
## Default S3 method:
ar.burg(x, aic = TRUE, order.max = NULL,
na.action = na.fail, demean = TRUE, series,
var.method = 1, ...)
## S3 method for class 'mts'
ar.burg(x, aic = TRUE, order.max = NULL,
na.action = na.fail, demean = TRUE, series,
var.method = 1, ...)
ar.yw(x, ...)
## Default S3 method:
ar.yw(x, aic = TRUE, order.max = NULL,
na.action = na.fail, demean = TRUE, series, ...)
## S3 method for class 'mts'
ar.yw(x, aic = TRUE, order.max = NULL,
na.action = na.fail, demean = TRUE, series,
var.method = 1, ...)
ar.mle(x, aic = TRUE, order.max = NULL, na.action = na.fail,
demean = TRUE, series, ...)
## S3 method for class 'ar'
predict(object, newdata, n.ahead = 1, se.fit = TRUE, ...)
參數
x |
單變量或多變量時間序列。 |
aic |
|
order.max |
要擬合的模型的最大階數(或階數)。默認為 |
method |
指定擬合模型方法的字符串。必須是默認參數中的字符串之一(前幾個字符就足夠了)。默認為 |
na.action |
調用函數來處理缺失值。目前,通過 |
demean |
應該在擬合過程中估計平均值嗎? |
series |
該係列的名稱。默認為 |
var.method |
估計創新方差的方法(參見“詳細信息”)。 |
... |
特定方法的附加參數。 |
object |
來自 |
newdata |
應用預測的數據。 |
n.ahead |
預測的提前步數。 |
se.fit |
邏輯:返回預測誤差的估計標準誤差? |
細節
為了明確起見,請注意 AR 係數的符號為
ar
隻是函數 ar.yw
、 ar.burg
、 ar.ols
和 ar.mle
的包裝。
如果 aic
為 true,則訂單選擇由 AIC 完成。這是有問題的,因為這裏的方法中隻有 ar.mle
執行真正的最大似然估計。 AIC 的計算方式就像方差估計是 MLE,從似然中省略了行列式項。請注意,這與在估計參數值下評估的高斯似然不同。在 ar.yw
中,創新的方差矩陣是根據 x
的擬合係數和自協方差計算的。
ar.burg
允許兩種方法來估計創新方差以及 AIC。方法 1 是使用 Levinson-Durbin 遞歸給出的更新(Brockwell 和 Davis,1991,第 242 頁的(8.2.6)),並遵循 S-PLUS。方法 2 是前向和後向預測誤差的平方和的平均值(如 Brockwell 和 Davis,1996 年,第 145 頁)。 Percival 和 Walden (1998) 討論了兩者。在多變量情況下,估計係數將(稍微)取決於方差估計方法。
請記住,ar
默認情況下在模型中包含一個常量,方法是在擬合 AR 模型之前刪除 x
的總體平均值,或者 ( ar.mle
) 估計要減去的常量。
值
對於 ar
及其方法,類 "ar"
的列表包含以下元素:
order |
擬合模型的順序。這是通過在 |
ar |
擬合模型的估計自回歸係數。 |
var.pred |
預測方差:對時間序列方差中自回歸模型無法解釋的部分的估計。 |
x.mean |
用於擬合和預測的序列的估計平均值。 |
x.intercept |
(僅限 |
aic |
每個模型與 best-fitting 模型之間 AIC 的差異。請注意,後者的 AIC 可以為 |
n.used |
時間序列中的觀測值數量,包括缺失值。 |
n.obs |
時間序列中非缺失觀測值的數量。 |
order.max |
|
partialacf |
偏自相關函數的估計滯後 |
resid |
擬合模型的殘差,以第一個 |
method |
|
series |
時間序列的名稱。 |
frequency |
時間序列的頻率。 |
call |
匹配的調用。 |
asy.var.coef |
(單變量情況, |
對於 predict.ar
,預測的時間序列,或者如果 se.fit = TRUE
,則包含組件 pred
的列表(預測)和 se
(估計的標準誤差)。兩個組成部分都是時間序列。
注意
僅實現ar.mle
的單變量情況。
通過 method="mle"
擬合長序列可能會非常慢。
如果 x
包含缺失值,請參閱 NA
,還可以考慮使用 arima()
,可能與 method = "ML"
一起使用。
例子
ar(lh)
ar(lh, method = "burg")
ar(lh, method = "ols")
ar(lh, FALSE, 4) # fit ar(4)
(sunspot.ar <- ar(sunspot.year))
predict(sunspot.ar, n.ahead = 25)
## try the other methods too
ar(ts.union(BJsales, BJsales.lead))
## Burg is quite different here, as is OLS (see ar.ols)
ar(ts.union(BJsales, BJsales.lead), method = "burg")
作者
Martyn Plummer. Univariate case of ar.yw
, ar.mle
and C code for univariate case of ar.burg
by B. D. Ripley.
參考
Brockwell, P. J. and Davis, R. A. (1991). Time Series and Forecasting Methods, second edition. Springer, New York. Section 11.4.
Brockwell, P. J. and Davis, R. A. (1996). Introduction to Time Series and Forecasting. Springer, New York. Sections 5.1 and 7.6.
Percival, D. P. and Walden, A. T. (1998). Spectral Analysis for Physical Applications. Cambridge University Press.
Whittle, P. (1963). On the fitting of multivariate autoregressions and the approximate canonical factorization of a spectral density matrix. Biometrika, 40, 129-134. doi:10.2307/2333753.
也可以看看
ar.ols
、arima
用於 ARMA 模型; acf2AR
,用於 ACF 的 AR 構建。
arima.sim
用於模擬 AR 過程。
相關用法
- R ar.ols 通過 OLS 將自回歸模型擬合到時間序列
- R arima.sim 從 ARIMA 模型進行模擬
- R arima 時間序列的 ARIMA 建模
- R arima0 時間序列的 ARIMA 建模 – 初步版本
- R aggregate 計算數據子集的匯總統計
- R alias 查找模型中的別名(依賴項)
- R anova.glm 廣義線性模型擬合的偏差分析
- R anova.mlm 多元線性模型之間的比較
- R addmargins 在多維表或數組上設置任意邊距
- R anova 方差分析表
- R asOneSidedFormula 轉換為單邊公式
- R as.hclust 將對象轉換為 hclust 類
- R ansari.test 安薩裏-布拉德利檢驗
- R approxfun 插值函數
- R add1 在模型中添加或刪除所有可能的單項
- R acf 自協方差和互協方差以及相關函數估計
- R aov 擬合方差分析模型
- R ave 因子水平組合的組平均值
- R acf2AR 計算精確擬合 ACF 的 AR 過程
- R anova.lm 線性模型擬合的方差分析
- R stlmethods STL 對象的方法
- R medpolish 矩陣的中值波蘭(穩健雙向分解)
- R naprint 調整缺失值
- R summary.nls 總結非線性最小二乘模型擬合
- R summary.manova 多元方差分析的匯總方法
注:本文由純淨天空篩選整理自R-devel大神的英文原創作品 Fit Autoregressive Models to Time Series。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。