##Simulate from an AR(1):
set.seed(123)
y <- arima.sim(list(ar=0.4), 100)
##Simulate four independent Gaussian regressors:
xregs <- matrix(rnorm(4*100), 100, 4)
##estimate an AR(2) with intercept and four conditioning
##regressors in the mean, and log-ARCH(3) in the variance:
mymod <- arx(y, mc=TRUE, ar=1:2, mxreg=xregs, arch=1:3)
##print results:
print(mymod)
##print the entries of object 'mymod':
summary(mymod)
##extract mean coefficients:
coef(mymod)
##extract log-variance coefficients:
coef(mymod, spec="variance")
##extract all coefficients:
coef(mymod, spec="both")
##extract variance-covariance matrix of mean equation:
vcov(mymod)
##extract variance-covariance matrix of log-variance equation:
vcov(mymod, spec="variance")
##extract and plot the fitted mean values:
mfit <- fitted(mymod)
plot(mfit)
##extract and plot the fitted variance:
vfit <- fitted(mymod, spec="variance")
plot(vfit)
##extract and plot residuals:
epshat <- residuals(mymod)
plot(epshat)
##extract and plot standardised residuals:
zhat <- residuals(mymod, std=TRUE)
plot(zhat)
Run the code above in your browser using DataLab