How can I use a self-written function in bootstrap?

조회 수: 10 (최근 30일)
ZZ
ZZ 2018년 2월 9일
편집: Walter Roberson 2018년 2월 9일
bootstat = bootstrp(1000, @historicalVaR(returnsdata,P,cl),returnsdata)
Where historicalVaR is a self written function in the path, that calculates VaR of a data set. its inputs are: returnsdata = vector of returns P = size of investment cl = confidence interval
The error I am getting is:
bootstat = bootstrp(1000,@historicalVaR(returnsdata,P,cl),returnsdata)
Error: Unbalanced or unexpected parenthesis or bracket.
But I do not see how it is unbalanced. Is it possible to use such a function with inputs with bootstrp?

채택된 답변

Walter Roberson
Walter Roberson 2018년 2월 9일
편집: Walter Roberson 2018년 2월 9일
There are two syntaxes possible using @ :
  1. @function_name with no following () . This takes a handle to the corresponding function, and is the same as @(varargin) function_name(varargin{:})
  2. @(variable_list) expression . expression might include a call to a function. variable_list might be empty, such as @() disp('hello') .
I suspect you want
bootstat = bootstrp(1000, @(samples) historicalVaR(samples,P,cl), returnsdata)

추가 답변 (0개)

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by