Skip to content

Question: How to analytically compute omegabar steady-state value in MacroModelling #175

@Wastonvv

Description

@Wastonvv

Hi, thanks for this excellent package — it’s been incredibly helpful for building and solving DSGE models efficiently!

I’m currently implementing the BGG (1999) model using MacroModelling.jl, and I encountered some difficulty in defining the steady-state value of omegabar.

In this model, omegabar is implicitly defined through the following nonlinear condition:

function comp_omegabar(x, sigma, mu, L)
    F = cdf(Normal(), log(x)/sigma + sigma/2)
    F_p = 1/(sigma*x) * pdf(Normal(), log(x)/sigma + sigma/2)
    G = cdf(Normal(), log(x)/sigma - sigma/2)
    G_p = 1/sigma * pdf(Normal(), log(x)/sigma + sigma/2)
    Gamma = G + x * (1 - F)
    Gamma_p = 1 - F
    err = (Gamma_p - mu*G_p)/Gamma_p * (1 - Gamma) - (Gamma - mu*G)/(L - 1)
    return err
end

And in the @parameters block I tried to define it as:

omegabar[ss] -> fzero(x -> comp_omegabar(x, sigm, mu, L[ss]), 0, 2)

However, it seems that MacroModelling cannot directly handle this definition — it either fails to evaluate at steady state or gets stuck before computing the full model solution.

here is the complete code

@model BGG_1999 begin

    1/C[0] - lambd[0]=0

    zeta/M[0] - lambd[0] + bet *lambd[0] /pi1[1] = 0

    bet * lambd[1] *R[0] = lambd[0]

    lambd[0] *w[0] = xi /(1-H[0] )

    F[0] = normcdf(log(omegabar[0] )/sigm + sigm/2)
    G[0] = normcdf(log(omegabar[0] )/sigm - sigm/2)
    Gamm[0] = G[0] + omegabar[0] * (1 - F[0] )
    S[0] = Rk[1] /R[0] 

    L[0] = Q[0] * K[0] /N[0]                   
    
    (Gammap[0] - mu * Gp[0] ) / Gammap[0] *(1-Gamm[0] ) + (Gamm[0] - mu *G[0] )=1/S[0]
    (Gamm[0] -mu*G[0] )*S[0] = 1 - 1 / L[0]
    V[0] =(1 -  Gamm[0]) * S[0] *R[0] *Q[0] *K[0]        
    Ce[0] = (1-gamma_e)*V[0]
    N[0] = gamma_e * V[-1] + He * w_e[-1] # 
    Ye[0] =A[0] *K[-1] ^alph *(H[0] ^ (Omega) * He ^(1-Omega))^(1-alph) # 
    w[0] * H[0] =(1-alph) * Omega * pm[0] * Ye[0]
    w_e[0] * He =(1-alph) * (1-Omega) * pm[0] *Ye[0]
    Rk[0] = alph * pm[0] *Ye[0] / Q[-1] /K[-1] + Q[0] *(1-delt)/Q[-1] 
    pistar[0] = epsilon/(epsilon-1)* x1[0] /x2[0]
    x1[0] = lambd[0] * pm[0] * Y[0] + thet*bet*x1[1] *(pi1[1])^epsilon
    x2[0] =lambd[0] * Y[0] + thet*bet * x2[1] *(pi1[1])^(epsilon-1)
    thet * pi1[0] ^(epsilon-1)+(1-thet)* pistar[0] ^(1-epsilon) = 1
    K[0] =(1-delt) * K[-1] +I[0] - chi/2*(I[0] /K[-1] -delt)^2*K[-1] 
    Q[0] =1/(1-chi * (I[0] /K[-1] - delt))  
    Ye[0] = D[0] *Y[0]  
    D[0] = thet * pi1[0] ^epsilon*D[-1] +(1-thet) *pistar[0] ^(-epsilon)
    Y[0] =C[0] +Ce[0] +I[0] +chi/2 *(I[0] /K[-1] -delt)^2*K[-1] +mu *G[0] *Rk[0] *Q[-1] *K[-1]  
    pi1[1] * R[0] = In[0] 
    log( In[0] / Ins ) = rho * log( In[-1] / Ins )+ (1-rho)* phipi* log(pi1[0] /pi1s ) + epsr[x]
    log(A[0] )= rhoa * log(A[-1] ) + epsa[x]
    # He[0] = 1
    Gammap[0] = 1 - F[0] 
    Gp[0] = normpdf(log(omegabar[0] )/ sigm + sigm/2) / sigm 
    
end

function comp_omegabar(x,sigma , mu ,L)
    F=cdf(Distributions.Normal() ,(log(x))/sigma+sigma/2 )
    F_p= 1/(sigma*x)*pdf(Distributions.Normal(),(log(x))/sigma+sigma/2);
    G=cdf(Distributions.Normal(),(log(x))/sigma-sigma/2);
    G_p=1/sigma*pdf(Distributions.Normal(),log(x)/sigma+sigma/2);
    Gamma=G+x*(1-F);
    Gamma_p=1-F;
    err=(Gamma_p-mu*G_p)/Gamma_p*(1-Gamma)-(Gamma-mu*G)/(L-1);
    return err
end


@parameters BGG_1999 begin
    sigm=0.48; 
    mu=0.12; 
    bet=0.99; 
    zeta=3.33; 
    alph=0.35;
    chi=1-0.64/(1-alph); 
    delt=0.025; 
    thet=0.8;
    rhoa=0.9;
    phipi=1.5;  
    rho=0.9;
    epsilon=11;
    Omega=0.8;
    xi = 1.4
    He = 1 
    Ins = 1/bet
    pi1s = 1
    gamma_e | L[ss] = 3/2
    omegabar[ss] ->  fzero( x -> comp_omegabar(x, sigm , mu, L[ss]) ,  0, 2) 
end
get_solution(BGG_1999)(:,:omegabar)

ERROR: AssertionError: Could not find stable first order solution.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions