sde_library_setup.m

来自「SIMULATION AND ESTIMATION OF STOCHASTIC 」· M 代码 · 共 853 行 · 第 1/4 页

M
853
字号
                error('''sigma'' must be specified');
             end
             Xzero = input('\nWrite the value of the initial condition X0: ');
             if(isempty(Xzero))
                error('X0 must be specified');
             end
            % store the parameters into the bigtheta array
             bigtheta(1) = Xzero;  
             bigtheta(2) = a; 
             bigtheta(3) = sigma;
             PARBASE = bigtheta; % the complete array of the user defined parameter values
          elseif( strcmp(LOADDATA,'Y') && strcmp(PARESTIMATE,'Y') )
             fprintf('\n'); 
             bigtheta(1:NUMDEPVARS) = XOBS(1,:);  % subsititute the state variable(s) initial condition(s) with the first observed value(s)
             PARBASE = [];
          end  % if( (strcmp(LOADDATA,'N') || strcmp(LOADDATA,'n')) && (strcmp(PARESTIMATE,'Y') || strcmp(PARESTIMATE,'y')) )
          %:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
          PARMASK = [0,1,1];  % write 1 for parameters to be estimated and 0 for fixed parameters. WARNING: PARMASK(1) should always be set to zero (corresponds to the SDE initial condition)
          %:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
     case 'M3B' 
          PROBLEM = 'M3';
          SDETYPE = 'Strat';
          NUMDEPVARS = 1;
          fprintf('\n\nYou choose     dXt = (a - sigma^2/2) * dt + sigma o dWt,   X(0) = X0');
          if( (strcmp(LOADDATA,'N') && strcmp(PARESTIMATE,'N')) || (strcmp(LOADDATA,'N') && strcmp(PARESTIMATE,'Y')) ||  (strcmp(LOADDATA,'Y') && strcmp(PARESTIMATE,'N')) )
             a  = input('\n\nWrite the value of the ''a'' parameter: ');
             if(isempty(a))
                error('''a'' must be specified');
             end
             sigma  = input('\nWrite the value of the ''sigma'' parameter: ');
             if(isempty(sigma))
                error('''sigma'' must be specified');
             end
             Xzero = input('\nWrite the value of the initial condition X0: ');
             if(isempty(Xzero))
                error('X0 must be specified');
             end
            % store the parameters into the bigtheta array
             bigtheta(1) = Xzero;  
             bigtheta(2) = a; 
             bigtheta(3) = sigma;
             PARBASE = bigtheta; % the complete array of the user defined parameter values
          elseif( strcmp(LOADDATA,'Y') && strcmp(PARESTIMATE,'Y') )
             fprintf('\n'); 
             bigtheta(1:NUMDEPVARS) = XOBS(1,:);  % subsititute the state variable(s) initial condition(s) with the first observed value(s)
             PARBASE = [];
          end  % if( (strcmp(LOADDATA,'N') || strcmp(LOADDATA,'n')) && (strcmp(PARESTIMATE,'Y') || strcmp(PARESTIMATE,'y')) )
          %:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
          PARMASK = [0,1,1];  % write 1 for parameters to be estimated and 0 for fixed parameters. WARNING: PARMASK(1) should always be set to zero (corresponds to the SDE initial condition)
          %:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
          
     %-------------------------------------------------------------------------------------------------------------------  
     
     case 'M4A' 
          PROBLEM = 'M4';
          SDETYPE = 'Ito';
          NUMDEPVARS = 1;
          fprintf('\n\nYou choose     dXt = a * Xt * dt + b * Xt * dWt,   X(0) = X0');
          if( (strcmp(LOADDATA,'N') && strcmp(PARESTIMATE,'N')) || (strcmp(LOADDATA,'N') && strcmp(PARESTIMATE,'Y')) ||  (strcmp(LOADDATA,'Y') && strcmp(PARESTIMATE,'N')) )
             a  = input('\n\nWrite the value of the ''a'' parameter: ');
             if(isempty(a))
                error('''a'' must be specified');
             end
             b  = input('\nWrite the value of the ''b'' parameter: ');
             if(isempty(b))
                error('''b'' must be specified');
             end
             Xzero = input('\nWrite the value of the initial condition X0: ');
             if(isempty(Xzero))
                error('X0 must be specified');
             end
            % store the parameters into the bigtheta array
             bigtheta(1) = Xzero;  
             bigtheta(2) = a; 
             bigtheta(3) = b;
             PARBASE = bigtheta; % the complete array of the user defined parameter values
          elseif( strcmp(LOADDATA,'Y') && strcmp(PARESTIMATE,'Y') )
             fprintf('\n'); 
             bigtheta(1:NUMDEPVARS) = XOBS(1,:);  % subsititute the state variable(s) initial condition(s) with the first observed value(s)
             PARBASE = [];
          end  % if( (strcmp(LOADDATA,'N') || strcmp(LOADDATA,'n')) && (strcmp(PARESTIMATE,'Y') || strcmp(PARESTIMATE,'y')) )
          %:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
          PARMASK = [0,1,1];  % write 1 for parameters to be estimated and 0 for fixed parameters. WARNING: PARMASK(1) should always be set to zero (corresponds to the SDE initial condition)
          %:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
     case 'M4B' 
          PROBLEM = 'M4';
          SDETYPE = 'Strat';
          NUMDEPVARS = 1;
          fprintf('\n\nYou choose     dXt = (a * Xt - 1/2 * b^2 * Xt) * dt + b * Xt o Wt,   X(0) = X0');
          if( (strcmp(LOADDATA,'N') && strcmp(PARESTIMATE,'N')) || (strcmp(LOADDATA,'N') && strcmp(PARESTIMATE,'Y')) ||  (strcmp(LOADDATA,'Y') && strcmp(PARESTIMATE,'N')) )
             a  = input('\n\nWrite the value of the ''a'' parameter: ');
             if(isempty(a))
                error('''a'' must be specified');
             end
             b  = input('\nWrite the value of the ''b'' parameter: ');
             if(isempty(b))
                error('''b'' must be specified');
             end
             Xzero = input('\nWrite the value of the initial condition X0: ');
             if(isempty(Xzero))
                error('X0 must be specified');
             end
            % store the parameters into the bigtheta array
             bigtheta(1) = Xzero;  
             bigtheta(2) = a; 
             bigtheta(3) = b;
             PARBASE = bigtheta; % the complete array of the user defined parameter values
          elseif( strcmp(LOADDATA,'Y') && strcmp(PARESTIMATE,'Y') )
             fprintf('\n'); 
             bigtheta(1:NUMDEPVARS) = XOBS(1,:);  % subsititute the state variable(s) initial condition(s) with the first observed value(s)
             PARBASE = [];
          end  % if( (strcmp(LOADDATA,'N') || strcmp(LOADDATA,'n')) && (strcmp(PARESTIMATE,'Y') || strcmp(PARESTIMATE,'y')) )
          %:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
          PARMASK = [0,1,1];  % write 1 for parameters to be estimated and 0 for fixed parameters. WARNING: PARMASK(1) should always be set to zero (corresponds to the SDE initial condition)
          %:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
          
     %------------------------------------------------------------------------------------------------------------------- 
     
     case 'M5A' 
          PROBLEM = 'M5';
          SDETYPE = 'Ito';
          NUMDEPVARS = 1;
          fprintf('\n\nYou choose     dXt = (a * Xt + c) * dt + (b * Xt + d) * dWt,   X(0) = X0');
          if( (strcmp(LOADDATA,'N') && strcmp(PARESTIMATE,'N')) || (strcmp(LOADDATA,'N') && strcmp(PARESTIMATE,'Y')) ||  (strcmp(LOADDATA,'Y') && strcmp(PARESTIMATE,'N')) )
             a  = input('\n\nWrite the value of the ''a'' parameter: ');
             if(isempty(a))
                error('''a'' must be specified');
             end
             b  = input('\nWrite the value of the ''b'' parameter: ');
             if(isempty(b))
                error('''b'' must be specified');
             end
             c  = input('\nWrite the value of the ''c'' parameter: ');
             if(isempty(c))
                error('''c'' must be specified');
             end
             d  = input('\nWrite the value of the ''d'' parameter: ');
             if(isempty(d))
                error('''d'' must be specified');
             end
             Xzero = input('\nWrite the value of the initial condition X0: ');
             if(isempty(Xzero))
                error('X0 must be specified');
             end
            % store the parameters into the bigtheta array
             bigtheta(1) = Xzero;  
             bigtheta(2) = a; 
             bigtheta(3) = b;
             bigtheta(4) = c;
             bigtheta(5) = d;
             PARBASE = bigtheta; % the complete array of the user defined parameter values
          elseif( strcmp(LOADDATA,'Y') && strcmp(PARESTIMATE,'Y') )
             fprintf('\n'); 
             bigtheta(1:NUMDEPVARS) = XOBS(1,:);  % subsititute the state variable(s) initial condition(s) with the first observed value(s)
             PARBASE = [];
          end  % if( (strcmp(LOADDATA,'N') || strcmp(LOADDATA,'n')) && (strcmp(PARESTIMATE,'Y') || strcmp(PARESTIMATE,'y')) )
          %:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
          PARMASK = [0,1,1,1,1];  % write 1 for parameters to be estimated and 0 for fixed parameters. WARNING: PARMASK(1) should always be set to zero (corresponds to the SDE initial condition)
          %:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
     case 'M5B' 
          PROBLEM = 'M5';
          SDETYPE = 'Strat';
          NUMDEPVARS = 1;
          fprintf('\n\nYou choose     dXt = [(a - 1/2 * b) * Xt + c - 1/2 * b * d] * dt + (b * Xt + d) o dWt,   X(0) = X0');
          if( (strcmp(LOADDATA,'N') && strcmp(PARESTIMATE,'N')) || (strcmp(LOADDATA,'N') && strcmp(PARESTIMATE,'Y')) ||  (strcmp(LOADDATA,'Y') && strcmp(PARESTIMATE,'N')) )
             a  = input('\n\nWrite the value of the ''a'' parameter: ');
             if(isempty(a))
                error('''a'' must be specified');
             end
             b  = input('\nWrite the value of the ''b'' parameter: ');
             if(isempty(b))
                error('''b'' must be specified');
             end
             c  = input('\nWrite the value of the ''c'' parameter: ');
             if(isempty(c))
                error('''c'' must be specified');
             end
             d  = input('\nWrite the value of the ''d'' parameter: ');
             if(isempty(d))
                error('''d'' must be specified');
             end
             Xzero = input('\nWrite the value of the initial condition X0: ');
             if(isempty(Xzero))
                error('X0 must be specified');
             end
            % store the parameters into the bigtheta array
             bigtheta(1) = Xzero;  
             bigtheta(2) = a; 
             bigtheta(3) = b;
             bigtheta(4) = c;
             bigtheta(5) = d;
             PARBASE = bigtheta; % the complete array of the user defined parameter values
          elseif( strcmp(LOADDATA,'Y') && strcmp(PARESTIMATE,'Y') )
             fprintf('\n'); 
             bigtheta(1:NUMDEPVARS) = XOBS(1,:);  % subsititute the state variable(s) initial condition(s) with the first observed value(s)
             PARBASE = [];
          end  % if( (strcmp(LOADDATA,'N') || strcmp(LOADDATA,'n')) && (strcmp(PARESTIMATE,'Y') || strcmp(PARESTIMATE,'y')) )
          %:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
          PARMASK = [0,1,1,1,1];  % write 1 for parameters to be estimated and 0 for fixed parameters. WARNING: PARMASK(1) should always be set to zero (corresponds to the SDE initial condition)
          %:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
          
     %-------------------------------------------------------------------------------------------------------------------    
     
     case 'M6A' 
          PROBLEM = 'M6';
          SDETYPE = 'Ito';
          NUMDEPVARS = 1;
          fprintf('\n\nYou choose     dXt = [1/2 * a * (a - 1) * Xt ^ (1-2/a)] * dt + a * Xt ^ (1-1/a) * dWt,   X(0) = X0');
          if( (strcmp(LOADDATA,'N') && strcmp(PARESTIMATE,'N')) || (strcmp(LOADDATA,'N') && strcmp(PARESTIMATE,'Y')) ||  (strcmp(LOADDATA,'Y') && strcmp(PARESTIMATE,'N')) )
             a  = input('\n\nWrite the value of the ''a'' parameter: ');
             if(isempty(a))
                error('''a'' must be specified');
             end
             Xzero = input('\nWrite the value of the initial condition X0: ');

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?