當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


R corAR1 AR(1) 相關結構

R語言 corAR1 位於 nlme 包(package)。

說明

此函數是 corAR1 類的構造函數,表示 1 階自相關結構。使用此構造函數創建的對象稍後必須使用適當的 Initialize 方法進行初始化。

用法

corAR1(value, form, fixed)

參數

value

滯後 1 自相關的值,必須介於 -1 和 1 之間。默認為 0(無自相關)。

form

~ t~ t | g 形式的單邊公式,指定時間協變量 t 和可選的分組因子 g 。此相關結構的協變量必須是整數值。當 form 中存在分組因子時,假定相關結構僅適用於同一分組級別內的觀測值;假設具有不同分組級別的觀測值是不相關的。默認為 ~ 1 ,這對應於使用數據中的觀察順序作為協變量,並且沒有組。

fixed

一個可選的邏輯值,指示是否應允許係數在優化中變化,或保持固定在其初始值。默認為 FALSE ,在這種情況下允許係數變化。

corAR1 的對象,表示 1 階自相關結構。

例子

## covariate is observation order and grouping factor is Mare
cs1 <- corAR1(0.2, form = ~ 1 | Mare)

# Pinheiro and Bates, p. 236
cs1AR1 <- corAR1(0.8, form = ~ 1 | Subject)
cs1AR1. <- Initialize(cs1AR1, data = Orthodont)
corMatrix(cs1AR1.)

# Pinheiro and Bates, p. 240
fm1Ovar.lme <- lme(follicles ~ sin(2*pi*Time) + cos(2*pi*Time),
                   data = Ovary, random = pdDiag(~sin(2*pi*Time)))
fm2Ovar.lme <- update(fm1Ovar.lme, correlation = corAR1())

# Pinheiro and Bates, pp. 255-258:  use in gls
fm1Dial.gls <-
  gls(rate ~(pressure + I(pressure^2) + I(pressure^3) + I(pressure^4))*QB,
      Dialyzer)
fm2Dial.gls <- update(fm1Dial.gls,
                 weights = varPower(form = ~ pressure))
fm3Dial.gls <- update(fm2Dial.gls,
                    corr = corAR1(0.771, form = ~ 1 | Subject))

# Pinheiro and Bates use in nlme:  
# from p. 240 needed on p. 396
fm1Ovar.lme <- lme(follicles ~ sin(2*pi*Time) + cos(2*pi*Time),
                   data = Ovary, random = pdDiag(~sin(2*pi*Time)))
fm5Ovar.lme <- update(fm1Ovar.lme,
                corr = corARMA(p = 1, q = 1))
# p. 396
fm1Ovar.nlme <- nlme(follicles~
     A+B*sin(2*pi*w*Time)+C*cos(2*pi*w*Time),
   data=Ovary, fixed=A+B+C+w~1,
   random=pdDiag(A+B+w~1),
   start=c(fixef(fm5Ovar.lme), 1) )
# p. 397
fm2Ovar.nlme <- update(fm1Ovar.nlme,
         corr=corAR1(0.311) )

作者

José Pinheiro and Douglas Bates bates@stat.wisc.edu

參考

Box, G.E.P., Jenkins, G.M., and Reinsel G.C. (1994) "Time Series Analysis: Forecasting and Control", 3rd Edition, Holden-Day.

Pinheiro, J.C., and Bates, D.M. (2000) "Mixed-Effects Models in S and S-PLUS", Springer, esp. pp. 235, 397.

也可以看看

ACF.lmecorARMAcorClassesDim.corSpatialInitialize.corStructsummary.corStruct

相關用法


注:本文由純淨天空篩選整理自R-devel大神的英文原創作品 AR(1) Correlation Structure。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。