- 积分
- 33
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2015-1-31
- 最后登录
- 1970-1-1
|
GrADS
系统平台: |
|
问题截图: |
|
问题概况: |
用MATLAB画出的MK检验突变点与滑动T检验得到的不一致,改怎么处理? |
我看过提问的智慧: |
看过 |
自己思考时长(天): |
3 |
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
本帖最后由 liuwenyan150825 于 2016-4-13 17:43 编辑
用MK检验与滑动T检验得到的结果不一致,怎么办?
MK检验程序- <p><p><p>MK检验程序
- clc,clear;
- [a,textdata]=xlsread('问题.xlsx');
- s=mean(reshape(a(:,2),12,[]));
- s;
- timeSeries=[1960:2010]';
- dataSeries=s'; %
- dataCount=length(dataSeries);
- %% 正序列计算
- SK=zeros(size(dataSeries)); % 定义SK
- UFK=zeros(size(dataSeries)); % 定义UFK
- s=0;
- for i=2:dataCount
- for j=1:i
- if dataSeries(i)>dataSeries(j)
- s=s+1;
- else
- s=s+0;
- end
- end
- SK(i)=s;
- E=i*(i-1)/4; % SK均值
- Var=i*(i-1)*(2*i+5)/72; % SK方差
- UFK(i)=(SK(i)-E)/sqrt(Var);
- end
- %% 逆序列计算
- oppSK=zeros(size(dataSeries));
- UBK=zeros(size(dataSeries));
- s=0;
- opphumiditySeries=flipud(dataSeries);
- for i=2:dataCount
- for j=1:i
- if opphumiditySeries(i)>opphumiditySeries(j)
- s=s+1;
- else
- s=s+0;
- end
- end
- oppSK(i)=s;
- E=i*(i-1)/4; % SK均值
- Var=i*(i-1)*(2*i+5)/72; % SK方差
- UBK(i)=0-(oppSK(i)-E)/sqrt(Var);
- end
- oppUBK=flipud(UBK);
- % xlswrite(outputdata,UFK,'Sheet2','A1');% 输出结果
- % xlswrite(outputdata,oppUBK,'Sheet2','B1');
- %% 制图
- figure(3);
- plot(timeSeries,UFK,'r-','linewidth',1.5);
- hold on
- plot(timeSeries,oppUBK,'b-.','linewidth',1.5);
- plot(timeSeries,1.96*ones(dataCount,1),':','linewidth',1);
- axis([min(timeSeries),max(timeSeries),-5,5]);
- legend('UF统计量','UB统计量','0.05显著水平');
- xlabel('t (year)','FontName','TimesNewRoman','FontSize',12);
- ylabel('统计量','FontName','TimesNewRoman','Fontsize',12);
- hold on
- plot(timeSeries,0*ones(dataCount,1),'-.','linewidth',1);
- plot(timeSeries,1.96*ones(dataCount,1),':','linewidth',1);
- plot(timeSeries,-1.96*ones(dataCount,1),':','linewidth',1);
- p=[];u=[];
- for n=1:length(UFK)
- if UFK(n)-oppUBK(n)>0
- p=[p,n];
- else
- u=[u,n];
- end
- end
- p
- u
- nian=timeSeries;
- delete=nian(p)
- 滑动T检验程序
- clc,clear;
- [a,textdata]=xlsread('问题.xlsx');
- s=mean(reshape(a(:,2),12,[]));
- s;
- timeSeries=[1960:2010]';
- dataSeries=s'; %
- dataCount=length(dataSeries);
- %% 设置步长与检验值
- step=10; % 步长
- v=step+step-2; % 计算自由度
- ttest=1.734; % 查表得t检验值,修改
- len1=step;
- len2=step;
- x=timeSeries(step:dataCount-step);
- for i=step:dataCount-step
- n1=dataSeries(i-step+1:i);
- n2=dataSeries(i+1:i+step);
- mean1=mean(n1);
- mean2=mean(n2);
- c=(len1+len2)/(len1*len2);
- var1=1/len1*sum((n1-mean1).^2);
- var2=1/len2*sum((n2-mean2).^2);
- delta1=len1*var1+len2*var2;
- delta=delta1/(len1+len2-2);
- t(i-step+1)=(mean1-mean2)/sqrt(delta*c);
- end
- %% 制图
- figure(1);
- plot(x,t,'r-','linewidth',1.5);
- xlabel('t (年)','FontName','TimesNewRoman','FontSize',12);
- ylabel('统计量','FontName','TimesNewRoman','Fontsize',12);
- axis([min(x),max(x),-4,4]);
- hold on
- plot(x,0*ones(i-step+1,1),'-.','linewidth',1);
- plot(x,ttest*ones(i-step+1,1),':','linewidth',1);% 更改数字
- plot(x,-ttest*ones(i-step+1,1),':','linewidth',1);% 更改数字
- legend('t统计量','0.05显著水平');
- 所用数据为51年的观测值,上传不上去啊</p><p>1028416496这是我的qq,知道的请加我一下,我可以把数据再发给您
- </p>
复制代码
|
|