Description Usage Arguments Details Value Author(s) Examples
vws
Allows the specification of a regression with lag(x, k), diff(x, p)
as well as ARMA errors.
structure
1 2 |
formula |
Regression formula to be evaluated |
ar |
number of autoregressive (AR) terms to be included in regression |
ma |
Number of moving average (MA) terms to be included in regression |
data |
The dataframe which contains the variables used |
method |
Estimation method (CSS-ML, ML, CSS) |
datecolumn |
Optional column of class Date |
lmclass |
if true and no ARMA errors specifed, object returned is of class lm |
Returns an object of class "vws", which inherits from class "arima". If no ARMA
structure of errors is specified and "lm" = true , the returned object is of
class "lm". Generic functions plot
and summary
can be used.
a list of x elements:
coef |
a vector of AR, MA and regression coefficients, which can be extracted by the coef method. |
sigma2 |
the MLE of the innovations variance. |
var.coef |
the estimated variance matrix of the coefficients coef, 'which can be extracted by the vcov method. |
loglik |
the maximized log-likelihood (of the differenced data), or the approximation to it used. |
aic |
|
arma |
A compact form of the specification, as a vector giving the number of AR, MA, 'seasonal AR and seasonal MA coefficients, plus the period and the number of non-seasonal and seasonal differences. |
residuals |
the fitted innovations. |
fitted |
Fitted values of the formula |
dates |
Optional dates for the fitted series |
Bjorn Backgard
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 | #Generate some data: y0 follows an ARMA process conditional on x1, x2
error.model=function(n){rnorm(n, sd=.2)}
y0 <- arima.sim(model=list(ar=0.6, ma = -0.9), n=100,
n.start=200, start.innov=rnorm(200, sd=.2),
rand.gen=error.model )
x1 <- arima.sim(model=list(ar=0.95), n=100,
n.start=200, start.innov=rnorm(200, sd=.2),
rand.gen=error.model)
x2 <- arima.sim(model=list(ar=0.95), n=100,
n.start=200, start.innov=rnorm(200, sd=.2),
rand.gen=error.model)
y <- y0 + 0.5*x2 + 0.2 * x1
par(mfrow = c(2,2)) #Plot the variables
plot(y0)
plot(x1)
plot(x2)
plot(y)
dt <- data.frame(y,x1,x2)
par(mfrow = c(1,1))
library(vws)
vws.mod <- vws(y~x1+x2, ar = 0, ma = 0, data = dt) #Fit model
summary(vws.mod) #Get regression output
plot(vws.mod, 2) #Examine autocorrelation structure, ARMA terms needed
vws.mod <- vws(y~x1+x2, ar = 1, ma = 1, data = dt) #Fit new model
summary(vws.mod) #Get regression output
plot(vws.mod, 2) #Examine autocorrelation structure
plot(vws.mod, 3) #Check AR and MA roots
tsdiag(vws.mod) #No evidence of remaining autocorrelation in errors
plot(vws.mod, 1) #Check fit of final model
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.