楼主: abcsk
449 2

[DSGE讨论专题] DSGE模型运行总说参数报错,求教 [推广有奖]

  • 2关注
  • 7粉丝

副教授

57%

还不是VIP/贵宾

-

威望
0
论坛币
21571 个
通用积分
13.2551
学术水平
20 点
热心指数
40 点
信用等级
26 点
经验
15654 点
帖子
363
精华
1
在线时间
700 小时
注册时间
2008-7-5
最后登录
2019-9-16

abcsk 发表于 2019-6-12 10:53:22 |显示全部楼层
30论坛币
报错内容:Starting Dynare (version 4.4.3).Starting preprocessing of the model file ...
ERROR: structure2.mod: line 6, cols 1-10: syntax error, unexpected PARAMETERS


错误使用 dynare (line 174)
DYNARE: preprocessing failed


请求帮助。


源代码:
var AP AS y yW c i G gdp k lambda q H m m2 HS HP yS yP pW pS pP kS kP nS nP bS bP w wSe wPe RSL RPL Rk Rd RS RP RSI RPI pi tao miu v vS vP U omgS omgP fomgS fomgP gomgS gomgP fdomgS fdomgP gdomgS gdomgP FomgS FomgP;% 共58个 variables
varexo eaS eaP
parameters rhoaS rhoaP omgk gamma beta eta psiH psiM delta psi g alphaP alphaS theta sigma mS mP ksiS ksiP gc fai lS lP omgm kappa fai_tao_u fai_tao_pi fai_tao_v  fai_miu_u fai_miu_pi fai_miu_v;                                    
% Parameter Calibration
rhoaS = 0.85;
rhoaP = 0.84;
omgk = 1;
gamma = 1;
beta=0.995;
eta=2;
psiH=1;
psiM =1;
delta=0.05;
psi = 3;
g = 1.0125;
alphaS = 0.5;
alphaP=0.55;
theta = 0.9;
sigma = 3; %psi的设置不太合理
mS = 0.4;
mP = 0.6;
ksiS = 0.9;
ksiP = 0.5;%mP设定的不能太小,否则会出现gdomgS/Ps为负,无解的情形,而mS设定也要适度,否则要么HSs太大,要么为0;ksiP不能太大,也会出现无解的情形。
gc=0.3;  
fai=0.7;
lS = 0.5;  
lP = 0;
omgm = 0.37;
kappa =1.587 ;
fai_tao_u = 0.2 ;
fai_tao_pi  = 0.3 ;
fai_tao_v = 0.5;
fai_miu_u = 0.4;
fai_miu_pi = 0.4 ;
fai_miu_v = 0.2;

%%求稳态
HSs = 0.3905;
omgSs = 0.4858;
omgPs = 0.4212 ;
cs = 0.4133;
fomgSs = 1/(kappa-1) * omgm^kappa * omgSs^(1-kappa);
fdomgSs = - omgm^kappa * omgSs^(-kappa);
gomgSs = (1 - lS) * (1 - mS) * kappa * omgm / (kappa-1) + lS * omgSs + (1-lS) * (1- (1-mS) * kappa / (kappa-1)) * omgSs^ (1-kappa) * omgm^kappa;
gdomgSs = lS + (1-lS) * ( 1-mS * kappa ) * omgSs^(-kappa) * omgm^kappa;

fomgPs = 1/(kappa-1) * omgm^kappa * omgPs^(1-kappa);
fdomgPs = - omgm^kappa * omgPs^(-kappa);
gomgPs = (1 - lP) * (1 - mP) * kappa * omgm / (kappa-1) + lP * omgPs + (1-lP) * (1- (1-mP) * kappa / (kappa-1)) * omgPs^ (1-kappa) * omgm^kappa;
gdomgPs = lP + (1-lP) * ( 1-mP * kappa ) * omgPs^(-kappa) * omgm^kappa;

FomgSs = kappa * omgSs^(1-kappa) * omgm^kappa / (1-kappa) - kappa * omgm / (1-kappa);
FomgPs = kappa * omgPs^(1-kappa) * omgm^kappa / (1-kappa) - kappa * omgm / (1-kappa);

%求稳态,求解对于初值非常敏感,设置有些初始值,会得到实数解,有些则得到复数解
ASs = 1; APs = 1; taos = 0.1; mius = 1; Us = 0.03; pis = 1+0.02; vs = 0.04; qs = 1;
Rks = qs * g / beta - qs * ( 1 - delta );
Rds = pis * g / beta;
RSs = (Rds - 1) / (1-taos) + 1;
RPs = (Rds - 1) / (1-taos) + 1;
Hs = 1 - Us;
HPs = Hs - HSs;
ws = cs * psiH * Hs ^eta;
kSs = (1-alphaS) * ws * HSs / (alphaS * theta * Rks);
kPs = (1-alphaP) * ws * HPs / (alphaP * theta * Rks);
ks = g * (kSs + kPs);
is = (1 - (1-delta) / g) * ks;
%A8
ySs = ASs * kSs ^(1-alphaS) * HSs^(theta * alphaS);
% A16
yPs = APs * kPs ^(1-alphaP) * HPs^(theta * alphaP);
%A26
pWs =(psi - 1) / psi;
% A35
yWs = (fai * ySs^((sigma - 1)/sigma) + (1-fai) * yPs^((sigma - 1)/sigma))^(sigma / (sigma - 1));
%A36
pSs = pWs * fai * yWs^(1/sigma) / ySs^(1 / sigma);
%A37
pPs = pWs * (1 - fai) * yWs^(1/sigma) / yPs^(1 / sigma);
%A9
% A17
%A10
wSes = alphaS * (1-theta) * ws * HSs / (alphaS * theta);
%A18
wPes = alphaP * (1-theta) * ws * HPs / (alphaP * theta);
%A12
RSIs = pSs * ySs / (ws * HSs / (alphaS * theta));
%A20
RPIs = pPs * yPs / (ws * HPs / (alphaP * theta));
%A15
nSs = wSes + ksiS * RSIs * ws * HSs / (alphaS * theta) * fomgSs;
% A23
nPs = wPes + ksiP * RPIs * ws * HPs / (alphaP * theta) * fomgPs;
%A13
bSs = gomgSs * ws * HSs / (alphaS * theta) * (RSIs / RSs);
%A21
bPs = gomgPs * ws * HPs / (alphaP * theta) * (RPIs / RPs);
% //A14///////////////////////////////////////////////////////
fun1 = nSs / (pis * g) / (ws * HSs / (alphaS * theta)) - (- gdomgSs * RSIs * fomgSs / (fdomgSs * RSs));
% //A22///////////////////////////////////////////////////////
fun2 = nPs / (pis * g) / (ws * HPs / (alphaP * theta)) - (- gdomgPs * RPIs * fomgPs / (fdomgPs * RPs));
%A45
RSLs = omgSs * RSIs * ws * HSs / (alphaS * theta) / bSs;
%A46
RPLs = omgPs * RPIs * ws * HPs / (alphaP * theta) / bPs;
%A43
vSs = 1 - RSIs * gomgSs * ws * HSs / (alphaS * theta) / (bSs * RSLs);
%A44
vPs = 1 - RPIs * gomgPs * ws * HPs / (alphaP * theta) / (bPs * RPLs);
% //A41//////////////////////////////////////////////////////
fun3 = vs - bSs * vSs / (bPs + bSs) - bPs * vPs / (bPs + bSs);
%A40
gdps = (is + cs) / (1 - gc);
%A32
Gs = gdps * gc;
% A33
ys = gdps + RSIs * mS * FomgSs * ws * HSs / (alphaS * theta) + RPIs * mP * FomgPs * ws * HPs / (alphaP * theta);
% //A34////////////////////////////////////////////////////
fun4 =ys - yWs;
% A2
lambdas = 1 / cs;
% A5
mss = cs * psiM / (1 - beta / (pis * g));
%A31
m2s = mss + bSs / (1 - taos) + bPs / (1 - taos);
%///////////////////////////////////////////////////////////////////////
%//////////////////////////////////////////////////////////////////////

model;
%(1) home Euler equation
k=(1-delta)*k(-1)/g+(1-omgk/2*(i*g/i(-1)-g)^2)*i;
%(2)
lambda=1/c;
%(3)
w=psiH*H^eta/lambda;
%(4)
beta * Rd(+1) * lambda(+1) / (pi(+1) * lambda * g) = 1;
%(5)
psiM / (lambda * m) + beta * lambda(+1) / (pi(+1) * g * lambda) = 1;
%(6)
q = beta * lambda(+1) / (lambda * g) * (Rk(+1) + q(+1) * (1 - delta));
%(7)
1 = q * (1 - omgk / 2 * (i * g / i(-1) - g)^2 - omgk * (g*i/i(-1) - g) * i * g / i(-1) )+ beta * q(+1) * lambda(+1) / (lambda * g) * omgk * (i(+1) * g / i - g) * (i(+1)*g/i)^2;
% (8)
yS = AS * (kS)^(1-alphaS) * (HS)^(theta*alphaS);
%(9)
w * HS = alphaS * theta * ( nS(-1) / (pi * g) + bS);
% (10)
wSe = alphaS * (1-theta) * (nS(-1)/(pi * g) + bS);
% (11)
Rk * kS = (1-alphaS) * (nS(-1)/(pi * g)+bS);
%(12)
RSI  = pS * yS /(nS(-1)/(pi * g)+bS);
%(13)
RSI * (nS(-1)/(pi * g)+bS) * gomgS = bS * RS;
%(14)
nS(-1)/(pi * g) / (nS(-1)/(pi * g)+bS) = -gdomgS * RSI * fomgS / (fdomgS * RS);
%(15)
nS = wSe + ksiS * RSI * (nS(-1)/(pi * g) + bS) * fomgS;
% (16)
yP = AP * (kP)^(1-alphaP) * (HP)^(theta*alphaP);
%(17)
w * HP = alphaP * theta * (nP(-1)/(pi * g)+bP);
% (18)
wPe = alphaP * (1-theta) * (nP(-1)/(pi * g)+bP);
% (19)
Rk * kP = (1-alphaP) * (nP(-1)/(pi * g)+bP);
%(20)
RPI  = pP * yP /(nP(-1)/(pi * g)+bP);
%(21)
RPI * (nP(-1)/(pi * g)+bP) * gomgP = bP * RP;
%(22)
nP(-1)/(pi * g) / (nP(-1)/(pi * g)+bP) = -gdomgP * RPI * fomgP / (fdomgP * RP);
%(23)
nP = wPe + ksiP * RPI * (nP(-1)/(pi * g) + bP) * fomgP;
%(24)
RS - 1 = (Rd - 1) / (1-tao);
%(25)
( RP - 1 ) * ( 1 - tao ) = Rd - 1;
%(26)
pW = (psi-1) / psi + gamma * pi *( pi / pis - 1 ) * c / (pis * psi * y) -beta * lambda(+1) * gamma * pi(+1) * (pi(+1) / pis - 1) * c(+1) / ( pis * psi * y);
% (27)
%(28)
tao = taos + fai_tao_u * (U - Us) + fai_tao_pi * (pi - pis) + fai_tao_v * (v - vs) ;
%(29)
miu = mius + fai_miu_u * (U - Us) + fai_miu_pi * (pi - pis) + fai_miu_v * (v - vs) ;
% (30)
miu = m2 / m2(-1);
%(31)
m2 = m + bS / ( 1- tao) + bP / ( 1 - tao);
% (32)
G = gdp * gc ;
%(33)
y = c + i + g + gamma * (pi / pis - 1)^2 * c / 2 + RSI * (nS(-1)/(pi * g) + bS) * mS * FomgS +  RPI * (nP(-1)/(pi * g) + bP) * mP * FomgP;
% (34)
y = yW;
%(35)
yW = (fai * yS^((sigma-1)/sigma) + (1-fai) * yP^((sigma-1)/sigma))^(sigma/(sigma-1));
%(36)
yS = fai^sigma * yW * (pW / pS)^sigma;
%(37)
yP = (1-fai)^sigma * yW * (pW / pP)^sigma;
%(38)
k(-1) / g = kS + kP;
% (39)
HS + HP = H;
%(40)
gdp = i + c + G;
%(41)
v = bP / (bP+bS) * vP + bS / (bP+bS) * vS;
%(42)
U = 1 - H;
%(43)
vS = 1 - RSI * (nS(-1) / (pi * g) + bS) * gomgS / (bS * RSL);
%(44)
vP = 1 - RPI * (nP(-1) / (pi * g) + bP) * gomgP / (bP * RPL);
% (45)贷款利率
omgS = RSL * bS / ( (nS(-1)/(pi * g) + bS) * RSI);
%(46)贷款利率
omgP = RPL * bP / ( (nP(-1)/(pi * g) + bP) * RPI);
%(47)technology shock
log(AS) = rhoaS * log(ASs) + (1-rhoaS) * ln(AS(-1)) + eaS;
%(48)technology shock
log(AP) = rhoaP * log(ASs) + (1-rhoaP) * ln(AP(-1)) + eaP;

fomgS = 1/(kappa-1) * omgm^kappa * omgS^(1-kappa);
fdomgS = - omgm^kappa * omgS^(-kappa);
gomgS = (1 - lS) * (1 - mS) * kappa * omgm / (kappa-1) + lS * omgS + (1-lS) * (1- (1-mS) * kappa / (kappa-1)) * omgS^ (1-kappa) * omgm^kappa;
gdomgS = lS + (1-lS) * ( 1-mS * kappa ) * omgS^(-kappa) * omgm^kappa;

fomgP = 1/(kappa-1) * omgm^kappa * omgP^(1-kappa);
fdomgP = - omgm^kappa * omgP^(-kappa);
gomgP = (1 - lP) * (1 - mP) * kappa * omgm / (kappa-1) + lP * omgP + (1-lP) * (1- (1-mP) * kappa / (kappa-1)) * omgP^ (1-kappa) * omgm^kappa;
gdomgP = lP + (1-lP) * ( 1-mP * kappa ) * omgP^(-kappa) * omgm^kappa;

FomgS = kappa * omgS^(1-kappa) * omgm^kappa / (1-kappa) - kappa * omgm / (1-kappa);
FomgP = kappa * omgP^(1-kappa) * omgm^kappa / (1-kappa) - kappa * omgm / (1-kappa);
end;


initval;% %Initial guesses for steady-state computation把稳态值赋予给内生变量
AP = APs;
AS = ASs;
y = ys;
yW = yWs;
c = cs;
i = is;
G = Gs;
gdp = gdps;
k = ks;
lambda = lambdas;
q = qs ;
H = Hs;
m = mss;
m2 = m2s;
HS = HSs;
HP = HPs;
yS = ySs;
yP = yPs;
pW = pWs;
pS = pSs;
pP = pPs;
kS = kSs;
kP = kPs;
nS = nSs;
nP = nPs;
bS  = bSs;
bP  = bPs;
w  =ws;
wSe = wSes;
wPe  =wPes;
RSL  =RSLs;
RPL  =RPLs;
Rk  = Rks;
Rd  = Rds;
RS  = RSs;
RP  = RPs;
RSI = RSIs;
RPI  = RPIs;
pi  = pis;
tao  = taos;
miu  =  mius;
v  = vs;
vS  = vSs;
vP  = vPs;
U  = Us;
omgS  = omgSs;
omgP  = omgPs;
fomgS  = fomgSs;
fomgP = fomPs;
gomgS  = gomgSs;
gomgP  =gomgPs;
fdomgS = fdomgSs;
fdomgP =fdomgPs;
gdomgS  =gdomgSs;
gdomgP =gdomgPs;
FomgS  = FomgSs;
FomgP = FomgPs;
end;


shocks;
var ea =0.1^2;
end;

resid(1);
steady;
check;
stoch_simul(order=1, irf=30,periods=5000,replic=1000);




已有 1 人评分经验 论坛币 收起 理由
linmengmiki + 100 + 100 鼓励积极发帖讨论

总评分: 经验 + 100  论坛币 + 100   查看全部评分

stata SPSS
きずな 发表于 2019-7-5 20:17:15 |显示全部楼层
varexo外生变量声明后没有加;,另外,很多参数没有在parameters模块中声明,这些应该是模型的稳态,需要在外部求解以后作为参数声明后才可以使用
RROR: DSGE.mod: line 181, cols 41-43: Unknown symbol: pis
ERROR: DSGE.mod: line 181, cols 58-60: Unknown symbol: pis
ERROR: DSGE.mod: line 181, cols 121-123: Unknown symbol: pis
ERROR: DSGE.mod: line 181, cols 142-144: Unknown symbol: pis
ERROR: DSGE.mod: line 184, cols 7-10: Unknown symbol: taos
ERROR: DSGE.mod: line 184, cols 31-32: Unknown symbol: Us
ERROR: DSGE.mod: line 184, cols 56-58: Unknown symbol: pis
ERROR: DSGE.mod: line 184, cols 80-81: Unknown symbol: vs
ERROR: DSGE.mod: line 186, cols 7-10: Unknown symbol: mius
ERROR: DSGE.mod: line 186, cols 31-32: Unknown symbol: Us
ERROR: DSGE.mod: line 186, cols 56-58: Unknown symbol: pis
ERROR: DSGE.mod: line 186, cols 80-81: Unknown symbol: vs
ERROR: DSGE.mod: line 194, cols 31-33: Unknown symbol: pis
ERROR: DSGE.mod: line 222, cols 23-25: Unknown symbol: ASs
ERROR: DSGE.mod: line 224, cols 23-25: Unknown symbol: ASs
回复

使用道具 举报

きずな 发表于 2019-7-5 20:20:51 |显示全部楼层
varexo声明外生变量后没有加;,另外很多符号都没有声明,这是无法运行的。这些应该是稳态吧?应该在外部计算好以后通过parameters导入取值就可以。
tarting Dynare (version 4.5.7).
Starting preprocessing of the model file ...
ERROR: DSGE.mod: line 181, cols 41-43: Unknown symbol: pis
ERROR: DSGE.mod: line 181, cols 58-60: Unknown symbol: pis
ERROR: DSGE.mod: line 181, cols 121-123: Unknown symbol: pis
ERROR: DSGE.mod: line 181, cols 142-144: Unknown symbol: pis
ERROR: DSGE.mod: line 184, cols 7-10: Unknown symbol: taos
ERROR: DSGE.mod: line 184, cols 31-32: Unknown symbol: Us
ERROR: DSGE.mod: line 184, cols 56-58: Unknown symbol: pis
ERROR: DSGE.mod: line 184, cols 80-81: Unknown symbol: vs
ERROR: DSGE.mod: line 186, cols 7-10: Unknown symbol: mius
ERROR: DSGE.mod: line 186, cols 31-32: Unknown symbol: Us
ERROR: DSGE.mod: line 186, cols 56-58: Unknown symbol: pis
ERROR: DSGE.mod: line 186, cols 80-81: Unknown symbol: vs
ERROR: DSGE.mod: line 194, cols 31-33: Unknown symbol: pis
ERROR: DSGE.mod: line 222, cols 23-25: Unknown symbol: ASs
ERROR: DSGE.mod: line 224, cols 23-25: Unknown symbol: ASs
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 我要注册

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2019-9-19 23:40