楼主: windsmild
4908 4

[词条] 有个MATLAB的ARFIMA的代码,但是不知道怎么代入数据,怎么用 [推广有奖]

  • 2关注
  • 1粉丝

已卖:789份资源

本科生

46%

还不是VIP/贵宾

-

威望
0
论坛币
18535 个
通用积分
2.1500
学术水平
3 点
热心指数
9 点
信用等级
2 点
经验
796 点
帖子
51
精华
0
在线时间
112 小时
注册时间
2013-5-10
最后登录
2022-11-1

楼主
windsmild 发表于 2015-2-8 01:20:02 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币

function [Z] = ARFIMA_SIM(N,F,O,d,stdx,er)

%The code performs the simulation of time series with autoregressive

%fractionally integrated moving average (ARFIMA) models that generalize

%ARIMA (autoregressive integrated moving average) and ARMA autoregressive

%moving average models.  ARFIMA models allow non-integer values of the

%differencing parameter and are useful in modeling time series with long memory.

%The model is generally represented  as ARFIMA(p,d,q) model where d is the differencing parameter

%and p and q are the order of the autoregressive and moving average parts of the model respectively.


%%% INPUTS

%%%->N =  # % Length of the time series we would like to generate  

%%%->F = [ F1 F2 F3 .... ] % Parameters of the AR model, length(F) is the order p. Default p = 0

%%%->O = [ O1 O2 O3 .... ] % Parameters of the MA model, length(O) is the order q. Default q = 0   

%%%->d = # ; % Fractionally differencing parameter, default d = 0

%%%->stdx = % Optional input: parameter to force the standard deviation of the

%output time series. Impose std(Z)==stdx   

%%%-->er = % Optional input: predefined time ser

%%%%%%%%% THE ARFIMA PROCESS IS DEFINED AS:  

%%%% F(B)[(1-B)^d]Z=O(B)er

%%%% F(B)Z=[(1-B)^-d]O(B)er

%%%%%%% where B is the backshift operator,

%%%% F(B)= 1+ B F1 + B^2 F2 ... + B^p Fp --> AR PART

%%%% O(B)= 1+ B O1 + B^2 O2 ... + B^q Oq --> MA PART  

%%%% er = white noise, it can be specified as an input

%%% Note that F(B) and O(B) are both defined with plus sign as in the "armax" function of matlab

%and in  Box et al., (1994).

%%% OUTPUTS

%-->Z =  Time series simulated with the ARFIMA mo

%%%%%%%%%% EXAMPLES

%%% White noise

%[Z] = ARFIMA_SIM(N);

%%% AR(1) model

%[Z] = ARFIMA_SIM(N,[F1]);

%%% MA(1) model

%[Z] = ARFIMA_SIM(N,[],[O1])

%%% ARMA(2,2) model

%[Z] = ARFIMA_SIM(N,[F1,F2],[O1,O2])

%%% ARFIMA(0,d,0)

%[Z] = ARFIMA_SIM(N,[],[],d)

%%% ARFIMA(1,d,1)

%[Z] = ARFIMA_SIM(N,[F1],[O1],d)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%   Simone Fatichi -- simonef@dicea.unifi.it

%   Copyright 2009

%   $Date: 2009/10/19 $

%%%inizialization

X=zeros(1,N); Y=zeros(1,N); Z=zeros(1,N);

%%%% FI(B)[(1-B)^d]Z=O(B)e

%%%% FI(B)Z=[(1-B)^-d]O(B)e

%%%% FI(B)= 1+ B F1 + B^2 F2 ...

%%%% O(B) = 1+ B O1 + B^2 O2 ...

switch nargin

    case 1

        d=0;

        F=[];

        O=[];

        t=0;

        stdx=NaN;

    case 2

        d = 0;

        O =[];

        t = 0;

        stdx=NaN;

    case 3

        d = 0;

        t=0;

         stdx=NaN;

    case 4

        t=0;

         stdx=NaN;

    case 5

        t=0;

    case 6

        t=1;

    otherwise

        msgbox('ERROR: Not enough or too much input arguments')

        Z=[];

        return

end

e=normrnd(0,1,N,1);

if t==1

    e=er;

end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

if isempty(O) && isempty(F) && (d==0)

    Z=e;

    return

end

%%%%% N =length

MA_ord=length(O);

AR_ord=length(F);

%%%%%%%%%%%% Computing part: MA(q)

t=0;

if MA_ord >= 1

    for t=1:N

        j=0;map=0;

        for j=1:MA_ord

            if t > j

                map = map + O(j)*e(t-j);

            end

        end

        X(t)= e(t)+ map;

    end

else

    X=e;

end

t=0;

%%%%%%%%%%% Computing part: d

if d == 0

    Y=X;

else

    infi =100; s=0;

    for s=0:infi

        %b(s+1)=((-1)^s)*gamma(-d+1)./(gamma(s+1)*gamma(-d-s+1));

        b(s+1)=gamma(s+d)/(gamma(s+1)*gamma(d));

    end

    for t=1:N

        Y(t)=0;

        for s=0:infi

            if t > s

                Y(t)= Y(t)+ b(s+1)*X(t-s);

            end

        end

    end

end

%%%%%%%%%%%%% Computing part: AR(p)

t  = 0;

if AR_ord >= 1

    for t=1:N

        j=0; arp=0;

        for j=1:AR_ord

            if t > j

                arp = arp - F(j)*Z(t-j);

            end

        end

        Z(t)= Y(t)+ arp;

    end

else

    Z=Y;

end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Z=Z';

if not(isnan(stdx))

    Z=Z*stdx/std(Z);

end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%

end


下载地址:http://www.mathworks.com/matlabcentral/fileexchange/?search_submit=fileexchange&query=ARFIMA&term=ARFIMA  第一个就是。


已经有122个RV数据 想做lnRV-ARFIMA模型,但是不知道怎么用这个模型。


二维码

扫码加我 拉你入群

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

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

关键词:ARFIMA MATLAB matla atlab Mat function average memory moving useful

回帖推荐

石头天明 发表于2楼  查看完整内容

你首先需要对数据进行处理,取对数,然后选择ARIMA模型来进行拟合,得到AR,MA的参数及取差分的次数之后,再代入到函数中,如: F=[0.1 0.2 0.3]; >> O=[0.2 0.4 0.6]; ARFIMA_SIM(10,F,O,1) 结果: -1.3499 1.5500 2.3225 2.5563 4.3217 4.2146 3.8851 5.2215 6.7202 8.6223

本帖被以下文库推荐

沙发
石头天明 发表于 2015-2-9 09:33:43
你首先需要对数据进行处理,取对数,然后选择ARIMA模型来进行拟合,得到AR,MA的参数及取差分的次数之后,再代入到函数中,如:
F=[0.1 0.2 0.3];
>> O=[0.2 0.4 0.6];
ARFIMA_SIM(10,F,O,1)
结果: -1.3499
    1.5500
    2.3225
    2.5563
    4.3217
    4.2146
    3.8851
    5.2215
    6.7202
    8.6223
已有 3 人评分论坛币 学术水平 热心指数 信用等级 收起 理由
我的素质低 + 10 精彩帖子
windsmild + 1 + 1 + 1 精彩帖子
statax + 10 + 1 + 1 精彩帖子

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

藤椅
TRAMS 发表于 2017-1-22 10:56:40
有所受用,多谢。

板凳
6445741611 发表于 2017-5-14 23:29:25
求教求教 同要用ARFIMA模型 不知道要怎么带数据进去

报纸
lvlong.cfa 发表于 2018-3-7 15:41:35
1. 这是一个ARFIMA数据生成代码,非参数估计
2. 参数估计可以采用非线性最小二乘,只要想明白分整(1-L)^d操作,很容易matlab实现
3.ARFIMA可以和GARCH族、SV族结合,不断扩展。不过再怎么变最后的估计都是参数寻优,只要ARFIMA(0,d,0)会了,可举一反三

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

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2025-12-31 08:04