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 Comments

If you want help, you have to supply all necessary files to run your code. You can test this by using the "RUN" button in the menu bar.
run("booti3.m")
Error using load
Unable to find file or directory "meancimpr.dat".

Error in booti3 (line 25)
load meancimpr.dat;

Error in run (line 100)
evalin('caller', strcat(scriptStem, ';'));
Thank you, but I can't upload .DAT format files:
File format is unsupported for file:meancimpr.dat.
Then use a .zip file in which you include all necessary files.
Meancimpr.DAT file is in the folder Searching for Starting Values - Full Sample
Torsten
Torsten 15 minutes ago
Edited: Torsten 14 minutes ago
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).

Sign in to comment.

 Accepted Answer

dpb
dpb on 17 May 2026 at 15:06
Edited: dpb about 18 hours ago
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.

1 Comment

Svit
Svit 19 minutes ago
Edited: Svit 9 minutes ago
Many thanks to both. I changed the directory and now I can successfully run both French and Slovenian operation.
However, I am having major issues at running the final, third, step of my master's thesis. Please see the test.m file in attachment. The input file seems to be pvqlrsb.txt. I thoughed it was produced in previous two steps for Slovenia, but newly created file includes identical values as French original. Do you have any clue how to replace French data for Slovenian? The file used in previous two steps, Slovenia_centered3 is not required in the code apparently. Thank you so much!
Analyzing the code, I came to a conclusion that file est.m is possibly another input file to test.m, but I'm confused by pvqlrsb.txt. Are there two input files?

Sign in to comment.

More Answers (0)

Categories

Find more on Programming Utilities in Help Center and File Exchange

Products

Release

R2025b

Asked:

on 17 May 2026 at 13:39

Edited:

about 1 hour ago

Community Treasure Hunt

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

Start Hunting!