Ian Gregory
2007-Jun-16 01:57 UTC
[R] fSeries - Ox - ver: 240.10068 - Steps to make it work
-Bugs and fixes reported to Diethelm Wuertz.
-In the interim. To make the Ox functions part of the fSeries package work
please follow the following steps.
-------------------------------------------------
1. Install R-project.
2. Install fSeries.
3. Download: http://www.core.ucl.ac.be/~laurent/G@RCH/site/xbdcons/garch42.zip
(G@RCH package for Ox)
4. Download: http://www.doornik.com/download/b736gw/oxcons.html (Ox console)
5. Install Ox console to directory "c:\ox"
6. Copy: R-2.5.0\library\fSeries\ox\GarchOxModelling.ox
c:\ox\ox\lib\GarchOxModelling.ox
7. Load R-Project
8. Run:
library(fSeries)
data(dem2gbp)
x = dem2gbp[, 1]
garchOxFit(~garch(1,1),x)
------------------
Causes the errors:
Error in paste(OXPATH, "\\bin\\oxl.exe ", OXPATH,
"\\lib\\GarchOxModelling.ox", :
object "OXPATH" not found
------------------
This can be fixed by setting the directory in R-Project to where Ox is
installed. ie. OXPATH="c:\ox\ox".
9. garchOxFit(~garch(1,1),x)
10. Copy the G@RCH package files to "c:\ox\ox\packages\Garch42"
11. Change the line in GarchOxModelling.ox:
#import <packages/Garch40/garch>
to
#import <packages/Garch42/garch>
13.
garchOxFit(~garch(1,1),x)
Will give the following error:
--------------------------------------------------
Ox version 4.1 (Windows) (C) J.A. Doornik, 1994-2006
This version may be used for academic research and teaching only
Copyright for this package: S. Laurent and J.P. Peters, 2000-2006.
G@RCH package version 4.2, object created on 7-06-2007
-------------------------------------
Starting Values
==============Parameter Starting Value
Cst(M) 0.010000
Cst(V) 0.050000
ARCH(Alpha1) 0.100000
GARCH(Beta1) 0.800000
-------------------------------------
Bounds
=====
Parameter Lower Bound Upper Bound
Cst(M) -100.000000 100.000000
Cst(V) 0.000000 100.000000
ARCH(Alpha1) 0.000000 1.000000
GARCH(Beta1) 0.000000 1.000000
Runtime error: 'DoEstimation' wrong number of arguments
Runtime error occurred in main(207), call trace:
c:/ox/Ox\lib\GarchOxModelling.ox (207): main
Error in file(file, "r") : unable to open connection
In addition: Warning message:
cannot open file 'OxResiduals.csv', reason 'No such file or
directory'
--------------------------------------------------
14. This can be fixed by changing the line in GarchOxModelling.ox:
from garchobj.DoEstimation(); to
garchobj.DoEstimation(<>);
15.
Running:
garchOxFit(~garch(1,1),x)
Will give a 'typo' error is at the end of the estimation. Which needs
to be fixed by the developer
as it is compiled code.
However, now the function works and can call Ox from R-Prooject to estimate
models.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[1] "garch(1, 1)"
Ox version 4.1 (Windows) (C) J.A. Doornik, 1994-2006
This version may be used for academic research and teaching only
Copyright for this package: S. Laurent and J.P. Peters, 2000-2006.
G@RCH package version 4.2, object created on 11-06-2007
-------------------------------------
Starting Values
==============Parameter Starting Value
Cst(M) 0.010000
Cst(V) 0.050000
ARCH(Alpha1) 0.100000
GARCH(Beta1) 0.800000
-------------------------------------
Bounds
=====
Parameter Lower Bound Upper Bound
Cst(M) -100.000000 100.000000
Cst(V) 0.000000 100.000000
ARCH(Alpha1) 0.000000 1.000000
GARCH(Beta1) 0.000000 1.000000
Starting values
parameters
0.010000 0.050000 0.10000 0.80000
Initial function = -1312.86321151
Position after 5 SQPF iterations
parameters
0.0054353 0.038781 0.20486 0.60034
function value = -1125.76603281 steplen = 0.03125
Position after 10 SQPF iterations
parameters
-0.0088801 0.012371 0.17148 0.78507
function value = -1106.89461928
Position after 14 SQPF iterations
Status: Strong convergence
parameters
-0.0061830 0.010761 0.15341 0.80588
function value = -1106.58656395
Ian - Doing output
********************
** SPECIFICATIONS **
********************
Dependent variable : X
Mean Equation : ARMA (0, 0) model.
No regressor in the mean
Variance Equation : GARCH (1, 1) model.
No regressor in the variance
The distribution is a Gauss distribution.
Strong convergence using numerical derivatives
Log-likelihood = -1106.59
Please wait : Computing the Std Errors ...
Maximum Likelihood Estimation (Std.Errors based on Second derivatives)
Coefficient Std.Error t-value t-prob
Cst(M) -0.006183 0.0084616 -0.7307 0.4650
Cst(V) 0.010761 0.0028506 3.775 0.0002
ARCH(Alpha1) 0.153406 0.026568 5.774 0.0000
GARCH(Beta1) 0.805877 0.033542 24.03 0.0000
No. Observations : 1974 No. Parameters : 4
Mean (Y) : -0.01643 Variance (Y) : 0.22102
Skewness (Y) : -0.24951 Kurtosis (Y) : 6.62765
Log Likelihood : -1106.587 Alpha[1]+Beta[1]: 0.95908
The sample mean of squared residuals was used to start recursion.
The positivity constraint for the GARCH (1,1) is observed.
This constraint is alpha[L]/[1 - beta(L)] >= 0.
The unconditional variance is 0.262984
The conditions are alpha[0] > 0, alpha[L] + beta[L] < 1 and alpha[i] +
beta[i] >= 0.
=> See Doornik & Ooms (2001) for more details.
The condition for existence of the fourth moment of the GARCH is observed.
The constraint equals 0.966907 and should be < 1.
=> See Ling & McAleer (2001) for details.
Estimated Parameters Vector :
-0.006183; 0.010761; 0.153406; 0.805877
***************
** FORECASTS **
***************
Number of Forecasts: 15
Horizon Mean Variance
1 -0.006183 0.147
2 -0.006183 0.1517
3 -0.006183 0.1563
4 -0.006183 0.1606
5 -0.006183 0.1648
6 -0.006183 0.1688
7 -0.006183 0.1727
8 -0.006183 0.1764
9 -0.006183 0.1799
10 -0.006183 0.1833
11 -0.006183 0.1866
12 -0.006183 0.1897
13 -0.006183 0.1927
14 -0.006183 0.1956
15 -0.006183 0.1983
---------------
Forecasts errors measures cannot be computed because there are not enough
out-of-sample observations).
Elapsed Time : 0.219 seconds (or 0.00365 minutes).
***********
** TESTS **
***********
Statistic t-Test P-Value
Skewness -0.34713 6.3012 2.9538e-010
Excess Kurtosis 3.5233 31.994 1.3249e-224
Jarque-Bera 1060.7 .NaN 4.7645e-231
---------------
Information Criterium (to be minimized)
Akaike 1.125214 Shibata 1.125206
Schwarz 1.136537 Hannan-Quinn 1.129375
---------------
Q-Statistics on Standardized Residuals
Q( 10) = 10.1220 [0.4298588]
Q( 15) = 17.0402 [0.3164691]
Q( 20) = 19.2929 [0.5028690]
H0 : No serial correlation ==> Accept H0 when prob. is High [Q <
Chisq(lag)]
--------------
Q-Statistics on Squared Standardized Residuals
--> P-values adjusted by 2 degree(s) of freedom
Q( 10) = 9.05725 [0.3374891]
Q( 15) = 16.0714 [0.2452945]
Q( 20) = 17.5022 [0.4888708]
H0 : No serial correlation ==> Accept H0 when prob. is High [Q <
Chisq(lag)]
--------------
ARCH 1-2 test: F(2,1967)= 1.3009 [0.2725]
ARCH 1-5 test: F(5,1961)= 0.83951 [0.5215]
ARCH 1-10 test: F(10,1951)= 0.86584 [0.5649]
--------------
Residual-Based Diagnostic for Conditional Heteroskedasticity of Tse (2001)
RBD(10) = 8.28059 [0.6014503]
RBD(15) = 14.9050 [0.4582834]
RBD(20) = 15.6049 [0.7408121]
------------------------------------------------
P-values in brackets
Diagnostic test based on the news impact curve (EGARCH vs. GARCH)
Test P-value
Sign Bias t-Test 1.31906 0.18715
Negative Size Bias t-Test 0.24103 0.80953
Positive Size Bias t-Test 0.66341 0.50707
Joint Test for the Three Effects 2.87881 0.41069
---------------
Joint Statistic of the Nyblom test of stability: 0.664173
Individual Nyblom Statistics:
Cst(M) 0.16731
Cst(V) 0.35503
ARCH(Alpha1) 0.26363
GARCH(Beta1) 0.33496
Rem: Asymptotic 1% critical value for individual statistics = 0.75.
Asymptotic 5% critical value for individual statistics = 0.47.
---------------
Adjusted Pearson Chi-square Goodness-of-fit test
# Cells(g) Statistic P-Value(g-1) P-Value(g-k-1)
40 137.4083 0.000000 0.000000
50 160.5491 0.000000 0.000000
60 166.5471 0.000000 0.000000
Rem.: k = 4 = # estimated parameters
---------------
Error in .garchOxFit(formula.mean, formula.var, series = x, cond.dist, :
could not find function ".descrption"
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[[alternative HTML version deleted]]
Martin Becker
2007-Jun-16 10:31 UTC
[R] fSeries - Ox - ver: 240.10068 - Steps to make it work
I think there is still a small bug which I reported some time ago to
r-sig-finance
(https://stat.ethz.ch/pipermail/r-sig-finance/2005q4/000498.html) and
which takes effect if the time series is not stored in the variable 'x':
The line
write(x, file = "OxSeries.csv", ncolumns = 1, append = TRUE)
in .garchOxFit() (fSeries version 240.10068) should read
write(x = series, file = "OxSeries.csv", ncolumns = 1, append =
TRUE)
instead.
Incorporating the changes for OX-G at RCH4.2 could be a good occasion to
fix this as well :-)
Regards,
Martin
Ian Gregory wrote:> -Bugs and fixes reported to Diethelm Wuertz.
> -In the interim. To make the Ox functions part of the fSeries package work
please follow the following steps.
>
>
[snip]