最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

拓端tecdat|Matlab用BUGS馬爾可夫區(qū)制轉(zhuǎn)換Markov switching隨機(jī)波動率SV模型、序列蒙

2022-01-14 18:10 作者:拓端tecdat  | 我要投稿

原文鏈接:http://tecdat.cn/?p=24498

原文出處:拓端數(shù)據(jù)部落公眾號

在這個例子中,我們考慮馬爾可夫轉(zhuǎn)換隨機(jī)波動率模型。

統(tǒng)計模型

讓?

?是因變量和?

?未觀察到的對數(shù)波動率?

. 隨機(jī)波動率模型定義如下?



區(qū)制變量?

?遵循具有轉(zhuǎn)移概率的二態(tài)馬爾可夫過程


?表示均值的正態(tài)分布?

?和方差?

.

BUGS語言統(tǒng)計模型

文件“ssv.bug”的內(nèi)容:

  1. file = 'ssv.bug'; % BUGS模型文件名


  2. model

  3. {

  4. x[1] ~ dnorm(mm[1], 1/sig^2)

  5. y[1] ~ dnorm(0, exp(-x[1]))


  6. for (t in 2:tmax)

  7. {

  8. c[t] ~ dcat(ifelse(c[t-1]==1, pi[1,], pi[2,]))

  9. mm[t] <- alp[1] * (c[t]==1) + alp[2]*(c[t]==2) + ph*x[t-1]

安裝

  1. 下載Matlab最新版本

  2. 將存檔解壓縮到某個文件夾中

  3. 將程序文件夾添加到 Matlab 搜索路徑

addpath(path)

通用設(shè)置


  1. lightblue

  2. lightred


  3. % 設(shè)置隨機(jī)數(shù)生成器的種子以實(shí)現(xiàn)可重復(fù)性

  4. if eLan 'matlab', '7.2')

  5. rnd('state', 0)

  6. else

  7. rng('default')

  8. end

加載模型和數(shù)據(jù)

模型參數(shù)

  1. tmax = 100;

  2. sig = .4;

解析編譯BUGS模型,以及樣本數(shù)據(jù)

  1. model(file, data, 'sample', true);

  2. data = model;

繪制數(shù)據(jù)

  1. figure('nae', 'Lrtrs')

  2. plot(1:tmax, dt.y)

Biips 序列蒙特卡羅SMC

運(yùn)行SMC

  1. n_part = 5000; % 粒子數(shù)

  2. {'x'}; % 要監(jiān)控的變量

  3. smc = ?samples(npart);

算法的診斷。

diag ? (smc);

?

繪圖平滑 ESS


  1. sem(ess)


  2. plot(1:tmax, 30*(tmax,1), '--k')


繪制加權(quán)粒子


  1. for ttt=1:tttmax

  2. va = unique(outtt.x.s.vaues(ttt,:));


  3. wegh = arrayfun(@(x) sum(outtt.x.s.weittt(ttt, outtt.x.s.vaues(ttt,:) == x)), va);


  4. scatttttter(ttt*ones(size(va)), va, min(50, .5*n_parttt*wegh), 'r',...

  5. 'markerf', 'r')

  6. end

匯總統(tǒng)計

summary(out, 'pro', [.025, .975]);

繪圖濾波估計

  1. mean = susmc.x.f.mean;

  2. xfqu = susmc.x.f.quant;

  3. h = fill([1:tmax, tmax:-1:1], [xfqu{1}; flipud(xfqu{2})], 0);


  4. plot(1:tmax, mean,)

  5. plot(1:tmax, data.x_true)

繪圖平滑估計


  1. mean = smcx.s.mean;

  2. quant = smcx.s.quant;


  3. plot(1:t_max, mean, ?3)

  4. plot(1:t_max, data.x_true, 'g')

邊際濾波和平滑密度

  1. kde = density(out);

  2. for k=1:numel(time)

  3. tk = time(k);

  4. plot(kde.x.f(tk).x, kde.x.f(tk).f);

  5. hold on

  6. plot(kde.x.s(tk).x, kde.x.s(tk).f, 'r');

  7. plot(data.xtrue(tk));

  8. box off

  9. end

Biips 粒子獨(dú)立 Metropolis-Hastings

PIMH 參數(shù)


  1. thi= 1;

  2. nprt = 50;

運(yùn)行 PIMH

  1. init(moel, vaibls);

  2. upda(obj, urn, npat); % 預(yù)燒迭代

  3. sample(obj,...

  4. nier, npat, 'thin', thn);

一些匯總統(tǒng)計

summary(out, 'prs');

后均值和分位數(shù)

  1. mean = sumx.man;

  2. quant = su.x.qunt;


  3. hold on

  4. plot(1:tax, man, 'r', 'liith', 3)

  5. plot(1:tax, xrue, 'g')

MCMC 樣本的蹤跡


  1. for k=1:nmel(timndx)

  2. tk = tieinx(k);

  3. sublt(2, 2, k)

  4. plot(outm.x(tk, :), 'liedh', 1)

  5. hold on

  6. plot(0, d_retk), '*g');

  7. box off

  8. end

后驗直方圖

  1. for k=1:numel(tim_ix)

  2. tk = tim_ix(k);

  3. subplot(2, 2, k)

  4. hist(o_hx(tk, :), 20);

  5. h = fidobj(gca, 'ype, 'ptc'); ? ?hold on

  6. plot(daau(k), 0, '*g');


  7. box off

  8. end

后驗的核密度估計

  1. pmh = desity(otmh);

  2. for k=1:numel(tenx)

  3. tk = tim_ix(k);

  4. subplot(2, 2, k)

  5. plot(x(t).x, dpi.x(tk).f, 'r');

  6. hold on

  7. plot(xtrue(tk), 0, '*g');

  8. box off

  9. end

Biips 敏感性分析

我們想研究對參數(shù)值的敏感性?

算法參數(shù)

  1. n= 50; % 粒子數(shù)

  2. para = {'alpha}; % 我們要研究靈敏度的參數(shù)

  3. % 兩個分量的值網(wǎng)格

  4. pvs = {A(:, B(:';

使用 SMC 運(yùn)行靈敏度分析

smcs(modl, par, parvlu, npt);

繪制對數(shù)邊際似然和懲罰對數(shù)邊際似然率

  1. surf(A, B, reshape(ouma_i, sizeA)

  2. box off


最受歡迎的見解

1.用R語言模擬混合制排隊隨機(jī)服務(wù)排隊系統(tǒng)

2.R語言中使用排隊論預(yù)測等待時間

3.R語言中實(shí)現(xiàn)馬爾可夫鏈蒙特卡羅MCMC模型

4.R語言中的馬爾科夫機(jī)制轉(zhuǎn)換(Markov regime switching)模型

5.matlab貝葉斯隱馬爾可夫hmm模型

6.用R語言模擬混合制排隊隨機(jī)服務(wù)排隊系統(tǒng)

7.Python基于粒子群優(yōu)化的投資組合優(yōu)化

8.R語言馬爾可夫轉(zhuǎn)換模型研究交通傷亡人數(shù)事故預(yù)測

9.用機(jī)器學(xué)習(xí)識別不斷變化的股市狀況——隱馬爾可夫模型的應(yīng)用


拓端tecdat|Matlab用BUGS馬爾可夫區(qū)制轉(zhuǎn)換Markov switching隨機(jī)波動率SV模型、序列蒙的評論 (共 條)

分享到微博請遵守國家法律
且末县| 上饶市| 江城| 闽清县| 巩义市| 扶沟县| 凤台县| 嫩江县| 汾阳市| 界首市| 和林格尔县| 信丰县| 北宁市| 新竹县| 屏山县| 鄄城县| 东乡| 宣化县| 大足县| 石城县| 乐亭县| 潮安县| 明光市| 营口市| 凤阳县| 齐河县| 志丹县| 永安市| 汉中市| 米泉市| 靖边县| 乌兰浩特市| 马公市| 桐城市| 阿尔山市| 辽源市| 星子县| 郴州市| 镇雄县| 宽城| 怀安县|