楼主: ywh19860616
26304 92

[问答] 怎么把这个矩阵保存到excel中 [推广有奖]

11
ywh19860616 发表于 2011-11-24 22:53:26 |只看作者 |坛友微信交流群
epoh 发表于 2011-11-24 21:06
头脑坏了,
应该在s-plus修改数据才方便
####in R
谢谢epoh老师了,软件功能就是比excel强大一些
您按这种方式导出的csv,哈哈,在excel也是看不全的,只有256列
已有 1 人评分学术水平 热心指数 信用等级 收起 理由
epoh + 1 + 1 + 1 潜心学习,追根究底

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

一份耕耘,一份收获。

使用道具

12
ywh19860616 发表于 2012-10-22 14:38:49 |只看作者 |坛友微信交流群
epoh老师,您抽空能否看下看下这个winbugs程序,
模型和数据确认都可以通过,但是获取初始值
时就出错。

file.doc

59.5 KB

一份耕耘,一份收获。

使用道具

13
epoh 发表于 2012-10-23 21:22:52 |只看作者 |坛友微信交流群
ywh19860616 发表于 2012-10-22 14:38
epoh老师,您抽空能否看下看下这个winbugs程序,
模型和数据确认都可以通过,但是获取初始值
时就出错。
...
老兄,你的朋友似乎是要做Multivariate Stochastic Volatility Models
中的Model 3 (MSV with Granger causality or GC-MSV).
只是不知他的公式依据什么而来:
  thmean[i,1]<-mu1+phi11*(th[i-1,1]-mu1)+phi12*(th[i-1,2]+mu2);
  thmean[i,2]<-mu2+phi21*(th[i-1,1]-mu1)+phi22*(th[i-1,2]+mu2);

若要依他的程序运行也可以
只要加上initial values
list(phi1star=0.99, phi2star=0.99,mu1=0,mu2=0,itaua2=100,itaub2=100,rhoep=0.7,phi21=0,phi12=0)
ywh_gc_msv.txt    ywh_gc_msv.txt (28.46 KB)
已有 3 人评分学术水平 热心指数 信用等级 收起 理由
kk22boy + 5 + 5 + 5 观点有启发
zhangtao + 5 + 5 + 5 热心帮助其他会员
ywh19860616 + 5 + 5 + 5 谢谢epoh老师

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

使用道具

14
ywh19860616 发表于 2012-10-23 21:35:31 |只看作者 |坛友微信交流群
epoh 发表于 2012-10-23 21:22
老兄,你的朋友似乎是要做Multivariate Stochastic Volatility Models
中的Model 3 (MSV with Granger  ...
是的,epoh老师,就是Multivariate Stochastic Volatility Models。
非常感谢epoh老师提醒,那个公式我让他再确认下,很有可能是
他写错了,他是根据别人的程序自己修改的,自己不是很懂。
epoh老师,这个模型您有相应的程序吗。

已有 1 人评分学术水平 热心指数 信用等级 收起 理由
epoh + 3 + 3 + 3 补偿

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

一份耕耘,一份收获。

使用道具

15
epoh 发表于 2012-10-23 22:12:13 |只看作者 |坛友微信交流群
ywh19860616 发表于 2012-10-23 21:35
是的,epoh老师,就是Multivariate Stochastic Volatility Models。
非常感谢epoh老师提醒,那个公式我 ...
MULTIVARIATE STOCHASTIC VOLATILITY MODELS:
BAYESIAN ESTIMATION AND MODEL COMPARISON.pdf
  http://harrisd.net/papers/ARCHSV ... s/YuMeyer2006ER.pdf
  1. model                                                               
  2. {  
  3. #distribution of Ys                                                            
  4. ###################                                                            
  5. for (i in 1:N) {
  6.     ysigmadet[i]<-exp(th[i,1]+th[i,2])*(1-rhoep*rhoep);        
  7.     Yisigma2[i,1,1] <- exp(th[i,2])/ysigmadet[i];
  8.     Yisigma2[i,2,2] <- exp(th[i,1])/ysigmadet[i];
  9.     Yisigma2[i,1,2] <- -rhoep*exp(0.5*th[i,1]+0.5*th[i,2])/ysigmadet[i];               
  10.     Yisigma2[i,2,1] <- Yisigma2[i,1,2];
  11.     Y[i,1:2]~ dmnorm(muy[],Yisigma2[i,,]);  
  12.     }
  13. muy[1]<-0;
  14. muy[2]<-0;
  15. thmean[1,1] <- mu1;   
  16. thmean[1,2] <- mu2;
  17. th[1,1]~dnorm(thmean[1,1],itaua2);
  18. th[1,2]~dnorm(thmean[1,2],itaub2);
  19. for (i in 2:N) {
  20.                 thmean[i,1] <- mu1 + phi1*(th[i-1,1]-mu1)+phi12*(th[i-1,2]-mu2);   
  21.                 thmean[i,2] <- mu2 + phi2*(th[i-1,2]-mu2);
  22.                 th[i,1]~dnorm(thmean[i,1],itaua2);
  23.                 th[i,2]~dnorm(thmean[i,2],itaub2);
  24.    }                                                                           
  25. #distribution of phi, mu, rhoep                                                   
  26. ###########################                                                     
  27. phi1star ~ dbeta(20,1.5);   
  28. phi1 <- 2*phi1star -1;  
  29. phi2star ~ dbeta(20,1.5);   
  30. phi2 <- 2*phi2star -1;
  31. phi12~dnorm(0,0.1);

  32. itaua2 ~ dgamma(2.5,0.025);                                                      
  33. sigma1 <- sqrt(1/itaua2);
  34. itaub2 ~ dgamma(2.5,0.025);                                                      
  35. sigma2 <- sqrt(1/itaub2);                                             
  36. mu1 ~ dnorm(0,0.04);
  37. mu2 ~ dnorm(0,0.04);
  38. rhoep~dunif(-1,1);
  39. }
  40. #init
  41. list(phi1star=0.99, phi2star=0.99,mu1=0,mu2=0,itaua2=100,itaub2=100,rhoep=0.7,phi12=0)
  42. #data
复制代码
已有 2 人评分学术水平 热心指数 信用等级 收起 理由
zhangtao + 5 + 5 + 5 精彩帖子
ywh19860616 + 5 + 5 + 5 谢谢您

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

使用道具

16
ywh19860616 发表于 2012-10-23 22:22:01 |只看作者 |坛友微信交流群
epoh 发表于 2012-10-23 22:12
MULTIVARIATE STOCHASTIC VOLATILITY MODELS:
BAYESIAN ESTIMATION AND MODEL COMPARISON.pdf
  http:/ ...
谢谢epoh老师,记得他让我下载过这篇文献,那应该是
原来的程序存在问题,非常谢谢。
一份耕耘,一份收获。

使用道具

17
zhangtao 发表于 2012-10-24 07:57:34 |只看作者 |坛友微信交流群
epoh 发表于 2012-10-23 22:12
MULTIVARIATE STOCHASTIC VOLATILITY MODELS:
BAYESIAN ESTIMATION AND MODEL COMPARISON.pdf
  http:/ ...
% Read data
A=xlsread('X:\freret\Data1.xls');
W=wk1read('X:\freret\weight.wk1');
请问题Dtata1.xls和weight.wk1这两个数据文件epoh老师您有吗?要是有,请帮忙提供,非常感谢!
本文来自: 人大经济论坛 Matlab及其他计量软件专版 版,详细出处参考: https://bbs.pinggu.org/forum.php? ... 1&from^^uid=11232
数学好就是要天天学

使用道具

18
epoh 发表于 2012-10-24 14:46:08 |只看作者 |坛友微信交流群
zhangtao 发表于 2012-10-24 07:57
% Read data
A=xlsread('X:\freret\Data1.xls');
W=wk1read('X:\freret\weight.wk1');
帮你看了,似乎Paul Elhorst的网站也没提供DEMO数据
ttp://www.regroningen.nl/elhorst/software.shtml   
已有 1 人评分学术水平 热心指数 信用等级 收起 理由
zhangtao + 5 + 5 + 5 好的意见建议

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

使用道具

19
zhangtao 发表于 2012-10-24 20:01:07 |只看作者 |坛友微信交流群
epoh 发表于 2012-10-24 14:46
帮你看了,似乎Paul Elhorst的网站也没提供DEMO数据
ttp://www.regroningen.nl/elhorst/software.shtml  ...
lotus.rar (628.68 KB)
To get started, select MATLAB Help or Demos from the Help menu.
??? Error using ==> wk1read
File not found.
Error in ==> demoLMsarsem_panel at 1
A=wk1read('E:\lotus\cigarette.wk1',1,0); % data set with T=30
??? Error using ==> wk1read
File not found.
Error in ==> demopanelscompare at 38
A=wk1read('E:\lotus\cigarette.wk1',1,0);
>>
epoh老师,您好!
以上问题如何解决?
非常感谢!
数学好就是要天天学

使用道具

20
zhangtao 发表于 2012-10-24 20:09:35 |只看作者 |坛友微信交流群
clear all;

A=wk1read('cigardemo.wk1',1,0);
W1=wk1read('Spat-Sym-US.wk1');
为什么这个wk1read又没有问题?可以读'cigardemo.wk1'
% Dataset downloaded from www.wiley.co.uk/baltagi/
% Spatial weights matrix constructed by Elhorst
% -------------------------------------------------------------------------
% written by: J.Paul Elhorst 5/2008
% University of Groningen
% Faculty of Economics and Business
% 9700AV Groningen
% the Netherlands
% j.p.elhorst@rug.nl
%
% REFERENCES:
% Elhorst J.P. (2008) Serial and spatial autocorrelation. Economics Letters
% http://dx.doi.org/10.1016/j.econlet.2008.03.009
% -------------------------------------------------------------------------
% dimensions of the problem
T=6; % number of time periods
N=46; % number of regions
% row-normalize W
W=normw(W1); % function of LeSage
y=A(:,[3]); % column number in the data matrix that corresponds to the dependent variable
x=A(:,[4,5,6]); % column numbers in the data matrix that correspond to the independent variables
xconstant=ones(N*T,1);

% serial and spatial error correlation, including logpn variable
% one constraint on the paramaters active
vnames=strvcat('logcit','constant','logp','logpn','logy');
serialspatial(y,[xconstant x],W,N,T,vnames);

% serial and spatial error correlation, without logpn variable
% no constraint active, numerical problems with one of the t-values
x=A(:,[4,6]); % column numbers in the data matrix that correspond to the independent variables
vnames=strvcat('logcit','constant','logp','logy');
serialspatial(y,[xconstant x],W,N,T,vnames);



Optimization terminated: Search direction less than 2*options.TolX
and maximum constraint violation is less than options.TolCon.
Active inequalities (to within options.TolCon = 1e-006):
  lower      upper     ineqlin   ineqnonlin
                          3           

model with both serial and spatial autocorrelation
Dependent Variable =         logcit   
R-squared          =    0.9921   
Rbar-squared       =    0.9920   
sigma^2            =    0.0021   
log-likelihood     =       -380.51003  
***************************************************************
Variable       Coefficient  Asymptot t-stat    z-probability
constant          3.184573        12.127214         0.000000
logp             -0.480758        -9.024798         0.000000
logpn             0.226449         3.151678         0.001623
logy              0.368082         6.157506         0.000000
ser.aut           0.963577       116.546888         0.000000
spat.aut.         0.036423        97.200039         0.000000

Optimization terminated: Search direction less than 2*options.TolX
and maximum constraint violation is less than options.TolCon.
Active inequalities (to within options.TolCon = 1e-006):
  lower      upper     ineqlin   ineqnonlin
                          3           

model with both serial and spatial autocorrelation
Dependent Variable =         logcit   
R-squared          =    0.9918   
Rbar-squared       =    0.9917   
sigma^2            =    0.0021   
log-likelihood     =       -375.63073  
***************************************************************
Variable       Coefficient  Asymptot t-stat    z-probability
constant          3.355565        12.831304         0.000000
logp             -0.438336        -8.355384         0.000000
logy              0.322546         5.463177         0.000000
ser.aut           0.963577       110.933671         0.000000
spat.aut.         0.036423        94.006837         0.000000

>>
数学好就是要天天学

使用道具

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

本版微信群
加好友,备注cda
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-5-1 11:11