Description Usage Arguments Details Value See Also Examples
compose.ar1
composes AR(1) process realization by given vector(s)
of innovations.
decompose.ar1
extracts AR(1) process residuals from time
series.
1 2 3 4 5 |
arcoef |
A number specifying autoregression coefficient. |
innov |
A univariate or multivariate time series containing the innovations. |
data |
A univariate or multivariate time series containing the process realization(s). |
init |
A number specifying the value of the process just prior to the start
value in |
xregcoef |
A vector specifying coefficients for the external regressors. |
xreg |
A matrix-like object of the same row count as
|
init.xreg |
A vector specifying the values of external regressors just prior to
the start values in |
Here AR(1) process with external regressors is a linear regresson with AR(1) model for the error term:
\code{y[t] = b[1]*x[t, 1] + … + b[k]*x[t, k] + z[t]}
\code{z[t] = a*z[t-1] + e[t]}
Use xreg = NULL
for the regular AR(1) process.
An object of the same type and dimensions as innov
/data
(typically time series).
arima
for more general ARMA(p, q) processes.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | ## Simple
e <- ts(c(0, 1, 0, 1, 0), freq = 12)
compose.ar1(0.1, e)
compose.ar1(0.1, e, 1)
x <- ts(c(0, 1, 0, 1, 0), freq = 12)
decompose.ar1(0.1, x)
decompose.ar1(0.1, x, 1)
## Multiseries
compose.ar1(0.1, ts(cbind(0, 1)))
compose.ar1(0.1, ts(cbind(c(0, 1, 0), c(1, 0, 1))))
decompose.ar1(0.1, ts(cbind(0, 1)))
decompose.ar1(0.1, ts(cbind(c(0, 1, 0), c(1, 0, 1))))
## External regressors
xreg1 <- rep(2, 5)
xreg2 <- matrix(rep(c(2, 1), each = 5), 5, 2)
e <- ts(c(0, 1, 0, 1, 0), freq = 12)
compose.ar1(0.1, e, xregcoef = 0.5, xreg = xreg1)
compose.ar1(0.1, e, xregcoef = 0.5, init = 0, xreg = xreg1, init.xreg = -2)
compose.ar1(0.1, e, xregcoef = c(1, -1), xreg = xreg2)
x <- ts(c(0, 1, 0, 1, 0), freq = 12)
decompose.ar1(0.1, x, xregcoef = 0.5, xreg = xreg1)
decompose.ar1(0.1, x, xregcoef = 0.5, init = 0, xreg = xreg1, init.xreg = -2)
decompose.ar1(0.1, x, xregcoef = c(1, -1), xreg = xreg2)
## Back-test
a <- 0.5
innov <- ts(rnorm(10), frequency = 12)
init <- 1
xrcoef <- seq(-0.1, 0.1, length.out = 3)
xreg <- matrix(1:30, 10, 3)
init.xreg <- 1:3
x <- compose.ar1(a, innov, init, xrcoef, xreg, init.xreg)
r <- decompose.ar1(a, x, init, xrcoef, xreg, init.xreg)
stopifnot(all.equal(innov, r))
|
Loading required package: cmrutils
Loading required package: chron
Loading required package: fda
Loading required package: splines
Loading required package: Matrix
Loading required package: fds
Loading required package: rainbow
Loading required package: MASS
Loading required package: pcaPP
Loading required package: RCurl
Attaching package: ‘fda’
The following object is masked from ‘package:graphics’:
matplot
Loading required package: zoo
Attaching package: ‘zoo’
The following objects are masked from ‘package:base’:
as.Date, as.Date.numeric
Jan Feb Mar Apr May
1 0.000 1.000 0.100 1.010 0.101
Jan Feb Mar Apr May
1 0.10000 1.01000 0.10100 1.01010 0.10101
Jan Feb Mar Apr May
1 NA 1.0 -0.1 1.0 -0.1
Jan Feb Mar Apr May
1 -0.1 1.0 -0.1 1.0 -0.1
Time Series:
Start = 1
End = 1
Frequency = 1
Series 1 Series 2
1 0 1
Time Series:
Start = 1
End = 3
Frequency = 1
Series 1 Series 2
1 0.0 1.00
2 1.0 0.10
3 0.1 1.01
Time Series:
Start = 1
End = 1
Frequency = 1
Series 1 Series 2
1 NA NA
Time Series:
Start = 1
End = 3
Frequency = 1
Series 1 Series 2
1 NA NA
2 1.0 -0.1
3 -0.1 1.0
Jan Feb Mar Apr May
1 1.000 2.000 1.100 2.010 1.101
Jan Feb Mar Apr May
1 1.10000 2.01000 1.10100 2.01010 1.10101
Jan Feb Mar Apr May
1 1.000 2.000 1.100 2.010 1.101
Jan Feb Mar Apr May
1 NA 0.1 -1.0 0.1 -1.0
Jan Feb Mar Apr May
1 -1.1 0.1 -1.0 0.1 -1.0
Jan Feb Mar Apr May
1 NA 0.1 -1.0 0.1 -1.0
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.