Results 1 to 6 of 6

Math Help - Help needed to perform bootstrap with matlab

  1. #1
    Newbie
    Joined
    Jan 2009
    Posts
    6

    Help needed to perform bootstrap with matlab

    I have been given an m-file that amongst other things does a bootstrap calculation but I seem to be hitting a brick wall.

    Here is the file I am using:
    [nz,ntv] = size(obs);
    % means
    disp(' ')
    mobs = mean(obs);
    disp (['mean observed values = ' num2str(mobs)])
    mest = mean(est);
    disp (['mean estimated values = ' num2str(mest)])
    % standart deviations
    sdobs = std(obs);
    disp (['std dev observed values = ' num2str(sdobs)])
    sdest = std(est);
    disp (['std dev estimated values = ' num2str(sdest)])
    % assessment of goodness-of-fit
    % correlation and coefficient of determination (explained variance)
    [corre,p] = corrcoef([obs est]);R2=corre.^2;
    disp (['R2 corre^2 = ' num2str(R2(1,2)) ' p = ' num2str(p(1,2))])
    % mean absolute error
    imae = sum(abs(obs-est))/ntv;
    disp (['mae = ' num2str(imae)])
    % root mean square error
    rmse = sqrt(sum((obs-est).^2)/ntv);
    disp (['rmse = ' num2str(rmse)])
    disp(' ')
    % Nash-Sutcliffe coeff of efficiency
    E = 1-(sum((obs-est).^2)/sum((obs-mobs).^2));
    disp (['N-Sut efficiency (E) = ' num2str(E)])
    stat = bootstrp(500,@Nash_Sut,obs,est);
    [a b]=ci95(stat);
    disp ([ 'E 95% ci = ' num2str(a) ' ' num2str(b)])
    disp (' ');clear stat
    % log Nash-Sutcliffe coeff of efficiency
    Elog = 1-(sum((log(obs)-log(est)).^2)/sum((log(obs)-log(mobs)).^2));
    disp (['Elog = ' num2str(Elog)])
    stat = bootstrp(500,@log_Nash_Sut,obs,est);
    [a b]=ci95(stat);
    disp ([ 'E 95% ci = ' num2str(a) ' ' num2str(b)])
    disp (' ');clear stat
    % Modified Nash-Sutcliffe coeff of efficiency
    E1 = 1-(sum(abs(obs-est))/sum(abs(obs-mobs)));
    disp (['N-Sut efficiency modified (E1) = ' num2str(E1)])
    stat = bootstrp(500,@m_Nash_Sut,obs,est);
    [a b]=ci95(stat);
    disp ([ 'E1 95% ci = ' num2str(a) ' ' num2str(b)])
    disp (' '); clear stat
    % index of agreement
    d = 1-(sum((obs-est).^2)/sum((abs(obs-mobs)+abs(obs-mobs)).^2));
    disp (['Index of agreement (d) = ' num2str(d)])
    stat = bootstrp(500,@I_agree,obs,est);
    [a b]=ci95(stat);
    disp ([ 'd 95% ci = ' num2str(a) ' ' num2str(b)])
    disp (' '); clear stat
    % Modified index of agreement
    d1 = 1-(sum(abs(obs-est))/sum((abs(obs-mobs)+abs(obs-mobs))));
    disp (['Index of agreement modified (d1) = ' num2str(d1)])
    stat = bootstrp(500,@m_I_agree,obs,est);
    [a b]=ci95(stat);
    disp ([ 'd1 95% ci = ' num2str(a) ' ' num2str(b)])
    disp (' '); clear stat
    and this is the result:
    mean observed values = 17.9477
    mean estimated values = 17.7683
    std dev observed values = 6.4146
    std dev estimated values = 2.1859
    R2 corre^2 = 0.034055 p = 0.32894
    mae = 152.28
    rmse = 34.3907

    N-Sut efficiency (E) = 0.0088419
    ??? Error using ==> feval
    Undefined command/function 'Nash_Sut'.

    Error in ==> bootstrp at 77
    thetafit = feval(bootfun,varargin{:});

    Error in ==> goodfit2 at 53
    stat = bootstrp(500,@Nash_Sut,obs,est);
    Can anyone help me resolve the problem? It seems that matlab does not like Nash_sut and the rest as a Bootfun.

    Secondly, and more to save time, how do I modify the m-file so that instead of running this for every obs and est file I have (there are 50+ of each), I could put them all into one file each ie in columns and get the outputs for each individual column?
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by Kean View Post
    I have been given an m-file that amongst other things does a bootstrap calculation but I seem to be hitting a brick wall.

    Here is the file I am using:


    and this is the result:


    Can anyone help me resolve the problem? It seems that matlab does not like Nash_sut and the rest as a Bootfun.

    Secondly, and more to save time, how do I modify the m-file so that instead of running this for every obs and est file I have (there are 50+ of each), I could put them all into one file each ie in columns and get the outputs for each individual column?
    offending line is:

    stat = bootstrp(500,@Nash_Sut,obs,est);

    Where in Nash_Sut defined, and what is it?? If it is a function handel for an anonymous function then it does not need the @.

    CB
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Jan 2009
    Posts
    6
    Hi CB,

    from what I know nash_sut is the function above ie: E = 1-(sum((obs-est).^2)/sum((obs-mobs).^2)).

    The idea is that by bootstraping one can determine the significance of E. How would I be able to correct the problem/rewrite the code to fix this?

    Kean
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by Kean View Post
    Hi CB,

    from what I know nash_sut is the function above ie: E = 1-(sum((obs-est).^2)/sum((obs-mobs).^2)).

    The idea is that by bootstraping one can determine the significance of E. How would I be able to correct the problem/rewrite the code to fix this?

    Kean
    Then what is the @ doing in that statement?

    CB
    Follow Math Help Forum on Facebook and Google+

  5. #5
    Newbie
    Joined
    Jan 2009
    Posts
    6
    You got me! I have no idea, i am a relative newbie to matlab and definitly never used bootstrp before.
    Follow Math Help Forum on Facebook and Google+

  6. #6
    Newbie
    Joined
    Jan 2009
    Posts
    6
    So if I want the bootfun to be the function mentioned how do I enter it into the bootstrp statement.

    I tried to enter the entire function but that did not work, should I create a new m-file with the function, and then enter that m-file?
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Some help in matlab needed please
    Posted in the Math Software Forum
    Replies: 1
    Last Post: February 5th 2010, 10:01 AM
  2. More matlab help needed please
    Posted in the Math Software Forum
    Replies: 1
    Last Post: February 4th 2010, 06:33 AM
  3. Matlab Help needed
    Posted in the Math Software Forum
    Replies: 1
    Last Post: September 1st 2009, 08:33 PM
  4. Matlab-help needed
    Posted in the Math Software Forum
    Replies: 2
    Last Post: December 20th 2008, 12:39 PM
  5. MATLAB - matrice help needed
    Posted in the Math Software Forum
    Replies: 1
    Last Post: May 11th 2008, 05:01 AM

Search Tags


/mathhelpforum @mathhelpforum