源码简介

% Example Script for MS_AR_Simul.m and MS_AR_Fit.m (run it in the same directory - just press f5)

% This script will first simulate a 2 states MS model with some pre defined parameters
% using MS_AR_Sim.m and then fit the model with MS_AR_Fit.m.

% You can change the coefficients for your own flavor

% You'll see that fmincon() is doing a pretty good job estimating the MS
% model (cheers for it!)

clear;

nr=1000;                % Number of observations in simulation
advOpt.distrib='t';     % Distribution to use ('Normal' or 't' - default = 'Normal')
advOpt.std_method=1;    % Method for standard error calculation

Coeff.p=[.9 .2 ; ...    % Transition matrix (this also defines the value of k)
.1 .8 ];       % Each collum of it should sum to 1
% Notes that the transition matrix output for fitting may
% not be exactly equal to this one since the
% the fit function doesn't know which states is
% 1 2, it just tries to find them and
% separate. This means that the pii (prob os staying at state i) can be
% deslocated through the collums, but it
% should respect the structure at Coeff.p

Coeff.C(1,1)= .01;   % Setting up the mean constant at State 1
Coeff.C(1,2)=-.01;   % Setting up the mean constant at State 2

Coeff.v(1,1)= 3;   % Setting up the student distribution parameter at State 1
Coeff.v(1,2)= 5;   % Setting up the student distribution parameter at State 2

Coeff.AR(:,1)=[ .2  .1 -.1];   % Setting up the AR param at State 1 (you can increase/decrease it as wanted)
Coeff.AR(:,2)=[-.5 -.1  .1];   % Setting up the AR param at State 2 (you can increase/decrease it as wanted)

Coeff.Std(1,1)=.02;  % Setting up the standard deviavion at State 1
Coeff.Std(1,2)=.05;  % Setting up the standard deviavion at State 2

ar=size(Coeff.AR,1);    % Number of lags in autoregressive component
k=length(Coeff.p);      % Number of states simulated (according to Coeff.p)

x=Simul_Out.Sim_x;

figure(2);  % Making sure matlab plots both figures
[Spec_Output]=MS_AR_Fit(x,ar,k,advOpt);    % Fitting to get parameters

rmpath('m_Files');

本站长期招聘程序代写高手，欢迎加入华南地区matlab团队 想创业却没有经验的人 无论你是否有过网上开店的经验，都可以随时联系在线客服，建立自己独立的网站 想开网店却不知道如何入手 淘宝创业成本低而且风险小，如果想开淘宝店的朋友可以联系在线客服。 想兼职创业，却不擅长交际与服务的人 在家创业月入5000元。网站程序+百套群发工具+网赚资料+域名+空间+本站终身代理资格，这样你网赚的条件全具备了。每天3小时管理、推广、收钱。 缺乏能快速赢利型产品的人 导入多种最新流行营销软件+网赚教程，让入驻者轻松加盟、复制有效成交技巧、快速赚钱。

源码评论评论内容只代表网友观点，与本站立场无关！

评论摘要(共 0 条，得分 0 分，平均 0 分) 查看完整评论

浏览说明

* 本站所有源码全部公开，随时随地浏览!
* MATLAB软件如用于商业用途，请购买正版!
* 如果您发现下载链接错误，请点击报告错误谢谢！
* 站内提供的所有软件包含破解及注册码均是由网上搜集，若侵犯了你的版权利益，敬请来信通知我们!