| 1 |
// Tests the normcdf(), normpdf(), erf(), erfc(), trigonometric and hyperbolic functions |
| 2 |
|
| 3 |
var c k t u v w sin_x cos_x tan_x asin_y acos_y atan_y sinh_x cosh_x tanh_x asinh_zz acosh_zz atanh_z; |
| 4 |
varexo x y z zz; |
| 5 |
|
| 6 |
parameters alph gam delt bet aa; |
| 7 |
alph=0.5; |
| 8 |
gam=0.5; |
| 9 |
delt=0.02; |
| 10 |
bet=0.05; |
| 11 |
aa=0.5; |
| 12 |
|
| 13 |
@#if model_options == "" |
| 14 |
model; |
| 15 |
@#else |
| 16 |
model(@{model_options}); |
| 17 |
@#endif |
| 18 |
c + k - aa*x*k(-1)^alph - (1-delt)*k(-1); |
| 19 |
c^(-gam) - (1+bet)^(-1)*(aa*alph*x(+1)*k^(alph-1) + 1 - delt)*c(+1)^(-gam); |
| 20 |
t = normcdf(x, 2, 3); |
| 21 |
u = normpdf(x, 1, 0.5); |
| 22 |
v = erf(x); |
| 23 |
w = erfc(x); |
| 24 |
sin_x = sin(x); |
| 25 |
cos_x = cos(x); |
| 26 |
tan_x = tan(x); |
| 27 |
asin_y = asin(y); |
| 28 |
acos_y = acos(y); |
| 29 |
atan_y = atan(y); |
| 30 |
sinh_x = sinh(x); |
| 31 |
cosh_x = cosh(x); |
| 32 |
tanh_x = tanh(x); |
| 33 |
asinh_zz = asinh(zz); |
| 34 |
acosh_zz = acosh(zz); |
| 35 |
atanh_z = atanh(z); |
| 36 |
end; |
| 37 |
|
| 38 |
initval; |
| 39 |
x = 1; |
| 40 |
y = 0; |
| 41 |
z = 0.1; |
| 42 |
zz = 1.1; |
| 43 |
k = ((delt+bet)/(1.0*aa*alph))^(1/(alph-1)); |
| 44 |
c = aa*k^alph-delt*k; |
| 45 |
t = 0; |
| 46 |
u = 0; |
| 47 |
v = 0; |
| 48 |
w = 0; |
| 49 |
end; |
| 50 |
|
| 51 |
steady; |
| 52 |
|
| 53 |
check; |
| 54 |
|
| 55 |
shocks; |
| 56 |
var x; |
| 57 |
periods 1; |
| 58 |
values 1.2; |
| 59 |
var y; |
| 60 |
periods 1,2; |
| 61 |
values 0.5, 1; |
| 62 |
var z; |
| 63 |
periods 1; |
| 64 |
values 0.5; |
| 65 |
var zz; |
| 66 |
periods 1; |
| 67 |
values 1.2; |
| 68 |
end; |
| 69 |
|
| 70 |
perfect_foresight_setup(periods=20); |
| 71 |
perfect_foresight_solver; |
| 72 |
|
| 73 |
if(abs(oo_.steady_state(5) - erf(1)) > 1e-10) |
| 74 |
error('Test failed in static @{mode_name} for erf') |
| 75 |
end |
| 76 |
|
| 77 |
if (abs(oo_.endo_simul(5, 2) - erf(1.2)) > 1e-10) |
| 78 |
error('Test failed in dynamic @{mode_name} for erf') |
| 79 |
end |
| 80 |
|
| 81 |
if(abs(oo_.steady_state(6) - erfc(1)) > 1e-10) |
| 82 |
error('Test failed in static @{mode_name} for erfc') |
| 83 |
end |
| 84 |
|
| 85 |
if (abs(oo_.endo_simul(6, 2) - erfc(1.2)) > 1e-10) |
| 86 |
error('Test failed in dynamic @{mode_name} for erfc') |
| 87 |
end |
| 88 |
|
| 89 |
if(abs(oo_.steady_state(4) - normpdf(1, 1, 0.5)) > 1e-10) |
| 90 |
error('Test failed in static @{mode_name} for normpdf') |
| 91 |
end |
| 92 |
|
| 93 |
if (abs(oo_.endo_simul(4, 2) - normpdf(1.2, 1, 0.5)) > 1e-10) |
| 94 |
error('Test failed in dynamic @{mode_name} for normpdf') |
| 95 |
end |
| 96 |
|
| 97 |
if (abs(oo_.steady_state(3) - normcdf(1, 2, 3)) > 1e-10) |
| 98 |
error('Test failed in static @{mode_name} for normcdf') |
| 99 |
end |
| 100 |
|
| 101 |
if (abs(oo_.endo_simul(3, 2) - normcdf(1.2, 2, 3)) > 1e-10) |
| 102 |
error('Test failed in dynamic @{mode_name} for normcdf') |
| 103 |
end |
| 104 |
|
| 105 |
|
| 106 |
sin_x_pos=strmatch('sin_x',M_.endo_names,'exact'); |
| 107 |
if(abs(oo_.steady_state(sin_x_pos) - sin(1)) > 1e-10) |
| 108 |
error('Test failed in static @{mode_name} for sin') |
| 109 |
end |
| 110 |
|
| 111 |
if (abs(oo_.endo_simul(sin_x_pos, 2) - sin(1.2)) > 1e-10) |
| 112 |
error('Test failed in dynamic @{mode_name} for sin') |
| 113 |
end |
| 114 |
|
| 115 |
cos_x_pos=strmatch('cos_x',M_.endo_names,'exact'); |
| 116 |
if(abs(oo_.steady_state(cos_x_pos) - cos(1)) > 1e-10) |
| 117 |
error('Test failed in static @{mode_name} for cos') |
| 118 |
end |
| 119 |
|
| 120 |
if (abs(oo_.endo_simul(cos_x_pos, 2) - cos(1.2)) > 1e-10) |
| 121 |
error('Test failed in dynamic @{mode_name} for cos') |
| 122 |
end |
| 123 |
|
| 124 |
tan_x_pos=strmatch('tan_x',M_.endo_names,'exact'); |
| 125 |
if(abs(oo_.steady_state(tan_x_pos) - tan(1)) > 1e-10) |
| 126 |
error('Test failed in static @{mode_name} for tan') |
| 127 |
end |
| 128 |
|
| 129 |
if (abs(oo_.endo_simul(tan_x_pos, 2) - tan(1.2)) > 1e-10) |
| 130 |
error('Test failed in dynamic @{mode_name} for tan') |
| 131 |
end |
| 132 |
|
| 133 |
asin_y_pos=strmatch('asin_y',M_.endo_names,'exact'); |
| 134 |
if(abs(oo_.steady_state(asin_y_pos) - asin(0)) > 1e-10) |
| 135 |
error('Test failed in static @{mode_name} for asin') |
| 136 |
end |
| 137 |
|
| 138 |
if (abs(oo_.endo_simul(asin_y_pos,1) - asin(0)) > 1e-10) || ... |
| 139 |
(abs(oo_.endo_simul(asin_y_pos, 2) - asin(0.5)) > 1e-10) || ... |
| 140 |
(abs(oo_.endo_simul(asin_y_pos, 3) - asin(1)) > 1e-10) |
| 141 |
error('Test failed in dynamic @{mode_name} for asin') |
| 142 |
end |
| 143 |
|
| 144 |
acos_y_pos=strmatch('acos_y',M_.endo_names,'exact'); |
| 145 |
if(abs(oo_.steady_state(acos_y_pos) - acos(0)) > 1e-10) |
| 146 |
error('Test failed in static @{mode_name} for acos') |
| 147 |
end |
| 148 |
|
| 149 |
if (abs(oo_.endo_simul(acos_y_pos,1) - acos(0)) > 1e-10) || ... |
| 150 |
(abs(oo_.endo_simul(acos_y_pos, 2) - acos(0.5)) > 1e-10) || ... |
| 151 |
(abs(oo_.endo_simul(acos_y_pos, 3) - acos(1)) > 1e-10) |
| 152 |
error('Test failed in dynamic @{mode_name} for acos') |
| 153 |
end |
| 154 |
|
| 155 |
atan_y_pos=strmatch('atan_y',M_.endo_names,'exact'); |
| 156 |
if(abs(oo_.steady_state(atan_y_pos) - atan(0)) > 1e-10) |
| 157 |
error('Test failed in static @{mode_name} for atan') |
| 158 |
end |
| 159 |
|
| 160 |
if (abs(oo_.endo_simul(atan_y_pos,1) - atan(0)) > 1e-10) || ... |
| 161 |
(abs(oo_.endo_simul(atan_y_pos, 2) - atan(0.5)) > 1e-10) || ... |
| 162 |
(abs(oo_.endo_simul(atan_y_pos, 3) - atan(1)) > 1e-10) |
| 163 |
error('Test failed in dynamic @{mode_name} for atan') |
| 164 |
end |
| 165 |
|
| 166 |
// Hyperbolic |
| 167 |
|
| 168 |
sinh_x_pos=strmatch('sinh_x',M_.endo_names,'exact'); |
| 169 |
if(abs(oo_.steady_state(sinh_x_pos) - sinh(1)) > 1e-10) |
| 170 |
error('Test failed in static @{mode_name} for sinh') |
| 171 |
end |
| 172 |
|
| 173 |
if (abs(oo_.endo_simul(sinh_x_pos, 2) - sinh(1.2)) > 1e-10) |
| 174 |
error('Test failed in dynamic @{mode_name} for sinh') |
| 175 |
end |
| 176 |
|
| 177 |
cosh_x_pos=strmatch('cosh_x',M_.endo_names,'exact'); |
| 178 |
if(abs(oo_.steady_state(cosh_x_pos) - cosh(1)) > 1e-10) |
| 179 |
error('Test failed in static @{mode_name} for cosh') |
| 180 |
end |
| 181 |
|
| 182 |
if (abs(oo_.endo_simul(cosh_x_pos, 2) - cosh(1.2)) > 1e-10) |
| 183 |
error('Test failed in dynamic @{mode_name} for cosh') |
| 184 |
end |
| 185 |
|
| 186 |
tanh_x_pos=strmatch('tanh_x',M_.endo_names,'exact'); |
| 187 |
if(abs(oo_.steady_state(tanh_x_pos) - tanh(1)) > 1e-10) |
| 188 |
error('Test failed in static @{mode_name} for tanh') |
| 189 |
end |
| 190 |
|
| 191 |
if (abs(oo_.endo_simul(tanh_x_pos, 2) - tanh(1.2)) > 1e-10) |
| 192 |
error('Test failed in dynamic @{mode_name} for tanh') |
| 193 |
end |
| 194 |
|
| 195 |
asinh_zz_pos=strmatch('asinh_zz',M_.endo_names,'exact'); |
| 196 |
if(abs(oo_.steady_state(asinh_zz_pos) - asinh(1.1)) > 1e-10) |
| 197 |
error('Test failed in static @{mode_name} for asinh') |
| 198 |
end |
| 199 |
|
| 200 |
if (abs(oo_.endo_simul(asinh_zz_pos,1) - asinh(1.1)) > 1e-10) || ... |
| 201 |
(abs(oo_.endo_simul(asinh_zz_pos, 2) - asinh(1.2)) > 1e-10) |
| 202 |
error('Test failed in dynamic @{mode_name} for asinh') |
| 203 |
end |
| 204 |
|
| 205 |
acosh_zz_pos=strmatch('acosh_zz',M_.endo_names,'exact'); |
| 206 |
if(abs(oo_.steady_state(acosh_zz_pos) - acosh(1.1)) > 1e-10) |
| 207 |
error('Test failed in static @{mode_name} for acosh') |
| 208 |
end |
| 209 |
|
| 210 |
if (abs(oo_.endo_simul(acosh_zz_pos,1) - acosh(1.1)) > 1e-10) || ... |
| 211 |
(abs(oo_.endo_simul(acosh_zz_pos, 2) - acosh(1.2)) > 1e-10) |
| 212 |
error('Test failed in dynamic @{mode_name} for acosh') |
| 213 |
end |
| 214 |
|
| 215 |
atanh_z_pos=strmatch('atanh_z',M_.endo_names,'exact'); |
| 216 |
if(abs(oo_.steady_state(atanh_z_pos) - atanh(0.1)) > 1e-10) |
| 217 |
error('Test failed in static @{mode_name} for atanh') |
| 218 |
end |
| 219 |
|
| 220 |
if (abs(oo_.endo_simul(atanh_z_pos,1) - atanh(0.1)) > 1e-10) || ... |
| 221 |
(abs(oo_.endo_simul(atanh_z_pos, 2) - atanh(0.5)) > 1e-10) |
| 222 |
error('Test failed in dynamic @{mode_name} for atanh') |
| 223 |
end |
| 224 |
|
| 225 |
/* |
| 226 |
Local Variables: |
| 227 |
mode: dynare |
| 228 |
End: |
| 229 |
*/ |