Computing the standard errors
이전 댓글 표시
Dear all,
for my master's thesis, I have to compute the standard errors of the estimated model parameters using a bootstrap approach. Trying to run the file "booti2.m", I obtain the following error:
>> booti2
Index exceeds the number of array elements. Index must not exceed 19.
Error in llfn (line 61)
sigvtr = bigthet(20);
^^^^^^^^^^^
Error in
fminunc (line 233)
f = feval(funfcn{3},x,varargin{:});
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in
booti2 (line 87)
[thetstar,fstar,exitflag] = fminunc(@llfn,bigtheto,options);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Caused by:
Failure in initial objective function evaluation. FMINUNC cannot continue.
>>
Please note, that before I could run the original "booti.m" file with data for France successfully, while now I can't run neither Slovenian nor French file. Thank you so much! Meancimpr.DAT file is in the folder Searching for Starting Values - Full Sample
댓글 수: 5
Svit
12분 전
Torsten
4분 전
Then use a .zip file in which you include all necessary files.
Svit
대략 2시간 전
There are two files named "llfn.m" in the .zip file, one in the folder "Searching for Starting Values - Full Sample", the other in the folder "Computing Bootstrapped Standard Errors - Full Sample".
In one of them, there is a line
sigvtr = bigthet(20);
in the other, this line is missing.
From the error message it is obvious that "llfn" is called with an array "bigthet" with only 19 instead of the necessary 20 elements. So the llfn-version with an expected length of 20 for "bigthet" cannot be used (or bigthet has to be modified before the call to llfn).
답변 (1개)
Since LLFN is the objective function of a call to fminunc, I'd refer you back to the documentation and prior discussions we had about how it (fminunc) works to determine the size of the solution vector, and therefore the required dimensions ot the starting estimate and solution vectors in that function.
With @Torsten's observation that there are multiple LLFN m-files apparently for different purposes with the same name, that appears to be the issue.
We don't have any clue about how the original author organized his code, but from there being different folders/directories for the different purposes, it appears you may need to change your working directory to the correct one for the particular task you're after so the files there will be found in preference to others of the same name (see <How MATLAB resolves functions>).. The better solution would have for them to have been named differently so they wouldn't be confused -- and maybe even reflect their purpose? What a novel idea!
This illustrates even more the importance I've noted before of not continuing to treat this code as a black box; you've got to become intimately familiar with what is there and how it is organized and intended to be used.
카테고리
도움말 센터 및 File Exchange에서 Programming Utilities에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!