楼主: oivio
6046 2

用matlab做方差比检验的问题 [推广有奖]

  • 0关注
  • 5粉丝

已卖:675份资源

讲师

89%

还不是VIP/贵宾

-

威望
0
论坛币
2202 个
通用积分
3.3066
学术水平
13 点
热心指数
9 点
信用等级
7 点
经验
2162 点
帖子
139
精华
0
在线时间
889 小时
注册时间
2009-2-16
最后登录
2025-12-24

楼主
oivio 发表于 2010-5-28 18:40:43 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
以下的这个程序是用来做方差比检验的m-file 大家看看有问题么
我跑出来的结果只有一个数,而我要得到两个数的,即同方差和异方差下的方差比

function [VR,Zk,Zhk]=vrt_full(x,k)
%
% Syntax: [vr,zk,zhk]=vrt(x,k)
%
% Calculates the Variance Ratio Test (VR Test) of a time series x, with
% and without the heteroskedasticity assumption.
% input  : x is a vector of time serie (observed prices)
%          k is a scalar
% output : VR is the value of the VRTest
%          Zk is the homoscedastic statistic of the variance ratio
%          Zhk is the heteroscedastic statistic of the variance ratio
%
x=xlsread('D:\A股\数\book1.xls');
k=2;
rt1=diff(x); % one period rate of return

T=length(rt1);
i=1:T-k+1;
M=zeros(T-k+1,k);
for j=1:k,
    M(:,j)=i+j-1;
end
rtk=sum(rt1(M'));  % k period rate of return

moy=mean(rt1);
v=var(rt1);
m=k*(T-k+1)*(1-k/T);
VR=1/m*sum((rtk-k*moy).^2)/v; % Variance ratio statistic

Zk=sqrt(T)*(VR-1)*(2*(2*k-1)*(k-1)/(3*k))^(-.5); % homoscedastic statistic

j=1:k-1;
vec1=(2/k*(k-j)).^2;
rst=(rt1-moy).^2;
aux=zeros(1,k-1);
for i=1:k-1,
   aux(i)=rst(i+1:T)'*rst(1:T-i);
end
vec2=aux/((T-1)*v)^2;
Zhk=(VR-1)*(vec1*vec2')^(-.5); % heteroscedastic statistic
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:MATLAB matla atlab Mat Atl 方差 MATLAB 检验

沙发
gssdzc 在职认证  发表于 2010-5-28 19:22:56
ding...........

藤椅
蒋科学 在职认证  发表于 2010-9-4 20:18:50
ding。。。。。。。。。。。。

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

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