##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)
##undertake General-to-Specific (GETS) model selection of
##the mean:
meanmod <- getsm(mymod)
##undertake General-to-Specific (GETS) model selection of
##the log-variance:
varmod01 <- getsv(mymod)
##undertake General-to-Specific (GETS) model selection of
##the log-variance (simplified model):
varmod02 <- getsv(meanmod)
##print results:
print(meanmod)
print(varmod01)
print(varmod02)
##print the entries of object 'gets':
summary(meanmod)
summary(varmod01)
summary(varmod02)
##extract coefficients of the simplified (specific) model:
coef(meanmod) #mean spec
coef(varmod01) #log-variance spec 1
coef(varmod02) #log-variance spec 2
##extract the paths searched:
paths(meanmod) #mean
paths(varmod01) #log-variance spec 1
paths(varmod02) #log-variance spec 2
##extract the terminal models:
terminals(meanmod) #mean
terminals(varmod01) #log-variance spec 1
terminals(varmod02) #log-variance spec 2
##extract variance-covariance matrix of simplified
##(specific) model:
vcov(meanmod) #mean spec
vcov(varmod01) #log-variance spec 1
vcov(varmod02) #log-variance spec 2
##extract and plot the fitted values:
mfit <- fitted(meanmod) #mean fit
plot(mfit)
vfit01 <- fitted(varmod01) #variance fit
plot(vfit01)
vfit02 <- fitted(varmod02) #variance fit
plot(vfit02)
##extract and plot residuals:
epshat <- residuals(meanmod) #mean residuals
plot(epshat)
zhat01 <- residuals(varmod01) #standardised residuals
plot(zhat01)
zhat02 <- residuals(varmod02) #standardised residuals
plot(zhat02)
Run the code above in your browser using DataLab