Skip to content

Preparing data for Superior predictive ability (SPA) test

1 message · Karthik Raju

#
Sorry Brian, I misunderstood your last reply.

Intent: Evaluate forecasting accuracy of autoregressive models
Approach: Apply Superior Predictive Ability (SPA) test in the ?ttrTests? 
package to assess the forecasting accuracy
Version: R ver. 3.0.2 (2013-09-25) - "Frisbee Sailing"
Editor: R Studio ver. 0.98.1091
rugarch package: 1.3-4
ttrTests package: 1.7
Code: http://dropbox.unl.edu/uploads/20141219/e61f31203e15e90d/sample.zip

I am lost and looking for some direction on how to use a loss function 
series to evaluate the efficacy of volatility forecasts between models 
fm1 through fm5 using the SPA test in the "ttrTests" package.

My attempt is as follows:

spa <- dataSnoop(MeanSquareError,bSamples=1000,test="SPA")

# The structure of "MeanSquareError" loss function series is as follows:
Day   msefm1      msefm2    ..  msefm5
T+1   0.0000464   0.0000411 ..  0.0000407
T+2   0.0000461   0.0000421 ..  0.0000428
...
T+49  0.0000174   0.0000653 ..  0.0001126
T+50  0.0000174   0.0000657 ..  0.0001138

My code is structured as follows:

# To load the sample data in the "rugarch" package
data(sp500ret)

# To specify the desired autoregressive models
model1 = ugarchspec(variance.model = list(model = "sGARCH",garchOrder = 
c(1, 1)), distribution.model = "std")
model2 = ugarchspec(variance.model = list(model = "gjrGARCH",garchOrder 
= c(1, 1)), distribution.model = "std")
model3 = ugarchspec(variance.model = list(model = "sGARCH",garchOrder = 
c(1, 1)), distribution.model = "std")
model4 = ugarchspec(variance.model = list(model = "csGARCH",garchOrder = 
c(1, 1)), distribution.model = "std")
model5 = ugarchspec(variance.model = list(model = "apARCH",garchOrder = 
c(1, 1)), distribution.model = "std")

# To estimate the autoregressive models specified
m1 = ugarchfit(sp500ret, spec = model1)
m2 = ugarchfit(sp500ret, spec = model2)
m3 = ugarchfit(sp500ret, spec = model3)
m4 = ugarchfit(sp500ret, spec = model4)
m5 = ugarchfit(sp500ret, spec = model5)

# To forecast the volatility for next 50 days with the parameters 
estimated above
fm1 = ugarchforecast(m1,data=NULL,n.ahead=50, n.roll= 0, out.sample = 0)
fm2 = ugarchforecast(m2,data=NULL,n.ahead=50, n.roll= 0, out.sample = 0)
fm3 = ugarchforecast(m3,data=NULL,n.ahead=50, n.roll= 0, out.sample = 0)
fm4 = ugarchforecast(m4,data=NULL,n.ahead=50, n.roll= 0, out.sample = 0)
fm5 = ugarchforecast(m5,data=NULL,n.ahead=50, n.roll= 0, out.sample = 0)

I used the extractor function "sigma" in the "rugarch" package to 
extract the conditional standard deviation of the forecasts fm1 through 
fm5, which is then fed to a spreadsheet to estimate the Mean Square 
Error (MSE) loss function series for the 50 days.

# The MSE loss function series is then imported into R.
MeanSquareError <- read.csv("F:/MeanSquareError.csv")

Now, how do I go about using this ?MeanSquareError? loss function series 
such as this: spa<-dataSnoop(MeanSquareError, bSamples=1000, 
test="SPA")? Please note that I am not looking to convert 
?MeanSquareError.csv?  into R-data, rather I am searching for a way to 
apply the SPA test.

Thank you for your time.

Karthik

Brian G. Peterson wrote on 2014-11-29 03:51 PM +0530: