楼主: 文雅13
18830 124

[问答] R2winbugs到出数据时出现错误 [推广有奖]

41
文雅13 发表于 2012-11-29 15:39:11
文雅13 发表于 2012-11-28 21:00
上传错误,要不老师您先下载,然后你再卖给我个东西,我给你还回去?
老师,您帮我看看?

42
文雅13 发表于 2012-11-29 21:00:40
文件

2.rar
下载链接: https://bbs.pinggu.org/a-1222400.html

6.43 KB

本附件包括:

  • 2.doc

43
epoh 发表于 2012-11-29 21:07:46
文雅13 发表于 2012-11-29 21:00
文件
看到了,但没有用
需要的是完整的数据
winbugs才能测试

44
epoh 发表于 2012-12-12 21:19:37
文雅13 发表于 2012-11-29 15:39
老师,您帮我看看?
   Burn In Samples.ppt (177.5 KB)
Burn In Samples
page 18/19

Often users use a “burn in” period of initial samples that they
discard when estimating the posterior distribution.  
This period allows the MCMC sampling procedure to stabilize.

To leave out “5000” burn-in samples for estimating the posterior,
enter the number “5000+1” in the “Beg” field of the Sample Monitor Tool.

45
文雅13 发表于 2012-12-12 22:03:39
epoh 发表于 2012-12-12 21:19
Burn In Samples
page 18/19
谢谢

46
zhangtao 发表于 2012-12-14 08:44:58
epoh 发表于 2012-12-12 21:19
Burn In Samples
page 18/19
epoh老师,您好!
   在R中有没有做VaR,Black Scholes期权定价模型, 二项式期权定价,金融衍生品定价、Markivtz均值方差模型,风险管理等的包?
非常感谢!
数学好就是要天天学

47
epoh 发表于 2012-12-14 10:18:51
zhangtao 发表于 2012-12-14 08:44
epoh老师,您好!
   在R中有没有做VaR,Black Scholes期权定价模型, 二项式期权定价,金融衍生品定价、 ...
PerformanceAnalytics: Econometric tools for performance and risk analysis
  http://cran.r-project.org/web/pa ... nalytics/index.html

fOptions: Basics of Option Valuation
  http://cran.r-project.org/web/packages/fOptions/

fPortfolio: Rmetrics - Portfolio Selection and Optimization
  http://cran.r-project.org/web/packages/fPortfolio/index.html

  portfolioSpec() Specification of Portfolios
  portfolioSpec(
            model = list(type = "MV", optimize = "minRisk",...
            #Markowitz mean – variance portfolio named "MV"
已有 1 人评分学术水平 热心指数 信用等级 收起 理由
zhangtao + 5 + 5 + 5 好的意见建议

总评分: 学术水平 + 5  热心指数 + 5  信用等级 + 5   查看全部评分

48
zhangtao 发表于 2012-12-15 18:00:37
epoh 发表于 2012-12-14 10:18
PerformanceAnalytics: Econometric tools for performance and risk analysis
  http://cran.r-project ...
epoh老师,您好!
     z=iddata(DX);%将DX转化为matlab接受的格式
这句话中的iddata这个函数有什么用?

“z=iddata(DX);%将DX转化为matlab接受的格式"这句话是什么意思?

y=xlsread('f:\高锰酸钾指数.xls','A1:A72');
%figure(2)
%subplot(2,1,1)
%autocorr(y);     %原序列的自相关函数图MA(q),观察系数是否在区间(-2T^(1/2),-2T^(1/2))内
%subplot(2,1,2)
%parcorr(y);      %原序列的偏相关函数图AR(p),观察系数是否在区间(-2T^(1/2),-2T^(1/2))内
%如果该序列不是平稳的做差分图,否则跳过该步
DX=y;
[H,PValue,TestStat,CriticalValue] = adftest(DX); %是否是稳定序列
for i = 1:10
    if H== 1
        break;
     else
      DX=diff(y,i);  %进行差分
     end
end

figure(3);
subplot(2,1,1)
autocorr(DX)    %差分序列DX自相关函数图MA(q),观察系数是否在区间(-2T^(1/2),-2T^(1/2))内
subplot(2,1,2)
parcorr(DX);    %差分序列DX偏相关函数图AR(p),观察系数是否在区间(-2T^(1/2),-2T^(1/2))内

%对差分后的序列做拟合和预测,求出最好的阶数
DX=reshape(y,72,1);
z=[DX;zeros(12,1)];
z=iddata(DX);%将DX转化为matlab接受的格式
test = [];
% p = [0 1 2 3];    %自回归对应PACF,给定滞后长度上限p和q,一般取为T/10、ln(T)或T^(1/2),这里取
%  T/10=12;
% q = [0 1 2 3];     %移动平均对应ACF
for p = 1:3   %自回归对应PACF,给定滞后长度上限p和q,一般取为T/10、ln(T)或T^(1/2),这里取T/10=12
     for q = 1:3    %移动平均对应ACF
         m = armax(z(1:60),[p,q]);        
         AIC = aic(m);                      %armax(p,q),选择对应FPE最小,AIC值最小的模型
         test = [test;p q AIC];
     end
end
for k = 1:size(test,1)
     if test(k,3) == min(test(:,3))      %选择AIC值最小的模型
         p_test = test(k,1);
         q_test = test(k,2);
         break;
     end
end

%拟合过程
m1 = armax(z(1:60),[p_test q_test]);        %armax(p,q),[p_test q_test]对应AIC值最小
figure(4)
e = resid(m1,z);     %拟合做残差分析
plot(e);
grid;
title('残差序列');
%检验残差的自相关和偏相关函数
figure(5)
subplot(2,1,1)
autocorr(e.OutputData)      %一阶差分序列z自相关函数图MA(q),置信水平0.95
subplot(2,1,2)
parcorr(e.OutputData)    %一阶差分序列z偏相关函数图AR(p),置信水平0.95

%预测过程
p=predict(m1,z,1);%lcl m是任何idmodel对象(idpoly,idss,idgrey或idarx),z是包含输入输出数据的iddata对象。1是预测时间长度
                      % p是模型的预测输出,为包含预测值的iddata对象
数学好就是要天天学

49
epoh 发表于 2012-12-15 19:15:47
zhangtao 发表于 2012-12-15 18:00
epoh老师,您好!
     z=iddata(DX);%将DX转化为matlab接受的格式
这句话中的iddata这个函数有什么用? ...
我没安装System Identification Toolbox
function iddata()我不熟

50
epoh 发表于 2012-12-15 19:19:42
文雅13 发表于 2012-11-29 21:00
文件
你要让程序运行应该不难,
重点在于你要提供完整的数据及程序,
供测试修改,
否则都在原点打转.

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-31 09:53