📄 example_ms_ar_fit_with_mex.m
字号:
% Example Script for MS_AR_Fit.m with mex version of Hamilton's
% Filter. The gain in speed is quite impressive (up to 5x when comparing
% against non mex version).
%
% The mex function was created using a c++ API provided by NR
% (http://www.nr.com/). This makes it easier by using matrix notation (and
% not pointers notation in the usual mex enviroment).
%
% The mex function was deleloped using matlab 2008a and C++ MS Visual Express 2008 compiler
% (you can get it free at microsoft site).
%
% WARNING. It will NOT compile under LCC. You'll need to recompile the
% files with a proper compiler for it to work on your pc. The name of the
% target file is mex_MS_Filter.cpp (it also uses nr3matlab.h).
clear;
addpath('m_Files');
load Example_Data.mat; % load .mat file
ar=4; % Number of lags in autoregressive component
k=2; % Number of states
x=ret; % Time series from example.mat
advOpt.distrib='Normal'; % Distribution to use ('Normal' or 't' - default = 'Normal')
advOpt.std_method=1; % Method for standard error calculation
advOpt.useMex=1; % Use mex version of likelihood?
[Spec_Output]=MS_AR_Fit(x,ar,k,advOpt); % fit the model
rmpath('m_Files');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -