NLS estimation: workaround for Octave random failure to read the generated ssr_*.m file

pac-components
Sébastien Villemot 2021-09-23 16:21:08 +02:00
parent 7083f1d692
commit f7149d60cc
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
2 changed files with 15 additions and 1 deletions

View File

@ -251,6 +251,13 @@ fprintf(fid, 'r = %s-(%s);\n', lhs, rhs);
fprintf(fid, 's = r''*r;\n');
fclose(fid);
% Workaround for Octave bug https://savannah.gnu.org/bugs/?46282
% Octave will randomly fail to read the ssr_* file generated in the +folder
if isoctave
rename(['+' M_.fname], ['+' M_.fname '-tmp']);
rename(['+' M_.fname '-tmp'], ['+' M_.fname]);
end
% Create a function handle returning the sum of square residuals for a given vector of parameters.
ssrfun = @(p) feval([M_.fname '.ssr_' eqname], p, DATA, M_, oo_);
@ -456,4 +463,4 @@ if ~noprint
dyn_table(title, preamble, afterward, oo_.nls.(eqname).pnames, ...
{'Estimates','t-statistic','Std. Error'}, 4, ...
[oo_.nls.(eqname).beta oo_.nls.(eqname).tstat sqrt(diag(C))]);
end
end

View File

@ -164,6 +164,13 @@ fprintf(fid, 'r = %s-(%s);\n', lhs, rhs);
fprintf(fid, 's = r''*r;\n');
fclose(fid);
% Workaround for Octave bug https://savannah.gnu.org/bugs/?46282
% Octave will randomly fail to read the ssr_* file generated in the +folder
if isoctave
rename(['+' M_.fname], ['+' M_.fname '-tmp']);
rename(['+' M_.fname '-tmp'], ['+' M_.fname]);
end
% Copy (sub)sample data in a matrix.
DATA = data([range(1)-1, range]).data;