| 1 |
// --+ options: json=compute, stochastic +-- |
| 2 |
|
| 3 |
var y x z; |
| 4 |
|
| 5 |
varexo ey ex ez; |
| 6 |
|
| 7 |
parameters gamma rho; |
| 8 |
|
| 9 |
gamma = .3; |
| 10 |
rho = .9; |
| 11 |
|
| 12 |
model; |
| 13 |
|
| 14 |
[name='eqx'] |
| 15 |
x = x(-1)^.8*exp(ex) ; |
| 16 |
|
| 17 |
[name='eqz'] |
| 18 |
z = exp(ez); |
| 19 |
|
| 20 |
[name='eqy'] |
| 21 |
y = x^(1-gamma)*z^gamma*abs(y(-1))^rho + ey; |
| 22 |
|
| 23 |
end; |
| 24 |
|
| 25 |
histval; |
| 26 |
x(0) = 0.1; |
| 27 |
z(0) = 0.5; |
| 28 |
end; |
| 29 |
|
| 30 |
shocks; |
| 31 |
var ex = .05; |
| 32 |
var ez = .05; |
| 33 |
var ey = .01; |
| 34 |
end; |
| 35 |
|
| 36 |
// Simulate a sample. |
| 37 |
simulations = simul_backward_model([], 5000); |
| 38 |
|
| 39 |
// Set residuals in the estimated equation to NaNs. |
| 40 |
simulations.ey = dseries(NaN); |
| 41 |
|
| 42 |
// Set initial guess for the estimated parameter. |
| 43 |
clear('eparams') |
| 44 |
eparams.gamma = 0.6; |
| 45 |
eparams.rho = 0.3; |
| 46 |
|
| 47 |
// Call estimation routine. |
| 48 |
if ~isoctave |
| 49 |
% Under Octave, estimate.nls (provided by matlab/+estimate/nls.m) is not |
| 50 |
% accessible because there is a function which has the same name as the |
| 51 |
% +estimate package, namely matlab/cli/estimate.m. This is a known Octave |
| 52 |
% bug (https://savannah.gnu.org/bugs/?func=detailitem&item_id=46889). |
| 53 |
estimate.nls('eqy', eparams, simulations, 1001Y:5000Y, 'annealing') |
| 54 |
end |