Why does MATLAB crash when I use GARCHLLFN?

1 view (last 30 days)
Why does MATLAB crash when I use GARCHLLFN?
I have the following code in MATLAB:
R=1;M=0;P=1;Q=1;X=[];C=1.3;AR=0.1;K=0.5;GARCH=0.9;ARCH=0.05;
spec=garchset('R',R,'P',1,'Q',1, 'C', C,'AR',AR,'K',K,'GARCH',GARCH,'ARCH',ARCH);
[Innovations, Sigma, y] = garchsim(spec,500);
Parameters=[C,AR,K,GARCH,ARCH];
[LL,G,H,Inno,Sig] = garchllfn(Parameters,y,R,M,P,Q,X);
If I run this code, I get the following error:
------------------------------------------------------------------------
Assertion detected at Mon Jun 03 15:21:19 2002
------------------------------------------------------------------------
Assertion failed: (hdr->in_use != 0), at line 870 of file "./mwmem.c".
Attempt to free previously freed memory
Configuration:
MATLAB Version: 6.0.0.88 (R12)
Operating System: Microsoft Windows 2000
Window System: Version 5.0 (Build 2195: Service Pack 2)
Processor ID: x86 Family 6 Model 8 Stepping 6, GenuineIntel
Virtual Machine: Java 1.1.8 from Sun Microsystems Inc.
Stack Trace:
[0] matlab.exe:_mnSignalHandler(0xffffffff, 0, 0, 1) + 452 bytes
[1] matlab.exe:_ThrowAssertion(0x1d8e6140, 0, 0x65737341, 0x6f697472) + 167 bytes
[2] matlab.exe:_MATLABAssertFcn(0x015df108 ": (hdr->in_use != 0),", 0x015deaa4 "./mwmem.c", 870, 0x015df120 "Attempt to free previously freed..") + 131 bytes
[3] libut.dll:_ut_assertstr(0x015df108 ": (hdr->in_use != 0),", 0x015deaa4 "./mwmem.c", 870, 0x015df120 "Attempt to free previously freed..") + 25 bytes
[4] libut.dll:_mw_free(0x1d8e6148, 2, 0x028fccc8, 0x014baa20) + 239 bytes
[5] libut.dll:_utFree(0x1d8e6148, 1, 0x028fccc8, 0x014baa30) + 25 bytes
[6] libmx.dll:_mxDestroyArrayContents(0x028fccc8, 502, 0x014baa70, 0x24b91448) + 175 bytes
[7] libmx.dll:_mxDestroyArray(0x028fccc8, 0x028f15f8 "C:\WINNT\Profiles\MBERKE~1.MAT\L..", 0x1db47430, 0x1db51ec8) + 50 bytes
[snip]

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
This crash is caused by incorrect usage of GARCHLLFN. GARCHLLFN is intended only as a helper function to GARCHINFER. Instead of calling GARCHLLFN directly, please use GARCHINFER.
Here is some information on why the crash is happening:
The GARCHLLFN has the following note in the help:
Note: This is a performance-sensitive objective function called by an iterative numerical optimizer. For this reason, no argument checking is performed. Although this function may be called directly, it is better accessed by calling GARCHINFER. Type "help garchinfer" for details.
Since there is no argument checking, the code will crash if the inputs are not in the proper format.
The incorrect section of code is in the parameters:
Parameters=[C,AR,K,GARCH,ARCH];
The Parameters input needs to be a column vector. This is documented in the help of GARCHLLFN:
Parameters - Column vector of process parameters associated with fitting conditional mean and variance specifications to an observed return series.
The parameters variable above is a row vector instead of a column vector. Change it to a column vector to avoid getting the crash.
PLEASE NOTE: You should use GARCHINFER instead of GARCHLLFN. Future versions of MATLAB may change the behavior of GARCHLLFN slightly, so that calling it directly may cause your code to break in future versions. Calling GARCHINFER will prevent this problem in future versions and will make your code more stable.

More Answers (0)

Categories

Find more on Software Development Tools in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!